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,274 @@
# CONTRACT — v1-2-6-editor
- date: 2026-11-03 | flow: ship-feature | branch: feature/v1-2-anatomical-sheets
- status: active
- worktree: /tmp/claude-1000/-home-bchanot-Documents-faunosteo/e641af9a-743e-46d0-9804-99667836040e/scratchpad/v1-2
(every command runs from this worktree; never from /home/bchanot/Documents/faunosteo, never against DEV:
the `supabase_*_faunosteo` containers are DEV and are never touched; the sandbox is `faunosteo_dbsandbox_*`)
- base: 7f618d0 (memory commit after V1-2.5 VERIFIED at b4415a3)
- contract of the step: docs/development/V1-2_ANATOMICAL_SHEETS.md §16.7 and §8.1-§8.4, with §6.2, §6.6, §6.7,
§9.2-§9.4, §10, §11.1-§11.2, §17.9, §17.11; design docs/design/v1-2-4 boards 04, 05, 06 A (approved, BDR-096),
REVUE.md ratified wordings
## REQUEST (verbatim — IMMUTABLE)
# FAUNOSTEO — Validation V1-2.5 et autorisation V1-2.6
Décision propriétaire : **ALL**.
J'accepte le checkpoint final V1-2.5 au HEAD `b4415a3`.
**V1-2.5 VERIFIED**
J'autorise l'enregistrement des deux mémoires proposées, puis le démarrage de V1-2.6 conformément au contrat existant.
## 1. Mémoires
Créer les deux entrées proposées :
**BDR — Décisions V1-2.5**
- Ordre des états et contrôles d'autorisation.
- Fonctionnement du bouton Réessayer.
- Expiration des habilitations à 23:59:59.999, heure de Paris, le jour choisi.
- Ordre des espèces limité à 0–9 999.
- Deux écarts UX acceptés.
- Parcours de récupération MFA sécurisé obligatoire avant production.
- Réserve concernant les tests mobiles et les tests sandbox supplémentaires.
**LRN — Retours techniques**
- Comportement de GoTrue v2.197 sur la réutilisation des codes TOTP, en distinguant les observations de toute garantie générale.
- Particularité de la réponse Storage HTTP 400 avec `statusCode: "409"`.
- Nécessité d'une sandbox neuve et de l'ordre `test-db → e2e:shell → test`, en conservant l'explication du problème de partage d'état.
Vérifier les identifiants BDR/LRN existants avant attribution. Ne pas créer de collision.
Commiter et pousser ces modifications sur `feature/v1-2-anatomical-sheets`.
## 2. Démarrage V1-2.6 autorisé
Développer l'éditeur anatomique de niveau 1, en respectant strictement le contrat V1-2 §16.7 et §8.2.
Périmètre :
- Onglets et formulaires structurés.
- Import de dessin SVG avec nettoyage par le cœur Rust.
- Gestion des vues principales et secondaires.
- Points, zones et liens anatomiques.
- Édition des propriétés d'annotations.
- Catalogue et arbre des constats.
- Indicateurs de revue et éléments `to_confirm`.
- Enregistrement, récupération locale et gestion des conflits.
- Consultation en lecture seule sous 1 024 px.
- Parcours clavier et accessibilité prévus au contrat.
Ne pas inventer de nouvelles fonctionnalités hors périmètre.
Ne pas modifier le design approuvé V1-2.4 sans défaut démontré.
## 3. Test fonctionnel obligatoire
Démontrer sur une sandbox fraîche un parcours complet :
1. Connexion avec un compte possédant les habilitations nécessaires.
2. Création d'une nouvelle fiche pour une espèce autre que le cheval.
3. Import d'un SVG réel.
4. Vérification et nettoyage du dessin par le cœur Rust.
5. Création d'une vue secondaire.
6. Création et modification de points, zones et liens.
7. Création des catégories et constats prévus par le contrat.
8. Enregistrement du brouillon.
9. Rechargement du navigateur et récupération correcte du travail.
10. Gestion d'un conflit de modification entre deux sessions.
11. Soumission de la fiche.
12. Vérification de sa progression dans le workflow, jusqu'à `verifying` conformément aux règles existantes.
Respecter les règles concernant les éléments `to_confirm` et les verdicts. Ne pas contourner les contrôles pour faire réussir la démonstration.
## 4. Tests et qualité
Exécuter les tests contractuels, notamment :
- E2E A2, A3 et A4.
- Parcours clavier et champs numériques.
- Import SVG hostile et valide.
- Contrôles des permissions.
- Gestion des conflits.
- Rechargement et récupération.
- Affichage mobile à 320 et 375 px.
- Lecture seule sous 1 024 px.
- Intégration des composants Rust/Wasm.
- Non-régression des fiches équines historiques.
Préserver les oracles et les protections de sécurité déjà validés.
Exécuter les suites sandbox dans l'ordre requis, sur une pile neuve, sans masquer les problèmes de pollution d'état.
Relancer `check:all` et une revue indépendante de conformité et de sécurité sur le code final.
## 5. Livrable testable par le propriétaire
Au checkpoint V1-2.6, fournir une procédure pratique pour que je puisse tester l'éditeur dans un navigateur :
- Commandes exactes pour démarrer les services isolés nécessaires.
- URL locale de l'application.
- Méthode d'accès au compte de test, sans exposer de secret dans les logs.
- Parcours précis pour créer une fiche.
- Opérations que je dois pouvoir tester.
- Résultat attendu pour chaque étape.
- Procédure d'arrêt et de nettoyage de la sandbox.
Ne pas affirmer que le produit a été validé par le propriétaire avant mon essai.
## 6. Contraintes
- Travail uniquement sur `feature/v1-2-anatomical-sheets`.
- Commits et push réguliers.
- Aucune fusion vers develop, main ou release.
- Aucune opération sur Supabase DEV.
- Aucun worker DEV.
- Aucune migration DEV.
- Aucune modification des ressources équines historiques.
- Aucun déploiement de production.
- Aucun début de V1-2.7.
La reconstruction des images et les opérations sur la sandbox jetable sont autorisées si nécessaires, après vérification des cibles et de l'absence d'exécution concurrente.
## 7. Checkpoint final
Présenter :
- HEAD et commits.
- Fonctionnalités réalisées.
- Résultats des tests.
- Résultats de l'audit indépendant.
- Écarts et risques résiduels.
- Démonstration complète d'une fiche non équine.
- Procédure de test manuel par le propriétaire.
Ne déclarer V1-2.6 VERIFIED qu'après satisfaction des critères techniques contractuels.
S'arrêter avant V1-2.7 et attendre mon retour après essai de l'éditeur.
## CLARIFICATIONS
Q: Conflict dialog « author and time » (§6.2) has no data source; §16.7 says SQL none / A: [gated 2026-11-03]
read migration M8 (sandbox only, as M7 in V1-2.5): the admin read of the draft returns the last save's actor and
time (from the audit), no write path, no policy or rule change; the deviation from « SQL changes: none » is
recorded in the contract. DEV untouched.
Q: Board 06 A shows « Prévisualiser »; §8.2 lists follow the round and withdraw; §16.8 gives V1-2.7 the
practitioner preview, the round screen and the withdrawal / A: [gated 2026-11-03] deferred to V1-2.7: V1-2.6
submits, then shows the frozen draft with « Revue n° N · vérification en cours » and a link to the sheet's
overview; no « Prévisualiser » and no withdrawal before V1-2.7 (visible deviation from board 06 A, recorded).
Q: Which drawing for A2 (« un SVG réel », non-equine, exported then cleaned) / A: [gated 2026-11-03] the
committed Inkscape 1.4.3 export (`crates/core/tests/fixtures/svg/exports/inkscape-1.4.3-*.svg`, a real export,
cleaning offered) plus a hostile file; the owner may import a drawing of their own at the trial.
Q: Undo / redo control (not on board 04) / A: [gated 2026-11-03] two icon buttons « Annuler » and « Rétablir »
in the tool column under the zoom, plus Ctrl+Z and Ctrl+Shift+Z.
## ACCEPTANCE CRITERIA
Memory part (§1 of the request): done before this contract, commit 7f618d0 pushed (BDR-099, LRN-113; ids
checked across develop, main, feature/v1-1, feature/v1-2: next free were BDR-099 and LRN-113).
1. Route `/app/admin/sheets/:sheetId/draft` exists under `RequireAdmin`; the page loads the sheet's draft
(admin read for the draft version, `get_sheet_version`, drawings downloaded under RLS, an editable
`PreviewSheet`) and shows the permission states of BDR-099 (loading, failed read with « Réessayer », not
authorised); an active `sheet_editor` grant gives the edit mode; reviewer-only and publisher-only accounts
get the read-only mode; a draft frozen by a `verifying`, `open` or `approved` round is read-only with a
notice naming the round; a sheet without a draft says so with a link to the overview. The overview offers
the editor link; A1 (new sheet) and W1 (working copy) land on the editor (§11.2).
2. The editable preview handle replaces the document (`replace_document`) and adds drawings (`add_drawing`)
in place, and after a runtime trap rebuilds from the CURRENT document text and the drawings held, never
from the initial input.
3. Tabs Général, Vues et illustrations, Annotations, Constats, Références, Vertèbres, Vérification (§11.1),
ARIA tabs; every change is one core `sheet.edit` command run on commit (blur, confirm, pointer-up), never
per keystroke; TypeScript keeps no document schema and no Zod copy (ts-rs types only).
4. Général: FR/EN name, description, scope disclaimer, attribution (authors, licence, notes); annotation
categories (name FR/EN, colour) add, edit, delete.
5. Références: add, edit, delete; type, citation, URL (http or https only), DOI. Vertèbres: add (code typed at
creation, read-only after), edit, reorder ↑/↓, delete. A refused removal (`has_dependents`) lists the
dependents from `sheet.dependents`; no cascade deletion.
6. Vues et illustrations: main view and detail views (parent; own drawing or crop entered as numeric
`view_box` values over the parent's preview), rename, delete (dependents listed). Drawing upload: the file
is read by the core (`clean_svg`); hard rejection and active content refused with the reason in FR/EN, no
cleaning offered; cleanable: the cleaned drawing composed by the core and the removed names (a removed
`<style>` named) shown, then one confirmation « Nettoyer et utiliser cette version »; clean: used. The bytes
registered, hashed and uploaded are `SvgCleaning.stored` with the core's sha256; register, upload at
`<sha256>.svg` (an existing object, Storage HTTP 400 with body `statusCode` "409", counts as present),
confirm; the drawing state (ok, missing, rejected) is shown; the §9.3 closed codes have FR/EN messages.
7. Annotations: on the core-composed view (`view.canvas`), tools select, point, zone, detail-view link, zoom;
a point by one click with its radius in a field; a zone and a link as polygons by successive clicks,
closed, Escape cancels a tracing; a link chooses the view it opens; selection on the drawing or in the
list; a selected circle or polygon moves as a block (page preview during the drag, the core command on
pointer-up); a `path` annotation is displayed, selectable, deletable and replaceable by a polygon, never
moved or edited as path data; zoom and pan; every coordinate (cx, cy, r, each vertex x and y) in numeric
fields, vertices added and removed in the list; a keyboard-only path creates and edits points, zones and
links (numeric fields).
8. Annotation properties: FR and EN name, category, laterality, finding zone, vertebral region, colour,
review marking; « Marquer comme relu » on one element; delete with the dependents shown when refused.
9. Constats: tree of finding zones, categories (kind) and nodes up to depth 8: add, rename FR/EN, describe
FR/EN, vet referral flag, cite references, review marking of one element, « Marquer comme relu » on one
category or one zone (never sheet-wide), reorder among siblings with ↑/↓, delete with a confirmation
listing what goes; no move to another parent, no drag and drop.
10. Vérification (board 06 A): the core report's issues with an FR and EN message per code and a link to the
element, the completeness counts, the statuses per group, the document size (`report.document_bytes`)
against 2 MiB, the caps exceeded; `to_confirm` elements informative, never blocking submission (C7);
submission note required as on board 06 A (non-blank, at most 1 000 characters); « Soumettre à la revue »
disabled while the in-page check has errors or the page has unsaved changes, with the hint; a submission
calls `submit_sheet_review` on the saved revision and the page then shows the draft frozen with its round
`verifying`.
11. Save: explicit « Enregistrer » (`save_sheet_draft` with `expected_revision`, no change note: accepted
deviation of REVUE.md); header « Révision N · modifications non enregistrées »; every server failure kind
mapped to an FR/EN message; « Annuler les modifications » returns to the last saved document after a
confirmation; the leave guard (`useLeaveGuard`) is armed while unsaved.
12. Conflict (§6.2): `draft_conflict` opens a dialog with the server revision (and its author and time if the
owner's answer provides them) and « Recharger » or « Garder ma version »; the second saves the local
document on the new revision only after an explicit confirmation naming what it replaces; nothing is
overwritten silently.
13. Local recovery (§6.2): a browser copy of the unsaved document in the report editor's persistence pattern
(sessionStorage), keyed by version and revision, written on each committed change while unsaved, its
status bound to the real write (LRN-057), removed after a successful save or an explicit discard; offered
back on opening when it differs from the server document, restored through the core, never sent
automatically; proven by a restore round trip (LRN-058).
14. Undo and redo: a stack bounded by 8 MiB of document strings (UTF-8 bytes).
15. Ids generated by the page `<prefix>-<10 characters a-z2-7>` (crypto random), inside the stable-id grammar,
never derived from labels, never editable, never reused within the document.
16. Below 1 024 px (board 05): read-only, badges « Brouillon » and « Lecture seule », the notice title alone
(L15, BDR-099 §17.11), tabs, the whole drawing at opening, zoom and pan, a properties summary, no editing
action; unsaved work in memory survives a width change. No horizontal scroll at 320, 375 and 768 px.
17. Security: stored drawing bytes are never inserted into the page; only core-composed trees are rendered
(DOMParser + importNode); the cleaning preview is composed by the core under a scope unique in the page;
the original file is never rendered; no `innerHTML` / `dangerouslySetInnerHTML` carries drawing or
document data; the page-drawn overlay (selection, vertices, tracing) holds numbers only.
18. Unchanged: SQL migrations (unless the owner's conflict answer adds a read migration, sandbox only), the
core's rules and readers, the readers of user data, the equine legacy sources, seed and oracles, the
goldens; the wasm module within its 600 000 B gzip budget; `pnpm r5:import-equine --check` without
difference.
19. i18n: FR and EN parity; the ratified wordings (REVUE.md, §17.9, §17.11) used verbatim; the new labels
listed for a separate owner review, not declared approved.
20. Tests: unit (editor state, ids, undo bound, recovery, conflict, upload steps, issue mapping); `e2e:shell`
A2, A3, A4 with a conflict between two sessions and a local recovery after a reload; keyboard path
through numeric fields; hostile and valid SVG imports; permissions (editor, reviewer-only read-only,
account without capability refused); read-only at 320, 375 and a width under 1 024 px; axe on the
editor and the read-only mode; core-wasm proofs; equine non-regression (catalogue P1, the equine working
copy opening in the editor read path, `r5:import-equine --check`).
21. Demonstration on a fresh sandbox of the request's §3 journey (steps 1 to 12) for a non-equine species,
built from scratch in the UI, saved, reloaded, conflicted, submitted; the validation panel shows no error
while elements are still `to_confirm`; the round reaches `verifying` (no verification worker started).
22. Gates: fresh sandbox, suites in the order `test-db → e2e:shell → test`, state-dependent failures reported,
never masked; `pnpm check:all` green; fresh independent verifier and security review on the final code.
23. An owner test procedure (commands, local URL, test-account access without secrets in logs, journey,
operations, expected results, teardown), and a checkpoint report; V1-2.6 not declared validated by the
owner.
24. Constraints: work on `feature/v1-2-anatomical-sheets` only, regular commits and pushes, no merge, no DEV
operation, no DEV worker, no DEV migration, no production deployment, no V1-2.7 work.
## FILE SCOPE
- apps/app/src: new editor module (route, state, canvas, tabs, dialogs), App.tsx route, AdminSheetRoute and the
creation / working-copy landing, AppLayout width for the editor page, i18n fr.ts / en.ts, core wrappers
(editable preview, `sheet.edit`, `sheet.dependents`, `clean_svg`), lib/id.ts or an editor id module
- apps/app/tests/unit: editor tests; apps/app/e2e/shell: editor specs and support helpers; e2e fixtures
- packages/supabase/src: sheet asset register / upload / confirm accessors and kinds, exports, unit tests
- packages/core-wasm/src: a TS wrapper only if the glue needs one (no Rust change planned)
- docs: BROWSER_TESTS.md, V1-2 contract state lines (§16.7), design README / REVUE pointers, owner test
procedure, label proposals under .claude/audits
- .claude/tasks (plan, TODO), .claude/memory (through memory.sh)
- NOT in scope: crates/**, supabase/migrations/** (except a read migration if the owner chooses it),
supabase/seed/**, legacy sources, goldens, oracles