From 4e0a6c04d6b810a10834fb28d096caeb70d0a5ab Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 25 Oct 2026 04:00:15 +0100 Subject: [PATCH] docs(docs): R5.7 census, ledger, reproducibility, RUST.md 11.23 CLAUDE.md, WORKSPACE, packages/README, README, sheet model, SUPABASE, TEST_STRATEGY, PDF-FORMAT and ANNOTATION-RENDERING follow the deletion; RUST.md 11.23 records the census, counts, the historical TS replay procedure and hashes; CHANGELOG, TODO, R5.7 plan and contract. --- .claude/tasks/TODO.md | 10 +- .../contracts/2026-10-25-rust-r5-7-cleanup.md | 50 +++++++ .../plans/2026-10-25-rust-r5-7-cleanup.md | 43 ++++++ CHANGELOG.md | 5 + CLAUDE.md | 47 +++--- README.md | 10 +- docs/ANNOTATION-RENDERING.md | 6 +- docs/PDF-FORMAT.md | 2 +- docs/development/ANATOMICAL_SHEET_MODEL.md | 12 +- docs/development/RUST.md | 138 ++++++++++++++++++ docs/development/SUPABASE.md | 4 +- docs/development/TEST_STRATEGY.md | 2 +- docs/development/WORKSPACE.md | 8 +- packages/README.md | 20 +-- 14 files changed, 301 insertions(+), 56 deletions(-) create mode 100644 .claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md create mode 100644 .claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 28eb41eb..4f0c1489 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -349,7 +349,15 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [x] gates: security PASS (1 MEDIUM, 6 LOW), verifier ECARTS(3) = export grants alias without fingerprint_verified (fix needs snapshot_rules.rs, outside scope) → checkpoint, STOP, owner decision - [x] R5.6 M1 correction + full rehearsal (owner 2026-10-25; snapshot_rules.rs authorised): recognises_historical_stamp, null block refused, warnings allowed, depth 128; fresh worktree r56final: rust:check + check:all 01:53:59 green; security PASS (LOW); verifier CONFORME 8/8 → checkpoint, STOP (activation on signal) - [x] R5.6 D-R5 switch ACTIVE (owner go 2026-10-25, commit 9e87016): seed sheet-ref 03e7f6ab + migration map 0e991bc2 only, --check 0 diff, rust:check + check:all green, security PASS LOW, verifier ECARTS(1)=S7 wording → Clarification; BDR-070; rollback not transparent for post-switch reports (settle before user release) → checkpoint, STOP, no merge, no R5.7 - - [ ] R5.7 consumer census, domain fixtures moved, packages deleted, xmldom + prettier out of the lockfile, docs, ledger; `pnpm check:all`; merge only on the owner's signal + - [ ] R5.7 consumer census, domain fixtures moved, packages deleted, xmldom + prettier out of the lockfile, docs, ledger; `pnpm check:all`; merge only on the owner's signal (owner go 2026-10-25 « Validation R5.6 et autorisation R5.7 »: rollback limit accepted on the branch, no intermediate release; plan `.claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md`, contract `.claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md`; stop at the checkpoint, no merge) + - [x] R5.7a census + matrices (LEDGER 407: 256 ported, 149 replaced, 2 deleted, 0 gap; FILES 112), 15 anatomy + 1 domain uncovered contracts ported first (+19 Rust tests, curation_leaves.rs new) + - [x] R5.7b `report-v2.*.json` → `crates/core/tests/fixtures/` (sha256 kept), Rust readers repointed + - [x] R5.7c deletion (anatomy, domain, TS upload script, legacy scripts, Dockerfile lines, lockfile by `pnpm install`) + - [x] R5.7d census tests (r4 xmldom inverted + non-vacuity, R5 census, ESLint ban) + - [x] R5.7e historical reproducibility documented and rehearsed (59521dc: git status clean, 144+262; 756b7ef: 2 files, 144+263) in a detached worktree + - [x] R5.7f docs (CLAUDE.md, WORKSPACE, packages/README, README, RUST.md §11.23, CHANGELOG, sheet model, SUPABASE, TEST_STRATEGY, PDF-FORMAT) + - [ ] R5.7g checks (frozen install, rust:check, check:all green 03:58:13, --check 0 diff, TS 943→546, Rust 364→383) + fresh security + fresh verifier → checkpoint, STOP + - [ ] owner action (non-blocking): `packages/{anatomy,domain}/node_modules` leftovers (git-ignored pnpm symlinks; recursive delete refused to Claude) → `rm -r packages/anatomy/node_modules packages/domain/node_modules && rmdir packages/anatomy packages/domain` - [ ] DEV hardening (owner 2026-10-24, risk accepted temporarily, not scheduled): Supabase on CLI demo keys + 54321 LAN-open (rootless, UFW allow incoming, no 54321 rule) → own JWT secret/signing keys via env() or narrower 54321 rule before any untrusted device or user (ENVIRONMENTS.md §3.6); never these keys in production; `confirm_sheet_asset_upload` object check before public exposure - [ ] 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. diff --git a/.claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md b/.claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md new file mode 100644 index 00000000..07e3bcf2 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md @@ -0,0 +1,50 @@ +# CONTRACT: R5.7 consumer census and deletion of `packages/anatomy` and `packages/domain`, owner brief 2026-10-25 « Validation R5.6 et autorisation R5.7 » + +- branch `feature/rust-r5-pipeline-core`, base 756b7ef (R5.6 active since 9e87016) +- plan `.claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md` + +## Clauses + +C1. **Census.** Every consumer of `packages/anatomy` and `packages/domain` outside them is listed (runtime and type +imports, fixtures read by Rust, TS tests, oracles and goldens, pnpm scripts, build dependencies, seed scripts, docs, +dev and check tools, historical references). Nothing still required by an active feature is deleted. + +C2. **Matrices.** `crates/core/tests/curation/FILES.tsv` names every deleted tracked file with its Rust counterpart or the +reason it goes; `crates/core/tests/curation/LEDGER.tsv` has one row per TS case of both packages at 756b7ef (407), with the +case's contract, old location, equivalent after the deletion, status ported / replaced / kept / deleted (with the +justification), and the historical reference kept. No row is a gap: a contract still relevant and uncovered is ported first. + +C3. **Fixtures.** `report-v2.full.json` and `report-v2.minimal.json` move under `crates/core/tests/fixtures/` with their bytes +unchanged (sha256 before = after, recorded); the Rust readers use the new place. No oracle, golden, frozen digest, migration +data, N-1 reader or reference PDF is changed, regenerated or removed; a moved reference file keeps its sha256. + +C4. **Active checks preserved.** The contracts the brief §5 lists stay covered by tests that run in `pnpm rust:check` or +`pnpm check:all` (sheet model validation, reference integrity, deterministic UUIDs, legacy catalog conversion, changeset +application, migration map, statistics, seed SQL, SVG rendering, RFC 8785, historical aliases, PDF import and export, old +archive compatibility); the application and interface suites keep passing; test counts before and after are measured and +documented. + +C5. **Historical reproducibility.** The documentation names the reference commits of the TypeScript pipeline, the versions +(Node, pnpm, dependencies), the historical generation and comparison commands, the isolated-worktree procedure and the expected +sha256 of the artifacts; the procedure is rehearsed once; the old engine is not reintroduced in the current tree. + +C6. **Dependencies and scripts.** The two packages' own dependencies leave the lockfile through `pnpm install`; `@xmldom/xmldom` +and `tsx` are gone; root `prettier` stays (used by `pnpm format` and `db:types`); `pnpm import:equine` stays the Rust pipeline; +`import:equine:legacy` and `assets:upload:legacy` are removed; no other dependency changes major version; the lockfile installs +with `--frozen-lockfile`. + +C7. **Census tests.** `r4.census.test.ts` proves xmldom and the TS engines are no active dependency, and cannot pass on a +lockfile or tree that reintroduces them (a non-vacuity check); a census proves no production path (app, glue, supabase package, +Dockerfile, Vite/TS config) imports a deleted engine, and that the two matrices agree with the tree. + +C8. **Docs.** CLAUDE.md, WORKSPACE.md, packages/README.md, RUST.md §11, CHANGELOG, TODO, the curation commands and the test +registers are updated; the seed SQL header is kept (frozen bytes) and explained beside it; audits are append-only; the brief §10 +follow-ups stay tracked (rollback limit, DEV hardening, migration-map cascade debt, direct export API trust boundary, SQL checks +before public exposure, accepted LOW items). + +C9. **Checks.** `pnpm install --frozen-lockfile`, `pnpm rust:check`, `pnpm check:all`, `pnpm import:equine --check` (0 +difference), the RFC 8785, alias and archive suites, PDF and `report:compare`, the N-1 reader, the moved fixtures, the sheet and +seed integrity suites, and the absence of any import of the deleted packages, all green on the final state. + +C10. **Limits.** Branch only; no merge, no release, no deploy, no Supabase DEV data change, no migration, no new feature; no +seed byte changed. diff --git a/.claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md b/.claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md new file mode 100644 index 00000000..aba6c16c --- /dev/null +++ b/.claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md @@ -0,0 +1,43 @@ +# PLAN: Rust R5.7, consumer census, `packages/anatomy` and `packages/domain` deleted, guarantees kept + +- date: 2026-10-25 | branch `feature/rust-r5-pipeline-core` at 756b7ef (R5.6 active, 9e87016) +- spec: owner brief 2026-10-25 « Validation R5.6 et autorisation R5.7 » (§1 to §13); plan R5 §B.5 row R5.7 and §B.6 + (`.claude/tasks/plans/2026-10-22-rust-r5-pipeline-core.md`); RUST.md §11; BDR-068, BDR-070 +- contract: `.claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md` +- limits: no merge, no 0.2.0, no deploy, no Supabase DEV data, no migration, no SaaS feature, no oracle regenerated, + no seed byte changed, no major version bump; stop at the checkpoint (brief §12) + +## Facts at the start (756b7ef) + +- TS cases to retire: anatomy 144 in 22 files, domain 263 in 13 files (vitest JSON, all green). +- Consumers outside the two packages: anatomy → root script `import:equine:legacy`, Dockerfile COPY, docs, Rust + module comments; domain → anatomy, Dockerfile COPY, the Rust suites reading + `packages/domain/tests/fixtures/report-v2.{full,minimal}.json` (`report_rules`, `archive_rules`), the app ESLint ban, + `r4.census.test.ts` (xmldom pinned under anatomy), docs, SQL migration comments (frozen, never edited). +- `packages/supabase/scripts/upload-sheet-assets.ts` (`assets:upload:legacy`): TS upload tool, replaced by the Rust bin + at R5.5 (owner e2e PASS 11/11). +- Root `prettier` stays (`pnpm format`, `db:types`, `db:types:check`); `tsx` only under anatomy; `@xmldom/xmldom` + only under anatomy. +- The `report-v2.*.json` fixtures of domain are byte-identical to the app's copies (sha256 e96b0882…, ba79698c…). +- Seed SQL header names `packages/anatomy`: frozen bytes (sha c5a24312…), kept, documented beside. + +## Subtasks + +1. Census + matrices: tests ledger `crates/core/tests/curation/LEDGER.tsv` (407 rows: ported / replaced / kept / + deleted, target, oracle, note), files matrix `crates/core/tests/curation/FILES.tsv` (every deleted file → its Rust + counterpart or reason). GAPs found by the mapping are ported before any deletion. +2. Fixtures: `report-v2.{full,minimal}.json` → `crates/core/tests/fixtures/`, `git mv`, sha256 before = after; Rust + readers repointed. +3. Ports of uncovered contracts (from the mapping), on frozen oracles, in Rust or durable vitest. +4. Deletion: `packages/anatomy`, `packages/domain`, TS upload script + `assets:upload:legacy`, + `import:equine:legacy`, Dockerfile COPY lines, lockfile by `pnpm install`; Rust module comments that cite deleted + paths point at the reference commit. +5. Census tests: `r4.census` xmldom assertion turned into "no importer, no package resolves xmldom", with a non-vacuity + check; new R5 census (packages gone, no production path imports a TS engine, ledger and files matrix consistent with + the tree); app ESLint ban extended to `@faunosteo/anatomy` and xmldom. +6. Historical reproducibility: reference commits, versions, commands, isolated-worktree procedure, expected sha256 of the + 18 files; rehearsed once in a detached worktree. +7. Docs: CLAUDE.md, WORKSPACE.md, packages/README.md, README.md, RUST.md §11.23, CHANGELOG, ANATOMICAL_SHEET_MODEL.md, + SUPABASE.md, TEST_STRATEGY.md, PDF-FORMAT.md (xmldom line stale), ANNOTATION-RENDERING.md; follow-ups kept (brief §10). +8. Checks: frozen-lockfile install, rust:check, check:all, `import:equine --check`, targeted suites, census, counts. +9. Gates: fresh security audit, fresh verifier on the contract; memory; checkpoint, STOP. diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fef03a0..c023545f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ Versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Removed (2026-10-25, Rust R5.7: the TypeScript pipeline and domain packages) + +- `packages/anatomy` (legacy importer, curation pipeline, TypeScript renderer, `import-equine` CLI) and `packages/domain` (Zod schemas and rules) are deleted, with the TypeScript upload script `packages/supabase/scripts/upload-sheet-assets.ts` and the scripts `pnpm import:equine:legacy` and `assets:upload:legacy`. The Rust core does all of it: `pnpm import:equine` and `pnpm assets:upload` are unchanged for the user. `@xmldom/xmldom` leaves the lockfile; `tsx` is no longer a dependency of any package (pnpm keeps it only as an optional peer of vite); root Prettier stays (`pnpm format`, `db:types`). +- Every one of the 407 TypeScript test cases is dispositioned in `crates/core/tests/curation/LEDGER.tsv` (ported, replaced by a frozen oracle, or deleted with its reason, none uncovered) and every deleted file in `crates/core/tests/curation/FILES.tsv`; the contracts the TypeScript alone still checked are ported to Rust (the 612 legacy leaves and 26 legacy annotations, region inference, the R5.1 artifact ledger, the generated folders' file list, the migration-map oracle entry by entry, review overlay removals, the halo filter, reserved and dollar-tag refusals). The `report-v2.*.json` fixtures moved to `crates/core/tests/fixtures/` with their bytes unchanged. No oracle, golden, digest or seed byte changed. The historical TypeScript pipeline stays replayable from commit 59521dc (official writer) or 756b7ef (last revision holding it) in a detached worktree (`docs/development/RUST.md` §11.23). + ### Changed (2026-10-25, Rust R5.6: the sheet fingerprint convention `sha256-rfc8785-validated-v1`) - The equine sheet's fingerprint is now the SHA-256 of the RFC 8785 canonical form of the validated document: `12d78872…74e2` in `draft/sheet-ref.json` (with a `fingerprint` block naming the convention) and in `draft/report-migration-map.json`, the only two seed files changed; `document.json`, the drawing and the SQL seed are byte-identical. The previous value `27c7383c…2660` stays recognised for this sheet only, through the core's compiled registry and a fingerprint recomputed from the loaded document: old reports and PDFs open with no message and no rebase, and a re-export keeps their stamp so older readers keep the archive. A report written after the switch, opened by a build from before it, is rebased with nothing lost. `pnpm import:equine` runs the Rust pipeline; the TypeScript generator stays as `pnpm import:equine:legacy` until R5.7 (`docs/development/RUST.md` §11.22). diff --git a/CLAUDE.md b/CLAUDE.md index 7773db9c..d43608c9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,8 +15,8 @@ writes conclusion, and exports an A4 PDF. PDF carries the full JSON state as a n attachment so importing it restores the session for a follow-up. SPA deployed via Docker + nginx on Scaleway VPS. Backend foundation on Supabase (PostgreSQL + Auth + RLS) since Step 3 of the SaaS plan: profiles, platform roles and -audit log exist; Step 4 added the canonical anatomical sheet model (`packages/domain`, -tables `species`, `anatomical_sheets` / `_versions` / `_assets`). Step 5 moved the +audit log exist; Step 4 added the canonical anatomical sheet model (since R2 in +`crates/core/src/domain/sheet`; the TypeScript `packages/domain` left at R5.7), tables `species`, `anatomical_sheets` / `_versions` / `_assets`). Step 5 moved the application onto that model: the editor renders the bundled reference sheet (the curated equine DRAFT, `SHEET_BUNDLE=draft`), writes Report v3 and imports v2 PDFs through a generated migration map. Step 6 made the PDF an autonomous archive: the @@ -40,8 +40,11 @@ Rust R2 moved the application's domain rules into `crates/core` (sheet, report a archive contracts, integrity rules, sheet index, migration, rebase, snapshot, layered archive reading, editor reducers, findings and vertebra rules, report operations), reached through the wasm facade and `packages/core-wasm`, loaded lazily by the sheet -pages only (`docs/development/RUST.md` §8); `packages/domain` is frozen for the PDF -engine, the pipeline and the compare CLI. +pages only (`docs/development/RUST.md` §8). R5 moved the anatomical pipeline (legacy +importer, curation, migration map, review files, seed SQL, upload tool) into the core +(feature `curation`); R5.6 switched the sheet fingerprint to `sha256-rfc8785-validated-v1`; +R5.7 deleted `packages/anatomy` and `packages/domain` (`RUST.md` §11.23, test ledger +`crates/core/tests/curation/LEDGER.tsv`). MVP species: equine only. Open-source MIT. --- @@ -74,8 +77,8 @@ MVP species: equine only. Open-source MIT. ## Build commands -pnpm workspace: `apps/app` = the private application, `packages/domain` = pure -Zod domain model (anatomical sheet document), `packages/supabase` = Supabase +pnpm workspace: `apps/app` = the private application, `packages/core-wasm` = the +Rust core in the browser (runtime, generated types, frozen N-1 reader), `packages/supabase` = Supabase access layer (see `docs/development/WORKSPACE.md`). Every command below runs from the repository root and delegates to the packages. @@ -118,9 +121,9 @@ pnpm db:types:check # CI diff # Reference sheet in the app: the dev server bundles the curated draft; a build does not pnpm build:preview # SHEET_BUNDLE=draft build (manual validation, preview deployments) pnpm preview:draft # same, then serves it -pnpm import:equine --check | --out # since R5.6 the official seed writer: the Rust pipeline (same as `pnpm r5:import-equine`), fingerprint `sha256-rfc8785-validated-v1`; `pnpm import:equine:legacy` = the TypeScript generator (pre-switch convention) until R5.7 +pnpm import:equine --check | --out # since R5.6 the official seed writer: the Rust pipeline (same as `pnpm r5:import-equine`), fingerprint `sha256-rfc8785-validated-v1`; the TypeScript generator left at R5.7 (replayed from a historical revision only, RUST.md §11.23) pnpm r5:import-equine --check | --out # the Rust pipeline (R5.2 importer, R5.3 draft, R5.4 review files): compare the 18 generated files with the committed folders (bytes; app drawings under the declared R3 rule), or write /{legacy-import,draft} into an empty folder; never deletes (scripts/import-equine.sh, first run compiles) -pnpm assets:upload [--check] # R5.5: uploads the sheet drawings of a generated seed folder to the LOCAL stack's private bucket (Rust `upload-sheet-assets`, feature `upload`; SUPABASE_URL local with a port, SUPABASE_SERVICE_ROLE_KEY typed, never printed; no overwrite, confirm after verify; run by hand, scripts/upload-sheet-assets.sh); the TypeScript one is `assets:upload:legacy` until R5.7 +pnpm assets:upload [--check] # R5.5: uploads the sheet drawings of a generated seed folder to the LOCAL stack's private bucket (Rust `upload-sheet-assets`, feature `upload`; SUPABASE_URL local with a port, SUPABASE_SERVICE_ROLE_KEY typed, never printed; no overwrite, confirm after verify; run by hand, scripts/upload-sheet-assets.sh) pnpm e2e:sheet-assets # scripts/sheet-assets-e2e.sh: that tool against the local stack (upload, rerun, anon and wrong key, refused destinations); run by hand pnpm report:compare ... # archive check: attachment vs its v3 reading, unresolved items flagged (docs/PDF-FORMAT.md); the core's `report-compare` binary since R4.7 (scripts/report-compare.sh, first run compiles) @@ -172,7 +175,7 @@ pnpm test # vitest watch — dev loop Test files live in `apps/app/tests/unit/*.test.ts(x)`; golden fixtures in `apps/app/tests/fixtures/`. The 612 legacy catalog leaves run through the v2 → v3 migration -in both `packages/anatomy` (against the draft document) and the app (sheet index + PDF roundtrip). Setup: `apps/app/tests/setup.ts` imports +in the core (`crates/core/tests/curation_leaves.rs`, against the draft document) and the app (sheet index + PDF roundtrip). Setup: `apps/app/tests/setup.ts` imports @testing-library/jest-dom. Suites run on the bundled reference sheet (`tests/helpers/sheet.ts`); frozen v2 fixtures under `tests/fixtures/`. SQL: `supabase/tests/*.sql` (pgTAP) run by `packages/supabase/tests/db/pgtap.test.ts` on PGlite (part of `pnpm test:run`) and by `pnpm db:test` on the real stack. @@ -259,13 +262,7 @@ faunosteo/ ├─ eslint.config.js, index.html, package.json (@faunosteo/app) ├─ tsconfig*.json, vite.config.ts, vitest.config.ts │ (end of apps/app) -├─ packages/domain/ ← @faunosteo/domain (pure, no DOM, zod only): anatomical-sheet (document, integrity rules, sheet-index), report (v3, v2 migration, rebase), archive (sheet snapshot, envelope v1, branding, labels, layered reader) -│ ├─ src/anatomical-sheet/{schema,validate,create}.ts ← canonical sheet document + integrity rules -│ └─ tests/{fixtures/horse-slice.ts,*.test.ts} -├─ packages/anatomy/ ← @faunosteo/anatomy: legacy importer, curation pipeline, frozen TS annotation-layer renderer + view composer (`./render`: the pipeline until R5; no app and no PDF consumer since R4.8) -│ ├─ src/legacy/{svg,catalog,regions,ids,report,importer}.ts, src/cli/import-equine.ts -│ ├─ src/curation/{schema,targets,fields,ops,rename,apply,types,assets,labels,stats,changelog,review-report,overlay,seed,sources,pipeline}.ts ← changeset → draft -│ └─ tests/ ← counts preserved, special cases, determinism, curation ops, golden artifacts +│ (packages/domain and packages/anatomy deleted at R5.7: their sources resolve at 756b7ef, crates/core/tests/curation/{FILES,LEDGER}.tsv) ├─ packages/supabase/ ← @faunosteo/supabase │ ├─ src/{index,client,database.types,anatomical-sheets,assets}.ts ← typed client, generated types, publish gate, avatar flow (closed AssetFailure kinds) │ ├─ tests/e2e/avatar-flow.e2e.ts + vitest.e2e.config.ts ← real-stack end-to-end (`pnpm e2e:avatar`), skipped without the stack env @@ -409,8 +406,8 @@ Database (Supabase) ### Annotation rendering - docs/ANNOTATION-RENDERING.md is the source of truth: the drawing carries no annotation element, the markers are - drawn from the document (Rust core for the canvas since R3, `crates/core/src/anatomy`; the frozen TS renderer - `@faunosteo/anatomy/render` for the pipeline until R5, same output), with the attributes listed there + drawn from the document (the Rust core, `crates/core/src/anatomy`, for the canvas since R3, the PDF since R4 and + the pipeline's review drawings since R5), with the attributes listed there - Every SVG the product draws goes through the core's one reader (`anatomy::svg::read_svg`): caps before any parse, allowlist, reference graph; a product drawing with anything removed is refused at load, never repaired - Never rely on element id, className or a label for click targeting or behaviour — always `data-anno-id` @@ -421,8 +418,8 @@ Database (Supabase) ### Schemas - The data contracts live in Rust since R2 (`crates/core/src/domain/{sheet,report,archive}`, Zod semantics reproduced: strict where Zod was strict, optional absent, nullable required, Zod schema field order); - `packages/domain` is frozen (no new logic) for the pipeline until R5 (the app no longer depends on it: R4.8), - and its Zod copy under `packages/core-wasm/tests/n-1` is the permanent N-1 reader. Never change a contract + `packages/domain` was deleted at R5.7; its byte-identical Zod copy under `packages/core-wasm/tests/n-1` is the + permanent N-1 reader. Never change a contract without bumping the version on a breaking change (additive optional fields keep it); a change touches the Rust struct, the regenerated ts-rs types and the N-1 test - Every report entering the store comes from the core (new report, draft restore, import, reducer outputs); @@ -494,16 +491,16 @@ Database (Supabase) - Avatar UI follows the validated mockup: photo in Mon compte (Informations personnelles), sidebar, drawer and top bar link to Mon compte; JPEG / PNG / WebP only, never SVG; no signed URL for the owner-only avatar (download under RLS). -### Anatomical sheet model (packages/domain + migration 20261008110000) +### Anatomical sheet model (crates/core/src/domain/sheet + migration 20261008110000) - `docs/development/ANATOMICAL_SHEET_MODEL.md` is the source of truth: document shape, issue codes, tables, RPCs. - Ids are stable slugs never derived from labels; labels are `{ fr, en }` objects. Annotation → findings is the explicit `finding_zone_id`; vertebral regions are ordered data with free codes. No label matching at runtime. - A published version is immutable (trigger, every role). Change = new draft (`create_sheet_draft`) then - `publish_sheet_version`. Integrity rule codes are shared by `validateSheetDocument` (TS) and + `publish_sheet_version`. Integrity rule codes are shared by `validate_sheet_document` (Rust core) and `private.sheet_document_issues` (SQL); add a rule on both sides and in the spec table. - Document schema change → bump `SHEET_DOCUMENT_SCHEMA_VERSION`, extend the SQL CHECK on `document_schema_version`. - Official equine sheet = generated seed `draft/` (`pnpm import:equine --out` into an empty folder, then reviewed and copied; never edit `legacy-import/` or `draft/` by hand; - the golden test fails on drift). Every content change goes through `curation/changes.json` (traced in CHANGELOG.md). + `curation_draft` / `curation_review` fail on drift, `pnpm import:equine --check` lists it). Every content change goes through `curation/changes.json` (traced in CHANGELOG.md). It is a DRAFT until a platform admin publishes it after business review of `REVIEW-REPORT.md`. - Sheet SVG bytes live in Storage bucket `anatomical-sheet-assets` as `.svg`; uploads are an operator task (`pnpm assets:upload ` with the service key in env), never from the browser. @@ -529,7 +526,9 @@ Database (Supabase) Study and roadmap: `docs/development/RUST_ARCHITECTURE_REVIEW.md` (validated with the amendments of Annex C). Done: R0, R1 (worker), R2 (domain core used by the app, `docs/development/RUST.md` §8), R3 (anatomy core: SVG reader, layer, composition; editor canvas on it, -RUST.md §9; validated and merged 2026-10-17). Next: R4 (PDF core), R5 (pipeline); release 0.2.0 unaffected. +RUST.md §9; validated and merged 2026-10-17), R4 (PDF core, RUST.md §10; merged 2026-10-21). R5 (pipeline, +RUST.md §11: R5.1 to R5.7, the TypeScript packages deleted) on `feature/rust-r5-pipeline-core`, not merged; +release 0.2.0 unaffected. - Any logic that can run in Rust with no significant loss (features, UX, graphics, data compatibility, security, reliability, useful performance, diff --git a/README.md b/README.md index 8c401205..d9106969 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ full report JSON embedded as a native PDF attachment. Re-importing that PDF restores the state for a follow-up. Multi-species by design. The MVP ships the **horse** sheet: a canonical anatomical -sheet document (drawing + annotations + findings catalog, `packages/domain`) +sheet document (drawing + annotations + findings catalog, `crates/core/src/domain/sheet`) generated and curated under `supabase/seed/anatomical-sheets/equine/`. Another species is another sheet document, no code change. See `docs/development/ANATOMICAL_SHEET_MODEL.md` §6 for how a sheet is produced. @@ -93,7 +93,7 @@ docker compose up --build ```bash pnpm typecheck # TypeScript strict, no emit pnpm lint # ESLint 9 flat config, 0 warnings -pnpm test:run # vitest run (domain, anatomy, supabase/PGlite, app) +pnpm test:run # vitest run (core-wasm, supabase/PGlite, app) pnpm build # tsc + vite build → apps/app/dist/ pnpm report:compare ... # archive PDF vs its v3 reading, unresolved items flagged (the core's binary; first run compiles) pnpm rust:check # native: fmt, clippy -D warnings, cargo test, ts-rs export, cargo deny @@ -152,8 +152,8 @@ faunosteo/ pnpm workspace (see docs/development/WORKSPACE.md) ├─ src/lib/ id, dates, assert utilities ├─ src/styles/ Tailwind v4 CSS + design tokens ├─ tests/unit/ vitest tests on the bundled sheet (+ frozen v2 fixtures) -├─ packages/domain/ @faunosteo/domain: canonical sheet document + report document (v3, v2 migration) -├─ packages/anatomy/ @faunosteo/anatomy: legacy importer, curation pipeline, annotation-layer renderer + view composer +├─ packages/core-wasm/ @faunosteo/core-wasm: the Rust core in the browser (runtime, generated types, frozen N-1 reader) +├─ crates/ Rust: core (contracts, rules, SVG, PDF, anatomical pipeline), wasm facade, worker ├─ packages/supabase/ @faunosteo/supabase: typed client, generated types, PGlite SQL test harness ├─ supabase/ CLI config, SQL migrations, local seed (incl. the equine sheet), pgTAP tests ├─ docker/ entrypoint.sh + nginx.conf @@ -169,7 +169,7 @@ v0.1.0 MVP — implementation complete. - `pnpm typecheck` ✅ - `pnpm lint` ✅ -- `pnpm test:run` ✅ — 367 tests across the workspace (domain, anatomy, supabase, app) +- `pnpm test:run` ✅ — the vitest suites of the workspace (core-wasm, supabase, app); `pnpm rust:check` runs the Rust ones - `pnpm build` ✅ The first species ships as the equine anatomical sheet: the historical diff --git a/docs/ANNOTATION-RENDERING.md b/docs/ANNOTATION-RENDERING.md index ea791925..924b6446 100644 --- a/docs/ANNOTATION-RENDERING.md +++ b/docs/ANNOTATION-RENDERING.md @@ -11,9 +11,9 @@ application draws the markers itself from the canonical document annotations of one view into a `` appended last to the view's ``, above the drawing. Since R3 the editor canvas gets the whole view (sanitised drawing + layer) from the Rust core -(`crates/core/src/anatomy`); the PDF engine and the curation pipeline still -use the TypeScript renderer (`packages/anatomy/src/render`) until R4 and R5, -with the same output. +(`crates/core/src/anatomy`); so do the PDF writer (R4) and the curation +pipeline's review drawings (R5). The TypeScript renderer +(`packages/anatomy/src/render`) it replaced was deleted at R5.7. ## Elements emitted per annotation diff --git a/docs/PDF-FORMAT.md b/docs/PDF-FORMAT.md index ad395395..46ec1414 100644 --- a/docs/PDF-FORMAT.md +++ b/docs/PDF-FORMAT.md @@ -27,7 +27,7 @@ branding have changed since the export. Design record: `safeText`: control characters are stripped and any glyph WinAnsi cannot encode becomes `?` (en and em dashes, accented letters, `•`, `·` are fine; `⚠` is not, hence the `(!)` vet-referral marker). -- Drawings: the sheet SVG asset is parsed with xmldom, sanitised (allowlist +- Drawings: the sheet SVG asset is read by the core's one SVG reader (`anatomy::svg`, since R3/R4; xmldom left at R5.7), sanitised (allowlist below), framed on the view box, the marker layer is generated from the document and the observation's zones are filled `#b85a3f` at 0.85 opacity with a blur halo on the main view; every other marker is dropped. The SVG diff --git a/docs/development/ANATOMICAL_SHEET_MODEL.md b/docs/development/ANATOMICAL_SHEET_MODEL.md index bb12b519..00930217 100644 --- a/docs/development/ANATOMICAL_SHEET_MODEL.md +++ b/docs/development/ANATOMICAL_SHEET_MODEL.md @@ -15,7 +15,7 @@ Out of scope here: the legacy importer and the official equine draft | Layer | Where | Role | | ------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| Canonical document | `packages/domain/src/anatomical-sheet/` (Zod) | The sheet content: views, annotations, finding tree, vertebral regions, translations. Self-describing (`schema_version`). | +| Canonical document | `crates/core/src/domain/sheet/` (Rust; Zod until R5.7) | The sheet content: views, annotations, finding tree, vertebral regions, translations. Self-describing (`schema_version`). | | Relational identity | `supabase/migrations/20261008110000_anatomical_sheets.sql` | Who owns the sheet, visibility, versions and their status, provenance of copies, assets, audit. | The database stores the document as JSONB in @@ -276,7 +276,7 @@ with the community step (§17.4). | Criterion | Where it is proven | | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | -| A sheet with several views and annotations explicitly linked to findings | `packages/domain/tests/fixtures/horse-slice.ts` (2 views, trigger, spine region, bilateral joint, 3 finding kinds); schema + integrity tests | +| A sheet with several views and annotations explicitly linked to findings | `crates/core/tests/fixtures/horse-slice.json` (from `horse-slice.ts`, deleted at R5.7; 2 views, trigger, spine region, bilateral joint, 3 finding kinds); schema + integrity tests | | Ids stable under translation | test: renaming every label leaves ids, references and `validateSheetDocument` output unchanged | | Published versions immutable | pgTAP: UPDATE of content / status / number on a published row → `42501` for the table owner; zero rows touched through the API role | | New version leaves old ones intact | pgTAP: v2 draft then publish; v1 row byte-identical, `current_version_id` moves | @@ -304,8 +304,8 @@ the decision lands; only the naming one is implemented in this document. ## 6. Official equine sheet: import (Step 4b) and curation (Step 4c) A deterministic pipeline (since R5.6 the Rust one, `pnpm import:equine --check | --out `, -`crates/core` feature `curation`; the TypeScript original in `packages/anatomy` stays as -`pnpm import:equine:legacy` until R5.7) reads the historical files kept under +`crates/core` feature `curation`; the TypeScript original `packages/anatomy` was deleted at +R5.7, replayable from a historical revision, `docs/development/RUST.md` §11.23) reads the historical files kept under `supabase/seed/anatomical-sheets/equine/legacy-sources/` (`Horse.svg`, `Horse_head.svg`, `pathologies.json`, `vertebrae.ts`, never edited), then the authored curation files, and writes under @@ -317,7 +317,7 @@ authored curation files, and writes under | `curation/` | authored, committed | `references.json` (the references registry) and `changes.json` (the changeset) | | `draft/` | generated working revision | curated `document.json`, `assets.json` + `assets/horse.svg`, `sheet-ref.json` (sheet id, null version id, the `sha256-rfc8785-validated-v1` fingerprint of the document and its `fingerprint` block, RUST.md §11.22), `report-migration-map.json` (legacy ids and finding paths → the draft, for Report v2 imports), `CHANGELOG.md`, `REVIEW-REPORT.md`, `review/annotations-.svg` (before/after drawing per view), `review/app-.svg` (the application's own rendering), `equine_draft.sql` | -Changeset (`packages/anatomy/src/curation/schema.ts`): each change has an +Changeset (`crates/core/src/curation/draft/schema.rs`): each change has an id `CHG-nnn`, a level (A demonstrated error, B supported improvement, C uncertain: a `question` is then required), a kind (correction, terminology, translation, restructure, enrichment, reference, geometry, @@ -396,7 +396,7 @@ applier's rename, move and removal records over every node of the legacy baseline (792 nodes: 571 identical, 180 renamed or moved, 7 re-homed under another category when the match is unique, 34 removed = `null`), maps the 27 legacy `data-anno-id` to annotation ids with the legacy names, and the `head` -detail key to the view. `migrateReportV2ToV3` (packages/domain) reads it; a +detail key to the view. `migrate_report_v2_to_v3` (`crates/core/src/domain/report/read.rs`) reads it; a report keeps what the map cannot place, flagged `unresolved`. Annotation colour (Step 5, additive, schema_version stays 2): `annotations[].color` diff --git a/docs/development/RUST.md b/docs/development/RUST.md index 2d567951..71937f29 100644 --- a/docs/development/RUST.md +++ b/docs/development/RUST.md @@ -3682,3 +3682,141 @@ anatomy 15. Security PASS, LOW only (`.claude/audits/2026-10-25-rust-r5-6-active authorised, settled by the contract Clarification of 2026-10-25 (`.claude/audits/2026-10-25-rust-r5-6-active-verify.md`). Wasm 531,715 B gzip (518,018 before the switch, +13.7 KB), under the earlier 600 KB reference mark; no budget added. + +### 11.23 R5.7: consumer census, `packages/anatomy` and `packages/domain` deleted (2026-10-25) + +Owner brief « Validation R5.6 et autorisation R5.7 ». Plan `.claude/tasks/plans/2026-10-25-rust-r5-7-cleanup.md`, +contract `.claude/tasks/contracts/2026-10-25-rust-r5-7-cleanup.md`. Base 756b7ef (R5.6 active). + +**Census (before any deletion).** Outside the two packages: `packages/anatomy` was reached by the root script +`import:equine:legacy`, the Dockerfile (`COPY packages/anatomy/package.json`), the workspace (`pnpm -r test:run` ran its 144 +cases inside `pnpm check`), `r4.census.test.ts` (xmldom pinned under it), the SQL seed header (text) and docs and Rust module +comments (text). `packages/domain` was reached by `packages/anatomy` (5 runtime symbols), the Dockerfile, the Rust suites +`report_rules` and `archive_rules` (they read `packages/domain/tests/fixtures/report-v2.{full,minimal}.json` from disk), the +app ESLint ban (a closed door), docs and three SQL migration comments (applied migrations, never edited). No application, +glue or Supabase-package source imported either (grep + `r4.census`). `packages/domain/src` is byte-identical to the frozen +N-1 copy `packages/core-wasm/tests/n-1/domain` (`diff -r`), which stays. `packages/supabase/scripts/upload-sheet-assets.ts` +(`assets:upload:legacy`) was the TS upload tool replaced at R5.5. + +**Matrices.** `crates/core/tests/curation/FILES.tsv`: the 112 tracked files that left (110 deleted, the 2 fixtures moved), +each with its Rust counterpart (55 ported, 48 replaced, 9 package tooling or test helpers deleted). `crates/core/tests/curation/LEDGER.tsv`: +one row per TS case at 756b7ef (anatomy 144 in 22 files, domain 263 in 13), with its contract, status, target, oracle and +note: 256 ported, 149 replaced (frozen oracle, byte-exact committed seed, golden), 2 deleted (`never mutates its inputs`: the +Rust applier takes `&Value`, no aliasing hazard; `r2-horse-slice`: it wrote the JSON fixture from the `.ts` one, the JSON is +the source now), 0 uncovered. The 64 domain rows of `archive.branding-labels` re-registered by two other files are listed +as such. Mapping by two read-only analyses, every target checked against `cargo test -- --list` (154 cargo targets, 0 +missing) and by `apps/app/tests/unit/r5.census.test.ts` on every run. + +**Contracts ported first** (the mapping found 15 anatomy cases whose contract only the TypeScript checked, and one partial +domain oracle): `curation_leaves.rs` (new, 8 tests: the 612 leaves 442/141/29, leaves land on leaves, FR and EN snapshots and +the vet flag per finding, the 29 removed with their legacy path, the 141 moves split 134/7 inside their zone, v3 re-read +stable, the 26 observable legacy ids on the right view with their names, C7 kept on a defined region); `curation_draft` (+7: +a cite of a reference the same change added, the view box read and `1 2 3` refused, the map following a move through a +just-renamed path, `CHG-000` reserved, the dollar-quote tag refused, the 16 rows of the R5.1 ledger equal to the committed +files with the pre-switch substitution, the two generated folders holding exactly the ledger's files plus the byte copies); +`curation_format` (+1: `inferRegionCode`, the 12 rows of `js-semantics.json` no Rust test read, and the TS cases); +`curation_review` (+1: an annotation dropped by a change drawn `removed`); `anatomy_compose` (+1: the halo filter never +duplicated on a root that holds it); `report_contract` (+1: `migration-map.draft.json` read entry by entry as Zod read it, +27 annotations, 792 paths, 34 nulls, the committed map differing only by its fingerprint). Partial points kept as notes in +the ledger (no business contract lost): the empty document's `view_box: null` literal, two relabel assertions, the +`snapshotIndexSource` and `buildSheetIndex` TS-only adapters, JS identity probes. + +**Fixtures.** `report-v2.full.json` (`e96b0882…729c`) and `report-v2.minimal.json` (`ba79698c…dfe7`) moved by `git mv` to +`crates/core/tests/fixtures/`, sha256 equal before and after (also asserted by `r5.census`); identical to the app's copies +under `apps/app/tests/fixtures/`, which stay. Kept untouched: the R2 oracles (`oracles/*.json`, `characterisation.json`, +`verdicts.json`), R3 (`oracles/r3`), R4 (`oracles/r4`, `pdf/LEDGER.tsv`, the app goldens and `goldens/r4` digests), R5 +(`oracles/r5`, 13 files), the pre-switch seed copies (`fixtures/r5-6/pre-switch`), `fixtures/horse-slice.json`, the +conformance fixtures, every reference PDF, the migration data, the N-1 readers. The generators that wrote them left with the +packages; an oracle is never regenerated. + +**Deleted.** `packages/anatomy`, `packages/domain`, `packages/supabase/scripts/upload-sheet-assets.ts`, the scripts +`import:equine:legacy` and `assets:upload:legacy`, the two Dockerfile `COPY` lines. Lockfile through `pnpm install --offline` +then `--fix-lockfile`: 69 lines removed, `@xmldom/xmldom` 0.9.12 gone, the two importers gone; `tsx` 4.23.15 is declared by +no package and stays resolved only as vite's optional peer, marked `optional: true` (`pnpm dedupe --check` clean: removing +it would take a hand edit); no other version moved; `--frozen-lockfile` installs. Root Prettier stays (`pnpm format`, +`db:types`, `db:types:check`). Left on disk, git-ignored: `packages/{anatomy,domain}/node_modules` (pnpm symlinks; the +recursive delete was refused to Claude by the permission layer, owner action as for `packages/pdf`). + +**Census tests.** `r4.census.test.ts`: xmldom, the TS domain and the pipeline package banned from the app and glue sources +and manifests; the lockfile holds no `@xmldom/xmldom` and no `packages/{anatomy,domain}` importer, with a non-vacuity check +(the importer split finds `.`, `apps/app`, `packages/core-wasm`). `r5.census.test.ts` (10 cases): the packages and the TS +upload script absent; no manifest declares them, xmldom or tsx, no `:legacy` script, `import:equine` and `assets:upload` run +the Rust binaries; the lockfile importers equal the manifests on disk (non-vacuity) and resolve none of them; no app, Vite, +glue or Supabase-package source imports them (non-vacuity: `@faunosteo/core-wasm` is found); the Dockerfile copies only +existing manifests; the ESLint ban names `@faunosteo/domain`, `@faunosteo/anatomy`, `@xmldom/xmldom`; every `FILES.tsv` row +absent with its counterpart present; every `LEDGER.tsv` row absent, 407 = 144 + 263, valid status, each cargo target a `fn` +of its test file, each oracle file present; the moved fixtures' sha256; the oracles, pre-switch copies and N-1 readers present. + +**Test counts.** Before (756b7ef, vitest JSON): TypeScript 943 (app 436, core-wasm 60, supabase 40, anatomy 144, domain 263); +Rust core 364 (features `cli,upload`) + worker 33. After: TypeScript 546 (app 446 = 436 + the 10 R5 census cases, core-wasm 60, +supabase 40); Rust core 383 (+19 ports) + worker 33. The 407 deleted cases are covered as the ledger says. + +**Historical reproducibility (rehearsed 2026-10-25, detached worktree under the session scratchpad).** + +| | | +|---|---| +| Last commit where the TypeScript pipeline was the official seed writer | `59521dc1953e6005045ca5b39434de6377033237` (`pnpm import:equine` = TS) | +| Last commit holding the TypeScript pipeline | `756b7ef34d9cac9cfcb8288fecbf07599837a5ba` (`pnpm import:equine:legacy`) | +| Tooling | Node 24 (rehearsed on v24.21.0), pnpm 10.13.1 (corepack), lockfile sha256 `a8611f22…1334` (same at both commits) | +| Dependencies resolved | zod 3.25.76, @xmldom/xmldom 0.9.12, prettier 3.8.3, tsx 4.23.15, typescript 5.9.3, vitest 3.2.7, eslint 9.39.4, @types/node 20.19.41 | + +```bash +git worktree add --detach 59521dc +cd && corepack pnpm install --frozen-lockfile --offline # or without --offline +corepack pnpm import:equine # TS writer: rewrites the two seed folders of this worktree only +git status --porcelain # empty: the TS reproduces the committed seed byte for byte +corepack pnpm --filter @faunosteo/anatomy --filter @faunosteo/domain test:run # 144 + 262 green +# at 756b7ef: corepack pnpm import:equine:legacy → exactly draft/sheet-ref.json and draft/report-migration-map.json +# differ (pre-switch values, equal to crates/core/tests/fixtures/r5-6/pre-switch); run the suites on a clean tree +# (they read the committed seed): 144 + 263 green +``` + +Rehearsal results: at 59521dc `git status` empty after the run, 144 + 262 green; at 756b7ef the two files only, at +`2c0716f1…b285` and `4139c51d…fce9`, and 144 + 263 green on the clean tree (one run of the suites over the tree the generator +had just rewritten failed `r2-oracles` "committed migration map after R5.6", as it should). + +Expected sha256 of the TypeScript output (the committed seed except the two R5.6 files; the 16 text rows are also +`oracles/r5/pipeline.json` `artifacts`, asserted by `curation_draft`): + +| File (under `supabase/seed/anatomical-sheets/equine/`) | sha256 | +|---|---| +| `draft/assets/horse.svg` | `0ea5202fa3b95bac167b87c12ee969ab0272e085b60c2d34dbca6202c5f08541` | +| `draft/assets.json` | `c490dc758b330f372548a595826e2d4de73dcb935af1e39cb4883d5b31927cf5` | +| `draft/CHANGELOG.md` | `48c010c8c8010f81d201005b485ecfe01e0b8c8ea76b944d220bcf2174d8b6c7` | +| `draft/document.json` | `27c7383c445c73dc2001ebf4794a3ea63d416910bbbaa0d7848dd720de7c2660` | +| `draft/equine_draft.sql` | `c5a24312c6a77cdd7e545dc34ebee377abd1ef9f9868fbffedbd6c21f53bed1e` | +| `draft/report-migration-map.json` | `4139c51d3acd69ba9ca0ee6bb7bd7ebe7be4eb818e330ff278b37e1d04b7fce9` | +| `draft/review/annotations-head.svg` | `2d6858a1891cdae36ffd364b30bc7586bcfcc1ea76a79ac0cda99497a21672e6` | +| `draft/review/annotations-main.svg` | `1fd2e385468b1013ccd34f03ddf2ad80a7755f8d6b9071514e48aafa0e7bd4e4` | +| `draft/review/app-head.svg` | `8d33077cdc87d2b979a58d75e271102fb9b18fcc2fa93ebd97758672f5eb3e80` | +| `draft/review/app-main.svg` | `985a043aa1871b58ceec1f96e4fc4c6edd02e05bdb82694787a5c4ea5d6f81d5` | +| `draft/REVIEW-REPORT.md` | `fbdaa58db0dbc092b7a0cd039804e1879f1351669abf7c6d0a0cf1189f0c8bfb` | +| `draft/sheet-ref.json` | `2c0716f1536e4182cde9ffb0f183c7255d1ad6a1fc754d72011ff8090304b285` | +| `legacy-import/assets/Horse_head.svg` | `9c03b98c0e55e3f684ce314b88dab2a0e11f488af6cc9140d61e1b2d5f9cb94c` | +| `legacy-import/assets/Horse.svg` | `5fe3819c8bf07f18fcc51f40f3d06b1bc82e6202a62afa003e8639867b5b212d` | +| `legacy-import/assets.json` | `109b0e7b8a03d398ea89ef278021f73d4f387992bbfdb2196c9cb7bec4232f2f` | +| `legacy-import/document.json` | `91e459f4c0ac8043831242c9fccde01f75f1023464db909f1c29571aa8a414c2` | +| `legacy-import/IMPORT-REPORT.md` | `7233bca100c8c1acc6e16310acd9e3e241e6760ab73855dcbf3a2bb92282d240` | +| `legacy-import/legacy-id-map.json` | `4ec2b4e3a0ee7d901145ce45f9cc240d28e30997155a51c6d53ea1c1a36667b7` | + +The old engine is not reintroduced in the tree; no third engine is kept. + +**Seed SQL header.** `equine_draft.sql` line 2 still reads "Generated by `pnpm import:equine` (packages/anatomy)". Changing it +would change the frozen seed bytes (`c5a24312…ed1e`, ledger row): kept, explained in `curation/draft/seed.rs` beside the +emitted text and here. The generator is the Rust module since R5.6. + +**Rust pipeline parity.** `pnpm import:equine --check`: legacy-import 6 files, draft 12 files, 0 differences (app-main under +the declared R3 trigger-name rule). + +**Checks on the final state.** `pnpm install --frozen-lockfile` ok; `pnpm rust:check` green; `pnpm check:all` green 03:58:13 +(advisories ok, wasm, `pnpm check`, app image, worker sandbox tests and runtime image); RFC 8785 and alias (`sheet_fingerprint` +11, `r5_6_switch` 14), archives (`archive_rules` 38, `report_rules` 17 on the moved fixtures), PDF (`pdf_*`, `pdf_compare` 16), +the N-1 suites (`n-1.reader`, `r5-6.n-1`, `n-1.scanner`), seed and sheet integrity (`curation_*`, `sheet_rules`, +`sheet_conformance`), the census suites. + +**Follow-ups kept (brief §10, unchanged by R5.7).** The rollback limit of reports written after R5.6 (a build that can roll +back must recognise both conventions before any public exposure; tested by `r5_6_switch`); DEV Supabase hardening +(ENVIRONMENTS.md §3.6); the migration-map cascade debt (§11.12); the direct export API trust boundary (§11.22); the SQL +checks before public exposure (`confirm_sheet_asset_upload`); the accepted LOW items of §11.16 to §11.22. Once the generators +are gone, a change of `curation/changes.json` cannot re-freeze `pipeline.json` or the synthetic oracles: the Rust tests that +pin the real draft (46 changes, 825 records, the 612 fates, the fingerprints) then need an owner decision on a new baseline. diff --git a/docs/development/SUPABASE.md b/docs/development/SUPABASE.md index aa51a57e..81aa3bf2 100644 --- a/docs/development/SUPABASE.md +++ b/docs/development/SUPABASE.md @@ -155,8 +155,8 @@ UTF-8, 3 network. The DEV address counts only if it is an address of this machine. The key is never printed and goes through no proxy. `pnpm e2e:sheet-assets` runs the whole behaviour against the local stack (upload, rerun, anon and wrong key, -refused destinations, unreachable port). The TypeScript tool stays as -`pnpm --filter @faunosteo/supabase assets:upload:legacy` until the R5.7 census. +refused destinations, unreachable port). The TypeScript tool +(`packages/supabase/scripts/upload-sheet-assets.ts`) was deleted at R5.7 (RUST.md §11.23). ### 3.2 Files worker (Storage, Step 8) diff --git a/docs/development/TEST_STRATEGY.md b/docs/development/TEST_STRATEGY.md index 374ebac7..b8eadd28 100644 --- a/docs/development/TEST_STRATEGY.md +++ b/docs/development/TEST_STRATEGY.md @@ -19,7 +19,7 @@ Status: Step 0 deliverable, 2026-10-08. Current state: 32 files under | SQL/TS contract | generated types diff check | CI | every PR touching `supabase/` | | Rust core and facade | `cargo test` (unit + fixture tests reading the repository JSON in place), `clippy -D warnings`, `cargo deny`; ts-rs types drift check | `crates/*`, `pnpm rust:check` (native, `scripts/rust-check.sh`; same file in the builder image), `pnpm check:all` | before every Rust commit and every merge; CI job `rust` prepared, no runner yet | | Rust/TS contract | vitest on the built module: byte equality with `JSON.stringify(…, null, 2)` on the real documents, ts-rs types against the Zod output types, the runtime (lazy load, trap → poison → offline re-instantiation, handle rebuild, cap, retry), panic and stack traps on `pkg-proofs`, served size budget and measurements | `packages/core-wasm/tests` (refused, never skipped, when `pkg/` or `pkg-proofs/` is missing or stale) | `pnpm check:all` (after the native `wasm:build`); CI `check` prepared | -| Freeze-then-switch oracles (R2) | outputs of the TypeScript frozen before the switch and checked by cargo: Zod output of the reference documents (byte-equal), 84 report / archive cases, 765 Zod verdicts, 49 editor cases, 26 sheet conformance fixtures (also inlined into the generated pgTAP `011`, drift-checked), the three archive envelopes (deep-equal through the app path) | `crates/core/tests/{oracles,conformance,fixtures}`, generators in `packages/domain/tests/r2-*.test.ts` and `apps/app/tests/unit/archive.envelopes.test.ts` (`MAKE_R2_ORACLES` / `MAKE_R2_FREEZE`, never regenerated without an owner decision) | every Rust commit (`pnpm rust:check`), `pnpm check:all` | +| Freeze-then-switch oracles (R2) | outputs of the TypeScript frozen before the switch and checked by cargo: Zod output of the reference documents (byte-equal), 85 report / archive cases, 765 Zod verdicts, 49 editor cases, 26 sheet conformance fixtures (also inlined into the generated pgTAP `011`, drift-checked), the three archive envelopes (deep-equal through the app path) | `crates/core/tests/{oracles,conformance,fixtures}`, generators `packages/domain/tests/r2-*.test.ts` (deleted at R5.7, at 756b7ef; the oracles stay) and `apps/app/tests/unit/archive.envelopes.test.ts` (`MAKE_R2_ORACLES` / `MAKE_R2_FREEZE`, never regenerated without an owner decision) | every Rust commit (`pnpm rust:check`), `pnpm check:all` | | N-1 reader (permanent) | every draft and archive the core-fed application writes parses with the Zod schemas of the last TypeScript build (`packages/core-wasm/tests/n-1`, develop 1a7ee7d) | `apps/app/tests/unit/n-1.reader.test.ts`, `archive.envelopes.test.ts` | every commit (`pnpm test:run`) | | CSP on the image (R2) | the real app image behind the DEPLOY.md CSP in headless Chromium: with `'wasm-unsafe-eval'` the core runs the editor path, without it the degraded state and an untouched draft; no module request on `/login`, `/app/account`, `/` | `docker/csp-proof/app-image.sh` | before a merge touching the core loading or the image; manual (needs Chromium) | | Worker sandbox | integration tests against the musl binary that ships: fixture corpus through the full sandbox, refusals, SIGSYS on a denied syscall, output cap, `RLIMIT_AS` abort, `RLIMIT_CPU`, deadline; seccomp allowlist derived by `strace` and compared | `crates/worker/tests/sandbox.rs`, Dockerfile stage `test` (`pnpm worker:test`, Docker only, never native) | every `crates/worker` commit, `pnpm check:all`; CI `docker` job prepared | diff --git a/docs/development/WORKSPACE.md b/docs/development/WORKSPACE.md index 06fa5d4e..1e1f4c64 100644 --- a/docs/development/WORKSPACE.md +++ b/docs/development/WORKSPACE.md @@ -13,8 +13,9 @@ faunosteo/ │ ├─ src/ public/ tests/ scripts/ index.html │ ├─ vite.config.ts vitest.config.ts tsconfig*.json eslint.config.js │ └─ package.json app dependencies and scripts -├─ packages/domain/ @faunosteo/domain: canonical anatomical sheet document (Zod) + integrity rules +├─ packages/core-wasm/ @faunosteo/core-wasm: the Rust core in the browser (runtime, ts-rs types, frozen N-1 reader) ├─ packages/supabase/ @faunosteo/supabase: typed client, generated types, PGlite SQL tests +├─ crates/ Rust workspace: core (contracts, rules, SVG, PDF, anatomical pipeline), wasm, worker ├─ supabase/ Supabase CLI config, migrations, seed, pgTAP tests (docs/development/SUPABASE.md) ├─ docker/ nginx.conf, entrypoint.sh (unchanged) ├─ docs/ conventions, audit, development plan @@ -35,7 +36,7 @@ Future units, created only by the step that needs them: |---|---|---| | `apps/public-web` | SSR public site (landing, practitioner profiles, search) | plan Step 22 | | `crates/worker` | Rust job runner (avatars at R1, then emails, expiry, calendar sync, imports) — created at R0, replaces the planned `apps/worker` | R0 (2026-10-12) | -| `packages/*` | shared domain, anatomy, core-wasm, supabase (i18n, config, ui planned; `pdf` deleted at R4.8) | see `packages/README.md` | +| `packages/*` | core-wasm, supabase (i18n, config, ui planned; `pdf` deleted at R4.8, `domain` and `anatomy` at R5.7) | see `packages/README.md` | Rust workspace (plan R0, `docs/development/RUST.md`): `Cargo.toml` at the root with `crates/core` (library), `crates/wasm` (browser facade, built into @@ -111,7 +112,8 @@ Package-scoped: `pnpm --filter @faunosteo/app