diff --git a/.claude/memory/evals.md b/.claude/memory/evals.md index 929c474e..3e9e6eb1 100644 --- a/.claude/memory/evals.md +++ b/.claude/memory/evals.md @@ -71,3 +71,12 @@ Method: packages/anatomy 30 vitest (counts in=out on both sides, special cases, Result: first pass verifier ECARTS(4) (self-referential in=out control, undeclared importer-authored labels, docs vs literal sql_paths, silent FR→EN fallback) + security PASS with MEDIUM hash-claim bypass (register_sheet_asset accepts any sha256 → editor reads foreign objects). All fixed: `uploaded_at` + `confirm_sheet_asset_upload` (service role) required by the read predicate, bob-claims-hash pgTAP, authored-label anomalies (27 anomalies now), seeds-listed test, Dockerfile missing workspace manifests (found by building, not by the gates). Anomalies: real image `storage.protect_delete` aborts direct DELETE tests (LRN-041); pg_temp fixtures need service_role grants; docker build raced the lockfile refresh (rebuild clean). Action: fresh verifier re-dispatched on the delta; BDR-034, LRN-041. + +--- + +## EVAL-010 | 2026-10-10 | Step 4c equine curation — research agents, changeset, gates + +Method: 4 research agents (skull, axial, limbs, osteo/legal), every citation tagged VERIFIED-fetched/snippet/UNVERIFIED; changeset authored in scratch python (44 changes / 679 ops / 48 refs) → pipeline Zod + 20 integrity rules; anatomy 100 vitest (ops, rename propagation, overlay, golden), pgTAP 001–008 on PGlite and real stack (`db reset`, `db test` 267/267, `gen types` diff clean); root check (68+21+100+278, lint 0, build); `docker build`; Storage e2e after upload (owner 200, alice/anon 400); gridded `magick` crops to verify point positions; fresh verifier ×3 + security-auditor ×1. +Result: verifier pass 1 ECARTS(4): B changes left targets `inherited` (CHG-008/032/039 + partials), 3 stale doc numbers, lockfile outside contract scope (orchestrator omission), eslint-disable any in a test → executor: applier rule (B/C ⇒ touched findings/annotations `to_confirm`, `reviewed` refused in B/C), typed test reads, docs. Pass 2 ECARTS(2): JSAVA citation without author (completed from the PDF: Le Roux & Carstens 2018, DOI), DEPLOY.md stale `faunosteo-web`. Pass 3 ECARTS(1): 3 stale doc lines (migration list, "two assets", CLAUDE.md migrations) → fixed by hand, cap of 3 verifier passes reached, not re-verified. Security PASS, LOW: SQL gate did not check reference url scheme → `reference.url.scheme` added (migration still unmerged, pgTAP 008 10 cases); `.env.example` COMPOSE_PROJECT_NAME=osteo-report overrides compose `name:` → file denied to Claude, user action. +Anomalies: ImageMagick MSVG drops `fill="none"` shapes and shapes with `` child (LRN-042); two legacy points (t18-l1, l6-s1) floated above the silhouette, found only by the overlay render, not by the catalog audit; Supabase `db reset` unconfirms the asset row (upload script must re-run: objects kept, row confirmed). +Action: user validation of the draft content (REVIEW-REPORT §10: 11 questions); never publish; Step 5 only after validation. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 3a34f275..ad73daad 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -187,3 +187,4 @@ Step 4 validated + finished into develop. User decisions on the 7 open points - Gates 4b: verifier ECARTS(4) + security PASS/MEDIUM → fixed same session (confirm_sheet_asset_upload + uploaded_at in read predicate, 27 anomalies declared, seeds-listed test, Dockerfile manifests for domain/anatomy, docker build green). Real stack 256/256, Storage e2e verified. EVAL-009. Fresh verifier re-run on delta; stop for user validation. - 2026-10-10 Step 4c on feature/step-04c-equine-curation: Docker `faunosteo_` convention (BDR-035); schema v2 (references, review_status, count_range; migration 20261010100000, pgTAP 008); curation pipeline (executor) + review overlays; 4 research agents (skull, axial, limbs, osteo/legal) → 44 changes / 679 ops / 48 refs authored from scratch python modules; draft 811 nodes, 28 annotations, 0 integrity errors; 9 points moved, carpus added, 9 questions for the osteopath. Root check green, real stack pgTAP + types clean, docker build OK. BDR-036, LRN-042. Gates next; stop for user validation; no publication. +- Gates 4c: verifier ×3 (4→2→1 écarts, last 3 doc lines fixed by hand at cap), executor closed the applier rule + typed tests; security PASS (LOW url scheme → SQL rule `reference.url.scheme`). Real stack 267/267, Storage e2e OK. EVAL-010. Awaiting user validation; `.env.example` COMPOSE_PROJECT_NAME left to the user (file denied). diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 1e63b3e5..b56c1d91 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -77,14 +77,14 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [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) - [x] 4b.5 verify: pnpm check green (61+30+20+278), real stack 256/256, types in sync, docker build OK, Storage API 400→200 after confirmation (alice/anon 400); verifier ECARTS(4) + security MEDIUM (hash claim) → fixed (uploaded_at + confirm RPC, authored labels, seeds-listed test, Dockerfile manifests); EVAL-009 - [x] Step 4b VALIDATED by user 2026-10-09 → finished into develop. Draft stays private, never auto-published. -- [ ] Step 4c — equine sheet audit, correction, enrichment (2026-10-09, branch feature/step-04c-equine-curation). User brief: research-backed audit of SVG annotations + findings catalog, corrections by confidence level (A demonstrated / B supported, flagged / C uncertain, question for the osteopath), traceable changeset (id, before, after, nature, rationale, references, level, needs confirmation), reproducible baseline of the 4b import, no publication, no design redesign (propose first). +- [ ] Step 4c (DONE, awaiting user validation; never publish) — equine sheet audit, correction, enrichment (2026-10-09, branch feature/step-04c-equine-curation). User brief: research-backed audit of SVG annotations + findings catalog, corrections by confidence level (A demonstrated / B supported, flagged / C uncertain, question for the osteopath), traceable changeset (id, before, after, nature, rationale, references, level, needs confirmation), reproducible baseline of the 4b import, no publication, no design redesign (propose first). - [x] 4c.0 Docker naming convention `faunosteo_` (compose container/project names; Supabase CLI names fixed `supabase_<svc>_<project_id>` → documented limit). Docs + memory (BDR). - [x] 4c.1 domain schema v2: document `references` registry + node `reference_ids`, `review_status` on nodes and annotations, `count_range` on vertebral regions; rules `finding.reference.missing`, `region.count_range.invalid`; tests; migration extending the schema CHECK + SQL issues; types regen; pgTAP. - [x] 4c.2 packages/anatomy curation layer: changeset schema (Zod, JSON data), applier (set / rename / add / remove / move / cite / annotation ops), before-values captured by the applier, CHANGELOG + REVIEW-REPORT generators, diff v1 → draft; seed dir restructure: `legacy-import/` (baseline, generated) + `draft/` (curated working revision, seeded); cleaned SVG asset (legacy markers stripped), head view = view_box crop of the single asset. - [x] 4c.3 research (parallel agents, WebSearch): axial skeleton + vertebral variation; skull/sutures/SBS/TMJ/hyoid; appendicular nomenclature NAV/Barone; osteopathic terminology + French legal scope + vet red flags; catalog analyzer pass. Output: findings with verifiable references, classified A/B/C. - [x] 4c.4 content changes: sphenoid zone restructured (SSB tree duplicated under sphenoid), terminology (lésion → dysfonction, NAV names, FR grammar), 62 EN descriptions + EN disclaimer, vet flags audit, references registry + citations, additions (carpus…), SVG point moves (B, before/after renders), Cd range 15–21. - [x] 4c.5 reports: REVIEW-REPORT.md for the osteopath (10 sections, questions ranked), CHANGELOG table, before/after review SVGs (draft/review/, PNG renders by operator), quantitative before/after. - - [~] 4c.6 verify (root check, PGlite + real stack 008 incl., types, docker build green; gates pending): pnpm check, PGlite + real stack pgTAP, types, docker build, golden tests; gates verifier + security; docs (spec §6/§7, SUPABASE.md, CLAUDE.md, plan Step 4c, CHANGELOG); memory (BDR/LRN/EVAL/journal). Stop for user validation. + - [x] 4c.6 verify (root check 68+21+100+278, PGlite + real stack 267/267, types, docker build, Storage e2e; verifier ×3 → fixes, security PASS; EVAL-010): pnpm check, PGlite + real stack pgTAP, types, docker build, golden tests; gates verifier + security; docs (spec §6/§7, SUPABASE.md, CLAUDE.md, plan Step 4c, CHANGELOG); memory (BDR/LRN/EVAL/journal). Stop for user validation. --- diff --git a/docs/development/ANATOMICAL_SHEET_MODEL.md b/docs/development/ANATOMICAL_SHEET_MODEL.md index 8aab9ab9..ea8c40a5 100644 --- a/docs/development/ANATOMICAL_SHEET_MODEL.md +++ b/docs/development/ANATOMICAL_SHEET_MODEL.md @@ -140,6 +140,7 @@ Integrity rules (error unless stated): | `reference.id.duplicate` | reference ids unique | | `finding.reference.missing` | every `reference_ids` entry (categories and nodes, any depth) is declared | | `region.count_range.invalid` | `count_range.min ≤ count ≤ count_range.max` when a range is given | +| `reference.url.scheme` (SQL only; Zod refuses it at parse) | every `references[].url` is null or starts with `http://` / `https://` | A draft may be saved with errors. Publishing a document with errors is refused in TypeScript (`assertPublishable`) and in SQL: diff --git a/supabase/migrations/20261010100000_sheet_document_schema_v2.sql b/supabase/migrations/20261010100000_sheet_document_schema_v2.sql index 8b990d12..5a7963fa 100644 --- a/supabase/migrations/20261010100000_sheet_document_schema_v2.sql +++ b/supabase/migrations/20261010100000_sheet_document_schema_v2.sql @@ -96,6 +96,16 @@ begin ) then v_issues := private.append_issue(v_issues, 'region.count_range.invalid'); end if; + -- Zod refuses non-http(s) reference urls at parse; a document sent straight + -- to the RPC must meet the same bar before anything renders it as a link. + if exists ( + select 1 + from jsonb_array_elements(coalesce(p_doc -> 'references', '[]'::jsonb)) ref + where jsonb_typeof(ref -> 'url') = 'string' + and (ref ->> 'url') !~ '^https?://' + ) then + v_issues := private.append_issue(v_issues, 'reference.url.scheme'); + end if; return v_issues; end; $$; diff --git a/supabase/tests/008_sheet_document_schema_v2.sql b/supabase/tests/008_sheet_document_schema_v2.sql index 8a4db50c..6f60463c 100644 --- a/supabase/tests/008_sheet_document_schema_v2.sql +++ b/supabase/tests/008_sheet_document_schema_v2.sql @@ -1,7 +1,7 @@ -- Document schema_version 2: references registry, review status, count -- ranges. Only version 2 is stored; the SQL gate re-checks the new rules. begin; -select plan(8); +select plan(10); insert into auth.users (id, email) values ('50000000-0000-0000-0000-00000000000a', 'alice-v2@test.local'); @@ -73,6 +73,14 @@ select is( private.sheet_document_issues(jsonb_set(pg_temp.doc('[]', '[]', 'null'), '{references}', '"x"')), '{document.shape}'::text[], 'a non-array references registry is a shape error' ); +select is( + private.sheet_document_issues(pg_temp.doc('[{"id":"bad","type":"web","citation":"x","url":"javascript:alert(1)","doi":null}]', '[]', 'null')), + '{reference.url.scheme}'::text[], 'a reference url outside http(s) is reported' +); +select is( + private.sheet_document_issues(pg_temp.doc('[{"id":"ok","type":"web","citation":"x","url":"https://example.org/a","doi":null}]', '[]', 'null')), + '{}'::text[], 'an https reference url passes' +); -- Only schema_version 2 rows are stored. set local role authenticated;