feat(domain): equine legacy importer (packages/anatomy) + generated official equine sheet seed as draft

This commit is contained in:
bchanot committed 2026-10-09 00:38:48 +02:00
1 parent f4682cdba5
commit 52bfc11553
43 files changed
+18466 -33

No files matched your search

+33 -3
View File
@@ -284,6 +284,36 @@ the decision lands; only the naming one is implemented in this document.
| 6 | Server-side validation and integrity for every publication; the frontend is never a security boundary. | SQL already re-checks references, sizes and species. The full shape check (Zod) moves server-side before community publication: plpgsql shape rules or an Edge Function gate, decided at the community step. |
| 7 | Account deletion handles dependencies and transfers explicitly (RGPD); no dependency may block the erasure of personal data forever. | Retention step (§16): published versions get their `created_by` / `published_by` anonymised through a dedicated system path (the immutability guard will allow that single transition), personal sheets are transferred or archived, `creator_user_id` keeps `on delete restrict` only as the backstop that forces the explicit path. |
Still open, technical only: the Storage layout `<sha256>.svg` is applied by
the importer step (4b) with a bucket policy that authorises through the
sheet, never through a hash alone.
## 6. Official equine sheet: import (Step 4b)
`packages/anatomy` holds a one-off, deterministic importer
(`pnpm import:equine`) that reads `Horse.svg`, `Horse_head.svg` and
`pathologies.json` and writes `supabase/seed/anatomical-sheets/equine/v1/`:
the canonical `document.json`, `legacy-id-map.json` (every legacy
`data-anno-id`, category slug and view key → new id), `assets.json` and the
byte-identical SVG copies, `IMPORT-REPORT.md` (French, for the osteopath:
volumes in / out, every mapping, every anomaly to validate) and
`equine_v1.sql`, the idempotent seed that creates the platform-owned sheet
`faunosteo-cheval` (private, official) with its two asset rows and draft v1.
Rules of the import:
- ids are explicit and stable: annotation id = catalog zone key when FR and
EN names match exactly (26 / 26), finding zone id = catalog key, views
`main` and `head`, trigger `head-trigger`; nothing matches by label at
runtime;
- no medical correction: catalog ids and labels are kept verbatim
(`ssb-dysfunctions` under `sphenoid` included) and every doubt is an entry
of the report; only technical slugs (degraded category ids) are
normalised, and the report says so;
- no publication: the seed inserts a draft through
`private.insert_sheet_draft` (audited with a null actor) and never calls
`publish_sheet_version`; only a platform admin can publish it, after the
business review of the report (pgTAP 007 pins both);
- the source files under `apps/app/public/species/equine/` stay untouched
and keep serving the current application.
Storage: bucket `anatomical-sheet-assets` (private, SVG only, 20 MiB cap),
objects `<sha256>.svg`, read policy `anatomical_sheet_assets_read` through
`private.can_read_sheet_asset_object` (published reference of a usable
sheet, or editor); no API writes (operator upload, `SUPABASE.md` §3.1).