chore(memory): BDR-103, LRN-119, U2b decisions contract and TODO

This commit is contained in:
bchanot committed 2026-11-06 14:56:50 +01:00
1 parent 604f502b44
commit a43145a03f
5 files changed
+183 -1

No files matched your search

+10
View File
@@ -807,3 +807,13 @@ Observation, not a routine: worktree held uncommitted format-only Prettier chang
- **Reference**: 592 143 B of 600 000 B → margin 7 857 B (raw 1 569 864 B; pkg built 2026-11-04 after last core change `bbab0e6`; re-measured 2026-11-05 with same call, same figure).
- **Rule**: margin = same call, same params (`level: 9`), same `pkg` file as gate. No system gzip substitute: results differ. Measure after every core change (each new op). Never raise ceiling silently: raise = explicit owner decision (D-R13) on measured figure.
- **How**: after `pnpm wasm:build`, run size test (prints figure) or `node -e` with `zlib.gzipSync(buf, {level: 9})` on that file.
## LRN-119 — React 19.2 Activity keeps state but re-runs effects on reveal: audit one-shot mount effects, no general ban (2026-11-06)
- **Context**: V1-2.6 U1 plan (2e46c14) chose kept-mounted `hidden` wrappers over React 19.2 `<Activity>` for tab places; owner asked distinction recorded, no general ban (2026-11-06).
- **Fact (react.dev/reference/react/Activity, checked 2026-11-06)**: `mode="hidden"` keeps state, refs and DOM (`display: none`) but destroys Effects (cleanups run); reveal re-creates them (setups run again). Conceptually hidden = unmounted with saved state. Hidden children still re-render on prop changes, at lower priority.
- **Trap**: state kept ≠ effects quiet. Effect that does one-shot action on mount re-fires at each reveal:
- `apps/app/src/catalogue/useFraming.ts:69` `useEffect(() => setFraming(FIT), [resetKey])` → zoom and pan reset at each return, though framing state was kept.
- `apps/app/src/components/editor/findings/FindingTree.tsx:31-33` `useEffect(() => focus(focusId), [focusId])` → stale `focusId` re-focuses tree item at each return (steals focus).
- **Rule**: before wrapping subtree in `<Activity>`, audit its effects. Idempotent on re-run (subscriptions, listeners, measures with cleanup) → fine. One-shot on mount (reset, focus, scroll, fetch, write) → make reveal-safe (apply once per key via ref, consume one-shot request) or keep `hidden` wrapper. `hidden` wrapper: no effect runs on switch, but hidden places re-render at normal priority (U1 plan §2 cost control). `<Activity>` stays allowed where audit passes.
- **Future application**: U1 makes `focusId` one-shot and bans focus in mount effects; U2b search, filter panel, drawing in filter panel (`useFraming` reuse) follow same rule, so a later move to `<Activity>` stays possible.
- **Status (2026-11-06)**: correct, amended 2026-11-06 after fresh verifier: hidden Activity keeps state (useRef values included) and DOM; refs to DOM elements detached while hidden (safelyDetachRef, react-dom 19.2.6), re-attached on reveal in layout phase before effects re-run; impact lines unchanged.