# CONTRACT — v1-2-6-editor - date: 2026-11-03 | flow: ship-feature | branch: feature/v1-2-anatomical-sheets - status: active - worktree: /home/bchanot/Documents/faunosteo-v1-2 (durable since 2026-11-04, LRN-114; was a session scratchpad) (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 - [amended 2026-11-05, V1-2.6 UX U0] level 1 as built here is NOT declared validated as a whole (owner T11); the redesign (sub-steps U1 to U8 of `docs/development/V1-2-6_UX_PLAN.md`) follows the 16 boards of `docs/design/v1-2-6` (validated 2026-11-05), which replace v1-2-4 boards 04 and 05 for editing (board 05's narrow-screen read-only mode stays the reference under O14 A, C16); the criteria it changes carry an amendment note below. Precedence for the redesign: where a criterion of this contract, with or without a note, differs from the validated v1-2-6 boards or from the V1-2 contract as amended (§8.2-§8.4, §17.12), the amended contract prevails first, then the boards. Two exceptions: a difference listed in `docs/development/V1-2-6_UX_DECISIONS.md` (« Points from the boards for U1 and later ») is an open owner question, and until the owner answers it the criterion stays as written; a point owned by another step (V1-2.7: preview, withdrawal) stays with that step. The other criteria stay in force ## 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. [amended 2026-11-05, U0, §17.12: the two buttons move to the editor header on every tab (ARBITRAGES choice 2, built at U1); the history command is named « Annuler la dernière modification » (T15); the shortcuts are unchanged.] Q: Plan approval (8 visible choices, rescue copy) / A: [gated 2026-11-03] owner brief « GO propriétaire V1-2.6 »: plan, lots A-M, C1-C24 and the 8 choices approved; M8 on the throwaway sandbox only; no JSON export button for the recovery copy; local recovery kept with exact messages on its state and limits; a local restore never silently overwrites a newer server revision; execution gated on a targeted independent re-check of the six FATAL fixes. Q: Re-check REMAINING(2) (default radius out of frame; pending copy overwritten) / A: [gated 2026-11-03] owner brief « arbitrages propriétaire sur REMAINING(2) »: radius `min(12 + 0.03 × max(w, h), min(w, h) / 2)` in the drawing's frame, the clicked position kept when a valid radius exists, a position correction shown and confirmed, never silent, never below the core's minimums, never `out_of_frame`, the core keeps the authority; editing blocked while a recovery offer is unanswered (« Restaurer la copie » / « Ignorer la copie », consultation allowed); conflict N from `draft_version.revision`, author and date from `draft_last_save`, failed read → « Recharger » / « Réessayer », « Garder ma version » disabled; two-copy cap kept with no automatic eviction of an unresolved copy; AAL2 residual risk recorded, not fixed; second targeted re-check, then execution without a new authorisation if conforming. Q: Re-check REMAINING(1) (F1 unmeasured views; C26 refinement for annotations already out; minor effects) / A: [gated 2026-11-04] owner brief « GO propriétaire après REMAINING(1) »: F1 fix approved; C26 refined by seven repair rules (new annotation valid before integration; a valid annotation never made invalid; an annotation already out repairable; intermediate values kept in the form; geometry applied only when the whole satisfies the core; no diagnostic hidden; a frame change never silently invalidates); 4 px drag threshold, unreadable copy kept with « Ignorer la copie » naming the loss, leave guard while a decision is pending and not after; execution of lots A-M authorised without a third plan review; stop on a blocking defect or a contractual impossibility. ## 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). [amended 2026-11-05, V1-2.6 UX U0, V1-2 contract §17.12; built at U1] Four tabs: Général, Annotations, Constats, Vérification. Views, drawings, annotation categories and vertebral regions move into Annotations; Références becomes a side panel opened from the header or from a finding; Annuler and Rétablir sit in the header on every tab. The commit rule and the ts-rs-only rule above are unchanged. 4. Général: FR/EN name, description, scope disclaimer, attribution (authors, licence, notes); annotation categories (name FR/EN, colour) add, edit, delete. [amended 2026-11-05, U0, §17.12] Categories leave Général for the category panel of Annotations (U3: swatch and name, palette and hex, staged « Appliquer », delete when unused, « Réaffecter à… »). From U6 the three fixed categories Os, Articulations, Vertèbres keep their names and roles (no delete, name read-only), their colour and fill opacity stay adjustable; other categories stay free. 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. [amended 2026-11-05, U0, §17.12] References move to a side panel (C3). Vertebral regions open from the vertebra-role category at U6 (board 09): reorder by grip handle or Alt+arrows, staged « Appliquer »; the ↑/↓ buttons stay until then; whether a region code stays read-only after creation is settled at U6. 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 `