From 17d919971e6ac5be53bed2489de1e9779d21f360 Mon Sep 17 00:00:00 2001 From: bchanot Date: Thu, 29 Oct 2026 14:05:28 +0100 Subject: [PATCH] chore(memory): V1-2.2 checkpoint, evidence, BDR-086, LRN-097/098, TODO --- .claude/audits/2026-10-29-v1-2-2-evidence.md | 81 +++++++++++++++++++ .claude/audits/2026-10-29-v1-2-2-mutations.py | 28 +++++++ .claude/memory/decisions.md | 8 ++ .claude/memory/journal.md | 3 + .claude/memory/learnings.md | 10 +++ .claude/tasks/TODO.md | 13 ++- .../tasks/contracts/2026-10-29-v1-2-2-core.md | 70 ++++++++++++++++ docs/development/RUST.md | 4 +- 8 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 .claude/audits/2026-10-29-v1-2-2-evidence.md create mode 100644 .claude/audits/2026-10-29-v1-2-2-mutations.py create mode 100644 .claude/tasks/contracts/2026-10-29-v1-2-2-core.md diff --git a/.claude/audits/2026-10-29-v1-2-2-evidence.md b/.claude/audits/2026-10-29-v1-2-2-evidence.md new file mode 100644 index 00000000..c018eb40 --- /dev/null +++ b/.claude/audits/2026-10-29-v1-2-2-evidence.md @@ -0,0 +1,81 @@ +# V1-2.2 evidence (2026-10-29) + +Owner brief « Autorisation de démarrer V1-2.2 », V1-2.1 VERIFIED at `ac71c5b`. Worktree +`feature/v1-2-anatomical-sheets`. Code commits `64a4384`, `cf37aa2`, `8ae7565`, docs `741c25c`. +Contract `docs/development/V1-2_ANATOMICAL_SHEETS.md` §16.3; verifier contract +`.claude/tasks/contracts/2026-10-29-v1-2-2-core.md`; record `docs/development/RUST.md` §12. + +## 1. Owner answers taken before the code (contract §17.4) + +| Question | Answer | +|---|---| +| No Inkscape, Illustrator, Figma or Affinity on the machine: how to get real editor exports | the owner supplies them (`crates/core/tests/fixtures/svg/exports/owner/`); cairo and ImageMagick exports committed meanwhile | +| Strict-parse failure code (§6.5 vs §6.7) | `verification.integrity.document` | +| Draft preview with caps excess or missing drawings | reported for drafts, refused for published and deprecated versions | + +## 2. Gates on the working tree before the commits + +| Gate | Result | +|---|---| +| `pnpm rust:check` | exit 0; 201 cargo result lines, 1 849 passed, 0 failed, 3 ignored (every feature run of the script); clippy `-D warnings` clean; `cargo deny`: bans, licenses, sources ok | +| `pnpm wasm:build` | 1 771 003 B raw, 582 722 B gzip -9 (script); core-wasm proofs green | +| `pnpm check` | exit 0; core-wasm 16 files 65 tests, supabase 11 files 128 tests, app 65 files 566 tests; lint clean; app build done | +| size budget (`packages/core-wasm/tests/size.test.ts`) | 592 136 B by Node's gzip ≤ 600 000 B (531 715 B before V1-2.2) | + +The first build was 635 654 B gzip (over budget): serde's tagged readers for `EditCommand` / +`NewElement` and an owned-`Value` read of the document each compiled a second copy of the +schema's reader. Reading both through `&Value` gave 606 750 B, then 582 722 B. + +## 3. New suites (cargo, debug) + +| Suite | Tests | Notes | +|---|---|---| +| `sheet_size` | 6 | 17 PostgreSQL vectors (PGlite 17.5, `oracles/v1-2-2/size.json`); seed 184 105 B = the real image's value | +| `sheet_review` | 9 | equine 188 / 31 / 620 over 839 elements, 30 groups | +| `sheet_verdict` | 13 | at every cap: 493 ms debug, 107 ms release, document 1 165 850 B | +| `sheet_preview` | 8 | index tables and canvases equal to the bundled `LoadedSheet` | +| `sheet_edit` | 11 | 400 random commands on two documents | +| `svg_clean` | 8 | 42 hostile files; 3 000 generated: 123 clean, 2 697 cleanable (fixpoint), 180 cycles refused | +| `packages/core-wasm/tests/preview.test.ts` | 5 | shipped module; `clean_svg` slowest 0.4 ms over 45 inputs | + +## 4. Mutation run + +Script: `.claude/audits/2026-10-29-v1-2-2-mutations.py` (run from the repository root: each mutant applied, its suite run, the file restored). + +| Mutant | Suite | Result | +|---|---|---| +| caps `>` → `>=` | sheet_verdict | killed | +| digest without its group key | sheet_review | killed by `a_removal_digest_is_bound_to_its_group_key`, written for it before the run | +| event handlers not active | svg_clean | killed | +| drawing hash unchecked | sheet_verdict | killed | +| content update keeps `reviewed` | sheet_edit | killed | +| fingerprint unchecked at load | sheet_preview | killed | +| `inherited` counted as read | sheet_review | survived the first run; killed once `an_inherited_element_alone_keeps_its_group_uncoverable` was added | +| redrawn views ignored | sheet_edit | killed | +| numeric scale ignored | sheet_size | killed | +| removal groups never made | sheet_review | killed | + +## 5. DEV and protected branches + +- No Supabase CLI call, no SQL, no migration, no seed, no worker start in this step. The DEV + containers (`supabase_*_faunosteo`) were read with `docker ps` / `docker inspect` only: started + 2026-10-28 14:45 UTC, before this session (`supabase_auth_faunosteo` restarts=3 already then). + Snapshot before the gate: `scratchpad/docker-inspect-before.txt`; after: section 6. +- No merge, no checkout of `develop`, `main` or `release/*`; commits only on + `feature/v1-2-anatomical-sheets`, pushed by the post-commit hook. + +## 6. Gates on the committed branch and reviews + +| Commit | `pnpm check:all` | Reviews | +|---|---|---| +| `741c25c` | exit 0, every stage, e2e:ui PASSED | verifier ECARTS(6); security PASS (2 MEDIUM, 2 LOW) — fixed in `8294d54` | +| `8294d54` | exit 0 | verifier ECARTS(3) (A6 owner exports, A12 outside its commands, helper unrecorded); security PASS (4 MEDIUM, 8 LOW) — fixed in `ca31b78` except the owner decisions of RUST.md §12.6 | +| `ca31b78` | exit 0; cargo 1 879 passed 0 failed; vitest core-wasm 65, supabase 128, app 566; e2e:ui PASSED; module 596 671 B (Node gzip) ≤ 600 000 | — | + +The first two reviewers (Fable 5.1) stopped at once on exhausted usage credits and produced nothing; they ran again on Opus. +`e2e:shell` not run (needs the sandbox stack; no screen changed). + +Containers after the gates (`docker inspect`, read-only): identical to the snapshot of section 5 (DEV +`supabase_*_faunosteo` and the V1-2.1 sandbox: same start times and restart counts). + +Known: commit `64a4384` alone does not build (`facade::clean_svg` names the module of `cf37aa2`); the branch head does. diff --git a/.claude/audits/2026-10-29-v1-2-2-mutations.py b/.claude/audits/2026-10-29-v1-2-2-mutations.py new file mode 100644 index 00000000..4dde50d9 --- /dev/null +++ b/.claude/audits/2026-10-29-v1-2-2-mutations.py @@ -0,0 +1,28 @@ +# V1-2.2 mutation run (evidence .claude/audits/2026-10-29-v1-2-2-evidence.md §4): each mutant is +# applied to its source file, its cargo suite runs, the file is restored. Run from the repo root. +import subprocess, shutil, sys +root='.' +muts=[ + ('M1 caps off by one','crates/core/src/domain/sheet/caps.rs','.filter(|&(_, value, limit)| value > count(limit))','.filter(|&(_, value, limit)| value >= count(limit))','sheet_verdict'), + ('M2 digest without key','crates/core/src/domain/sheet/review.rs',' object.insert("group".to_owned(), Value::String(key.to_owned()));\n','','sheet_review'), + ('M3 no active class','crates/core/src/anatomy/svg/sanitize.rs',' if local.starts_with("on") {\n return true;\n }',' if local.starts_with("on") {\n return false;\n }','svg_clean'), + ('M4 hash unchecked','crates/core/src/domain/sheet/verdict.rs',' if sha256_hex(bytes) != row.sha256 {',' if false && sha256_hex(bytes) != row.sha256 {','sheet_verdict'), + ('M5 update keeps reviewed','crates/core/src/domain/sheet/edit.rs',' if changed {\n set_annotation_status(&mut next, ReviewStatus::ToConfirm);\n }','','sheet_edit'), + ('M6 fingerprint unchecked','crates/core/src/domain/sheet/preview.rs',' if stored.is_none() || stored != self.fingerprint.as_deref() {',' if false {','sheet_preview'), + ('M7 inherited not counted unread','crates/core/src/domain/sheet/review.rs',' self.to_confirm == 0 && self.inherited == 0',' self.to_confirm == 0','sheet_review'), + ('M8 redrawn views ignored','crates/core/src/domain/sheet/edit.rs',' reconfirm_redrawn_views(&mut next, &drawn_before);\n','','sheet_edit'), + ('M9 numeric scale ignored','crates/core/src/domain/sheet/size.rs','if scale > 0 {','if false {','sheet_size'), + ('M10 removal never made','crates/core/src/domain/sheet/review.rs',' if !groups.iter().any(|g| g.key == key) {',' if false {','sheet_review'), +] +for name,path,old,new,suite in muts: + src=open(path).read() + if src.count(old)!=1: + print(name,'ANCHOR NOT FOUND x',src.count(old)); continue + open(path,'w').write(src.replace(old,new)) + try: + r=subprocess.run(['bash','-c',f'. scripts/rust-env.sh && cargo test -q -p faunosteo-core --test {suite} 2>&1 | tail -3'],capture_output=True,text=True) + out=r.stdout + killed=('FAILED' in out) or ('error' in out.lower() and 'could not compile' in out) + print(f"{name}: {'KILLED' if 'FAILED' in out else ('COMPILE-ERR' if 'could not compile' in out else 'SURVIVED')}") + finally: + open(path,'w').write(src) diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 357868fa..677b9c01 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -633,3 +633,11 @@ Owner brief « V1-2.1 : décisions finales du propriétaire » on checkpoint 2af - M6 option A: `grant.self_review` dropped from `grant_catalog_right` + `SHEET_FAILURE_KINDS`. Owner at aal2 + verified factor may self-grant `sheet_reviewer`. Separation stays per round: author refused at ack + approve (`review.separation`), author approval refused again at publish (`publish.approval.invalid`). pgTAP 015 flipped, 017 owner-reviewer block (7 cases). Residual: owner reviewing others' drafts is now a normal path, audited like any grant. - M7: Git fixture accepted for V1-2.1 upgrade rehearsal (horse.svg, sha256 = DEV asset row). Bytes/metadata/relations compared before/after. No DEV Storage read -> live DEV object integrity NOT shown; checked when owner applies M4-M6 on DEV. Contract §12.3, §16.2, §17.3. - Size: one measure = UTF-8 bytes of jsonb text form `octet_length(content::text)` (`": "`, `", "` separators, jsonb key order, numeric without exponent). Base table CHECK `pg_column_size` (binary jsonb, uncompressed at write, bigger than text for dense docs) replaced in M5 by the text measure; `check_document_structure` drops pg_column_size. TS/Rust: no check today; core must compute same form in V1-2.2 (compact JSON.stringify shorter -> necessary not sufficient). Alternative rejected: compact JSON measure (SQL cannot compute it exactly: numeric prints no exponent). + +## BDR-086 — V1-2.2 core authoring surface: verdict, PreviewSheet, edits, cleaning (2026-10-29) +- **Status**: implemented + tested; READY FOR REVIEW; DEV untouched +V1-2.2 core built (contract §16.3), no SQL/screen/DEV. Owner answers 2026-10-29 before code: editor exports (Inkscape/Illustrator/Figma/Affinity) supplied by owner under tests/fixtures/svg/exports/owner, cairo 1.18.4 + ImageMagick 7.1.2-18 exports committed meanwhile; strict-parse fail = `verification.integrity.document` (+ `.base`), 19 rule errors = `verification.validation.rules` (§6.7 aligned on §6.5); PreviewSheet draft = caps excess + missing drawings reported, published/deprecated = refused. +Design choices: verdict snake_case in the shape M5 SQL reads (groups[{key,digest,coverable}], drawings[{asset_id,sha256}], fingerprint), pure `compute_verdict`, NOT exported to wasm (O15). Digest = sha256(JCS({"group": key, ...content})) from typed doc (omitted status written inherited); general = doc minus views/annotations/finding_zones; view: = views of id + annotations drawn in it; zone: = zones of id; removal = {removed:true}; coverable = no to_confirm/inherited. Size = PG jsonb text measure (`size.rs`), oracle by PGlite 17.5. Edit: free op `sheet.edit` doc in → doc out; refuses ambiguous keys (duplicate id among siblings), unknown keys, id change, bad position, finding depth > 8; no cascade beyond tree descendants (dependents lists the rest); views whose drawing/crop changed → annotations to_confirm. Cleaning: sanitiser walk classes removals `active` (script, embeds, image, animation, a, on*, external refs, @import, javascript:, expression(, image-set(, behavior:, backslash); cleaning-only reading drops oversized title/desc (stored reader still refuses, too_complex). +Alt: verdict in wasm (rejected, O15); handle-applied edits (kept free op, page holds text for undo); serde tagged derive for commands (rejected: +100 KB wasm). + +Reviews: verifier ECARTS(6) then ECARTS(3) (owner exports, helper); security PASS x2, MEDIUMs fixed (PIs, HTML fetchers, long-title bypass, quadratic groups, cubic view walk, bounds). Open owner: dangling #id across inlined drawings, clean upload = original bytes, stricter-than-table refusals, edit reading (contract 8.1/9.2), cairo rgb() colours. Module 596 671 B of 600 000. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index bd2bb3bf..f0c8a7ce 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -481,3 +481,6 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp - V1-2.1 review pass on 1281667: verifier ECARTS(6) (missing proofs: AR-1 B matrix, non-owner rights RPCs, publish.species.other; LOW docs), security PASS + MEDIUM number-exponent OOM (9000 x 1e131071 = 1 GiB text, raw OOM). Fixed 3eba6d8: bounded number walk before text measure; pgTAP 020 (449). Re-run 5620399: pgTAP 1807 x2 both stacks, suite 86/86 x2 both. Correction: earlier 'DEV metadata identical' = DEV container state only (ids, start times), no DEV data read. - V1-2.1 second reviews on 7c4bf12: security BLOCK HIGH = my number walk quadratic (jsonb_path_query per row, PG17 list_delete_first; 200k numbers 2.2 s native, ~26 s near cap). Fixed 538d103: jsonb_path_query_array + jsonb_array_elements (linear, 600k 0.4 s). Verifier ECARTS(1) LOW: red-on-old raw log now committed (.out). Rerun 2379d28: pgTAP 1808, suite 87/87 x2 both stacks. - V1-2.1 final: code 2379d28 (= HEAD code), check:all green on 532c61e, security PASS (1f9fa8b), verifier CONFORME on doc deltas after ECARTS(3) LOW fixed. Declared VERIFIED pending owner. Open V1-2.3: e2e:avatar DEV target, quadratic status walks, ingress cap, schema_version 2.0 raw 22P02. DEV containers untouched. STOP at checkpoint. + +## 2026-10-29 +- 2026-10-29 V1-2.2 core built (size, review groups, verdict, PreviewSheet, sheet.edit, clean_svg); owner answers before code (exports by owner, integrity.document, draft load). Verifier ECARTS 6 then 3, security PASS x2, fixes ca31b78; check:all green. DEV untouched. STOP: READY FOR REVIEW. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index ee674458..8ea3a7c9 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -663,3 +663,13 @@ Adapting pgTAP across PGlite and the real Supabase image: the fixtures must resp ## LRN-096 — jsonb_path_query row iteration is quadratic; numeric text has no exponent (2026-10-28) PostgreSQL 17 `jsonb_path_query` (SRF) builds its whole match list on the first call and pops rows with `list_delete_first` -> O(n^2) when iterated row by row (FOR loop, count(*)): 200k matches 2.2 s, 400k ~27 s. Early `exit` saves nothing. Use one `jsonb_path_query_array(...)` then `jsonb_array_elements` (linear: 600k 0.4 s). Also: `numeric` prints no exponent, so `octet_length(jsonb::text)` of `1e131071` x 9000 (90 kB payload) = 1.2 GB -> raw OOM; sum printed numbers first. Apply to any SQL walk over user jsonb (status walks `sheet_all_reviewed`, `sheet_has_to_confirm` use the same SRF pattern, bounded today by core caps). + +## LRN-097 — serde tagged enums and owned-Value reads double the wasm size (2026-10-29) +serde derive cost in wasm: internally/adjacently tagged enums buffer through serde's private Content, so every type reachable through them gets a second Deserialize monomorphization (ContentDeserializer); `serde_json::from_value` (owned Value) is a third, distinct from `T::deserialize(&value)`. V1-2.2 measured: edit commands with tagged derive + owned from_value of the document = 635.7 KB gzip (budget 600); commands read via `Value` then `T::deserialize(&inner)`, document via `&Value` = 582.7 KB. +Apply: in crates reaching wasm, read tagged wire forms through `serde_json::Value` with hand dispatch on the tag (keep ts-rs shape with `ts(tag, content, rename_all)`), always deserialize documents from `&Value`, measure `pnpm wasm:build` gzip after any new op; probe by removing one export at a time (cargo release wasm + gzip -9) before guessing. + +## LRN-098 — Real SVG exports vs the allowlist; what the tree never reads (2026-10-29) +Real vector exports vs R3 allowlist: cairo 1.18 writes colours as `rgb(20%, 40%, 70%)`; allowlist drops any function call in presentation attributes → cleaned drawing keeps shapes, loses colours. ImageMagick 7 MVG export writes style settings as bare text between elements (dropped silently, not a "removal"). Property test generators for SVG must avoid repeated attribute names (XML malformed) or most cases test nothing. +Apply: classify fixtures by actual outcome before writing expectations; report colour loss on cleaning as an owner decision (allow numeric rgb()/rgba() = reader change); dedupe attribute names in generators. + +Also: the tree drops processing instructions and comments, so "read with no removal" is not "bytes safe": `` survives in stored bytes; scan PIs separately (fail-closed) wherever original bytes are kept. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 14c03abf..d72f6cf1 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -537,7 +537,7 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [x] owner ratified O1-O23 (brief « V1-2.0 : ratification des arbitrages O1 à O23 et consolidation du contrat », 2026-10-28, BDR-082) - [ ] consolidation (docs only): contract rewritten (decisions §17, contradictions C1-C14 §19.2, steps §16 with 9 headings each); IMPLEMENTATION_PLAN §0 + Steps 13/17 notes, ANATOMICAL_SHEET_MODEL stale Zod/TS mentions + V1-2 pointer, OPEN_QUESTIONS conflicts 1-2, V1-1 §5.4 pointer (N1 amended), rule sheet-model, CLAUDE.md pointer; 3 fresh challengers (business CONCERNS 3 major, security FATAL 1 arbitration + 6 major, simplicity CONCERNS 5 major) integrated (contract §19.3); commit + push branch; STOP at checkpoint: owner final review, no V1-2.1 - [x] AR-1 ratified option B by the owner 2026-10-28 (BDR-083): `aal2` on every platform role change; contract §5.7 (rule, inventory, bootstrap, factors, recovery, sessions), F17-F19, M4 scope, tests §15, DEV order §16.11 (enrol before M4); docs only; independent security review then commit + push; no code, migration or DEV change - - [ ] V1-2.1 server access and workflow (M4, M5): owner go 2026-10-28 (brief « V1-2.1 : SQL, habilitations et cycle de vie »); sandbox only, DEV untouched; STOP at checkpoint (report §14). State 2026-10-28: BUILT + TESTED on sandbox, checkpoint report delivered, awaiting owner validation; BDR-084, LRN-095 + - [ ] V1-2.1 server access and workflow (M4, M5): owner go 2026-10-28 (brief « V1-2.1 : SQL, habilitations et cycle de vie »); sandbox only, DEV untouched; STOP at checkpoint (report §14). State 2026-10-28: BUILT + TESTED on sandbox, checkpoint report delivered; VERIFIED by the owner 2026-10-29 at ac71c5b (M4/M5 accepted for the branch, not for DEV or production); BDR-084, LRN-095 - [x] A prep: worktree deps; sandbox (old schema) service_role grants recorded (ALL on 7 tables → 0 after F12); F1-F17,F19 reproduced on old schema (repro_old.out), F18 two-session race - [x] B M4 `20261028100000_sheet_access_hardening`: grants table + rights RPCs; has_mfa / has_aal2_session / grant_active / caller_has; catalogue reader predicate + policies; can_edit_sheet on capability (F14); AR-1 B role RPCs + private writers (F19), F17, F18 advisory lock; F1 F3 F5 F6 F8 F9 F12 F13 F15 F16; historical-sheet + asset triggers; fork/visibility/personal-create dropped; shim auth.sessions + auth.mfa_factors; pgTAP 015 + 001/003/004 adapted - [x] C M5 `20261028110000_sheet_review_workflow`: version/sheet columns, version guards (content/revision/author, freeze, publish gate, deprecation), rounds/comments/acks, lifecycle + review + publish(review_id) RPCs, species RPCs, working copy, read RPCs, upload (register, confirm with storage check F7, INSERT policy, 2 MiB), operator read RPC, mirror dropped + `sheet_all_reviewed`, superseded signatures dropped; pgTAP 016 + 005/006/007 rewritten, 008/011 deleted, Rust generator trimmed + ledger retargeted @@ -563,7 +563,16 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [x] H4 gates: pgTAP fresh + upgraded, PGlite + unit, sandbox suite ×2, concurrency, fresh + M3→M5 (M7 rehearsal), types, check:all; fresh verifier + security on final HEAD; DEV metadata before/after — sandbox done on 7eca441 (pgTAP 1352 ×2 per stack, suite 86/86 ×2 per stack, types match, M7 diff = bucket + service_role only, DEV containers untouched: same ids, start times, restart counts; nothing on DEV read); check:all + reviews on final HEAD pending - [x] H6 review findings on 1281667 (verifier ECARTS(6), security PASS + 1 MEDIUM): number-exponent amplification → raw OOM (bounded number-text pre-sum, closed code, pgTAP); AR-1 B §15 matrix (015); rights RPCs refused for non-owners (015); `publish.species.other` alone (017); docs §1, §9.5, §12.2 vectors, evidence §3; then gates again + fresh reviews — done 3eba6d8/5620399: pgTAP 1807 ×2 per stack, suite 86/86 ×2 per stack, PGlite 128, bomb proof on real image; second reviews on 7c4bf12: verifier ECARTS(1) LOW (raw red-on-old log → committed .out), security BLOCK(1) HIGH quadratic number walk → linear 538d103, perf fixture 2379d28; rerun 2379d28: pgTAP 1808 ×2 per stack, suite 87/87 ×2 per stack; final: check:all green on 532c61e; security PASS on 1f9fa8b (code = final); verifier ECARTS(3) LOW docs on 1f9fa8b → fixed, delta verifiers → CONFORME on 532c61e. Open for V1-2.3: `e2e:avatar` targets DEV (verifier O3), quadratic status walks, ingress body cap, schema_version 2.0 raw 22P02 - [x] H5 memory (BDR M6/size, journal), commit + push branch, final report - - [ ] V1-2.2 core verdict, preview, change list, edit primitives, SVG cleaning · V1-2.3 drawings and worker verification (M6) · V1-2.4 wireframes (editor, review, admin entry) · V1-2.5 catalogue, admin space, rights, species, MFA · V1-2.6 editor level 1 · V1-2.7 preview, review, publication UI · V1-2.8 equine working copy and review preparation · V1-2.9 FR/EN acceptance and closure (owner checkpoints V1-2.3, V1-2.4, V1-2.6, V1-2.7, V1-2.8, V1-2.9 + each DEV operation of contract §16.11) + - [x] V1-2.2 core: verdict, PreviewSheet, edit primitives, SVG cleaning (owner brief 2026-10-29 « Autorisation de démarrer V1-2.2 », V1-2.1 VERIFIED at ac71c5b; contract §16.3; sandbox only, DEV untouched; no SQL, no screen; STOP at checkpoint, no V1-2.3; state 2026-10-29: READY FOR REVIEW, owner checkpoint). Owner answers 2026-10-29: editor exports (Inkscape/Illustrator/Figma) supplied by the owner, cairo + ImageMagick exports committed meanwhile; strict-parse failure = `verification.integrity.document` (§6.5; §6.7 wording aligned); PreviewSheet draft = caps + missing drawings reported, published/deprecated = fatal + - [x] A size: `domain/sheet/size.rs` PostgreSQL jsonb text measure (`octet_length(content::text)`, numbers as `numeric` prints them, linear); oracle: corpus measured by the sandbox PostgreSQL + the pgTAP 017 vectors (cap − 1, cap, cap + 1, 3- and 4-byte, dense, exponent numbers) + - [x] B review model: element keys, caps report (SnapshotCaps, all), completeness (statuses, vet referrals, uncited), groups + digests (general, view:, zone:, removal groups, coverable), change list vs base + - [x] C verdict: `domain/sheet/verdict.rs` pure function (binding, document text, base text, drawings with row sha256/size/bytes) → verdict in the shape M5 reads (`groups[{key,digest,coverable}]`, `drawings[{asset_id,sha256}]`, `fingerprint`); closed codes `verification.integrity.*` / `verification.validation.*`; not exposed to the browser (O15) + - [x] D PreviewSheet: builder (drawings by sha256 checked, read once), draft / published / deprecated, failures `drawing_missing`, `drawing_hash_mismatch`, `fingerprint_mismatch`, `invalid_document`, `caps`; `replace_document`, `add_drawing`, `view.canvas` shared with LoadedSheet, `preview.state` (report, drawings, index tables) + - [x] E `sheet.edit` primitives (insert, update, remove, move, set_status, mark_reviewed) with §6.6 status rules; `sheet.dependents` + - [x] F SVG classification + cleaning (§9.2): active/external removals classed in the sanitiser walk, `clean_svg(bytes)` (clean / cleanable / rejected), cleaned bytes ≤ 2 MiB, fixpoint property test, hostile corpus, cairo + ImageMagick exports (owner editor exports pending) + - [x] G wasm facade (`PreviewBuilder`, `PreviewSheet`, `clean_svg`, free ops) + ts-rs types + index; core-wasm proofs (equine preview = bundle index + fingerprint, mismatches, replace without re-read, hostile corpus in fresh instances) + - [x] H docs (RUST.md §12, contract §6.7/§8.1/§9.2/§10/§17.4, CLAUDE.md, sheet-model rule), gates, fresh reviews, evidence, memory, commit + push. Reviews: verifier ECARTS(6) then ECARTS(3) (A6 owner exports, A12 covered by check:all, helper recorded); security PASS ×2, every MEDIUM fixed except owner decisions below. check:all green on 741c25c and 8294d54 (rerun on final). Open for owner: dangling #id across inlined drawings (scope ids per view or refuse), clean file uploaded as original bytes (§9.2), stricter-than-table refusals and the edit-command reading (§8.1, §9.2 « for the owner's confirmation »), cairo rgb() colours lost on cleaning, editor exports pending. Open for V1-2.3: M6 must accept a failed verdict without groups/drawings; R2 view.parent.cycle quadratic; PreviewSheet under CoreRuntime poison/recovery at V1-2.5 + - [ ] V1-2.3 drawings and worker verification (M6) · V1-2.4 wireframes (editor, review, admin entry) · V1-2.5 catalogue, admin space, rights, species, MFA · V1-2.6 editor level 1 · V1-2.7 preview, review, publication UI · V1-2.8 equine working copy and review preparation · V1-2.9 FR/EN acceptance and closure (owner checkpoints V1-2.3, V1-2.4, V1-2.6, V1-2.7, V1-2.8, V1-2.9 + each DEV operation of contract §16.11) ## 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. diff --git a/.claude/tasks/contracts/2026-10-29-v1-2-2-core.md b/.claude/tasks/contracts/2026-10-29-v1-2-2-core.md new file mode 100644 index 00000000..782bdff5 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-29-v1-2-2-core.md @@ -0,0 +1,70 @@ +# Contract: V1-2.2 core (verdict, PreviewSheet, edit primitives, SVG cleaning) + +Source of truth: `docs/development/V1-2_ANATOMICAL_SHEETS.md` (the "V1-2 contract"), §16.3 for the +step, with the sections it cites. Owner brief 2026-10-29 « Autorisation de démarrer V1-2.2 ». Base +commit `ac71c5b` (V1-2.1 verified by the owner). Diff under review: `ac71c5b..HEAD` on +`feature/v1-2-anatomical-sheets`. + +## Scope (§16.3) + +1. The verdict function: strict parse, issues, caps, drawings, fingerprint, completeness, groups, + digests, removal groups, change list (§6.3, §6.4, §6.5, §6.6, §6.7). +2. `PreviewSheet` as the catalogue, preview and editor handle, with `view.canvas` on it (§8.1, §10). +3. `sheet.edit` primitives with the status rules of §6.6; `dependents` (§8.1). +4. SVG classification and cleaning (§9.2). +5. Application changes limited to the wasm facade and the ts-rs types; no SQL change; no screen. + +## Acceptance criteria (§16.3, §15 « Core ») + +- A1 Hash and fingerprint mismatches refused by `PreviewSheet`. +- A2 The equine draft previews with the same index and fingerprint as from the bundle. +- A3 An invalid draft draws with its issues. +- A4 A document replacement redraws without re-reading the drawings. +- A5 The groups of a derived version that deletes a zone include its removal group. +- A6 Vector-tool exports cleaned and hostile files refused (see owner decision D1 below). +- A7 Every edit primitive outputs a strictly parseable document, keeps existing keys and applies the + status rules (property tests). +- A8 Groups, digests and removal groups; the change list; the verdict function tested. +- A9 SVG classification and cleaning tested on committed vector-tool exports and the hostile corpus; + the cleaning fixpoint proven by a property test. +- A10 Caps fixtures at cap − 1, cap, cap + 1 and with astral characters. +- A11 The document size computed in the measure of §12.2 (`octet_length(content::text)`, the jsonb + text form, never `JSON.stringify`), reusing the pgTAP 017 vectors. +- A12 Wasm facade and ts-rs types; the N-1 reader untouched; the frozen oracles green. +- A13 None of the protected readers is modified: `crates/core/src/domain/{archive/read,report/rebase, + report/read,session}.rs`, `crates/core/src/pdf/{read,json_js,import}.rs`, the frozen + `packages/core-wasm/tests/n-1` copies. Any change there is a deviation. +- A14 The verdict is never computed or accepted from a page (O15): no RPC or browser path makes a + verdict authoritative. +- A15 Verdict shape compatible with what the M5 SQL (`supabase/migrations/20261028110000_sheet_review_workflow.sql`) + reads: `verdict->'groups'` items `{key, digest, coverable}`, `verdict->'drawings'` items + `{asset_id, sha256}`, `verdict->>'fingerprint'`. +- A16 No DEV operation, no SQL migration, no merge, no change outside the scope above beyond the + documents that record it. + +## Owner decisions taken during the step (2026-10-29, contract §17.4) + +- D1 The editors' exports (Inkscape, Illustrator, Figma, Affinity) are supplied by the owner later, + under `crates/core/tests/fixtures/svg/exports/owner/`; the exports of tools installed on the + development machine (cairo, ImageMagick) are committed meanwhile. A6 is therefore partially met + until the owner's files arrive; the report must say so. +- D2 A document that does not read strictly fails as `verification.integrity.document` (§6.5); the + 19 rule errors are `verification.validation.rules`. +- D3 `PreviewSheet` of a draft reports caps excess and missing drawings; a published or deprecated + version refuses them (`caps`, `drawing_missing`); hash mismatch and an unreadable document refuse + every mode. + +## Where to look + +- Core: `crates/core/src/domain/sheet/{size,keys,caps,review,report,verdict,preview,edit}.rs`, + `crates/core/src/anatomy/svg/{clean,sanitize,mod}.rs`, `crates/core/src/{ops,facade}.rs`. +- Wasm: `crates/wasm/src/lib.rs`; `packages/core-wasm/{src,types,tests/preview.test.ts}`. +- Tests: `crates/core/tests/{sheet_size,sheet_review,sheet_verdict,sheet_preview,sheet_edit,svg_clean}.rs`, + oracle `crates/core/tests/oracles/v1-2-2/`, fixtures `crates/core/tests/fixtures/svg/exports/`. +- Records: `docs/development/RUST.md` §12, the contract's §6.7, §9.2, §10, §17.4. + +## Commands + +- `pnpm rust:check` (fmt, clippy, all core feature suites, ts-rs export, cargo deny). +- `pnpm wasm:build` then `pnpm --filter @faunosteo/core-wasm test:run` (the size budget is 600 000 B). +- `cargo test -p faunosteo-core --test sheet_verdict` (and the other five suites). diff --git a/docs/development/RUST.md b/docs/development/RUST.md index 87c4b17b..0c7fb791 100644 --- a/docs/development/RUST.md +++ b/docs/development/RUST.md @@ -3948,7 +3948,7 @@ trapping test stub (`apps/app/tests/helpers/core.ts`) lists the two new glue mem | Measure | Value | |---|---| -| shipped module | 1 777 104 B raw, 584 686 B gzip -9 (script), 593 582 B by Node's gzip in `size.test.ts`; budget 600 000 (D-R13); 531 715 B before V1-2.2 (RUST.md §11.22) | +| shipped module | 1 785 447 B raw, 587 470 B gzip -9 (script), 596 671 B by Node's gzip in `size.test.ts` (final, ca31b78); budget 600 000 (D-R13); 531 715 B before V1-2.2 (RUST.md §11.22) | | verdict at every cap, native | 107 ms release, 493 ms debug (document 1 165 850 bytes) | | `clean_svg`, shipped module | 45 hostile inputs and floods, slowest 0.4 ms | @@ -3967,7 +3967,7 @@ with a PI shown `rejected` by the preview as the verdict refuses it. ### 12.6 Residual risks and points for V1-2.3 -- The module's margin under its budget is about 6 KB by the test's measure: the V1-2.5 and V1-2.6 pages must not grow the +- The module's margin under its budget is about 3.3 KB by the test's measure: the V1-2.5 and V1-2.6 pages must not grow the core's browser surface without measuring. - cairo writes colours as `rgb(…)`: the allowlist removes any function from presentation attributes, so its cleaned exports lose their colours (named, visible in the preview). Allowing `rgb()` / `rgba()` with numeric arguments would be a