diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 2bf556d1..59dbad20 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -524,3 +524,14 @@ Decision (owner go): `check_v3_shape` on raw value before `Report::deserialize`: ## BDR-070 | 2026-10-25 | D-R5.6 active: fingerprint `sha256-rfc8785-validated-v1`, registry alias, M1 option 1 Decision (owner, activation 9e87016): sheet fingerprint = SHA-256(JCS RFC 8785 of R2 typed reading, no integrity error, warnings allowed, depth 128). Equine canonical 12d78872…74e2; old 27c7383c…2660 = sole TRUSTED_ALIASES entry, bound to sheet 503dc301 + content. Alias honoured only via LoadedSheet::recognises_historical_stamp (loader-verified v1 private state + document recomputed at decision + one-way registry pair + same sheet id); equivalence pub(crate). M1 option 1: snapshot of old report keeps its stamp (build_sheet_snapshot); export, archive reader strict. v0 refs (no block) load unverified, no privilege; null/malformed block refused. Rust = sole seed writer, TS legacy until R5.7. Alternatives rejected: A file-bytes (Prettier-bound), C Prettier reproduction; re-stamp at rebase (rewrites reports); export-side alias (M1 defect, no proof). Status: active on feature branch; rollback not transparent for post-switch reports (rebased, nothing lost) → settle before user release. + +## BDR-071 | 2026-10-25 | Product roadmap principle validated: P0 → V1-1 → V1-2 → V1-3 → V1-4 → V1-5 + +Decision (owner, brief « P0 : arbitrages documentaires et finalisation du contrat V1-1 »): order P0 docs → V1-1 clients + animals → V1-2 sheets from Supabase → V1-3 cloud bilans + history → V1-4 stored PDF + authorised sharing → V1-5 mobile + a11y pass; a11y + security apply at every step (IMPLEMENTATION_PLAN §0). Release readiness track RR-1..RR-10 stays separate: no V1 step authorises release or public exposure. C4 (records owned by workspace, no global client directory), C5 (writes = workspace members with write right), C6 (email confirmation ≠ pro verification) = owner orientations, awaiting business ratification. V1-1 orientations D1-D9, D16 recorded as proposals in `V1-1_OWNERS_ANIMALS.md` §9.1; no table, RPC, RLS or component before ratification. Owner also confirmed: anatomical reference changes only via curation sources + Rust pipeline until Step 17, no graphic sheet editor, equine draft unpublished until business review, no auto publication; bilan annotations ≠ reference changes. +Alt: plan's numeric step order (verification, cabinets, entitlements before any client screen). +Status: principle active; C4/C5/C6 + V1-1 orientations pending ratification; P0 merge awaits owner go. + +## BDR-072 | 2026-10-25 | Correction of BDR-041: professional verification = plan Step 9, not Step 11 + +BDR-041 point (2) names Professional Verification "Step 11"; IMPLEMENTATION_PLAN numbers it Step 9 (Step 10 cabinets, Step 11 entitlement skeleton). Plan numbering kept. BDR-041 left as written (append-only); this entry supersedes its step number only, rest of BDR-041 unchanged. Docs cite Step 9: plan Step 7 note, V1-1 contract §5.2, OPEN_QUESTIONS C6. +Status: active. diff --git a/.claude/memory/evals.md b/.claude/memory/evals.md index 884b48d2..e559e1b8 100644 --- a/.claude/memory/evals.md +++ b/.claude/memory/evals.md @@ -241,3 +241,9 @@ Action: claim a guard per call site, not per design; owner decision on snapshot_ Method: ledger 407 TS cases case by case before `git rm`; fresh verifier + security (opus) twice; check:all on R5.7 state, then rerun on 27bf59c after post-check edits; verifier ran 14 scratch reintroduction probes against census. Anomalies: round 1 verifier ECARTS(2): contract C6 "tsx gone" false vs pnpm optional peer (owner Clarification), digest typo `…dfe7` in docs. Two edits landed after first check:all → owner required full rerun. Census regex accepted `#[ignore]` targets (fixed) and still accepts ignore-before-test (LOW). Docs pointed to premerge record before it existed; `.bin/tsx` wording root-only; SUPABASE.md layout stale since R2. `pnpm audit` never run before this round (cargo advisories only): 57 pre-existing. Action: LRN-078, LRN-079; rerun gate after any post-check edit; run `pnpm audit` in every pre-merge round; checkpoint to owner, STOP before merge. + +## EVAL-034 | 2026-10-25 | Functional inventory put form validation in Rust, against D-R7 + +Method: P0 doc census + V1-1 contract drafting; inventory `.claude/audits/2026-10-25-functional-inventory.md` cross-checked with RUST_ARCHITECTURE_REVIEW Annex A. +Anomaly: inventory criterion 4 placed validation rules (formats, lengths, required fields) in `crates/core` behind wasm facade. D-R7: form constraints stay TypeScript (Zod, i18n keys), SQL CHECK = integrity boundary, constants module + PGlite parity test against `pg_constraint`. Contradiction caught and corrected before V1-1 implementation contract; no code written on it. +Action: V1-1 contract §1 + §8.3 follow D-R7. Check every proposal against Annex A D-R rows before writing it. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 5606f624..3241d5af 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -388,3 +388,11 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp ## 2026-10-25 (product survey) - Owner closed R0-R5, asked read-only functional survey + roadmap. 4 parallel analyzers. Inventory `.claude/audits/2026-10-25-functional-inventory.md`; release readiness track RR-1..RR-10 in TODO. - Finding: local tool and /app not linked; no client/animal/report tables; plan text drifted (step numbers, Node worker, Step 13 "published"). Proposed V1-1 owners + animals first, needs C4/C5/C6. STOP, no branch, no code. + +## 2026-10-25 (P0 + V1-1 contract) +- Owner validated roadmap P0, V1-1..V1-5; C4/C5/C6 = hypotheses. Census agent: ~100 stale doc sites. P0 edits in working tree (plan §0 + Steps 13/15/17/19-26, BACKEND_ARCH D-R9, DOMAIN_MAP roles, OPEN_QUESTIONS status table, snapshot notices, design owners, README DEV origin). `gitflow start chore/p0-doc-realignment` refused by permission layer → uncommitted on develop. +- V1-1 contract `docs/development/V1-1_OWNERS_ANIMALS.md`: workspace model, clients + animals + link roles, RPC writes, archive only, 17 decisions. Inventory criterion 4 (validation in core) contradicted D-R7, withdrawn. STOP before migration. + +## 2026-10-25 (P0 arbitration, branch chore/p0-doc-realignment) +- Owner created `chore/p0-doc-realignment` off develop by hand, P0 edits carried over; finalised on it. Owner orientations D1-D9, D16, C4-C6 into V1-1 contract as proposals (§9.1), sub-choices D4a/D6a/D6b/D7a/D9a, open D10-D15/D17. Contract fixes vs brief: no owner required on animal (was last-owner rule), birth year + optional date (was date + precision), display name sole required client field, staff access = no mechanism (was impersonation pointer). +- README split public 0.1.0 / develop / DEV-only / planned; CHANGELOG Unreleased note; DEPLOY status notice + CSP "not production-ready" markers (RR-5 keeps fixes). BDR-071, BDR-072 (BDR-041 step fix), EVAL-034. nginx `/species/` = code debt, untouched. No migration, code, manifest. STOP at checkpoint, merge on owner go. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 436e21ab..f54b4f62 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -125,7 +125,7 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [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) + - [ ] 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 9, BDR-072); 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 @@ -367,6 +367,21 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [ ] 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. --- +## Product roadmap V1 (owner 2026-10-25 « Validation de l'inventaire et cadrage P0 / V1-1 ») +Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheets served from Supabase → V1-3 cloud bilans + history → V1-4 stored PDF + authorised sharing → V1-5 cross-cutting mobile + a11y pass (a11y and security apply at every step). C4/C5/C6 and the V1-1 orientations (owner brief « P0 : arbitrages documentaires et finalisation du contrat V1-1 ») = proposed, awaiting ratification. No migration, component, API or table before the owner ratifies the V1-1 contract; no merge into main, no release/0.2.0 change, no deploy, no Supabase DEV change; equine draft stays unpublished. +- [ ] P0 docs realignment (docs only; branch `chore/p0-doc-realignment` created by the owner off develop, the working-tree edits carried over; merge into develop on the owner's go only) + - [x] census of stale text in active docs (worker Node / Edge Functions, step numbers, roles, Step 13 "published", deleted tools, OPEN_QUESTIONS statuses) + - [x] IMPLEMENTATION_PLAN: roadmap V1 section, step statuses, D-R9 in Steps 8/15/19/21/23/24/26, Step 13 DoD draft-only, deleted tools, Step 22 D-R8 + - [x] BACKEND_ARCHITECTURE §1/§5/§6/§7/§9, DOMAIN_MAP §1/§6/§7/§12/§18, design README owners, snapshot notices (FRONTEND_ARCHITECTURE, MIGRATION_STRATEGY, REPOSITORY_MIGRATION_MAP, TEST_STRATEGY), PDF_IMPORT_HARDENING step numbers, README DEV origin, CLAUDE.md roadmap line + - [x] OPEN_QUESTIONS: status per item with the deciding BDR / D-R, C4/C5/C6 owner hypotheses, real conflicts listed for arbitration + - [x] owner arbitration 2026-10-25: README separates public 0.1.0 / develop / DEV-only / planned; CHANGELOG Unreleased note (nothing deployed, 0.2.0 section on its branch); DEPLOY status notice (historical, unverified, would-break, security prerequisites) + CSP examples marked not production-ready (fixes stay RR-5); OPEN_QUESTIONS conflicts 1-4 resolved (curation-only path until Step 17 confirmed); BDR-071, BDR-072 (BDR-041 step number), EVAL-034 + - [x] commit on the branch, push + - [ ] merge into develop on the owner's go +- [x] V1-1 functional contract `docs/development/V1-1_OWNERS_ANIMALS.md` (no code); correction: inventory criterion 4 (validation in crates/core) contradicted D-R7 → form constraints TS + SQL CHECK + parity test (EVAL-034) + - [x] owner orientations D1-D9, D16, C4-C6 integrated as proposals (§9.1, SQL / permission impact marked); sub-choices D4a, D6a, D6b, D7a, D9a (§9.2); D10-D15, D17 kept open (§9.3); legal basis, client information, retention framed before public exposure (§9.4) + - [ ] owner ratification of §9.1, answers to §9.2 and D15 → first migration on a `feature/` branch +- [ ] Code debt (not P0, no change on the doc branch): `docker/nginx.conf` still has `location /species/` (public/species deleted at Step 5); remove with its own `chore/` or `bugfix/` branch + ## Release readiness track (owner 2026-10-25, distinct from the functional roadmap; nothing here authorises a release or exposure) Inventory: `.claude/audits/2026-10-25-functional-inventory.md`. Each item: treat or qualify before any release or public exposure; not fixed now unless an active critical flaw is shown. - [ ] RR-1 npm advisories (57, pre-existing; published severity kept apart from Faunosteo exposure). Zod 3.25.76 GHSA-mrhx-c7xc-m3w5 first: Zod parses only forms, the practitioner cache and one RPC result, no collection schema found; untrusted files go through the Rust core caps (PDF 50 MiB / 16 MiB attachment, depth 64, 400k values; sessionStorage value budget). Plan zod 4 as its own chore; drop zod from core-wasm `dependencies` if only its tests use it diff --git a/CHANGELOG.md b/CHANGELOG.md index c023545f..d615e6e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ Versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +Nothing in this section is released or deployed: faunosteo.com runs 0.1.0. +Everything below is on `develop` only, accumulated since 0.1.0: the SaaS +Steps 0 to 8 and the Rust migration R0 to R5 included. `release/0.2.0` (Steps +3 to 6) was cut on 2026-10-11 and never finished; its `[0.2.0]` section lives +on that branch and reaches this file only if the release is finished (TODO +RR-9). + ### 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`). diff --git a/CLAUDE.md b/CLAUDE.md index 3900c68e..4c137f25 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,6 +46,10 @@ importer, curation, migration map, review files, seed SQL, upload tool) into the 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. +Product roadmap (owner, 2026-10-25): P0 docs, then V1-1 clients and animals, V1-2 sheets from Supabase, +V1-3 cloud bilans, V1-4 stored PDF and sharing, V1-5 mobile and accessibility pass +(`docs/development/IMPLEMENTATION_PLAN.md` §0; V1-1 contract `docs/development/V1-1_OWNERS_ANIMALS.md`: +owner orientations proposed, awaiting ratification; nothing built). --- diff --git a/DEPLOY.md b/DEPLOY.md index cee17275..223269e9 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -1,5 +1,56 @@ # Deploy +## Status of this guide (2026-10-25) + +This guide was written for the static deployment of 0.1.0, the version +faunosteo.com runs, and is kept as that record. It is not a procedure for +`develop`: nothing authorises deploying it (release readiness track, TODO +RR-1 to RR-10). The corrections this file needs are TODO RR-5. + +Historical, true for 0.1.0 and wrong for an image with a backend: the +introduction below ("no backend, no database"), "Data persistence", +"Backups", "Backend CORS", "Frontend API base URL", the rollback's "no +server-side state", and the troubleshooting entries "CORS rejected in +browser" and "volume / data unexpectedly empty". + +Not verified for the current code: + +- the loopback claim: `docker-compose.yml` publishes `${PORT:-8080}` on every + interface, and rootful Docker bypasses UFW; +- "First-time VPS setup", "Routine deploys" and "Rollback" build the image on + the VPS; an image from R2 on compiles the Rust core and is never built there + (see "Image deploy by digest"); +- the fallback that serves `apps/app/dist/` from a plain `nginx:alpine` drops + `docker/nginx.conf` (the `env.js` no-cache rule, the `.wasm.gz` served with + `gzip_static`); +- the VPS sizing table, written before the Rust build stages. + +Would break the current application if applied as written: + +- the two CSP examples (Option A nginx, Option B Caddy), marked below as not + production-ready: without `'wasm-unsafe-eval'` the editor, the export and + the import cannot load the Rust core; without the Supabase origin in + `connect-src` (it falls back to `default-src 'self'`), sign-in and the + `/app` space fail unless Supabase is served from the same origin; +- a default build (`SHEET_BUNDLE=none`): no anatomical sheet, the editor + refuses to create or import a report. + +Security prerequisites before deploying anything built from `develop`: + +- the CSP of "WebAssembly and the CSP" with `connect-src` naming the Supabase + origin, checked on the image (`docker/csp-proof/app-image.sh`); +- the container port bound to loopback in fact, checked from outside the VPS; +- a hosting decision for Supabase (`docs/development/OPEN_QUESTIONS.md` Q2), + production SMTP with French auth email templates, captcha, OAuth ids, MFA + for platform roles (RR-3, RR-5); +- the worker's service key out of `.env`, its exposure to the `docker` group + settled (RR-4); +- images built off the VPS and pulled by digest, base images pinned (RR-6); +- the RLS and API items of RR-3 and RR-4 and the dependency advisories of + RR-1 treated or qualified. + +--- + Single nginx:alpine container behind a host reverse proxy that terminates TLS. The container serves a static SPA bundle (built from `apps/app`, Node 24, pnpm 10.13.1) from `/usr/share/nginx/html` @@ -298,6 +349,10 @@ previous image, never a rebuild of the old engine. ## Data persistence +Historical (0.1.0, no backend): once Supabase or the worker run beside the +application, the database and the Storage objects are server-side state that +this section and the next do not cover. + There are no server-side volumes to back up: - **In-flight session data** lives in the praticien's browser @@ -314,6 +369,10 @@ regenerated on every build. ## Backups (cron + retention) +Historical (0.1.0): the `.env` snapshot below is the whole backup only while +the server holds no data; `docs/development/STORAGE.md` §5.2 sets the order +for a backend (database dump first, files within 48 h). + Because there is no server-side state, the backup target is the source repository plus the `.env` file. @@ -430,6 +489,11 @@ systemctl status certbot.timer # auto-renew preinstalled on Ubuntu #### Security headers (Option A only) +Not production-ready (2026-10-25): the `Content-Security-Policy` line below is +the 0.1.0 header. It lacks `'wasm-unsafe-eval'` and the Supabase origin in +`connect-src`; any later image needs "WebAssembly and the CSP" below first +(correction tracked as TODO RR-5). + Add inside the `listen 443` block (under any existing `location` rules the certbot template inserted): @@ -460,6 +524,9 @@ the PDF preview emits data URLs. ### Option B — Caddy (auto-TLS, single file) +Not production-ready (2026-10-25): the `Content-Security-Policy` of this +Caddyfile is the 0.1.0 header, with the same gaps as Option A (TODO RR-5). + ```bash apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf https://dl.cloudsmith.io/public/caddy/stable/gpg.key | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg @@ -489,6 +556,9 @@ Caddy handles TLS issuance + renewal automatically. ### Backend CORS +Historical (0.1.0): since Step 7 the browser calls the Supabase API, a +cross-origin request unless Supabase is served from the same origin. + N/A. The app has no backend and makes no cross-origin requests. The only runtime fetches target the same origin (SVG assets, `env.js`). diff --git a/README.md b/README.md index d9106969..edd3c01c 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,52 @@ 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. -Open to every praticien who wants to use it. No authentication, no backend, -no central server in v1 — the PDF is the long-term record. Phase 2 will add -optional praticien accounts + server-side persistence on the same data -contract. +--- + +## Versions: what is public, what is in development + +| Where | What it is | +| ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Public, on faunosteo.com: **0.1.0** (2026-05-21) | The local tool alone, open to every praticien: a static application with no account, no backend and no central server. The exported PDF is the long-term record. | +| `develop` (not released, not deployed) | The local tool on the canonical anatomical sheet and Report v3, the PDF archive envelope, the Rust migration R0 to R5 (domain rules, SVG reader, PDF reader and writer, curation pipeline and files worker in `crates/`), and the SaaS foundations: Supabase schema under RLS, accounts, the `/app` space, the profile photo. | +| `release/0.2.0` | Cut on 2026-10-11 from plan Steps 3 to 6, never finished or deployed; its fate is TODO RR-9. | + +Available only in a development environment (they need the local Supabase +stack, `pnpm db:start`, and for the photo the worker container; no production +Supabase exists and hosting is undecided, `docs/development/OPEN_QUESTIONS.md` +Q2): + +- sign-up with email confirmation, sign-in, password recovery, OAuth buttons + behind configuration; +- the `/app` space: dashboard and Mon compte (personal, professional, + preferences, security sections); +- the profile photo, processed by the Rust worker; +- the curated equine sheet DRAFT in the editor, bundled only with + `SHEET_BUNDLE=draft` (`pnpm dev`, `pnpm build:preview`): not medically + validated, not published; a default build carries no sheet; +- the anatomical pipeline and archive tools (`pnpm import:equine`, + `pnpm assets:upload`, `pnpm report:compare`). + +Planned, not implemented (roadmap in +`docs/development/IMPLEMENTATION_PLAN.md` §0): V1-1 clients and animals (its +contract awaits the owner's ratification), V1-2 sheets served from Supabase, +V1-3 bilans stored in the cloud with history, V1-4 stored PDFs and authorised +sharing, V1-5 mobile and accessibility pass; then professional verification, +cabinets, entitlements, agenda, public site and the rest of the plan. Nothing +on `develop` authorises a release: the release readiness track (TODO RR-1 to +RR-10) comes first. --- ## Features +The local tool as it stands on `develop`. The public 0.1.0 has the canvas, +the detail view, the vertebra picker, the findings tree, PDF export and +re-import (report v2), the bilingual UI, the configurable identity and the +practitioner cache; laterality, the footer branding, Report v3 with the v2 +migration, the sheet document and the rescue copy came after it (CHANGELOG +`Unreleased`). + - **Anatomy canvas** — inline SVG drawing with markers rendered from the sheet document (hitbox + visible twin, delegated click listener) - **Observation builder** — group zones into clinical observations with severity and free-text notes - **Hierarchical findings tree** — per-zone picker with breadcrumb drill-down through the expert-authored catalog (26 zones for the horse), vet-referral badges on sensitive leaves, scope-disclaimer modal once per session @@ -61,13 +98,13 @@ corepack enable pnpm install cp .env.example .env # edit APP_* vars if desired -pnpm dev # http://localhost:5173 +pnpm dev # http://:5173 (the DEV origin, never localhost) ``` Development server on the private network (the DEV origin is the machine's LAN address, `scripts/dev-env.sh`): `pnpm db:start`, then `pnpm dev` and open `http://:5173` from any device of the network; Mailpit for the -sign-up mails on `:54324` (`docs/development/ENVIRONMENTS.md`). +sign-up mails through the DEV gateway on `:54325` behind basic auth, `pnpm dev:gateway` (`docs/development/ENVIRONMENTS.md`). Rust (core, browser module, worker): a user-level `rustup` installs the pinned toolchain from `rust-toolchain.toml` on first use; see @@ -114,7 +151,7 @@ docker build -t faunosteo . # multi-stage Docker image docker compose up --build # run with env_file: .env ``` -For production deployment (VPS provisioning, firewall, TLS, nginx reverse proxy, backups, hardening) — see [DEPLOY.md](DEPLOY.md). +For production deployment (VPS provisioning, firewall, TLS, nginx reverse proxy, backups, hardening) — see [DEPLOY.md](DEPLOY.md). It describes the static 0.1.0 deployment; read its status notice before deploying anything built from `develop`. --- @@ -128,9 +165,10 @@ For production deployment (VPS provisioning, firewall, TLS, nginx reverse proxy, - [docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md](docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md) — why and how the PDF became an autonomous archive (Step 6) - [docs/development/PDF_IMPORT_HARDENING.md](docs/development/PDF_IMPORT_HARDENING.md) — PDF import against decompression bombs: what lands now, what is required before external users - [docs/development/SUPABASE.md](docs/development/SUPABASE.md) — local Supabase stack, migrations, RLS tests, generated types -- [DEPLOY.md](DEPLOY.md) — production VPS deploy guide (Docker + nginx + TLS + hardening) +- [docs/development/IMPLEMENTATION_PLAN.md](docs/development/IMPLEMENTATION_PLAN.md) — SaaS plan; §0 holds the product roadmap and where each step stands +- [DEPLOY.md](DEPLOY.md) — production VPS deploy guide (Docker + nginx + TLS + hardening), written for the static 0.1.0 - [CHANGELOG.md](CHANGELOG.md) — versioned release notes -- [.claude/tasks/TODO.md](.claude/tasks/TODO.md) — implementation roadmap +- [.claude/tasks/TODO.md](.claude/tasks/TODO.md) — task list and release readiness track --- @@ -165,12 +203,9 @@ faunosteo/ pnpm workspace (see docs/development/WORKSPACE.md) ## Status -v0.1.0 MVP — implementation complete. - -- `pnpm typecheck` ✅ -- `pnpm lint` ✅ -- `pnpm test:run` ✅ — the vitest suites of the workspace (core-wasm, supabase, app); `pnpm rust:check` runs the Rust ones -- `pnpm build` ✅ +Public: 0.1.0 (2026-05-21), the local tool with no backend. `develop`: plan +Steps 0 to 8 and the Rust migration R0 to R5, merged, not released. The merge +gate is `pnpm check:all` (see "Verifying a change"); no CI runs on the forge. The first species ships as the equine anatomical sheet: the historical `Horse.svg`, `Horse_head.svg` and findings catalog (26 zones, 792 nodes) diff --git a/docs/design/README.md b/docs/design/README.md index 51869928..1cce98d6 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -30,7 +30,10 @@ step has built yet, with the step that owns them: | Element | Owner | |---|---| -| Bilans, Clients, Animaux, Agenda, Fiches anatomiques entries and screens | Steps 9 to 16 (clients/animals, cloud reports, agenda) | +| Clients and Animaux entries and screens | roadmap V1-1 (plan Step 12 reduced, `docs/development/V1-1_OWNERS_ANIMALS.md`) | +| Fiches anatomiques entry and screen | roadmap V1-2 (plan Step 13 reduced) | +| Bilans entry and screens | roadmap V1-3 (plan Step 14) | +| Agenda entry and screens | plan Step 20 | | Stat tiles (bilans créés, clients, animaux, rendez-vous) and "Derniers bilans" | once the reports and agenda tables exist; never invented numbers | | Notification bell | notifications step | | Avatar photo and "Modifier la photo" | built in Step 8 (2026-10-13): circle + "Modifier la photo" in Informations personnelles, photo in the sidebar / drawer badge and in the top bar with the name on desktop (link to Mon compte, no dropdown) | diff --git a/docs/development/ANATOMICAL_SHEET_MODEL.md b/docs/development/ANATOMICAL_SHEET_MODEL.md index 00930217..8dcc4730 100644 --- a/docs/development/ANATOMICAL_SHEET_MODEL.md +++ b/docs/development/ANATOMICAL_SHEET_MODEL.md @@ -298,7 +298,7 @@ the decision lands; only the naming one is implemented in this document. | 3 | A new publication becomes the current version; older versions are **not deprecated automatically** and stay readable under the access rules. | Already the behaviour of `publish_sheet_version`; deprecation stays a manual act. | | 4 | Official sheets are **platform-owned**, administered by authorised accounts. | Already the model: `creator_user_id = null`, `is_official = true`, platform admins edit. | | 5 | Name anatomical findings apart from the observations typed during a report. | Finding category kind `observation` renamed **`consultation_reason`** (`dysfunction` / `consultation_reason` / `anamnesis` / `custom`). The report-side object keeps the name Observation. | -| 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. | +| 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 (the Rust core's `sheet.check` since R2) moves server-side before community publication: plpgsql shape rules or a Rust service gate (Edge Functions retired, D-R9), 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. | ## 6. Official equine sheet: import (Step 4b) and curation (Step 4c) diff --git a/docs/development/BACKEND_ARCHITECTURE.md b/docs/development/BACKEND_ARCHITECTURE.md index e14d931a..8f581756 100644 --- a/docs/development/BACKEND_ARCHITECTURE.md +++ b/docs/development/BACKEND_ARCHITECTURE.md @@ -3,25 +3,32 @@ Status: Step 0 deliverable, 2026-10-08. Conceptual only. No migration, table, policy or function is created by this document. Table and function names follow `faunosteo-business-architecture.md` §4–§20. +Revised 2026-10-25 (P0): Edge Functions retired (D-R9, BDR-045), worker = +`crates/worker` in Rust, data contracts in `crates/core` (R2), bucket list and +signed-URL rule as built at Step 8 (`STORAGE.md`). Hosting stays open +(`OPEN_QUESTIONS.md` Q2). ## 1. Components and what runs where ```text -Browser (apps/app, anon key + user JWT) - │ tables via RLS, RPC (security definer), Storage signed URLs +Browser (apps/app, anon key + user JWT, Rust core as WebAssembly) + │ tables via RLS, RPC (security definer), Storage under storage.objects policies ▼ -Supabase (self-hosted on Scaleway at launch, §31) - ├─ Auth (GoTrue): email/password, Google, Apple, OTP, phone +Supabase (self-hosted on Scaleway at launch, §31; hosting open, Q2) + ├─ Auth (GoTrue): email/password, OAuth providers (Google, Apple), OTP, phone; keeps the OAuth flows (D-R9) ├─ PostgreSQL: schemas public / private / audit, RLS, functions, pg_cron - ├─ Storage: private buckets, storage.objects policies - ├─ Edge Functions (Deno): public endpoints, webhooks, signed-URL issuance - └─ Realtime (optional): report sync state -Worker (apps/worker, service key, same host) - └─ jobs table in PostgreSQL, no Redis -public-web (anon key, SSR) + └─ Storage: private buckets, storage.objects policies evaluated on public.assets +Rust worker (crates/worker, container faunosteo_worker, service key, same host) + └─ jobs claimed from PostgreSQL through RPCs (lease token), no Redis; decode child sandboxed +Rust HTTP services (same image, other subcommands, own secrets; from the first inbound need) + └─ webhooks (Stripe), OAuth callbacks of external calendars, public endpoints that SQL cannot serve +public-web (Astro, D-R8; anon key) └─ public views / RPCs only ``` +Edge Functions are not used (D-R9): limits on the self-hosted edge runtime, hand +deployment, and one Rust runtime for every server process. + The browser never holds a service-role key, admin credential, storage master key or third-party refresh token (§17.1). @@ -33,8 +40,8 @@ key or third-party refresh token (§17.1). | Google, Apple | GoTrue OAuth providers | Apple requires a paid developer account and a services id: dependency to confirm | | Phone verification | GoTrue phone OTP needs an SMS provider (Twilio, MessageBird, Vonage) | cost and EU processing to confirm; see `OPEN_QUESTIONS.md` Q7 | | Email verification | GoTrue, mandatory before professional features | | -| MFA | GoTrue TOTP; mandatory for owner/admin/moderator/support roles, enforced by RLS helper `has_mfa()` on admin tables | | -| Roles | `profile_roles` table, never JWT custom claims as the only source (claims can lag) | helpers read the table | +| MFA | GoTrue TOTP; mandatory for owner/admin/moderator/support roles, enforced by RLS helper `has_mfa()` on admin tables | TOTP enabled server-side; `has_mfa()`, enrolment and enforcement not built (`IDENTITY.md` §4, TODO RR-3) | +| Roles | `profile_roles` table with the `platform_role` enum (owner, admin, moderator, support: BDR-026), never JWT custom claims as the only source (claims can lag) | helpers read the table; professional statuses (practitioner, student, professor) come from verification, cabinet roles from membership, never from this enum | | Impersonation | dedicated RPC issuing a short-lived scoped session, audited, banner in UI (§17.5) | after MVP core | `profiles.id = auth.users.id`, created by a trigger on `auth.users` insert. @@ -51,7 +58,7 @@ Conventions fixed now so every step follows them: - UUID primary keys (`gen_random_uuid()`), `created_at` / `updated_at` with a shared trigger, soft delete `deleted_at` where the architecture names it. - Enums as PostgreSQL `enum` types when the value set is closed by the business (report status, appointment status), `text` + CHECK when the set is expected to grow (document types). -- JSONB documents (`reports.current_document`, `anatomical_sheet_versions.content_jsonb`) carry their own `schema_version` and are validated by the matching Zod schema at the application boundary and by a CHECK on `schema_version` in SQL. SQL does not re-implement Zod. +- JSONB documents (`reports.current_document`, `anatomical_sheet_versions.content`) carry their own `schema_version` and are validated by the Rust core's contracts (`crates/core/src/domain`, since R2) at the application boundary and by a CHECK on `schema_version` in SQL. SQL re-checks only what publication needs (`private.sheet_document_issues`, BDR-032), with the same rule codes as the core. - Every table exposed to the browser: RLS enabled, no `USING (true)` policy for `authenticated`, no anonymous policy on core tables (§17.4). ## 4. RLS strategy @@ -102,40 +109,42 @@ EXECUTE on those functions and nothing else. ## 5. Storage -Buckets, all private: `avatars`, `logos`, `professional-documents`, -`client-files`, `animal-files`, `report-files`, `anatomical-sheets`, `imports`. +Buckets, all private, as built (`STORAGE.md`): `avatars` (the only one with +policies), `logos`, `professional-documents`, `client-files`, `animal-files`, +`report-files`, `imports` (closed until their step writes the rules), and +`anatomical-sheet-assets` (sheet drawings, its own policy). -Object key: `///`. The -`assets` table is authoritative; `storage.objects` policies call the owning -helper (`can_view_report` for `report-files/...`). Reads go through signed -URLs issued by an RPC/Edge Function after the same check. +Object keys are built by the server from uuids +(`profiles///avatar.webp`, `quarantine///upload`). The +`assets` table is authoritative; `storage.objects` policies compare whole keys +through `assets`. Owner-only files are downloaded under the SELECT policy with +no signed URL (BDR-048); a shared kind may use a short-lived signed URL issued +by the Storage API after the same policy. There is no `issue_signed_url` RPC. -SVG pipeline (§15.3): upload lands in a quarantine prefix with -`assets.sanitization_status = pending`; a server sanitizer (Edge Function or -worker) rewrites the file (strip `