chore(memory): V1-2.6 plan, contract, gate re-check REMAINING(2)

This commit is contained in:
bchanot committed 2026-11-03 21:27:30 +01:00
1 parent 7f618d05a2
commit 4657abf1e3
4 files changed
+585

No files matched your search

@@ -0,0 +1,307 @@
# Plan: V1-2.6 editor level 1 (revised after challenge, 2026-11-03)
Contract `.claude/tasks/contracts/2026-11-03-v1-2-6-editor-1509.md` (criteria C1 to C24, CLARIFICATIONS [gated
2026-11-03]). Branch `feature/v1-2-anatomical-sheets`, worktree
`/tmp/claude-1000/-home-bchanot-Documents-faunosteo/e641af9a-743e-46d0-9804-99667836040e/scratchpad/v1-2`, base
7f618d0. Sandbox only (`pnpm db:sandbox`, containers `faunosteo_dbsandbox_*`); the `supabase_*_faunosteo`
containers are DEV: never touched, never a target. Every command runs with the worktree as an absolute,
verified cwd (LRN-110). One lot = one coherent change, committed and pushed by the orchestrator after its own
checks (`pnpm typecheck && pnpm lint && pnpm test:run`, plus the lot's checks).
Format note: the project's lot format (precedent `.claude/tasks/plans/2026-11-02-v1-2-5.md`), every choice closed
here; executors write the code and the tests. Reading list for every executor: the contract, this plan,
`docs/development/V1-2_ANATOMICAL_SHEETS.md` §6.2, §6.6, §8, §9.2-§9.4, §10, §11.1, `docs/design/v1-2-4/REVUE.md`
(ratified wordings), boards `04-editeur-desktop.png`, `05-lecture-seule-etroit.png`, `06-verification-etats.png`
(panel A only), the ts-rs types under `packages/core-wasm/types`.
## Architecture (closed decisions)
### Core and handle
- No Rust change (crates/** untouched): the core already offers `sheet.edit`, `sheet.dependents`, `sheet.empty`,
`clean_svg`, `PreviewSheet` with `replace_document` / `add_drawing`, `preview.state`, `view.canvas`. The wasm
module and its 600 000 B gzip budget are unchanged.
- The editor reuses `CataloguePreview` (`apps/app/src/catalogue/preview.ts`), extended, never duplicated: its kept
input (`document` text) and drawing list become mutable; `replaceDocument(text)` and `addDrawing(drawing)` call
the glue's `replace_document` / `add_drawing`. A new text is kept only after `replace_document` AND the following
`preview.state` both succeed; when `state` fails without a trap, `replace_document(previous)` rolls the handle
back, so the handle, the kept input and the store never diverge. The rebuild after a trap (generation change)
uses the kept input, so a text or file that trapped is never kept and never re-read automatically (LRN-058).
Kept drawings are a map keyed by asset id (a re-added id replaces its entry; the builder counts entries), holding
only drawings the core accepted (16 at most; `caps: drawings` gets its own message, a reload frees them). Every
successful `replaceDocument` / `addDrawing` bumps a store counter `handleVersion`.
- The draft handle is built with NO drawing (a draft builds with its drawings missing, §10; `add_drawing` works on
a draft and `view.canvas` looks drawings up live), then each downloaded drawing is added with `addDrawing`; a
refusal or a failed download becomes that drawing's state (`missing`, `hash mismatch`), never a load failure: one
bad drawing never blocks authoring (§9.3). A load dropped by the session token frees the preview it built;
`close()` frees the session's preview.
- Wrappers `apps/app/src/editor/core/editOps.ts`: `applyEdit(text, command)` (input text built as
`{"document":<text>,"command":<json>}`, output `{document}` serialised back with `JSON.stringify`),
`dependentsOf(text, key)`; `cleaning.ts`: `cleanSvg(bytes)`, `composeCleaningPreview(stored)` (a throwaway
`CataloguePreview`: `sheet.empty` → `sheet.edit insert` a detail view `view-<random>` under the main view with a
random uuid as its own drawing, the stored bytes added under that uuid, `canvas(<that view id>)`; the scope
`fv.view-<random>.` is unique in the page; freed when the dialog closes). The original file is never rendered.
- Content comparisons (recovery offer, unsaved flag) compare parsed JSON deeply (`sameDocument(a, b)`), never raw
strings: the server text is in jsonb key order, the core's in serde order.
### Ids
- `<prefix>-<10 chars a-z2-7>` from `crypto.getRandomValues`, prefixes `view`, `anno`, `cat`, `ref`, `zone`,
`fcat`, `node`; a `duplicate_key` answer regenerates once and retries; no document walk. Region codes are typed
at creation (the core checks the grammar), read-only afterwards.
### Store and sessions
- One Zustand store `editorStore`, module-level; `open(versionId, userId)` returns a session token, `close()`
invalidates it; EVERY async continuation (load, downloads, save, upload, conflict read, submit) checks the token
before writing and drops its result otherwise (StrictMode runs open → close → open in dev, the e2e and the
trial). DOM handlers read `getState()` (LRN-043).
- The page holds the document as ONE JSON text (`documentText`) and the saved pair (`savedText`, `savedRevision`)
taken from the SAME `get_sheet_version` answer (`revision` and `document` together; the admin read is never the
revision source). `catalogue/catalogue.ts` `readVersion` is exported and gains a draft mode that accepts
`draft`, returns `revision` and returns per-drawing settled results (`Promise.allSettled`, a failure kind per
asset id) instead of failing the load; the catalogue's all-or-nothing path is unchanged: no second loader.
- Every change is one `sheet.edit` command run on commit (blur with a changed value, Enter, a confirm button,
pointer-up), never per keystroke (BDR-050); field typing stays local; a field with a pending value commits it in
its unmount cleanup (mode switch). The new text is stored only after `replaceDocument` and `preview.state`
succeed; a refused command leaves everything unchanged and shows its closed kind next to the control.
- Undo/redo: arrays of texts; each entry's UTF-8 size measured once (`TextEncoder`); oldest undo entries dropped
while both stacks exceed 8 388 608 B; a new commit clears redo; save keeps both; a reload of the server draft
(« Recharger », discard after an older-copy restore) and « Annuler les modifications » clear both. Controls:
icon buttons « Annuler » / « Rétablir » in the tool column under the zoom; Ctrl+Z and Ctrl+Shift+Z outside text
fields (no Ctrl+Y).
### Creation of elements (no invented labels)
- No element is inserted with default labels. Each creation collects the fields the core requires, then one
`insert`:
- annotation (drawn or keyboard): the geometry is held as a pending outline in the overlay and the properties
panel opens in a « Nouveau point / Nouvelle zone / Nouvel accès » state with Nom (FR), Nom (EN), Catégorie
(first category preselected), Latéralité (no preselection, required), Vue ouverte (link, required), then
« Créer » inserts; « Annuler » drops the pending element. Zone de constats and Région vertébrale optional;
- annotation category: name FR/EN, colour optional; reference: type, citation, URL, DOI; region: code, name
FR/EN, count; detail view: name FR/EN, parent, own drawing or crop values; finding zone: name FR/EN; finding
category: kind, name FR/EN; node: name FR/EN.
- A blank optional field is sent as `null` where the type is nullable and omitted where it is an optional key
(`LocalizedOptionalText`); never "" (the core refuses empty strings).
### Rendering and canvas
- Only `view.canvas` trees are rendered, inserted with `DOMParser` + `importNode` through `buildView`, exported
from `CatalogueCanvas.tsx` and reused. Read-only modes mount `CatalogueCanvas` as is (board 05). The edit canvas
reuses `framing.ts` and `useFraming` with one added option `canPan(event)` (false when the press starts on a
selected marker or a drawing tool is active).
- A page-drawn overlay `<svg>` (numbers only: selection outline dashed dark, vertex circles, the tracing in
progress, the pending or dragged outline, the crop rectangle) sits over the drawing inside the same transformed
container, with the composed root's `viewBox` and `preserveAspectRatio`. Pointer → drawing coordinates through
the overlay's `getScreenCTM().inverse()`. `docs/ANNOTATION-RENDERING.md` gets an « Editor overlay (V1-2.6) »
section first, stating it draws no annotation and holds numbers only.
- Only the active tab panel is mounted, so one view's canvas is never twice in the DOM.
- Canvases follow the handle: the edit canvas rebuilds on `[viewId, handleVersion, attempt]`; the read-only
`CatalogueCanvas` is mounted with `key={handleVersion}`, so a restore, an upload or a drawing added after the
first paint is shown (no stale tree, no stuck `no_asset` notice).
- Pointer handling: `setPointerCapture` on press; `pointercancel` and `lostpointercapture` drop the drag with no
command; a switch to read-only mid-drag drops it.
### Tools (board 04)
- Sélectionner/déplacer, Point, Zone, Accès à une vue détaillée, separator, Zoom (−, +, Ajuster), separator,
Annuler, Rétablir. Select: a press on a marker selects it; a drag from a selected circle or polygon moves it as
a block (overlay preview; on pointer-up one `update` with coordinates translated by the drawing-unit delta,
rounded to 2 decimals); a drag on empty space pans. Point: one click holds a pending circle (radius = 12 + 3 % of the
frame's smaller side, so the visible disc `2 × max(2, r − 12)` is 6 % of it and passes the 4 px rule; frame = the
composed root's viewBox; unit-tested on 500×380, 640×480, 200×150). Zone and link: clicks add vertices;
Enter, a click on the first vertex or « Fermer le tracé » closes (3 vertices at least); Escape or « Annuler le
tracé » drops it. A detail-view link opens a direct child of its own view (core rule
`annotation.opens_view.invalid`): the link tool is enabled only while the current view has a direct detail
child (hint otherwise), and « Vue ouverte » lists only those children, in creation and in properties; every drawing tool
is disabled with « Créez d'abord une catégorie d'annotation (onglet Général). » while there is none.
- Keyboard path (C7): under the canvas, « Ajouter un point », « Ajouter une zone », « Ajouter un accès » hold a
pending element at the frame centre (zone and link: a triangle of 10 % of the smaller side) and open the
creation panel; then every coordinate is edited in numeric fields (cx, cy, r; rows « n | x | y »; « Ajouter un
sommet » after the selected row or the last; « Retirer » while more than 3 remain).
- A `path` annotation: shown and selectable; « Remplacer par un polygone » starts a tracing whose result replaces
its geometry; never moved; its path data never shown as editable.
- Selection also from the annotation list of the view (name, kind, review badge; keyboard reachable); the tag
« Sélection : <type> « <nom> » » over the drawing (board 04).
### Panels and tabs
- Properties panel (board 04): Nom (FR), Nom (EN), Catégorie, Couleur (« de la catégorie » or a hex value),
Latéralité, Région vertébrale, Zone de constats (point, zone), Vue ouverte (link), coordinates, review badge
(« À confirmer », « Relu », « Hérité, non relu »), « Marquer comme relu » (`set_status reviewed`, while not
`reviewed`), « Remettre à confirmer » (`set_status to_confirm`, while `reviewed`), « Supprimer » (confirmation;
a refusal lists the dependents).
- Général: names, description and scope disclaimer FR/EN, attribution (authors add/remove, licence, notes); section
« Catégories d'annotation » (list, add, rename, colour, delete with dependents).
- Vues et illustrations: main view (name, drawing state ok / missing / rejected with its detail, « Choisir une
illustration »), detail views (add, parent, own drawing or crop: four numeric `view_box` fields with the parent's
canvas beside them and the crop rectangle in the overlay; rename; delete with dependents).
- Constats: tree zones → categories → nodes (depth ≤ 8), `role="tree"` / `treeitem`, arrow keys; categories and
nodes carry a review badge, zones none (FindingZone has no status); actions: add zone, add category, add node
(disabled at depth 8), ↑ / ↓ (`move`), « Marquer comme relu » (zone and category: `mark_reviewed`; node:
`set_status reviewed`), « Remettre à confirmer » (categories and nodes only), delete with a confirmation listing
the descendants and, on refusal, the dependents.
- Références: list + form (type, citation, URL http/https checked by the core, DOI). Vertèbres: list (code, name,
count, optional range), add, edit, ↑ / ↓, delete.
- Read-only renders through shared field components that show their value as text when `readOnly` (action buttons
hidden by the same flag): each tab stays one component.
- Vérification (board 06 A): badges « N erreurs bloquantes » / « N éléments à confirmer »; one notice per error
issue with its FR/EN message and « Aller à … » when the path names an element; warnings apart; the info notice on
`to_confirm` elements; completeness; statuses per group; size « <n> o sur 2 097 152 o » from
`report.document_bytes`, caps exceeded named; « Note de soumission (obligatoire) » (trimmed 1 to 1 000
characters); « Soumettre à la revue » disabled with its hint while errors exist (« Corrigez les N erreurs
bloquantes pour soumettre. »), while unsaved (« Enregistrez le brouillon avant de le soumettre. ») or while the
note is empty. Submit → `submit_sheet_review(version_id, savedRevision, note)`; success → the admin read and the
version are reloaded, the page shows the `frozen` read-only state. No « Prévisualiser », no withdrawal (V1-2.7).
### Save, conflict, recovery
- Save: « Enregistrer » sends `sentText` with `expected_revision = savedRevision`, no change note; the answer is
parsed as `{revision: number}` (`unavailable` otherwise). Success: `savedText = sentText`, `savedRevision =
answer`, unsaved = `!sameDocument(current, sentText)`; the recovery copy is removed when unsaved is off, else
rewritten on the new revision. `draft.unchanged` sets the saved pair to (`sentText`, the `expected_revision`
sent). Other kinds → header notice, document and copy kept.
- Conflict (`draft_conflict`): the page reads `get_official_sheet_admin` (M8 `draft_last_save`) and opens a
dialog: « Une autre session a enregistré la révision N » + « par <nom>, le <date heure Paris> » (a neutral
« depuis une autre session de votre compte » when `saved_by` is the caller); « Recharger » → a confirmation
« Abandonner vos modifications et recharger la révision N ? » → reload of the server draft (text and revision
from one `get_sheet_version`, the listed drawings the handle lacks downloaded and added), both stacks cleared,
copy removed; « Garder ma version » → a confirmation
« Remplacer la révision N (<nom>, <date>) par votre version ? » → save with `expected_revision = N`; a new
conflict re-opens the dialog; « Annuler » changes nothing.
- Local recovery: sessionStorage (the report editor's pattern), key `osteo:sheet-draft:<userId>:<versionId>`,
value `{"v":1,"user_id","version_id","revision","written_at","document":<text>,"drawings":[{"asset_id","sha256"}]}`
(revision = the saved revision the edits started from: the copy is identified by version and revision). Written
SYNCHRONOUSLY by a store subscription on each committed change while unsaved, through `writeOrRemove` exported
from `state/persistence.ts`; its boolean is kept in the store. Removed after a successful save that leaves
nothing unsaved, after « Annuler les modifications », after « Ignorer », when undo returns to the saved content,
and after « Recharger ». At most two copies of other versions are kept (oldest removed by `written_at`); copies
of another account are never offered. On opening: a copy of this account and version whose document differs
(`sameDocument`) from the server's is offered in a notice under the header (« Une copie locale non enregistrée
de ce brouillon existe (révision N, <heure>). » with « Restaurer » / « Ignorer »); restore goes through the core
(`replaceDocument`; a refused copy is reported and kept, never applied), downloads the copy's drawings the page
does not hold (`downloadSheetDrawing`), sets unsaved. When the copy's revision R is older than the server's
revision M, the offer names both (« basée sur la révision R ; le serveur est à la révision M ») and, after a
restore, `savedRevision` stays R (the base the copy was written on) with a store flag `staleBase`: the first
save therefore meets `draft_conflict`, whose dialog shows revision M with its author and time (M8) and requires
the « Garder ma version » confirmation before anything is replaced; « Annuler les modifications » with
`staleBase` takes the « Recharger » path (server text and revision M). Nothing is overwritten silently. The offer
shows only in edit mode or `narrow` (a mode that can save); never sent automatically.
- Header status: only the failure variant « Copie locale impossible (stockage plein) » is shown (board 04 keeps
« Révision N · modifications non enregistrées »). Every message that promises kept work reads the real write
flag: session or MFA lost (`session_expired`, `rights.mfa`) and an unsaveable draft (`draft.frozen`,
`sheet.inactive`, `rights.capability`) say « une copie locale existe dans cet onglet » only when the last write
succeeded, otherwise that the unsaved changes cannot be kept.
- Leave guard (`useLeaveGuard`) armed while unsaved.
### Upload (§9.2-§9.3)
- File input (`.svg`, `image/svg+xml`), size ≤ 2 MiB checked before reading; bytes → `clean_svg`. `rejected` →
message per reason, nothing else. `cleanable` → dialog with the core-composed cleaned drawing, the removed names
(the `<style>` element named when `style_removed`), « Nettoyer et utiliser cette version » / « Annuler ».
`clean` → no dialog.
- Then: `register_sheet_asset(sheet_id, sha256, byte_size, file_name)` with the core's sha256 and size of
`stored`; read the row (`listSheetAssets(sheetId)`: id, sha256, byte_size, uploaded_at); if `uploaded_at` is set,
nothing is uploaded or confirmed (§9.3 step 2); if pending, upload `stored` at `<sha256>.svg` (`image/svg+xml`,
no upsert): ok → confirm; already present (HTTP 409, or 400 with `statusCode` "409") → confirm; refused by the
policy (403, or 400 with `statusCode` "403": a pending row registered by another account) → `confirm` once (the
other account's object may already be there); `upload_missing` then → closed code `upload.pending_other`; then `confirm_sheet_asset_upload(asset_id)` (`upload_missing`, `size_mismatch`). Then the
stored object is downloaded and added with `addDrawing`: `drawing_hash_mismatch` → `object_conflict`; `caps` →
its message. Then the view the upload started from gets the drawing (`update` view with `svg_asset_id`).
- Codes with FR/EN messages: `size_mismatch`, `hash_mismatch`, `svg_rejected` with the reason, `svg_active_content`,
`svg_not_canonical`, `too_large`, `upload_missing`, `object_conflict`, `upload.pending_other`, `caps`, and the
server kinds through `failureMessage` (allowlist extended).
### Modes, permissions, layout
- Edit mode needs, as a display rule only: an active `sheet_editor` own grant AND the admin or owner platform role
(`grant_active` needs both), a viewport ≥ 1 024 px, no freezing round, not the historical sheet, an active sheet.
Otherwise read-only with the reason's notice: `narrow` (board 05: badge « Lecture seule » with the lock icon,
notice title alone « L'édition nécessite une largeur d'écran d'au moins 1 024 px. », L15), `rights`, `frozen`
(« Revue n° N · vérification en cours » for `verifying`, the round status label otherwise, link to the
overview), `historical`, `inactive`. Unsaved work in memory survives a switch to narrow and back.
- Permission states on the route (BDR-099 order): own grants `loading` → waiting; a `rights.*` answer from the admin
read → « Accès non autorisé »; own grants `failed` → `PermissionsUnavailable` with « Réessayer »; `not_found` →
`SheetNotFound` (exported from `AdminSheetRoute.tsx`); no draft → notice + link to the overview.
- Tabs: wide, all seven (board 04); narrow (board 05), static lists: 640 to 1 023 px « Général, Annotations,
Constats, Vérification » + « Plus »; below 640 px « Annotations, Vérification » + « Plus »; « Plus » is a
disclosure (`aria-expanded`) listing the others; no width measurement.
- Layout: `AppLayout` drops `max-w-4xl` for `/app/admin/sheets/:sheetId/draft` (`matchPath`). From 1 280 px board
04's three columns; from 1 024 to 1 279 px the properties card goes under the canvas (tools + canvas columns),
the tab row scrolls within itself and the header wraps; no page horizontal scroll at 1 024 px.
- Links: the overview shows « Ouvrir le brouillon » (edit possible) or « Consulter le brouillon » when a draft
exists; A1 creation and W1 working copy navigate to `/app/admin/sheets/<id>/draft`.
### i18n
- Keys `editor.*` in fr.ts and en.ts (parity tests); ratified wordings verbatim (REVUE.md, contract §17.9, §17.11,
L15); every new label listed in `.claude/audits/2026-11-03-v1-2-6-label-proposals.md` for the owner's separate
review, none declared approved.
## Lots
| Lot | Content | Criteria | Checks |
|---|---|---|---|
| A | M8 `supabase/migrations/20261103100000_sheet_draft_last_save.sql`: redefines `public.get_official_sheet_admin` only (the list and the summary helper untouched) adding `draft_last_save` = `{revision, saved_at, saved_by: private.sheet_admin_person(actor)}` from the newest `audit.audit_logs` row with `resource_type = 'anatomical_sheet_version'`, `resource_id` = the draft, `action = 'anatomical_sheet_version.saved'`, `metadata->>'revision'` = the draft's revision, else null; body otherwise identical to M7; privileges restated as M7 has them. pgTAP `supabase/tests/023_sheet_draft_last_save.sql`: null on a fresh draft, actor and time after a save, the second editor after a second save, null after a non-save content write, same refusals as M7, no new privilege. `packages/supabase` schema `draft_last_save` (nullable). Sandbox fresh + upgrade from M7; `db:types --check`. Contract §12.3 and §16.7 amended (read migration, owner 2026-11-03) | C12, C18 | PGlite, `db:sandbox test-db`, types |
| B | `packages/supabase/src/sheets.ts`: `registerSheetAsset`, `listSheetAssets(sheetId)`, `uploadSheetDrawing` (→ `'uploaded' \| 'present'`, `upload.pending_other` on a policy refusal, Storage errors read on HTTP status and body `statusCode`, checked against the installed storage-js error type), `confirmSheetAssetUpload`, `parseSaveAnswer`; new kind `upload.pending_other`; exports; unit tests; sandbox test `packages/supabase/tests/sandbox/sheet-editor-assets.sandbox.ts` with bytes unique per run (pattern of `sheet-fixtures.ts`): register, upload, confirm, row read, second register of a confirmed hash (no upload), second editor on a pending row (`upload.pending_other` with its own statusCode) | C6 | unit, sandbox |
| C | `CataloguePreview` extension (mutators, kept input on ok only, accepted drawings only); `editor/core/editOps.ts`, `cleaning.ts`, `editor/ids.ts`, `sameDocument`; `CatalogueCanvas` exports `buildView`; `useFraming` option `canPan`; unit tests on the Node core: rebuild after a forced generation change keeps the replaced text and the added drawing, a refused text is not kept, a bad drawing refused alone, the cleaning preview's scope | C2, C3, C15, C17 | unit |
| D | `editor/state/editorStore.ts`, `undo.ts`, `recovery.ts`, `editor/issues.ts`; `persistence.ts` exports `writeOrRemove`; unit tests: session token drops late answers, commit, refusal unchanged, undo bound, redo cleared, save with commits in flight (sent text kept), save unchanged, conflict paths (reload clears stacks, keep mine with confirmation), recovery write flag, removal cases, restore round trip through the core, older-revision restore, other account ignored, other versions capped at two | C11-C14 | unit |
| E | Route `AdminSheetDraftRoute.tsx`, App.tsx, AppLayout width, header, tabs (wide and narrow), modes and permission states, recovery offer, conflict dialog, leave guard, overview links, A1/W1 landing, shared read-only field components; `readVersion` draft flag + revision; `failureMessage` allowlist; i18n | C1, C11-C13, C16 | unit |
| F | Général (+ annotation categories), Références, Vertèbres; shared delete-with-dependents dialog | C4, C5 | unit |
| G | Vues et illustrations + upload flow | C6, C17 | unit |
| H | `docs/ANNOTATION-RENDERING.md` overlay section first; Annotations: canvas, overlay, tools, list, creation panel, properties panel, keyboard creation, undo/redo controls | C7, C8, C14, C17 | unit |
| I | Constats tree | C9 | unit |
| J | Vérification panel + submission | C10 | unit |
| K | e2e `apps/app/e2e/shell/editor-*.spec.ts` reusing `createAccount`, `assignRole`, `seedGrant`, `enrolVerifiedFactor`, `stepUpAdmin`, `seedOfficialSheet`, `expectAccessible`, `expectNoHorizontalOverflow`, `dropLateReplays`; adds editor-only helpers. A2 (hostile refused, Inkscape export cleaned, attach, detail view by crop; both upload outcomes accepted), A3 (points, zones, links by clicks and by keyboard, move, numeric edits), A4 (zones, categories, nodes, refs, regions, reorder, mark reviewed, delete with dependents), journey (the brief's §3 steps 1-12 with two editor accounts: creation, upload, detail view, points/zones/links, categories and findings, save, reload with the beforeunload dialog accepted and the recovery offer, conflict, submit, round `verifying` read back in SQL, no error shown while elements are `to_confirm`), access (reviewer-only read-only, editor grant without admin role read-only, account without capability refused), narrow (320, 375, 800 px read-only, no horizontal scroll; 1 024 px edit without horizontal scroll), axe on editor and read-only, the equine working copy opening (sets aside an active copy first, as `sheets-concurrency.sandbox.ts` does); commit latency measured on the equine copy and on a synthetic document near 2 MiB (reported; budget 500 ms per commit on the equine copy); `docs/development/BROWSER_TESTS.md` | C16, C20, C21 | `e2e:shell` on a fresh sandbox |
| L | Owner trial: `scripts/db-sandbox.sh` subcommands `trial` (its own gateway container `faunosteo_dbsandbox_trial_gateway` on its own loopback port, refusing to start when that container exists, + Vite dev server on 127.0.0.1:5193 whose proxy forwards `/auth/v1`, `/rest/v1` and `/storage/v1` to that gateway so the browser stays same-origin (no CORS change), proven by the manual run; foreground, Ctrl+C stops both), `trial-account <email>` (password at a hidden prompt, confirmed account, nothing secret printed), `trial-grant <email> <kind>` (email and kind checked against fixed patterns and passed as psql variables; for `sheet_editor` / `sheet_publisher` also `private.assign_platform_role(null, <id>, 'admin')`, the same SQL as the e2e helpers); `docs/development/V1-2-6_OWNER_TRIAL.md` (commands, URL, account, TOTP enrolment, journey, operations, expected results, the freeze after a submission with no worker and no withdrawal, teardown); label proposals file | C23 | script review, manual run on the sandbox |
| M | Gates: fresh sandbox → `test-db` → `e2e:shell` → `test`; `check:all`; `r5:import-equine --check`; fresh verifier + security; docs (contract §16.7 state, TODO, design README pointer); memory; checkpoint report | C18, C22, C24 | all |
Dependencies: A, B, C independent; D needs A, C; E needs A, B, D; F-J need E; K needs A-J; L needs E; M last.
## Edge cases (all lots)
- Core trap mid-edit: the store keeps `documentText`; the handle rebuilds from its kept input; the canvas shows the
engine notice with retry (BDR-054); a command or file that trapped is not retried automatically.
- A drawing missing or refused: that view shows its state and the canvas notice; edits continue.
- Two tabs on the same draft: each its own copy; the server revision decides (conflict dialog).
- A save answer lost (`network`): the next save meets the conflict dialog with the neutral own-account wording.
- Escape in a native dialog closes it (LRN-082); e2e waits for a closed dialog before typing (LRN-111) and accepts
the beforeunload dialog before a reload.
## Disposition of memory (in force)
Honors BDR-043 (no rule in TS: translation and defaults are UI arithmetic, every check is the core's), BDR-050,
BDR-054/055/056 (failure states, honest unsaved wording, restore through the core), BDR-076, BDR-078, BDR-082,
BDR-084 (M8 reads through the RPC, no grant widening), BDR-085, BDR-086, BDR-087 (stored form; unique scope for
the cleaning preview; one canvas per view in the DOM), BDR-088/090 (Inkscape 1.4.3 fixture), BDR-091/092,
BDR-094, BDR-096 (boards followed; deviations listed), BDR-097, BDR-099; LRN-010, -017, -043, -055, -057, -058,
-060, -082, -085, -087, -088, -089, -094, -097, -101, -103, -104, -110, -111, -112, -113.
## Visible choices taken in this plan (for the owner at the validation gate)
1. Annotation categories edited in the Général tab.
2. Creation panels collect the required fields (names FR/EN, laterality with no preselection, category, opened
view) before the element exists; no default labels.
3. Keyboard creation buttons under the canvas, then numeric fields.
4. Read-only notices per reason (rights, frozen, historical, archived) besides board 05's narrow notice.
5. From 1 024 to 1 279 px the properties card goes under the canvas.
6. Overview links « Ouvrir le brouillon » / « Consulter le brouillon »; A1 and W1 land on the editor (§11.2).
7. Owner trial commands `pnpm db:sandbox trial`, `trial-account`, `trial-grant` and the doc
`docs/development/V1-2-6_OWNER_TRIAL.md`.
8. New closed code `upload.pending_other` (another account's unfinished upload of the same drawing).
Recorded deviations from board 06 A (owner answer): no « Prévisualiser », no withdrawal before V1-2.7.
## Challenge record (2026-11-03, three lenses, each CONCERNS(4), no BLOCKER tag)
Accepted and integrated: simplicity 1-11 (CataloguePreview extended, canvas and framing reused, static narrow
tabs, synchronous copy writes, one key per account and version, id retry on `duplicate_key`, recovery drawings in
the copy, loader and failure map reused, failure-only copy status, no Ctrl+Y, shared read-only fields, e2e
helpers reused); robustness 1-3 and 5-17 (sent text kept on save, session token, drawings added one by one and
the stored object re-read, removal cases, no pending write, account in the key, trapping input not kept, edit mode
needs the admin role, 16-drawing cap, two-step reload and neutral own-account wording, pointer capture, unique
test bytes and working-copy slot, trial gateway and SQL variables, admin role in trial-grant, M8 in
`get_official_sheet_admin` only with `resource_type`, 2 MiB latency); correctness 1-14 (confirmed row skips the
upload and a policy refusal is named, creation fields, discard removes the copy, deep comparison, saved revision
from the version answer, save answer parsed, zones without status, A before D and E, 1 024 px layout, older-copy
restore, stacks cleared on reload, one canvas per view, beforeunload in e2e).
Confirmation pass (one fresh correctness challenger on the revision): FATAL(6) → all 12 integrated: [BLOCKER] an
older restored copy saved over a newer revision → `savedRevision` stays the copy's base with `staleBase`, the
first save meets the conflict dialog; state failure after replace → rollback, kept input only after `state`;
draft `readVersion` per-drawing settled results; `handleVersion` drives canvas rebuilds and the read-only `key`;
link tool and « Vue ouverte » limited to direct detail children; default radius 12 + 3 %; drawings keyed by
asset id; `draft.unchanged` sets the saved pair; policy refusal tries `confirm` once; trial through a Vite proxy
(same origin); dropped loads and `close()` free the preview; recovery offer only where saving is possible. The
procedure allows one confirmation pass: these fixes go to the gate unchallenged again. Robustness 4: messages read the
write flag (integrated); a downloadable rescue copy (BDR-055 pattern) is a visible choice asked at the gate.