diff --git a/.serena/memories/common/testing.md b/.serena/memories/common/testing.md index b18fa3904b..95d999405c 100644 --- a/.serena/memories/common/testing.md +++ b/.serena/memories/common/testing.md @@ -48,6 +48,26 @@ For shape mutations, prefer production-path helpers such as `cls/generate-update `thf/apply-changes` validates by default and usually gives the most useful invariant failure. Pass `:validate? false` only for intentionally malformed intermediate state. +## Validation and repair tests + +`common-tests.files.repair-components-test` has one test per component error code: break a file with +the helpers (`ths/update-shape`, `thc/update-component`), assert the exact set of codes, then repair +as the backend does (validate + `cfr/repair-file` until valid, at most 10 passes, like +`app.srepl.procs.file-repair`) and assert the result. Repairs that never converge are pinned with +`tm/known-failure`. A deleted component's objects are reached with `ctkl/get-component data id true` +(`thc/get-component` skips deleted ones). + +## Component sync benchmark + +`common/dev/bench/component_sync.clj` times component sync on fixed-size worlds (one main into +10/100/1000 copies, 3 nesting levels, a chain of dependents, a variant switch, a library update). +Each world checks its result (how many rects end red) so it never times a no-op. Run from +`common/`: `scripts/bench-components` compares with `dev/bench/component_sync_baseline.edn` and +exits 1 when a world's lower quantile is more than 10% slower; `scripts/bench-components record` +rewrites the baseline (only on purpose, saying why). It takes about 4 minutes. Every commit that +touches sync, swap or change application runs it and quotes the table in its message. The lower +quantile is compared because the mean moves with background load (devenv watchers) and GC. + ## Geometry setup caution For geometry-sensitive tests, read `mem:common/geometry-invariants` before positioning shapes. Use geometry-preserving helpers or production change helpers rather than direct single-field edits. diff --git a/.serena/memories/frontend/composable-component-tests.md b/.serena/memories/frontend/composable-component-tests.md index 76db2a2cbf..5b891d4448 100644 --- a/.serena/memories/frontend/composable-component-tests.md +++ b/.serena/memories/frontend/composable-component-tests.md @@ -87,28 +87,111 @@ wrapper deftest in BOTH test namespaces (or only the frontend one if it needs fr Two pure runners (no store, JVM + CLJS): - `core/run-variant`/`run-all`: apply nodes only (no sync, `n/undo` throws). For engine tests. - `comp.runner/run-variant`/`run-all`: the case runner. Every comp node declares its kind via - `n/IComponentOperation` (`op-kind`: `:assembly`, `:user`, `:undo`, `:frontend-only`); the + `n/IComponentOperation` (`op-kind`: `:assembly`, `:user`, `:undo`, `:redo`, `:frontend-only`); the runner and the interpreter's `sync-op?` dispatch on it. A NEW node MUST implement it. User ops record their production changes (`n/record-changes`, nil when nothing changed); the runner throws if a `:user` op records nothing or another kind records changes. After a user op the runner syncs to a fixpoint (`ch/components-changed` + `generate-sync-file-changes`, one pass per cascade level, like the frontend watcher) and pushes op + syncs as one undo group. - `n/undo` reverts the latest group, no re-sync. The runner validates the file (against the + `n/undo` (`(n/undo k)` for k groups) reverts the latest group and moves it to a redo stack; `n/redo` applies it again + (interpreter: `dwu/redo`); neither re-syncs. A user op that pushes a group empties the redo + stack; one that changed nothing keeps it. The runner validates the file (against the situation's files) once settled: after the sync fixpoint and after an undo group; never between cascade passes, where an outer copy still points at the component its main dropped (`:component-id-mismatch`), nor with `{:sync? false}`. Assembly ops (create/instantiate/nest/variant - container): no sync, no undo group. `ResetCopyInstance` is a user op here (sync + undo), - unlike the interpreter (file install). `{:sync? false}` disables sync. `Rotate`/`ChangeHeight` + container): no sync, no undo group. `n/reset` (`reset-copy-instance` resets a lineage's latest copy) is a user op (sync + + undo); the interpreter sends `dwl/reset-component`. `{:sync? false}` disables sync. `Rotate`/`ChangeHeight`/`MoveShape` are `:frontend-only` and throw `::runner/frontend-only` (the placement step is frontend code). Swap and switch nodes use the production `clv/generate-component-swap-in-place` (+ `clv/find-switch-target` for switch), the same code the frontend events call. Not modelled: the `:modified-at` bump, and the swap/switch event follow-ups (token propagation, WASM text resize, layout update). Tests: `common-tests.logic.composable-runner-test`. +- Undo/redo round trip (`comp/undo_check.cljc`, alias `uc`), on by default in the pure runner + (`:undo-check?`): after each `:user` step that pushed a group, undo must give back the + normalized file before it and redo the file after it (the variant continues from the redone + file); a user step that pushed nothing must change nothing (`:no-undo-entry`); at the end, + undo back to the last assembly step (the baseline; a case's own undo below it moves it) and + redo all. Files compare through `app.common.test-helpers.normalize` (`thn/normalize-file`: + drops file/component `:modified-at`, optionally `:position-data`; shapes as plain maps). + Failures are recorded in the situation with labelled diffs (labels die with the variant, so + they are resolved when recorded) and a `:signature`, the set of what differs + (`uc/signature`: `[:object