diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 3ddf93e4..e3582897 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -288,3 +288,11 @@ User validated Step 4 and ruled: (1) public read by visibility, USE of a communi Scope guard from user: implement along the planned steps, keep 4b (equine import) free of community/account features. Status: closed (recorded in ANATOMICAL_SHEET_MODEL.md §5). + +--- + +## BDR-034 | 2026-10-09 | Equine import = generated seed, draft only; assets content-addressed in a private bucket read through the sheet + +Importer (packages/anatomy, one-off, deterministic) emits supabase/seed/anatomical-sheets/equine/v1: document.json, legacy-id-map.json, assets.json + SVG copies, IMPORT-REPORT.md (FR, for the osteopath), equine_v1.sql (idempotent: official platform-owned sheet `faunosteo-cheval` private + 2 asset rows + draft v1 via `private.insert_sheet_draft(null,…)`). Golden test = committed artifacts equal a fresh run. Ids: annotation = catalog zone key on exact FR+EN match (26/26), views main/head, trigger head-trigger, asset/sheet uuids derived from sha256 (uuid v5-like). No medical correction: ssb-dysfunctions kept + anomaly; only degraded slugs normalised and declared; 12 anomalies to validate, 6 informative. Seed listed in config sql_paths (every env) and applied by the PGlite harness (`seed/**`, never seed.sql). Storage: bucket anatomical-sheet-assets private, `.svg`, SELECT policy via `private.can_read_sheet_asset_object` (published reference of usable sheet, or editor), no API writes, operator upload script with service key from env. +Alt rejected: data migration for the sheet (immutable file for a draft meant to be edited); TS seeding via PostgREST (needs service key in a committed path); fuzzy zoneMatch at import (26/26 exact, strict equality + report suffices). +Status: closed; publication of v1 = explicit user decision after report review. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 2bbaf8cf..f617cf0d 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -180,3 +180,8 @@ Step 3 Supabase foundation on feature/step-03-supabase-foundation (9 commits, pu - Step 3 validated by user (session 4). chore/supabase-cli-gitignore finished into develop. Step 4 (sheet model) started on feature/step-04-anatomical-sheet-model. - Step 4 (session 4): spec docs/development/ANATOMICAL_SHEET_MODEL.md; packages/domain (Zod doc strict, 17 integrity rules, 60 tests, opus executor); migration 20261008110000 (species, sheets, immutable versions, assets, 11 RPCs, RLS) + pgTAP 005 (95 checks); types regenerated on real stack (Docker now OK), pgTAP 176/176 real + PGlite; publishSheetVersion gate; docs synced. 5 commits on feature/step-04-anatomical-sheet-model. BDR-030/031/032, LRN-038/039. Verifier + security gates dispatched. Next: user validation, Step 4b importer → equine draft. - Gates: verifier ECARTS(5) + security BLOCK(1) on first pass (private EXECUTE never revoked = BLK-007, foundation flaw). Fixed: hardening migration 20261008110100, explicit revokes + pgTAP census, set_sheet_visibility RPC, no direct draft DELETE, caps, authz-first, counter, asset copy scoped, SQL check split, url http(s) only. Real stack 210/210, root check green. Fresh verifier re-dispatched on the delta. + +## 2026-10-09 + +Step 4 validated + finished into develop. User decisions on the 7 open points → BDR-033 (follow-gated use, verified publication, no auto-deprecation, platform-owned official, kind rename, server validation, erasure path). Step 4b on feature/step-04b-equine-import: packages/anatomy importer (opus executor, 25 tests) → seed equine v1 as DRAFT (27 ann / 26 linked / 792 nodes / 612 leaves / 41 vet, 0 integrity issues, 18 anomalies reported, ssb-dysfunctions flagged); Storage migration + policy through the sheet, shim storage tables, harness applies seed/**, pgTAP 006/007 (238/238 real stack), assets uploaded + REST/Storage checks (owner 200, alice/anon 400). BDR-034, LRN-041. Gates dispatched; stop for user validation before Step 5. + diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index fa8a9756..6c646fdd 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -309,3 +309,10 @@ Apply: any pgTAP file with fixtures read while impersonating; any ordered result `alter default privileges in schema X revoke execute on functions from public` does nothing (BLK-007). Pattern: every migration ends with `revoke all on function private.f(args) from public` per function + explicit grants; a pgTAP census (`has_function_privilege('anon'|'authenticated', p.oid, 'execute')` over pg_proc of private/audit, compared to an allowlist via `string_agg(... order by proname::text collate "C")`) fails the next omission. `results_eq` over `name`-typed columns vs text literals raises "could not determine which collation" on PGlite → compare one aggregated string. Trigger functions that call other private functions must be `security definer` once EXECUTE is revoked (the invoking API role no longer holds it). Apply: every Supabase migration; the census is the backstop. + +--- + +## LRN-041 | 2026-10-09 | Real Supabase image vs PGlite shim: storage triggers, pnpm script cwd + +Real `storage.objects` carries `storage.protect_delete` (statement trigger: "Direct deletion from storage tables is not allowed") → a pgTAP that runs DELETE as an API role passes on the shim and aborts the whole file on the real stack; assert write restrictions through a `pg_policies` census instead. Shim stays minimal (buckets/objects columns actually touched). `pnpm --filter pkg script ` runs inside the package dir → resolve CLI paths from `process.env.INIT_CWD`. Node 24 strip-types cannot follow workspace directory imports (`ERR_UNSUPPORTED_DIR_IMPORT`) → tsx for CLIs that import workspace packages. +Apply: every pgTAP touching storage.*; every workspace CLI. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 8828bc4a..3687c1fe 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -70,12 +70,12 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [x] 4.5 docs: SUPABASE.md layout/tests, CLAUDE.md folder map + conventions + scopes, packages/README, IMPLEMENTATION_PLAN Step 4 adjustment note, CHANGELOG - [x] 4.6 verify: pnpm check green (61+17+278), db:reset + db:test 210/210 real stack, types in sync; verifier ECARTS(5) + security BLOCK(1) → all fixed (BLK-007 hardening migration, visibility RPC, +32 pgTAP, doc sync); BDR-030..032, LRN-038..040, EVAL-008 - [ ] Step 4b — equine import (2026-10-09, branch feature/step-04b-equine-import): legacy SVGs + catalog → official equine sheet as DRAFT, import report for business review, no publication - - [ ] 4b.0 kind rename observation→consultation_reason (BDR-033 #5); decisions in spec §5 + memory - - [ ] 4b.1 packages/anatomy: legacy importer (SVG walker via @xmldom/xmldom, catalog mapper, deterministic ids, legacy-id-map, import report with anomalies incl. ssb-dysfunctions), CLI `pnpm import:equine` writing supabase/seed/anatomical-sheets/equine/v1/{document.json,legacy-id-map.json,IMPORT-REPORT.md,assets/,equine_v1.sql}; tests: counts preserved (27 ann / 26 mapped / 792 nodes / 612 leaves / 41 vet), determinism, Zod + 0 integrity errors, golden artifacts - - [ ] 4b.2 migration 20261009100000 sheet asset storage: bucket anatomical-sheet-assets (private), object read policy through the sheet (published refs or editor), no API writes; shim storage tables; pgTAP - - [ ] 4b.3 seed: equine_v1.sql idempotent (platform-owned official sheet, private, draft v1, 2 asset rows, fixed ids) in config sql_paths + PGlite harness applies supabase/seed/**; pgTAP 006: draft present, not publishable by non-admin, sheet_document_issues empty, assets match; upload script for the SVG bytes (service key from env, user/operator runs) - - [ ] 4b.4 real stack: db reset + db test + types check + assets upload + REST read check; docs (SUPABASE.md, ANATOMICAL_SHEET_MODEL.md §6 import, CLAUDE.md, plan note, CHANGELOG) - - [ ] 4b.5 verify: pnpm check, verifier + security gates, capitalize + - [x] 4b.0 kind rename observation→consultation_reason (BDR-033 #5); decisions in spec §5 + memory + - [x] 4b.1 packages/anatomy: legacy importer (SVG walker via @xmldom/xmldom, catalog mapper, deterministic ids, legacy-id-map, import report with anomalies incl. ssb-dysfunctions), CLI `pnpm import:equine` writing supabase/seed/anatomical-sheets/equine/v1/{document.json,legacy-id-map.json,IMPORT-REPORT.md,assets/,equine_v1.sql}; tests: counts preserved (27 ann / 26 mapped / 792 nodes / 612 leaves / 41 vet), determinism, Zod + 0 integrity errors, golden artifacts + - [x] 4b.2 migration 20261009100000 sheet asset storage: bucket anatomical-sheet-assets (private), object read policy through the sheet (published refs or editor), no API writes; shim storage tables; pgTAP + - [x] 4b.3 seed: equine_v1.sql idempotent (platform-owned official sheet, private, draft v1, 2 asset rows, fixed ids) in config sql_paths + PGlite harness applies supabase/seed/**; pgTAP 006: draft present, not publishable by non-admin, sheet_document_issues empty, assets match; upload script for the SVG bytes (service key from env, user/operator runs) + - [x] 4b.4 real stack: db reset + db test + types check + assets upload + REST read check; docs (SUPABASE.md, ANATOMICAL_SHEET_MODEL.md §6 import, CLAUDE.md, plan note, CHANGELOG) + - [ ] 4b.5 verify: pnpm check green (61+25+19+278), real stack reset/test 238/238, types in sync, assets uploaded + Storage API 200/400/400; verifier + security gates dispatched; BDR-034, LRN-041 ---