diff --git a/.claude/rules/annotation-rendering.md b/.claude/rules/annotation-rendering.md new file mode 100644 index 00000000..da4f39ea --- /dev/null +++ b/.claude/rules/annotation-rendering.md @@ -0,0 +1,14 @@ +--- +paths: ["crates/core/src/anatomy/**", "docs/ANNOTATION-RENDERING.md"] +--- + +# Annotation rendering +- docs/ANNOTATION-RENDERING.md is the source of truth: the drawing carries no annotation element, the markers are + 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` + and the annotation's fields (`laterality`, `vertebral_region_code`, `opens_view_id`) +- Marker look (radii, opacities, strokes) is renderer style; colours are document data (`color` on categories + and annotations); no graphic redesign without prior validation diff --git a/.claude/rules/database.md b/.claude/rules/database.md new file mode 100644 index 00000000..14d4b318 --- /dev/null +++ b/.claude/rules/database.md @@ -0,0 +1,20 @@ +--- +paths: ["supabase/migrations/**", "supabase/tests/**", "packages/supabase/**", "apps/app/src/state/authStore.ts"] +--- + +# Database (Supabase) +- The auth session lives in the Supabase client (localStorage, PKCE); the app reads it through `state/authStore.ts` only. Profile columns the user may edit are the column grants in the profiles migrations; never widen them from the client. +- Platform roles (`platform_role`: owner/admin/moderator/support) are NOT professional + statuses (practitioner/student/professor come from verification, cabinet roles from + organization_members). Never add a professional status to `platform_role`. +- Every `public` table: RLS enabled, `revoke all` from API roles then exact grants, + separate policies per command, no `using (true)` for anon/authenticated (test-enforced). +- Writes that change privileges or sensitive state go through a security-definer RPC + that checks `auth.uid()` and calls `private.log_event()`. Never a direct table policy. +- Helpers in `private` are `security definer`, `set search_path = ''`, EXECUTE revoked + from public and granted only to the roles that evaluate them. +- A migration is never edited once applied. Each migration ships its pgTAP file with + allowed AND denied cases, and a regenerated `database.types.ts`. +- The browser holds the anon key only. The `service_role` key value never appears in env.js, .env.example or code; + operator scripts under `packages/*/scripts/` read it from the environment and are never bundled. +- pgTAP files run on PGlite and on the real image: scope counts to fixture ids, pin `collate "C"` on text ordering. diff --git a/.claude/rules/docker.md b/.claude/rules/docker.md new file mode 100644 index 00000000..83f4dcab --- /dev/null +++ b/.claude/rules/docker.md @@ -0,0 +1,28 @@ +--- +paths: ["Dockerfile", "docker-compose.yml", ".dockerignore", "docker/**"] +--- + +# Docker commands + +```bash +# Build image +docker build -t faunosteo . + +# Build an image that embeds the reference DRAFT sheet (preview only, never the default) +docker build --build-arg SHEET_BUNDLE=draft -t faunosteo . + +# Run with compose (reads .env for APP_* vars) +docker compose up --build + +# Stop +docker compose down +``` + +Naming convention: every Docker resource Faunosteo owns is prefixed `faunosteo_` +when the name is configurable (container `faunosteo_app`, Compose project +`faunosteo`); the Supabase CLI imposes `supabase__faunosteo`, documented +as a limit in DEPLOY.md "Docker resource naming". Never rename a resource that +holds data without keeping its volume. + +Note: no global pnpm needed. `corepack enable` once (reads `packageManager`), +or call `corepack pnpm `. Root scripts resolve `node_modules/.bin/pnpm`. diff --git a/.claude/rules/environments.md b/.claude/rules/environments.md new file mode 100644 index 00000000..c2662b49 --- /dev/null +++ b/.claude/rules/environments.md @@ -0,0 +1,15 @@ +--- +paths: ["scripts/dev-env.sh", "scripts/supabase.sh", "docker/dev-gateway/**", "docs/development/ENVIRONMENTS.md", "supabase/config.toml"] +--- + +# Environments and LAN access (docs/development/ENVIRONMENTS.md) +- The owner tests from other devices of the private network, never on the Ubuntu machine: every test surface + (app, Supabase API, Mailpit, Studio) is addressed by the DEV origin (`scripts/dev-env.sh`, `FAUNOSTEO_DEV_HOST`), + never by `127.0.0.1` / `localhost`, never hard-coded in a source (the automated browser suites are not a + surface for other devices: their dev servers and the sandbox stay on 127.0.0.1). The Supabase CLI runs only through + `scripts/supabase.sh` (`pnpm db:*`, `pnpm supabase`): config.toml reads the origin with `env()`. +- Exposure (least privilege, `pnpm dev:net-check`): LAN gets Vite 5173, the Supabase API 54321 and Mailpit + behind basic auth through the DEV gateway (`pnpm dev:gateway`, nginx, `faunosteo_dev_gateway`, 54325). The CLI + forces 0.0.0.0 on 54322 PostgreSQL, 54323 Studio, 54324 raw Mailpit: closed on the LAN interface by host UFW + rules (owner action, ENVIRONMENTS.md §3.2); SSH tunnel for Studio; the worker publishes no port. Nothing is exposed to the Internet; no production infrastructure + is touched from this repository. Rust is built natively; Docker runs services, the worker, sandbox tests and images. diff --git a/.claude/rules/i18n.md b/.claude/rules/i18n.md new file mode 100644 index 00000000..1c9a1103 --- /dev/null +++ b/.claude/rules/i18n.md @@ -0,0 +1,13 @@ +--- +paths: ["apps/app/src/i18n/**", "apps/app/src/state/localeStore.ts", "apps/app/src/pdf/labels.ts", "apps/app/src/auth/validation.ts", "apps/app/src/account/validation.ts"] +--- + +# i18n +- All user-facing strings live in `src/i18n/fr.ts` and `src/i18n/en.ts` (flat `Record`) +- Key convention: `.` — e.g. `common.cancel`, `home.new_report.title`, `pdf.subject` +- Both dicts must share the exact same key set; a key missing in one dict logs a warning in DEV +- Get the translate function in any component: `const t = useT()` then `t('common.cancel')` +- `src/state/localeStore.ts` holds current `Locale` (`'fr' | 'en'`), persisted to `localStorage` key `osteo:locale`; default: navigator-detected `fr`/`en`, or `'fr'` if no match; while signed in, `services/localeSync.ts` writes it to `profiles.locale` and applies the account locale on sign-in +- Form validation messages are i18n keys returned by the Zod schemas (`src/auth/validation.ts`, `src/account/validation.ts`), translated next to the field; GoTrue messages never reach the screen (`auth.failure.*`) +- Zone and finding names shown in the editor and the PDF come from the sheet document (`{ fr, en }` labels) and from the report's snapshots, not from the dict +- PDF static labels (section headings, metadata) live in `apps/app/src/pdf/labels.ts` (`defaultPdfLabels`, 25 keys, moved verbatim from the engine at R4.6) and are archived in the envelope; the app dicts hold no `pdf.*` key diff --git a/.claude/rules/pdf.md b/.claude/rules/pdf.md new file mode 100644 index 00000000..344a3a3c --- /dev/null +++ b/.claude/rules/pdf.md @@ -0,0 +1,11 @@ +--- +paths: ["crates/core/src/pdf/**", "apps/app/src/pdf/**"] +--- + +# PDF +- A4 portrait: 595.28 × 841.89 pt +- No raw URLs in PDF output — abbreviated citations only +- JSON attachment filename must start with osteo-report; content = report archive envelope v1 (report v3 + sheet snapshot + branding + labels); import accepts bare v2 (migrated), bare v3 and envelope v1; a bad snapshot never loses the report +- The writer (`crates/core/src/pdf/write`, since R4.6; the TypeScript engine deleted at R4.8) takes no clock and no I/O; rasterisation is the browser's, one raster per core request; every SVG it composes went through the core's one reader. The export is an incremental session (OD-2): the file is written as the rasters arrive, held once, handed out in parts; never accumulate rasters or build the file twice +- Page layout is frozen by the Step 6 goldens and the R4 oracles (O1 draw logs, O2 PDFs): any visible change needs a user decision and a golden regeneration; the R4 digests (`goldens/r4/pdf.*.sha256`) pin the writer's own bytes and are rewritten only for a declared structural change, with the O2 comparisons re-run +- Fonts are StandardFonts (Helvetica/TimesRoman, WinAnsi encoding) — TTF Inter/Fraunces planned but not yet embedded. Any non-Latin-1 glyph in PDF text must use an ASCII surrogate until the TTF migration lands (e.g. `(!)` instead of `⚠`). diff --git a/.claude/rules/schemas.md b/.claude/rules/schemas.md new file mode 100644 index 00000000..c411d8a2 --- /dev/null +++ b/.claude/rules/schemas.md @@ -0,0 +1,17 @@ +--- +paths: ["crates/core/src/domain/**", "packages/core-wasm/tests/n-1/**"] +--- + +# 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` 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); + form values are plain assignments (D-R7) +- Report version 3: zones by `(annotationId, viewId)`, findings by `(findingZoneId, path)`, severities + `mild|moderate|severe`, `sheet` reference; v2 is migrated through `report-migration-map.json` + (`migrateReportV2ToV3`, never throws on content, `unresolved: true` marks what the sheet no longer holds); + v1 and unknown versions are refused with a typed error diff --git a/.claude/rules/sheet-content.md b/.claude/rules/sheet-content.md new file mode 100644 index 00000000..39046636 --- /dev/null +++ b/.claude/rules/sheet-content.md @@ -0,0 +1,9 @@ +--- +paths: ["supabase/seed/anatomical-sheets/**"] +--- + +# Anatomical sheet content +- The findings catalog, the vertebral regions and the markers are the canonical sheet document; every content + change goes through `supabase/seed/anatomical-sheets/equine/curation/changes.json` (see the sheet model section) +- The curated draft is the reference content in development (`SHEET_BUNDLE=draft`); it is not medically + validated and a production build carries no sheet unless that flag is set on purpose diff --git a/.claude/rules/sheet-model.md b/.claude/rules/sheet-model.md new file mode 100644 index 00000000..0bcba0ae --- /dev/null +++ b/.claude/rules/sheet-model.md @@ -0,0 +1,17 @@ +--- +paths: ["crates/core/src/domain/sheet/**", "docs/development/ANATOMICAL_SHEET_MODEL.md", "supabase/seed/anatomical-sheets/**", "crates/core/src/bin/upload_sheet_assets/**"] +--- + +# 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 `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; + `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. diff --git a/.claude/rules/storage.md b/.claude/rules/storage.md new file mode 100644 index 00000000..355be6ac --- /dev/null +++ b/.claude/rules/storage.md @@ -0,0 +1,17 @@ +--- +paths: ["docs/development/STORAGE.md", "crates/worker/**", "supabase/migrations/**"] +--- + +# Files and Storage (migration 20261013100000, docs/development/STORAGE.md) +- `public.assets` is the authority over every user file: status, owner, keys, lease. Every write is an RPC; the browser + reads its own rows through an explicit column list (`select=*` is refused: lease columns are not granted). +- Object keys are server-built from uuids (`profiles///avatar.webp`, `quarantine///upload`); + policies on `storage.objects` compare whole strings through `assets` and pin one bucket literal each (census test). + A quarantine object is never readable by an API role; a final key is never writable by the browser. +- New buckets stay closed (row only, no policy) until their step writes the rules; `anatomical-sheet-assets` keeps its own policy. +- The worker holds the service key; the decode child has an empty environment, no file, no network, and is the only + process that decodes untrusted bytes. The parent checks the container header only. Rejections are closed codes. +- Deletions are row-driven: terminal rows enqueue their keys (48 h / 1 h grace), the sweeper serves the queue and the + quarantine leftovers; a clean row's object is never deleted. Backups: dump first, files within 48 h. +- 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). diff --git a/.claude/rules/stores.md b/.claude/rules/stores.md new file mode 100644 index 00000000..23bc8d2c --- /dev/null +++ b/.claude/rules/stores.md @@ -0,0 +1,9 @@ +--- +paths: ["apps/app/src/state/**"] +--- + +# Stores +- No direct store mutation outside Zustand actions +- No business logic in components — delegate to store actions +- sessionStorage keys: osteo:draft (auto-saved on every change, v3; a v2 draft is migrated and a stale draft rebased on restore once the sheet is loaded, by the core) and osteo:archive (the imported archive envelope, written only on import / new report / reset, never on edits); osteo:quarantine:{draft,archive} (an unreadable text set aside, a draft with its archive, an occupied slot never replaced, never dropped) and osteo:quarantine:draft-pre-rebase (the raw draft of a rebase that flagged items); a text whose set-aside fails is held in place (resolution panel, no new session over it), never removed or overwritten implicitly +- localStorage key: osteo:lastPractitioner (practitioner prefill cache) diff --git a/.gitignore b/.gitignore index fc5056b2..cd21f45e 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,4 @@ packages/core-wasm/pkg-proofs/ # DEV gateway credentials (generated by scripts/dev-gateway.sh) docker/dev-gateway/htpasswd docker/dev-gateway/mailpit-password +!.claude/rules/ diff --git a/CLAUDE.md b/CLAUDE.md index 44620711..1e4b83d1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -150,33 +150,6 @@ pnpm worker:image # Docker only: runtime image faunosteo_worker:dev (distro pnpm e2e:avatar # scripts/avatar-e2e.sh: worker container against the local stack + packages/supabase/tests/e2e (real-stack avatar flow) ``` -## Docker commands - -```bash -# Build image -docker build -t faunosteo . - -# Build an image that embeds the reference DRAFT sheet (preview only, never the default) -docker build --build-arg SHEET_BUNDLE=draft -t faunosteo . - -# Run with compose (reads .env for APP_* vars) -docker compose up --build - -# Stop -docker compose down -``` - -Naming convention: every Docker resource Faunosteo owns is prefixed `faunosteo_` -when the name is configurable (container `faunosteo_app`, Compose project -`faunosteo`); the Supabase CLI imposes `supabase__faunosteo`, documented -as a limit in DEPLOY.md "Docker resource naming". Never rename a resource that -holds data without keeping its volume. - -Note: no global pnpm needed. `corepack enable` once (reads `packageManager`), -or call `corepack pnpm `. Root scripts resolve `node_modules/.bin/pnpm`. - ---- - ## Test commands ```bash @@ -416,16 +389,6 @@ Database (Supabase) - Code: English (variable names, function names, comments, docs) - Never mix: no French variable names, no raw French/English string literals in JSX — use `useT()` -### i18n -- All user-facing strings live in `src/i18n/fr.ts` and `src/i18n/en.ts` (flat `Record`) -- Key convention: `.` — e.g. `common.cancel`, `home.new_report.title`, `pdf.subject` -- Both dicts must share the exact same key set; a key missing in one dict logs a warning in DEV -- Get the translate function in any component: `const t = useT()` then `t('common.cancel')` -- `src/state/localeStore.ts` holds current `Locale` (`'fr' | 'en'`), persisted to `localStorage` key `osteo:locale`; default: navigator-detected `fr`/`en`, or `'fr'` if no match; while signed in, `services/localeSync.ts` writes it to `profiles.locale` and applies the account locale on sign-in -- Form validation messages are i18n keys returned by the Zod schemas (`src/auth/validation.ts`, `src/account/validation.ts`), translated next to the field; GoTrue messages never reach the screen (`auth.failure.*`) -- Zone and finding names shown in the editor and the PDF come from the sheet document (`{ fr, en }` labels) and from the report's snapshots, not from the dict -- PDF static labels (section headings, metadata) live in `apps/app/src/pdf/labels.ts` (`defaultPdfLabels`, 25 keys, moved verbatim from the engine at R4.6) and are archived in the envelope; the app dicts hold no `pdf.*` key - ### Identity strings - NEVER hardcode APP_SITE_NAME, APP_BRAND_NAME, APP_FOOTER_NAME, APP_TAGLINE - Always read from ConfigProvider via useConfig() @@ -434,108 +397,6 @@ Database (Supabase) ### Design references - `docs/design/` holds the owner-validated mockups (Step 7 file = target for the whole SaaS shell: sidebar entries, dashboard tiles, Mon compte tabs, mobile tab bar). Any new screen follows them; elements they show that no step has built yet are listed in `docs/design/README.md` with their owning step. A redesign needs a new validated file there first. -### Annotation rendering -- docs/ANNOTATION-RENDERING.md is the source of truth: the drawing carries no annotation element, the markers are - 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` - and the annotation's fields (`laterality`, `vertebral_region_code`, `opens_view_id`) -- Marker look (radii, opacities, strokes) is renderer style; colours are document data (`color` on categories - and annotations); no graphic redesign without prior validation - -### 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` 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); - form values are plain assignments (D-R7) -- Report version 3: zones by `(annotationId, viewId)`, findings by `(findingZoneId, path)`, severities - `mild|moderate|severe`, `sheet` reference; v2 is migrated through `report-migration-map.json` - (`migrateReportV2ToV3`, never throws on content, `unresolved: true` marks what the sheet no longer holds); - v1 and unknown versions are refused with a typed error - -### Stores -- No direct store mutation outside Zustand actions -- No business logic in components — delegate to store actions -- sessionStorage keys: osteo:draft (auto-saved on every change, v3; a v2 draft is migrated and a stale draft rebased on restore once the sheet is loaded, by the core) and osteo:archive (the imported archive envelope, written only on import / new report / reset, never on edits); osteo:quarantine:{draft,archive} (an unreadable text set aside, a draft with its archive, an occupied slot never replaced, never dropped) and osteo:quarantine:draft-pre-rebase (the raw draft of a rebase that flagged items); a text whose set-aside fails is held in place (resolution panel, no new session over it), never removed or overwritten implicitly -- localStorage key: osteo:lastPractitioner (practitioner prefill cache) - -### PDF -- A4 portrait: 595.28 × 841.89 pt -- No raw URLs in PDF output — abbreviated citations only -- JSON attachment filename must start with osteo-report; content = report archive envelope v1 (report v3 + sheet snapshot + branding + labels); import accepts bare v2 (migrated), bare v3 and envelope v1; a bad snapshot never loses the report -- The writer (`crates/core/src/pdf/write`, since R4.6; the TypeScript engine deleted at R4.8) takes no clock and no I/O; rasterisation is the browser's, one raster per core request; every SVG it composes went through the core's one reader. The export is an incremental session (OD-2): the file is written as the rasters arrive, held once, handed out in parts; never accumulate rasters or build the file twice -- Page layout is frozen by the Step 6 goldens and the R4 oracles (O1 draw logs, O2 PDFs): any visible change needs a user decision and a golden regeneration; the R4 digests (`goldens/r4/pdf.*.sha256`) pin the writer's own bytes and are rewritten only for a declared structural change, with the O2 comparisons re-run -- Fonts are StandardFonts (Helvetica/TimesRoman, WinAnsi encoding) — TTF Inter/Fraunces planned but not yet embedded. Any non-Latin-1 glyph in PDF text must use an ASCII surrogate until the TTF migration lands (e.g. `(!)` instead of `⚠`). - -### Anatomical sheet content -- The findings catalog, the vertebral regions and the markers are the canonical sheet document; every content - change goes through `supabase/seed/anatomical-sheets/equine/curation/changes.json` (see the sheet model section) -- The curated draft is the reference content in development (`SHEET_BUNDLE=draft`); it is not medically - validated and a production build carries no sheet unless that flag is set on purpose - -### Database (Supabase) -- The auth session lives in the Supabase client (localStorage, PKCE); the app reads it through `state/authStore.ts` only. Profile columns the user may edit are the column grants in the profiles migrations; never widen them from the client. -- Platform roles (`platform_role`: owner/admin/moderator/support) are NOT professional - statuses (practitioner/student/professor come from verification, cabinet roles from - organization_members). Never add a professional status to `platform_role`. -- Every `public` table: RLS enabled, `revoke all` from API roles then exact grants, - separate policies per command, no `using (true)` for anon/authenticated (test-enforced). -- Writes that change privileges or sensitive state go through a security-definer RPC - that checks `auth.uid()` and calls `private.log_event()`. Never a direct table policy. -- Helpers in `private` are `security definer`, `set search_path = ''`, EXECUTE revoked - from public and granted only to the roles that evaluate them. -- A migration is never edited once applied. Each migration ships its pgTAP file with - allowed AND denied cases, and a regenerated `database.types.ts`. -- The browser holds the anon key only. The `service_role` key value never appears in env.js, .env.example or code; - operator scripts under `packages/*/scripts/` read it from the environment and are never bundled. -- pgTAP files run on PGlite and on the real image: scope counts to fixture ids, pin `collate "C"` on text ordering. - -### Environments and LAN access (docs/development/ENVIRONMENTS.md) -- The owner tests from other devices of the private network, never on the Ubuntu machine: every test surface - (app, Supabase API, Mailpit, Studio) is addressed by the DEV origin (`scripts/dev-env.sh`, `FAUNOSTEO_DEV_HOST`), - never by `127.0.0.1` / `localhost`, never hard-coded in a source (the automated browser suites are not a - surface for other devices: their dev servers and the sandbox stay on 127.0.0.1). The Supabase CLI runs only through - `scripts/supabase.sh` (`pnpm db:*`, `pnpm supabase`): config.toml reads the origin with `env()`. -- Exposure (least privilege, `pnpm dev:net-check`): LAN gets Vite 5173, the Supabase API 54321 and Mailpit - behind basic auth through the DEV gateway (`pnpm dev:gateway`, nginx, `faunosteo_dev_gateway`, 54325). The CLI - forces 0.0.0.0 on 54322 PostgreSQL, 54323 Studio, 54324 raw Mailpit: closed on the LAN interface by host UFW - rules (owner action, ENVIRONMENTS.md §3.2); SSH tunnel for Studio; the worker publishes no port. Nothing is exposed to the Internet; no production infrastructure - is touched from this repository. Rust is built natively; Docker runs services, the worker, sandbox tests and images. - -### Files and Storage (migration 20261013100000, docs/development/STORAGE.md) -- `public.assets` is the authority over every user file: status, owner, keys, lease. Every write is an RPC; the browser - reads its own rows through an explicit column list (`select=*` is refused: lease columns are not granted). -- Object keys are server-built from uuids (`profiles///avatar.webp`, `quarantine///upload`); - policies on `storage.objects` compare whole strings through `assets` and pin one bucket literal each (census test). - A quarantine object is never readable by an API role; a final key is never writable by the browser. -- New buckets stay closed (row only, no policy) until their step writes the rules; `anatomical-sheet-assets` keeps its own policy. -- The worker holds the service key; the decode child has an empty environment, no file, no network, and is the only - process that decodes untrusted bytes. The parent checks the container header only. Rejections are closed codes. -- Deletions are row-driven: terminal rows enqueue their keys (48 h / 1 h grace), the sweeper serves the queue and the - quarantine leftovers; a clean row's object is never deleted. Backups: dump first, files within 48 h. -- 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 (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 `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; - `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. - ### Component stubs - Scaffold stubs render
ComponentName placeholder
- Replace stub body entirely when implementing — no partial edits on stubs @@ -639,3 +500,7 @@ Examples: - `test(schema): cover Report version literal` - `feat(store): implement addObservation` - `feat(anatomy): parse data-anno-id from SVG` + +## Path-scoped rules +Project rules live in `.claude/rules/.md` and load on Read of a file +matching their `paths:` (never at session start): docker, i18n, annotation-rendering, schemas, stores, pdf, sheet-content, database, environments, storage, sheet-model.