# TODO — Osteo Report MVP ## Status (2026-05-21): catalog v2.0 + full 26-zone horse coverage in place — B4 polish + ship gate next Domain pivot bundle (B0 schema, B1 report v2, B2 UI/PDF, B3 i18n) shipped on `feat/findings-tree-v2`. Catalog upgraded v1.2→v2.0 by domain expert: 26 zones (was 3), 792 nodes, 612 leaves, 41 vet-referral leaves. Zero code change needed — schema was forward-compat since B0 (BDR-016, LRN-020). 154/154 tests green, lint 0, typecheck clean, vite build OK. --- ## DONE since 2026-05-21 (main +41 commits — the frozen Status block above is the 2026-05-21 snapshot) Current main @ 4991c10: 174/174 tests green (30 files), lint 0, typecheck clean, vite build OK. feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work below landed on main. No git tags yet (see CHANGELOG version note). ### Laterality + bilaterality - [x] LateralSideSchema (left/right) + Bone.lateral; data-anno-lateral parsed from SVG (e0abb1e, db50c67) - [x] LateralityPicker modal + zone-click integration; side in zone badges + PDF labels (20d60b9, 5a19ae1, 3323d4e, 773b002) - [x] Bilateral zones: separate findings picker per side (c853c68, 0c170bd) ### Editors - [x] SVG anatomy editor at /svg-editor — vanilla JS tool wrapped in React (ea81d8c, BDR-017) - [x] Standalone public/pathology-editor.html JSON tree editor (9cca51c, BDR-020/021/022) - [x] Tabbed welcome screen with project SVG picker (2273602) - [x] /editors listing page + footer links + locale-aware zone hover tooltip (5e24c2f, 569e571) ### Branding + UI - [x] Global footer: copyright + "Powered by ZenQuality" + "Paws in Harmony" logo, site + PDF (caac149, 3a67da7, d9cf2fa, 33a7f47) - [x] Unified AppHeader (logo brand + tagline) across routes (1f30280) - [x] Responsive mobile — full phone/tablet adaptation (a73d8da) - [x] Project renamed Zoosteo → Faunosteo across the codebase (2d6ed80) ### Infra - [x] Docker: no-cache header for species assets (53f62f7) - [x] pathology-editor.html prod 404 fixed — served from public/ so it ships to dist (2803cf7, LRN-029) - [x] gitflow socle + pre-commit hook adopted (4991c10) ### Tour + fixes 2026-07-12 (branch chore/tour-2026-07-12 — UNMERGED, review pending) - [x] /tour sweep: CVE deps patched (pnpm audit 0), SVG import sanitized, container non-root (**BREAKING: PORT >=1024**), nginx:1.31-alpine pin, dead code −93 lines (canvg dropped), docs synced. Report: .claude/audits/TOUR.md - [x] Post-tour fixes: aria-labels i18n (B-1/B-2), EN PDF title prefix (B-4), SvgEditor placeholders (B-5), species labelEn (B-6), draft restore (B-3, TDD), entrypoint escaping (SEC-9), PDF decompression cap (SEC-8, TDD), dead BoneState + 22 unused PNGs (CLN-6/7). 180/180 tests. --- ## SaaS migration (plan: docs/development/IMPLEMENTATION_PLAN.md) - [x] Step 0 — preparation docs in docs/development/ (2026-10-08, validated) - [x] Step 1 — characterisation tests: 7 files / 91 cases, 2 golden fixtures, docs/development/CHARACTERIZATION_REPORT.md; 271/271, typecheck, lint, build green (2026-10-08, branch feature/step-01-characterisation-tests, awaiting validation) - [x] Step 2 — monorepo workspace: apps/app via git mv (144 files), root scripts, Node 24 + pnpm 10.13.1 pins, Dockerfile node:24 + filtered build, CI .gitea/workflows/ci.yml, WORKSPACE.md; 271/271, typecheck, lint, build green from root (2026-10-08, branch feature/step-02-monorepo-workspace, uncommitted, awaiting validation) - [x] Step 3 — Supabase foundation (2026-10-08, feature/step-03-supabase-foundation merged into develop 7ea0b1f, USER VALIDATED 2026-10-08; real stack verified: start/reset, pgTAP 81/81, gen types diff, REST script — BLK-006 resolved) - [x] 3.0 context: plan Step 3, BACKEND_ARCHITECTURE §2-§9, business §4.1/§17/§29; Docker socket denied to user → PGlite harness as executable proof, pgTAP kept for `supabase test db` - [x] 3.1 supabase/config.toml (CLI pinned as root devDependency) + `supabase/seed.sql` (local users only) - [x] 3.2 migration 0001 foundation: schemas private/audit, set_updated_at, audit.audit_logs append-only, private.log_event - [x] 3.3 migration 0002 profiles: table, auth.users trigger, protected columns trigger, RLS own row (+ staff read), grants - [x] 3.4 migration 0003 platform roles: enum platform_role (owner/admin/moderator/support), profile_roles, private.is_platform_* helpers, grant/revoke RPC with audit, RLS - [x] 3.5 pgTAP tests supabase/tests/*.sql (schema, profiles RLS allow+deny, roles allow+deny, audit append-only) - [x] 3.6 packages/supabase: PGlite harness (auth shim + migrations) + vitest RLS suite (allow+deny), database.types.ts (generator format) + schema↔types consistency test, browser client factory - [x] 3.7 app integration: env.ts supabaseUrl/anonKey, lib/supabase.ts lazy client (null when unconfigured), entrypoint.sh + .env.example + compose; no UI change; tests - [x] 3.8 CI: supabase job (start, db reset, test db, gen types diff); check job runs PGlite suite via pnpm -r - [x] 3.9 docs: docs/development/SUPABASE.md (start/reset/test/types/bootstrap owner), CLAUDE.md folder map + scopes, README pointer - [x] 3.10 verify: typecheck, test:run 278 app + 13 supabase (81 pgTAP), lint 0, build OK; BDR-026..029, LRN-035/036, BLK-006, EVAL-006 - [x] Step 4 — canonical anatomical sheet model (2026-10-08, feature/step-04-anatomical-sheet-model merged into develop, USER VALIDATED 2026-10-09; 7 business decisions → BDR-033, spec §5). Scope re-split: model + validation + persistence + tests here; legacy importer → official equine DRAFT + import report = next step (user: no full import yet, draft verified before publication). Spec: docs/development/ANATOMICAL_SHEET_MODEL.md - [x] 4.0 context + spec: business §2.6–2.9/§7/§16/§17.3/§23, OPEN_QUESTIONS C1/C2/C8/C9/Q3/Q5/Q9, audit 07; ANATOMICAL_SHEET_MODEL.md written - [x] 4.1 packages/domain: AnatomicalSheetDocumentSchema (strict, localized {fr,en}, views tree, annotations union, finding tree with category kind), validateSheetDocument (integrity issues), assertPublishable, createEmptySheetDocument; fixture horse-slice; tests per rule + id-stability - [x] 4.2 migration 20261008110000_anatomical_sheets: species (seed equine), enums, sheets/versions/assets, triggers (one draft, published immutable, delete preconditions, species match), helpers can_edit/can_use_sheet, sheet_document_issues, lifecycle RPCs (create/draft/publish/deprecate/delete/fork/archive/restore/delete sheet/register asset), privileges + RLS - [x] 4.3 pgTAP 005_anatomical_sheets.sql: schema/privileges, lifecycle allowed path, immutability, fork provenance, deletion preconditions, denied paths (other user, anon, direct writes, official), invalid document refused at publish - [x] 4.4 packages/supabase: database.types.ts regenerated (real stack), schema-types test extended (tables, enums list, functions); index.ts row aliases; publishSheetVersion service (domain validation before RPC) + test - [x] 4.5 docs: SUPABASE.md layout/tests, CLAUDE.md folder map + conventions + scopes, packages/README, IMPLEMENTATION_PLAN Step 4 adjustment note, CHANGELOG - [x] 4.6 verify: pnpm check green (61+17+278), db:reset + db:test 210/210 real stack, types in sync; verifier ECARTS(5) + security BLOCK(1) → all fixed (BLK-007 hardening migration, visibility RPC, +32 pgTAP, doc sync); BDR-030..032, LRN-038..040, EVAL-008 - [ ] Step 4b — equine import (2026-10-09, branch feature/step-04b-equine-import): legacy SVGs + catalog → official equine sheet as DRAFT, import report for business review, no publication - [x] 4b.0 kind rename observation→consultation_reason (BDR-033 #5); decisions in spec §5 + memory - [x] 4b.1 packages/anatomy: legacy importer (SVG walker via @xmldom/xmldom, catalog mapper, deterministic ids, legacy-id-map, import report with anomalies incl. ssb-dysfunctions), CLI `pnpm import:equine` writing supabase/seed/anatomical-sheets/equine/v1/{document.json,legacy-id-map.json,IMPORT-REPORT.md,assets/,equine_v1.sql}; tests: counts preserved (27 ann / 26 mapped / 792 nodes / 612 leaves / 41 vet), determinism, Zod + 0 integrity errors, golden artifacts - [x] 4b.2 migration 20261009100000 sheet asset storage: bucket anatomical-sheet-assets (private), object read policy through the sheet (published refs or editor), no API writes; shim storage tables; pgTAP - [x] 4b.3 seed: equine_v1.sql idempotent (platform-owned official sheet, private, draft v1, 2 asset rows, fixed ids) in config sql_paths + PGlite harness applies supabase/seed/**; pgTAP 006: draft present, not publishable by non-admin, sheet_document_issues empty, assets match; upload script for the SVG bytes (service key from env, user/operator runs) - [x] 4b.4 real stack: db reset + db test + types check + assets upload + REST read check; docs (SUPABASE.md, ANATOMICAL_SHEET_MODEL.md §6 import, CLAUDE.md, plan note, CHANGELOG) - [x] 4b.5 verify: pnpm check green (61+30+20+278), real stack 256/256, types in sync, docker build OK, Storage API 400→200 after confirmation (alice/anon 400); verifier ECARTS(4) + security MEDIUM (hash claim) → fixed (uploaded_at + confirm RPC, authored labels, seeds-listed test, Dockerfile manifests); EVAL-009 - [x] Step 4b VALIDATED by user 2026-10-09 → finished into develop. Draft stays private, never auto-published. - [x] Step 4c VALIDATED by user 2026-10-10 → finished into develop; draft stays private, never auto-published — equine sheet audit, correction, enrichment (2026-10-09, branch feature/step-04c-equine-curation). User brief: research-backed audit of SVG annotations + findings catalog, corrections by confidence level (A demonstrated / B supported, flagged / C uncertain, question for the osteopath), traceable changeset (id, before, after, nature, rationale, references, level, needs confirmation), reproducible baseline of the 4b import, no publication, no design redesign (propose first). - [x] 4c.0 Docker naming convention `faunosteo_` (compose container/project names; Supabase CLI names fixed `supabase__` → documented limit). Docs + memory (BDR). - [x] 4c.1 domain schema v2: document `references` registry + node `reference_ids`, `review_status` on nodes and annotations, `count_range` on vertebral regions; rules `finding.reference.missing`, `region.count_range.invalid`; tests; migration extending the schema CHECK + SQL issues; types regen; pgTAP. - [x] 4c.2 packages/anatomy curation layer: changeset schema (Zod, JSON data), applier (set / rename / add / remove / move / cite / annotation ops), before-values captured by the applier, CHANGELOG + REVIEW-REPORT generators, diff v1 → draft; seed dir restructure: `legacy-import/` (baseline, generated) + `draft/` (curated working revision, seeded); cleaned SVG asset (legacy markers stripped), head view = view_box crop of the single asset. - [x] 4c.3 research (parallel agents, WebSearch): axial skeleton + vertebral variation; skull/sutures/SBS/TMJ/hyoid; appendicular nomenclature NAV/Barone; osteopathic terminology + French legal scope + vet red flags; catalog analyzer pass. Output: findings with verifiable references, classified A/B/C. - [x] 4c.4 content changes: sphenoid zone restructured (SSB tree duplicated under sphenoid), terminology (lésion → dysfonction, NAV names, FR grammar), 62 EN descriptions + EN disclaimer, vet flags audit, references registry + citations, additions (carpus…), SVG point moves (B, before/after renders), Cd range 15–21. - [x] 4c.5 reports: REVIEW-REPORT.md for the osteopath (10 sections, questions ranked), CHANGELOG table, before/after review SVGs (draft/review/, PNG renders by operator), quantitative before/after. - [ ] 4c follow-up (open, not blocking Step 5): 11 questions for the osteopath (draft/REVIEW-REPORT.md §10) → next changeset; legal scope text to re-read on consolidated Légifrance articles before publication; BLK-008 data migration v1→v2 before real data; user action `.env.example` COMPOSE_PROJECT_NAME=faunosteo (DEPLOY.md) - [x] 4c.6 verify (root check 68+21+100+278, PGlite + real stack 267/267, types, docker build, Storage e2e; verifier ×3 → fixes, security PASS; EVAL-010): pnpm check, PGlite + real stack pgTAP, types, docker build, golden tests; gates verifier + security; docs (spec §6/§7, SUPABASE.md, CLAUDE.md, plan Step 4c, CHANGELOG); memory (BDR/LRN/EVAL/journal). Stop for user validation. - [x] Step 5 — application on the canonical sheet (analysis validated 2026-10-10; implemented on feature/step-05-app-on-canonical-sheet; USER VALIDATED 2026-10-10, all paths OK; finished into develop 2026-10-10; D5 orphan findings documented as UX follow-up) - [x] 5.0 freeze: golden v2 PDFs + expected v3 docs; CHARACTERIZATION_REPORT refreshed - [x] 5.1 pipeline: report-migration-map.json (annotations, views, findingPaths 442/136/≤34), app-main.svg + app-head.svg review renders, category colours changeset (D1) - [x] 5.2 packages/domain: Report v3 (annotationId+viewId, free region codes, severity codes D8, sheet ref, unresolved findings, localAnnotations []), migrateReportV2ToV3, tests on fixtures + 612 leaves - [x] 5.3 app foundation: bundledSheetProvider (Vite alias @sheets), sheetIndex, sanitiser, renderAnnotationLayer (legacy look), AnatomyCanvas/DetailModal on views (head = crop) - [x] 5.4 zoneInteraction service + reducers, store split + sessionStoragePersistence (v2 migration on load), pickers/cards on sheetIndex (D6 ranges, D7 title), EditorRoute < 300 lines - [x] 5.5 PDF shim + attachment v3 + v2 import (gate D3) - [x] 5.6 delete legacy (registry, species/*, zoneMatch, spineZones, svgConvention, D4 tools), SVG convention doc replaced, CLAUDE.md map, CHANGELOG, plan note, memory - [x] 5.7 visual before/after (cmp renders), root check + docker + real stack green; verifier ×3 (gaps closed), security PASS (LOW fixed); EVAL-011. Manual FR/EN flow = user validation - [x] 5.8 per-leaf migration (user ask 2026-10-10, during manual validation): every legacy leaf (612 = 442 identical, 141 moved, 29 removed) as a v2 finding → migrated → resolved to a draft leaf (anatomy, map file) and through sheetIndex.nodeAt + PDF roundtrip (app); the 27 legacy annotations as zones on their views - [x] 5.9 archive check tool `pnpm report:compare ...`: v2 attachment vs migrated v3 side by side, unresolved flagged (removed vs unknown), `--full` opt-in for names/free text, control chars escaped, --diff of two PDFs, --summary; attachment.ts split read/parse (additive, D3); docs PDF-FORMAT/CLAUDE/README - [x] 5.10 final controls on the last lot: stale root script scaffold:species removed; verifier ×3 (2→1→CONFORME) + security ×2 PASS on criteria 16-18; EVAL-012 - [x] 5.11 user validation defect: findings picker text blurry on screen → permanent `will-change` on the list dropped (hotfix 1f0b710, regression test); PDF never affected - [ ] 5.12 follow-up (not Step 5): equine sheet anatomical enrichment with the osteopath + future sheet editor (Step 17); the 28 draft annotations (carpus added, points moved) are NOT a final catalog - [ ] Step 6 — autonomous PDF archives (analysis validated by user 2026-10-11 with D7 branding archived, D8 snapshot kept + explicit rebase, D13 messages → Part II contract + BDR-039; implementation on feature/step-06-pdf-archives, one executor per phase) - [x] 6.0 analysis: 3 analyzers (pipeline, model, app/tests) + size measurements (envelope 172 KB raw / 51 KB stored for 3 obs, 228 / 54 worst case) + 3 plan-challengers → plan rewritten - [x] 6.1 Phase 0 freeze (8b86b92: 39 goldens, demo fixture, bare v3 PDF, T12/T13; 206 app tests) with current code: demo report fixture, migrated-v2-with-unresolved builder, G3 bare v3 PDF, G1 text goldens (logos absent + present), G2 structural facts/placements/links, T12 HomeRoute + T13 EditorRoute characterisation - [x] 6.2 Phase 1 domain (cdc0943: 154 domain tests, snapshot 171 KB raw on the fixture): sheet-index moved, archive/snapshot (buildSheetSnapshot, assertSnapshot, caps), archive/envelope (schema v1, layered readArchiveDocument, SnapshotRejection), report/rebase (rebaseReportOnSheet), bundle carries asset sha + status/name, tests - [x] 6.3 Phase 2 anatomy (6940926: composeViewSvg + highlightLayer, 130 anatomy tests): render/compose.ts promoted from curation/app-review.ts, highlight on the layer tree, review drawing golden unchanged - [x] 6.4 Phase 3 packages/pdf (c179560: 53 engine tests, 36 goldens exact, resvg raster, demo envelope 55 KB / 136 KB stored): scaffold (no DOM lib, restricted globals, vitest node, Dockerfile, CI, README), svg/sanitize allowlist + horse.svg zero-removal, render moved, Branding/Rasterizer/exportedAt/safeText/dict, exportReportArchive (T3 both logo modes), readReportArchive (filename-first, layered, attachment_stripped; T4-T6, T8), T1/T7/T9/T10 resvg/T11, xmldom bundle size ≤ 50 KB gz - [x] 6.5 Phase 4 app (9bd5173: 222 app tests, archive kept in session, rebase + alerts, legacy PDF modules removed, xmldom ≈ 31 KB gz in the main chunk): browserRasterizer, branding.ts, export/import on the engine, rebase on import + draft restore, 2 new messages, old render/attachment/highlight code + pdf.* keys removed, report:compare on engine API, T2/T14/T15, suite migrated 1:1 - [x] 6.6 Phase 5 docs + gates (docs synced; verifier ECARTS(31 oracle/scope) → CONFORME 13/13; security BLOCK(1) → 4 fix loops → PASS; 656 tests, build, docker ×4 green) - [x] 6.8 user manual tests round 1 (2026-10-11): logos and picker text confirmed OK by the user after branding bundled (293a6e0) and the investigation; restore-rebase alert (e8f1734); STEP 6 VALIDATED BY USER 2026-10-11 - [x] 6.9 closure decisions (BDR-040): re-export-archive button REFUSED for good; import headlines full/partial (62b8a43); BLK-009 byte-scan reader + no object streams (60ee712), fresh security audit + verifier; gate before external users kept in PDF_IMPORT_HARDENING.md §5 - [ ] 6.10 finish into develop, release/0.2.0 prepped (Milestone A) — tag/merge to main on the user's go; Step 7 NOT started (UX/design discussion first) - [ ] 6.7 follow-ups recorded for Step 13: catalog asset cap aligned with the archive cap (2 MiB), allowlist sanitiser at upload, app canvas sanitiser (EVAL-011) - [ ] 5 follow-up: allowlist SVG sanitiser before Storage-served assets (Step 13); orphan findings UX (D5) at the report UX step; report:compare residuals (ZodError reason genericised, v3 lines computed once, long template lines); 16 MiB attachment cap without direct test - [x] Step 7 — identity: auth, profile, roles, /app shell (started 2026-10-11, branch feature/step-07-identity-app-shell; USER VALIDATED 2026-10-12, all screens and flows OK, no UI correction; mockups now versioned at docs/design/faunosteo-etape7-maquettes-validees.png; finished into develop). Scope decisions: professional fields = additive migration on profiles (practice_name, professional_title, siret free text, verification = later domain); MFA = documented gap (TOTP disabled in config, no has_mfa helper, no admin table); no TanStack Query (zustand store suffices); legacy routes untouched and unauthenticated; /app visible from Home only when Supabase is configured - [x] 7.0 plan + branch + ctx7 cache (supabase-js auth, config.toml providers) - [x] 7.1 config: appConfig.authProviders (APP_AUTH_PROVIDERS / VITE_AUTH_PROVIDERS, google|apple), entrypoint + env.example + DEPLOY table; config.toml: TOTP enroll/verify on, [auth.external.google|apple] via env(), redirect URLs; packages/supabase: auth service wrappers (typed errors), profile read/update service - [x] 7.2 migration 20261011100000_profiles_professional: practice_name, professional_title, siret (+ CHECKs, column grants); pgTAP 009; database.types regenerated (real stack) + schema-types map - [x] 7.3 app state: authStore (status loading|signed_out|signed_in, session, user, profile, roles), bootstrap on getSession + onAuthStateChange, profile fetch, roles fetch; locale sync (profile.locale → localeStore on sign-in, localeStore → profiles.locale while signed in); AuthProvider in App - [x] 7.4 auth screens: /login (email+password, OAuth buttons per authProviders, links), /signup (display name, email, password ×2, policy hints, "check your inbox" state), /forgot-password, /reset-password (PASSWORD_RECOVERY → new password), /auth/callback (code exchange → /app); AuthLayout (brand, cream card); not-configured state - [x] 7.5 /app shell: RequireAuth guard (redirect /login?next=), AppLayout (desktop sidebar: dashboard, account, local tool link, logout; mobile top bar + drawer), /app dashboard (welcome, profile completeness card, local tool card, no fake stats) - [x] 7.6 /app/account: personal (display, first, last, phone), professional (title, practice, siret), preferences (locale, timezone), security (change password, logout, MFA gap note), roles badge read-only - [x] 7.7 Home coexistence: "Mon espace / Se connecter" entry on the header when configured; characterisation tests T12 unchanged with default config - [x] 7.8 tests: config, authStore (fake client), locale sync, forms, guards, shell, dashboard, account; i18n parity; pgTAP 009 (PGlite + real stack 280/280); root check + docker build green; headless e2e vs local stack 20/20 (signup via Mailpit, recovery, logout, mobile) - [x] 7.9 docs (IDENTITY.md, SUPABASE.md, CLAUDE.md, CHANGELOG, plan note); memory BDR-041, LRN-047, EVAL-015, journal; gates: verifier ECARTS(2) → open-redirect fix + contract CHECK → CONFORME 16/16; security PASS (MEDIUM fixed, 3 LOW closed, TOTP enforcement = documented gap). User validated 2026-10-12; user action still open: `.env.example` += `APP_AUTH_PROVIDERS=` (file edit denied here) - [ ] 7.10 follow-ups kept by the user (2026-10-12), each owned by a later step: MFA mandatory before any sensitive admin feature (has_mfa helper + enrolment UI, IDENTITY.md §4; first admin screen); professional verification distinct from the SIRET format check (Step 11); real tests of Google and Apple once the provider ids exist (config.toml env(), APP_AUTH_PROVIDERS); integration of the report tool into the signed-in /app space (Step 14 gating); mockup elements not built yet listed in docs/design/README.md (bell, avatar photo → Step 8, stat tiles, tabs, mobile tab bar) - [ ] Step 8 = Rust R1 — files foundation + Supabase Storage + avatar (GO 2026-10-13: R0 validated, D1–D9 validated with D1 = Rust worker, D3 = top-bar avatar + name linking to Mon compte; branch feature/step-08-files-foundation, cut from the R0 tip because `gitflow finish` of R0 was refused by the harness classifier: the owner runs it). Analysis: docs/development/STEP8_FILES_ANALYSIS.md; contract-level spec written first in docs/development/STORAGE.md. Out: SVG upload (Step 13), other buckets' flows, PDF/anatomy ports, webhooks, CI/CD, VPS deploy, release 0.2.0 - [x] 8.0 analysis: facts (existing bucket + policy pattern, sanitiser, edge runtime off, CSP, deploy), design (assets table authority, server-built keys, quarantine prefix, worker `faunosteo_worker` with sharp + pdf sanitiser, storage.objects policies through assets, Storage API signing under RLS, sweeper/reconcile, backups file volume + restic, managed migration by rows), 10 security answers, scope, tests, risks, D1–D8 - [x] 8.1 migration 20261013100000_files_foundation: `asset_status`, `assets` (lease token added for stale-task refusal), 7 buckets (avatars open: 5 MiB, jpeg/png/webp; 6 closed; sheet bucket untouched), `private.can_read_avatar_object` / `can_upload_avatar_object`, storage.objects SELECT + INSERT policies, `private.object_purge_queue` + status/delete triggers (48 h final key of a deleted row, 1 h quarantine and rejected), `private.storage_ceiling()`, RPCs begin_avatar_upload / confirm_asset_upload / remove_avatar (authenticated), claim_avatar_jobs / complete_avatar_job / reject_avatar_job / mark_quarantine_purged / claim_purges / ack_purge / claim_quarantine_leftovers / expire_pending_uploads (service_role), closed error messages (P0001), explicit revokes, column grants - [x] 8.2 pgTAP 010: allowed + denied twins for every RPC and policy, the 8 scenarios of the owner's brief (cross-user read, cross-user replace/delete, anon, quarantine never readable, final key never uploadable, superseded/removed row never completes, stale lease refused, late bytes inert), purge queue contents and grace, policy census (one bucket literal per policy, 2/1/0 per bucket, total pinned), audit rows; 001 census += the two predicates; shim adjustments if needed; real stack `db:reset` + `db:test`; `db:types` + schema-types map - [x] 8.3 crates/worker R1 (fork A): `config` (env, no secret printed), `log` (JSON lines, field allowlist, child stderr escaped and truncated), `backend` trait + `http` (ureq 3, rustls + ring, PostgREST rpc + Storage object endpoints, 30 s timeouts, 5 MiB download cap, strict key validation before any URL), `decoder` trait over `Spawner`, `job` (claim → download → decode → PUT clean → complete → DELETE quarantine → mark purged; refusals → reject; `Broken` → alert + stop; complete refused → nothing deleted, the queue owns the object), `sweep` (claim_purges/ack, quarantine leftovers, expire pending), `watchdog` (per-stage deadlines, exit on overrun), `run` loop + `run --check`; unit tests on a fake backend + fake decoder; seccomp derivation re-run (the parent gained TLS/HTTP code, the child must stay at the traced set); JWT exp logged at start - [x] 8.4 packages/supabase `assets.ts` (fork B): beginAvatarUpload, uploadToQuarantine, confirmAssetUpload, removeAvatar, fetchOwnAvatarState, downloadAvatar, closed `AssetFailure` kinds (P0001 messages → kinds; storage errors → network/unknown); tests on a stub client - [x] 8.5 app (fork B): `account/avatarTransport.ts` (magic-byte sniff jpeg/png/webp, never SVG, createImageBitmap → canvas ≤ 1024 → JPEG 0.9, ≤ 5 MiB after transport), `AvatarSection` in Mon compte (circle photo/monogram, Modifier la photo, preview + Enregistrer/Annuler, processing with 1 s polling ≤ 30 s, rejection message per code, Supprimer with Dialog confirmation, in-flight row on mount), authStore `avatarUrl` blob (download under RLS, revoked on change/sign-out), `UserBadge` photo, top bar avatar + name → /app/account (D3), i18n FR/EN parity, component + store tests, `impeccable detect` - [x] 8.6 integration: docker-compose `worker` service under profile `worker` (read-only, cap_drop ALL, no-new-privileges, mem 512m, cpus 1, pids 64, external Supabase network), `.env.worker` variables documented (file not editable here), real-stack e2e `pnpm --filter @faunosteo/supabase test:e2e` (worker container against the local stack: Alice flow clean + download 200, replace, remove, Bob 400, anon 400, quarantine 400, late signed-upload bytes swept, purge after grace via clock shift) - [x] 8.7 docs: STORAGE.md final (model, keys, statuses, worker operations, purge/grace, reconciliation query, backup ordering + invariant, managed migration runbook), DEPLOY.md (worker service, env file, network, CSP connect-src), SUPABASE.md (worker in dev, buckets), RUST.md §3 (R1 loop), WORKSPACE.md, TEST_STRATEGY.md, IDENTITY.md §5 avatar steps, docs/design/README.md (avatar built), CLAUDE.md, CHANGELOG; CI yml untouched beyond a comment (no runner) - [x] 8.8 verify: `pnpm check:all` ×4, PGlite + real stack pgTAP (140 / 420), types unchanged, worker image + sandbox tests, e2e ×7, Chromium smoke 18/18, verifier CONFORME (pass 2), security PASS after 5 passes (BLOCK on my ceiling join fixed: bytes-present ceiling + 64 MiB per-account budget); BDR-048, LRN-051, EVAL-019, journal. OPEN: owner manual validation; owner runs `gitflow finish` for feature/rust-r0-foundation then, after validation, for this branch; `.env.worker` to create by hand (DEPLOY.md); residual LOWs documented in STORAGE.md §2.1 (colluding-account ceiling fill, search-domain on native glibc runs, ceiling race) - [x] 8.9 owner validation 2026-10-13: 10/10 manual + graphic → R0 (5cfb6f1) and R1 (f5865f0) finished into develop; identity + environments + LAN rule → BDR-049 - [x] chore/dev-lan-access (2026-10-13, owner validated computer + phone, merged): DEV origin centralised (`scripts/dev-env.sh`, `pnpm supabase` wrapper, `pnpm dev` on the LAN, config.toml env()), ENVIRONMENTS.md; automated 26/26 at http://192.168.1.100 (computer + phone viewports, URL audit); UFW rules applied by the owner, refusals verified from another device (54322/54323/54324 closed, 54321 open); Mailpit via gateway :54325 (basic auth); 10-step path validated by the owner on computer and phone - [ ] Rust by default (rule adopted 2026-10-12, BDR-043; orientation + 10 principles VALIDATED by the owner 2026-10-12, BDR-044; study `docs/development/RUST_ARCHITECTURE_REVIEW.md` rev 2 + Annex A decision table + Annex B R0 scope on chore/step-08-files-analysis; AWAITING the owner's validation of decisions D-R1..D-R14 (D-R6 withdrawn); R0 and Step 8 NOT started until then). Roadmap (each phase: oracles frozen with the old code, consumer-driven deletion, rollback row, gates): - [ ] R0 foundation (GO 2026-10-12, BDR-045; branch feature/rust-r0-foundation; Annex B; owner constraints: builds reproducible in Docker, no Rust on the VPS, live deployment untouched, frontend never loads the module, no R1): - [x] R0.1 toolchain: `docker/rust-builder.Dockerfile` (rust:1.99.0-bookworm + wasm target + wasm-bindgen-cli 0.2.129 + cargo-deny 0.20.2 + rustfmt/clippy), `docker/rust-run.sh` (named volumes faunosteo_cargo_registry / faunosteo_rust_target), `docker/rust-check.sh`, `docker/wasm-build.sh` (CLI/crate version lock), root scripts rust:builder / rust:check / wasm:build / worker:test / worker:image - [x] R0.2 workspace: Cargo.toml (3 members, pinned deps, lints unwrap/expect/disallowed_methods, dev deps optimised), rust-toolchain.toml 1.99.0, rustfmt/clippy/deny config, .cargo/config.toml (wasm stack 1 MiB, TS_RS_EXPORT_DIR), Cargo.lock, .gitignore/.dockerignore (target, pkg) - [x] R0.3 crates/core: js_number + JsPrettyFormatter (JSON.stringify semantics), report contract types (SheetRef, ReportZone, Vertebra, LateralSide, Unresolved) with optional-absent / nullable-null, facade `call(op, json)` with closed kinds; 12 cargo tests + ts-rs export (4 types committed under packages/core-wasm/types) - [x] R0.4 crates/wasm: facade (core_version, call, panic_for_test, recurse_for_test); build 224,713 B raw / 85 KB gzip (float_roundtrip on), instantiate ≈ 3 ms in Node - [x] R0.5 crates/worker: plain main, `decode` child (env check → rlimits AS 512 MiB / CPU 10 s soft, 12 s hard → seccomp allowlist TSYNC kill) → image decode with Limits → orientation → resize_to_fill 512 → libwebp-sys lossy; parent `Spawner` (env_clear, 512 KiB output cap, deadline, signal classification) + `webp_check` (RIFF allowlist, dims, no metadata); `run --check`, `version`; test-hooks (fixtures, violate, flood, alloc, spin, print-allowlist); Dockerfile alpine musl → test stage (sandbox tests + strace derivation) → distroless/static:nonroot - [x] R0.6 packages/core-wasm: loader (lazy, Node bytes), generated types, vitest proofs (facade, serialisation byte-equal with JSON.stringify on 4 real documents + number cases + Zod readers, panic/stack traps, size budget) skipped with a notice when pkg/ is absent - [x] R0.7 proofs recorded with numbers in RUST.md §5: panic=abort traps + stack-trap instance unusable + fresh instance via cache-busting import; serde_json `float_roundtrip` finding (byte parity on 4 real documents + number corpus, Zod readers); musl static + libwebp 1.6.0 (image 8.7 MB, read-only, caps dropped); seccomp allowlist derived by strace on the release binary = 7 syscalls + 7 abort path, 13/13 sandbox tests; CSP: refused with `script-src 'self'`, OK with `'wasm-unsafe-eval'` (Chrome 156, nginx 1.31, `docker/csp-proof/`); wasm 224,713 B raw / 85 KB gzip / ≈ 3 ms; runner cache NOT measurable here (pending on the forge, §5.7) - [x] R0.8 CI: job `rust` (builder image, fmt/clippy/test/deny, types drift, wasm build), `check` builds the wasm then runs the Node pipeline, `docker` builds the worker test stage + runtime started read-only/cap-drop, nightly advisories, manual `release-images` hardened after the security audit (typed input via env, advisories gate, ephemeral buildx builder, env secrets + per-job DOCKER_CONFIG + logout, main/develop only, pinned checkout; no deploy) - [x] R0.9 docs: RUST.md, DEPLOY.md (prepared digest deploy + CSP note, live procedure untouched), WORKSPACE.md, packages/README.md, CLAUDE.md (stack, map, commands, workflow), TEST_STRATEGY.md, CHANGELOG - [ ] R0 follow-ups from the security audits (R1 unless stated): base images and the buildkit engine image by digest (Step 27); verification decode of the child's output in a second sandboxed child; R1 treats Signalled/Timeout/OutputOverflow as rejections (content never alerts) and logs the child's stderr escaped only; negative tests for tkill(self, SIGTERM) and tgkill; iCCP fixture with image data so the allocation budget is seen firing; WebP structure residuals (duplicate ALPH, ALPH + VP8L, VP8X flags); dedicated release runner label that never runs PR jobs (Step 27); `actions/*@v4` in ci.yml pinned by commit (Step 27); drop `--features proofs` from docker/wasm-build.sh at R2 - [x] R0.10 gates: root `pnpm check` 777 tests green (existing suites untouched); verifier ×3 (CONFORME in substance, oracle fixes only); security ×3 (HIGH shell injection + 6 MEDIUM fixed; 3 MEDIUM introduced by the first fixes fixed; 2 MEDIUM of pass 3 fixed by the secret-less gates job); memory BDR-046, LRN-049, EVAL-017, journal. STOPPED for owner validation (2026-10-13); R1 not started - [ ] R0 owner points: review the worker's SAFETY comments (rewritten 2026-10-13 as technical invariants, the `[gated]` approval-looking markers removed); decide the registry (forge Gitea registry recommended) and set REGISTRY/REGISTRY_USER/REGISTRY_TOKEN secrets before the first `release-images` run; first run on the forge records the runner numbers (RUST.md §5.7) and validates the workflow syntax (job-level env, GITHUB_ENV path) - [ ] R0.11 native toolchain correction (owner brief 2026-10-13, delivered 2026-10-13, awaiting the owner's final validation: Ubuntu dev server native Rust, Docker for services/isolation/images, VPS separate, no CI active): - [x] R0.11.1 host audit: rustup 1.29.1 already user-level (~/.cargo, ~/.rustup), 1.99.0 auto-installed from rust-toolchain.toml, gcc/libc6-dev/pkg-config/libssl-dev/strace present, no sudo, no package needed - [x] R0.11.2 install (user-level, `--locked`, 100 s, registry cache warm): wasm32-unknown-unknown on 1.99.0, wasm-bindgen-cli 0.2.129, cargo-deny 0.20.2 - [x] R0.11.3 scripts: `scripts/rust-check.sh` + `scripts/wasm-build.sh` (moved from docker/, PATH guard `scripts/rust-env.sh`), `scripts/check-all.sh` pre-merge gate; root `rust:check` / `wasm:build` native, `rust:check:docker` / `wasm:build:docker` through the builder, `check:all`; worker unit tests in the native check (sandbox tests stay feature-gated in Docker) - [x] R0.11.4 worker: SAFETY comments rewritten as verifiable technical invariants (no `[gated]` approval marker), stride with checked arithmetic - [x] R0.11.5 CI files kept, header states prepared / never executed (no runner, no secrets), script paths updated - [x] R0.11.6 verification (native rust-check 32 s warm, cold workspace build 31.5 s; wasm 224 777 B native vs 224 713 B builder, path strings; 14 proofs; `pnpm check:all` 1 min 59 s green: 777 Node tests, 16 sandbox tests, allowlist covers the trace, worker read-only run --check): native versions; cargo fmt/clippy/test/build/deny; wasm native + core-wasm proofs; Docker builder, docker check, docker wasm, worker:test, worker:image run --check, app image; `pnpm check`; numbers compared with R0 (RUST.md §5) - [x] R0.11.7 docs: RUST.md §1/§4/§6, CLAUDE.md, README verifying, DEPLOY.md, WORKSPACE.md, TEST_STRATEGY.md, CHANGELOG, review Annex C addendum - [x] R0.11.8 gates: verifier ECARTS(2 doc prose) → CONFORME 11/11; security PASS ×2 (1 MEDIUM + 6 LOW then 1 MEDIUM + 2 LOW, fixed: advisories warn-only stage, fail-closed porcelain drift gate with --untracked-files=all, PATH guard append/absolute, literal rm, prctl c_ulong args); BDR-047, LRN-050, EVAL-018, journal - [ ] R0.11 follow-ups for the CI/CD step (owner): ci.yml push/PR triggers stay live, so registering a runner starts PR builds at once (keep, or switch to workflow_dispatch until then); `actions/*@v4` mutable tags (Step 27); advisories cadence while no nightly runs (`cargo deny check advisories` is warn-only in check:all); `--remap-path-prefix` if native and builder wasm must match byte for byte - [x] R1 = Step 8 worker in Rust (delivered 2026-10-13 on feature/step-08-files-foundation, see Step 8 block; awaiting owner validation): decode child dispatched before any thread, empty env, RLIMIT_AS/CPU, traced seccomp allowlist, `image` + `moxcms` + `libwebp-sys` in the child, parent RIFF-header check only, 512 KiB output cap, per-stage deadlines, service key - [x] R2 domain core (before Step 9; OWNER VALIDATED 10/10 2026-10-14, L1 closed, merged into develop c3f28d8, worktrees cleaned): sheet/report/archive contracts, `SheetHandle` + `SheetIndexData`, reducers, Finding builder, vertebra selection, publish gate; wasm facade (JSON strings, ts-rs types, poison + reinstantiate, lazy init); app switched; 3 envelopes frozen first; N-1 reader test; draft quarantine; conformance fixtures + generated pgTAP; `packages/domain` frozen for engine/pipeline - plan + contract: `.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md` (rev 2 after 3 challenges, 45 findings folded); branch `feature/rust-r2-domain-core`; owner wording of the 4 new strings validated 2026-10-13 - [x] R2.0 freeze: 3 archive envelopes (demo, v2full, v2unresolved; FR, no logos, fixed time) + verbatim N-1 Zod copy (`packages/core-wasm/tests/n-1`) (3114d67); Zod output oracles of the reference documents (`crates/core/tests/oracles`) - [x] R2.0b characterisation frozen from the TS: 84 report/archive cases + 765 Zod verdicts (fork B), 49 editor cases (fork C), 26 conformance fixtures (fork A), horse-slice JSON - [x] R2.1 Rust contracts (ee07008): byte-equal to Zod output on draft + legacy sheets, demo report; the 3 frozen envelopes round-trip byte-equal - [x] R2.2 Rust rules (0c47d0f, 21906c4): integrity rules, check, create, index data, read/migrate (612 leaves), rebase, snapshot, layered read, session restore/import; pgTAP 011 generated (PGlite 12/12, real 446/446) - [x] R2.3 editor rules (3639c87) + facade ops (6c0533c) - [x] R2.4 runtime (343d6f4): lazy, poison, offline recovery, per-generation handles, cap 3, retry, pkg/pkg-proofs, BUILD_STAMP; browser-checked dev + build; measurements (794dfd9) - [x] R2.5 app switch (74fcb37) + publish gate fail-closed (6891f9e); app 313/313 on the real core (fork D adapted 17 files, 24 new tests, found 2 src bugs fixed) - [x] R2.6 image + serving (7be94d4): wasm stage, gzip_static 372 KB served, CSP proof on the image 15/15 (Chromium only; no Firefox/WebKit build here), check:all green 2 min 17 s - [x] R2.7 docs (8e8c58e: RUST.md §8, CLAUDE.md, WORKSPACE, TEST_STRATEGY, packages/README, DEPLOY, CHANGELOG), verifier 12/12 + floor ECARTS(2) (deleted tests, owner micro-gate), security PASS ×2 (follow-ups e49009e), memory BDR-050 LRN-054 BLK-010 EVAL-020; STOP (no merge) - [x] R2 owner points (2026-10-14): manual LAN validation 10/10 + graphics accepted; L1 decided (refusal + quarantine, BDR-051); 2 deleted test files approved (coverage proven); worktree cleanup authorised after checks; merge go after L1 - [x] R2 closure (owner brief 2026-10-14) - [x] L1.1 core: `parse_json` never rewrites; refusal classified (`JsonReadError::LoneSurrogate`, strict hex scan, on failure only); kind `lone_surrogate` from parse_input, sheet.check, draft.restore, archive.import (20d03cf) - [x] L1.2 app: quarantine on `lone_surrogate`, `ImportError('lone_surrogate')` + `home.import.error_lone_surrogate` FR/EN (detailed wording), publish gate → `invalid_shape` (da8a037); dead `isCoreBuilt` removed (5020954) - [x] L1.3 tests: js scanner/parse, session draft/archive/import + normal text, facade kind, characterisation L1 + Zod verdict = explicit refusal (oracles untouched, loader spells escapes out), store quarantine verbatim, editor action refused report unchanged, import kind, real-module call, gate - [x] L1.4 checks: rust:check, stale-module refusal shown, wasm:build, Node 915, PGlite 12 files, real stack 446/446, types no drift, check:all green; verifier CONFORME 13/13, security PASS (6 LOW) - [x] L1.5 docs (RUST.md 8.6/8.7, PDF-FORMAT, CHANGELOG) + memory BDR-051, LRN-055, EVAL-021, journal - [ ] R2 follow-ups: Firefox/WebKit CSP run (no browser build here; owner's manual LAN run covers its browsers), import in a Web Worker + PDF import hardening gate (R4, PDF_IMPORT_HARDENING.md §5), React error boundary (not decided), base images by digest (Step 27), wording of the storage-full degraded notice, CSP refuses the footer's external credit logo (RUST.md 8.8), no CI/CD runner on the forge (workflows prepared, never executed), rustls 0.23.45 advisories RUSTSEC-2026-0346/0347/0348 (worker; not applicable: no brotli, built-in session cache, no ECH) → `cargo update -p rustls` ≥ 0.23.46 + worker:test + e2e:avatar, unreadable session archive under full storage removed by a later reset (security LOW, decision needed), `supabase/.temp/cli-latest` tracked by mistake (untrack + ignore), wasm-bindgen boundary invariant (JSON.stringify callers only, RUST.md 8.7) - [x] R2 maintenance (owner brief 2026-10-14, branch bugfix/r2-maintenance, merged into develop after gates; owner authorised the merge in the brief) - [x] A rustls 0.23.45 → 0.23.46 (RUSTSEC-2026-0346..0349; rust:check, worker:test, worker:image, e2e:avatar 5/5 on the new image; TLS path itself not exercised: local stack is HTTP) (f99b4a5) - [x] C `supabase/.temp/cli-latest` untracked, local copy kept (1312b36) - [x] B session texts never overwritten after a failed set-aside (owner UI choice: resolution panel + save-failure banner) (e34b7f2, a37c50b, c97b0e7): occupied slot refused, pair set-aside with rollback, `held` restore result, mirror on report change only, guarded new/import, discard + open-adapted behind confirmation, banner (draft or archive write refused); 27 new tests (app 346) - [x] gates: verifier 11/11 (floor false positive on `cli-latest`, clarified) + residual fixed; security PASS, 4 LOW fixed (archive refusal banner, download URL kept 30 s, header wording, comment); check:all green 1 min 29 s - [ ] follow-ups: UI for set-aside (quarantined) texts (owner: later); PDF export revokes its object URL at once (WebKit may cancel the download); "New report" replaces a readable draft without asking (unchanged, owner to decide if wanted); `writeCachedPractitioner` throws on a full localStorage before the report is created (no data loss) - [ ] R3 anatomy core (owner go 2026-10-14; branch feature/rust-r3-anatomy-core; plan `.claude/tasks/plans/2026-10-14-rust-r3-anatomy-core.md` rev 2 after 3 challenges, 32 findings): prescan + tree + allowlist sanitiser + reference budget + serialiser + layer + canvas/highlight composition in `crates/core`; app canvas on `view.canvas`; denylist deleted - [x] R3.0 freeze O1 canvas (47c5f49), O2 layer (969b872), O3 highlight (d1aa35e), O4/O5 sanitiser corpus (b440a2f, e316821), O6 Chromium references (scratchpad, 30/30 stable); roxmltree recursion measured (overflow < 3,000 levels on 1 MiB) → prescan (5f53aaa) - [ ] R3.0b ANNOTATION-RENDERING.md to the code - [ ] R3.1 svg prescan caps + tree + sanitiser + refs + number + serialiser (cargo O4/O5) - [ ] R3.2 layer + compose + op view.canvas + per-asset outcome + wasm tests/thresholds - [ ] R3.3 app switch + tests - [ ] R3.4 Chromium visual + DOM dump + timings + memory + LAN - [ ] R3.5 docs - [ ] R3.6 gates, stop for owner validation (no merge) - [ ] R4 pdf core: reader (Web Worker, BLK-009 browser measurements) + writer (`pdf-writer`, Std14 AFM, draw log; lines/rects/colours golden frozen with the TS engine first, D-R2) + `report-compare` tool; `packages/pdf` deleted; N-1 scanner reads R4 PDFs - [ ] R5 curation pipeline + importer + upload tool: seed golden regenerated once (new `documentSha256`, D-R5), `packages/anatomy` + `packages/domain` deleted, docs map; all before Step 13 - [ ] separate chore (D-R7): form constraints module + PGlite `pg_constraint`/config.toml parity test - [ ] Release 0.2.0 (branch release/0.2.0 = Steps 3–6, version.txt + package versions 0.2.0, CHANGELOG [0.2.0] 2026-10-11): deploy-trigger check done 2026-10-12 (CI = branches main/develop only, no tag trigger, no deploy job, docker job builds `faunosteo:ci` locally; hooks push only; DEPLOY.md deploy = manual on the VPS). Default 0.2.0 build carries NO sheet (SHEET_BUNDLE=none) → the live local tool must not be redeployed from main without `--build-arg SHEET_BUNDLE=draft`. Finish via /release-candidate (finish + tag span, tag push on explicit go); CHANGELOG back-merge conflict expected (Unreleased Step 7 above [0.2.0]). Awaiting the user's go. --- ## Phase A — DONE (kept for reference) - [x] Scaffold (deps, configs, Docker, schemas, stubs) - [x] Lib: id, dates, assert - [x] Anatomy: parseSvgBones, loadSvg, svgToPng raster - [x] Zustand store: full action set (initReport, hydrateReport, observation CRUD, conclusion/recommendations/nextAppointment setters, identity setters) - [x] sessionStorage draft mirror + localStorage practitioner cache (restore path was missing until f58a49f 2026-07-12 — refresh now keeps the session) - [x] UI primitives: Button, Card, Dialog, Input, Label, Select, Textarea, Badge, Chip - [x] Canvas: AnatomyCanvas (data-state highlighting, async-mount safe), DetailModal - [x] Observation chain: ObservationList, ObservationCard, PathologyPicker (flat — REMOVED, replaced by FindingsTreePicker B2), VertebraPicker, SeveritySelector, FreeTextPathologyInput - [x] Report forms + edit-infos dialog + home nav - [x] Routes: Home, NewReport, Editor (split layout + dialog), NotFound - [x] PDF pipeline: fonts, header, observationPage (2-col SVG grid), conclusionPage, attachment.ts, export, import - [x] Docker: Dockerfile, compose, entrypoint.sh runtime env, nginx SPA fallback - [x] Brand identity via env (ConfigProvider) - [x] Tests: 100/100 pass - [x] **Pathology JSON sample dropped** at `src/domain/species/equine/pathologies.json` (schema v1.1, 3 zones: sphenoid/ssb/atm — placeholder before full-body) --- ## Phase B — V1 REFACTOR (hierarchical findings + i18n) ### B0. Domain model — Findings tree (DONE 2026-05-20) - [x] **Schema**: `src/domain/schema/findings.ts` — `FindingNodeSchema` (recursive via `z.lazy`), `ZoneFindingsSchema`, `SpeciesFindingsSchema`, `SourceRefSchema` - [x] **Loader**: `src/domain/species/equine/pathologies.ts` parses the JSON via `SpeciesFindingsSchema.parse(data)` at boot (fail-fast) - [x] **Species manifest**: `findings: FindingsLoader` replaces `pathologies` in `SpeciesManifest` - [x] **JSON fix**: `species.id` set to `"equine"` to match registry - [x] **Tests**: `tests/unit/species.equineFindings.test.ts` (5 cases) replaces deleted `species.equinePathologies.test.ts` ### B1. Report schema v2 — observation findings (DONE 2026-05-20) - [x] `ObservationSchema` carries `findings: Finding[]` + `freeTextFindings: string[]`; old `pathologyIds`/`freeTextPathologies` removed - [x] `ReportSchema.version` literal bumped `1` → `2` - [x] Store `emptyObservation` + `initReport` updated to the v2 shape - [x] PDF import surfaces a distinct French-language `IncompatibleReportVersionError` message on v1 attachments (detected before Zod parse) - [x] Schema + store + PDF tests updated; `pathology.ts` schema + test deleted ### B2. UI — Findings tree picker (DONE 2026-05-20) - [x] `src/components/observation/FindingsTreePicker.tsx` (breadcrumb, drill-down, leaf toggle, retour button, vet-referral ⚠ badge, description_fr surfacing) - [x] `scope_disclaimer` modal shown once per session via `osteo:disclaimer-shown` sessionStorage flag - [x] `ObservationCard` migrated — one picker per zone with a catalog entry, single `FreeTextFindingInput` below - [x] `PathologyPicker` + `FreeTextPathologyInput` + their tests deleted; `FreeTextFindingInput` renamed equivalent kept - [x] `tests/unit/components.FindingsTreePicker.test.tsx` covers navigation, leaf select, vet-referral flag, retour, deselect ### B3. i18n FR/EN — site + PDF (DONE 2026-05-20) - [x] **Locale state**: `src/state/localeStore.ts` Zustand `'fr' | 'en'`, persisted `osteo:locale` - [x] **i18n dicts**: `src/i18n/{fr,en}.ts` (~90 keys each, parity-tested), `index.ts`, `useT.ts` hook - [x] **Language switcher**: `src/components/brand/LanguageSwitcher.tsx` segmented FR | EN toggle, integrated in ReportHeader + HomeRoute + NewReportRoute headers - [x] **Findings rendering**: FindingsTreePicker + ObservationCard read `name_fr`/`name_en` per locale; finding snapshots already dual (BDR-010) - [x] **PDF render**: `exportReportToPdf(report, { locale })` explicit option; static labels via dict snapshot; `formatDate(iso, locale)` replaces `formatDateFr`; finding leaf labels via `labelFr/EnSnapshot` - [x] **PDF import error i18n**: typed ImportError(kind + foundVersion); UI resolves message via dict (BDR-015) — caught by review (EVAL-002) - [x] **Out of scope (per design)**: `description_fr` + `scope_disclaimer` stay FR-only — vet-expert authoring needed for EN copy - [x] **Tests**: localeStore (3), useT (3), dict parity (2), LanguageSwitcher (2), formatDate FR+EN (7), PDF roundtrip per locale (3). 154/154 green. ### B4. PDF observationPage updates - [x] Render `findings` instead of `pathologyIds` (per-zone sections "CONSTATS — " + "CONSTATS LIBRES", joined `·` segmented) - [x] Show vet-referral icon (⚠) next to flagged findings (observationPage.ts:407) - [ ] `scope_disclaimer` footer on each obs page or first page only — decide - [x] Update `LRN-009`-style layout still applies (text-area reservation kept) ### B5. Stub cleanup (DONE 2026-05-20) - [x] `ZoneTooltip.tsx` deleted (unused stub) - [x] `Toast.tsx` deleted (unused stub — re-introduce later if notifications needed) - [x] CLAUDE.md folder map updated — `ObservationEditor`/`Toast`/`ZoneTooltip` removed, `FindingsTreePicker`/`FreeTextFindingInput`/`findings.ts` added --- ## Phase C — V1 SHIP gate - [x] Author full `horse.json` (placeholder → v2.0, 26 zones, 792 nodes, 612 leaves — done 2026-05-21) - [x] Fix SVG case `data-anno-name-fr="hyoïde"` → `"Hyoïde"` in `public/species/equine/Horse_head.svg` (done by user 2026-05-21; 26 JSON names ≡ 26 SVG names strict) - [ ] PDF QA manual pass: full flow → export → re-import roundtrip - Fonts embed, JSON attached, multi-SVG grid OK, locale FR + EN exports - [x] Docker build + compose up smoke test (VPS cold build validated — BLK-005, 990c8e7; local smoke not separately logged) - [x] env-var brand identity verified (tour 2026-07-12: docker run APP_BRAND_NAME=TourCheck → env.js correct, non-root; hostile-quotes case covered by 0214ae1) - [x] README finalize (install, dev, Docker, env vars, locale, MIT) - [x] CHANGELOG 0.1.0 entry - [x] docs/PATHOLOGIES-FORMAT.md — schema doc + authoring guide (initial shipped 70f21cc 2026-05-20; refreshed for v2.0 boolean-only contract 2026-05-21 — scope section, 5 taxonomy patterns, structural rules, breaking-change notice, horse stats, changelog v1.0→v2.0) - [x] Scaleway VPS deploy (TLS + live faunosteo.com — 2803cf7 fixed prod 404). CI build/push/deploy UNVERIFIED — no .github/workflows or Gitea CI in repo. --- ## Phase D — POST-V1 (not in MVP scope) - Capacitor wrap (iOS + Android) - Accounts + cloud sync (Supabase or self-host) - Multi-praticien (move localStorage cache to server profile) - RDV booking + push reminders - Other species (dog, cat, cow, goat, pig, chicken JSONs) - Pathology DB community contributions --- ## Memory cross-refs - BDR-001..BDR-022 — decisions registry - LRN-001..LRN-031 — learnings registry - BLK-001..BLK-005 — blockers (all resolved) Apply when implementing B-phase: - LRN-004 (data-anno-special opaque to parser) — zone IDs in JSON must match SVG `data-anno-id` - LRN-009 (pre-rasterize → reserve → grid) — keep applied in PDF observationPage - LRN-010 (gate DOM-mutate on async-mount) — relevant for any new SVG-mutating effect --- ## Estimated effort | Phase | Hours | |---|---| | B0. Findings schema + loader + tests | 3 | | B1. ReportSchema v2 + store + PDF import | 3 | | B2. FindingsTreePicker + disclaimer + integration | 6 | | B3. i18n FR/EN site + PDF | 5 | | B4. PDF observationPage update | 2 | | B5. Stub cleanup | 0.5 | | C. Full horse.json authoring (user) | external | | C. QA + docs + deploy | 4 | | **Total dev** | **~23h** |