# 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 (scope: the owner's final decision E1 below, which replaces D1, B6 and C1 on this point). - 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). ## Owner arbitrations at the checkpoint (2026-10-29, contract §17.4, last six rows) Brief « V1-2.2 : arbitrages du propriétaire et finalisation » on `17d9199`. Diff under review for this round: `17d9199..HEAD`. The criteria above still hold; these are added. - B1 A local reference (`href`, `xlink:href`, `url(#…)`) to an id the drawing does not define is refused (`dangling_reference`) by `read_svg` (stored drawings, verdict, preview, PDF snapshot gate) and by `clean_svg`, the latter only after active content is classified. Valid internal references keep working. - B2 `view.canvas` (on `LoadedSheet` and `PreviewSheet`) scopes every id and local reference of the drawing to its view (`fv..`); two canvases inlined in one page never resolve into each other; composition deterministic; stored bytes, sha256, fingerprints, archive snapshots and PDF views untouched. Tests: valid, absent, same ids in two views, cross-view attempt, many references to one id, repeated composition (`tests/svg_scope.rs`). - B3 Every accepted file (clean or cleanable) is uploaded in the stored form (`serialize::stored_form`); verdict (`verification.integrity.svg_not_canonical`), preview (`not_canonical`) and the upload tool refuse another form; the equine drawing's sha256 `0ea5202f…` and the fingerprint `12d78872…` unchanged. - B4 Strict numeric `rgb()` / `rgba()` kept; `url(` outside the document, `expression(`, scripts, active CSS and every other function still removed or refused; the cairo export keeps colours, shapes and references; fixpoint. - B5 `sheet.edit` `remove` refused atomically (`has_dependents`, document unchanged) while `dependents` holds anything but descendants; a removal never adds a referential issue (property test). - B6 (A6 scope superseded by E1) A6: real Inkscape 1.4.3 exports committed with their generator and provenance; Illustrator and Figma are not produced or imitated; A6 stays open until the owner's files arrive. - B7 Wasm: `--remove-name-section` only; the 600 000-byte cap and `size.test.ts` unchanged. - B8 Still: no SQL change, no protected reader modified (A13), the N-1 copies and frozen oracle files untouched (declared changes applied in tests only), no DEV operation, no merge. ### After the reviews of 5281337 (security BLOCK(1) HIGH, verifier ECARTS(2)) Delta under review: `5281337..HEAD`. - B9 A `url(` is kept only in its strict spelling (`sanitize::local_url_target`); every other spelling a browser could normalise (`%XX`, tab, space or unbalanced quote inside, empty or non-ASCII id) is active content; `url(` or `rgb(` glued to a longer name (ASCII or not) is another function; a colour is not glued to what follows; the composer refuses, fail-closed, a canvas keeping a reference outside its scope (`unscoped_reference`). Tests written apart from the reader (`svg_clean::every_url_spelling_but_the_strict_one_is_refused`, `svg_scope::every_reference_a_browser_reads_stays_in_its_view`). - B10 The verifier's doc drift fixed (RUST.md §12.1, §12.4, §12.5, §12.6; exports README); the MEDIUM (scope unique per document only) recorded as a requirement for any page inlining two documents (contract §10, RUST.md §12.7). ## Owner decisions at finalisation (2026-10-30, contract §17.5) Brief « V1-2.2 : finalisation et intégration A6 Figma » after the final review of `05de816` (verifier ECARTS(3), security PASS). Delta under review: `98060d7..HEAD`. The criteria above still hold; these are added, and C1 amends D1 and B6. - C1 (superseded by E1 for the A6 scope) A6 requires Inkscape (met, B6), Figma and Illustrator; Affinity is optional. Figma: the owner's two raw exports `owner/figma-web-20261030-default.svg` and `-ids.svg`, never edited, committed as permanent fixtures with fixed expectations. Illustrator: the real Adobe Illustrator only (VectorCraft is not equivalent). A6 stays open, and V1-2.2 is not VERIFIED, until the Illustrator exports are committed and pass. - C2 `maskUnits`, `maskContentUnits`, `clipPathUnits` allowed with `userSpaceOnUse` / `objectBoundingBox` only, any other value removed (owner go after the proposal); the Figma stored forms render pixel-identical to the raw files. - C3 A `url(` glued to a longer name is removed from every attribute (`sanitize::urls_unglued`, built on `url_openings`, no second parser); the composer comment says when `unscoped_reference` can happen; tests: glued in ordinary attributes, valid, absent, encoded and escaped spellings, attributes with no reference, canvas, preview and PDF composition of the same drawings, the fail-closed branch reached. - C4 The audit sentence the floor guard read as a suppression is reworded; the guard is not disabled or waived. - C5 Still: no SQL change, no protected reader (A13), N-1 copies, frozen oracles or equine historical data modified; no DEV operation, no merge, no deployment, no V1-2.3. ## Final owner decisions (brief « V1-2.2 : arbitrage définitif A6 et correction visibility », 2026-10-30, on `81f7639`) - E1 A6 scope, final: the tested perimeter is Figma (the owner's two raw exports `owner/figma-web-20261030-{default,ids}.svg`), Inkscape 1.4.3 (three real exports and their generator), cairo 1.18.4 and ImageMagick 7.1.2-18 (real exports, `generate.sh`). Adobe Illustrator and Affinity are optional: never declared compatible or validated without a real export read by the suite; their absence does not block V1-2.2. The `owner/` folder, its procedure (Illustrator `presentation` / `internal-css`, Affinity `web` / `hq`) and the suite reading any file put there stay, for a later test. - E2 Root visibility: a root `visibility` other than `visible` is refused by the shared reader (`root_visibility`) before a drawing can be verified or published; the cleaning, the verdict, the preview, the canvas and the PDF snapshot gate answer it; both composers refuse such a root (fail-closed). No historical asset, oracle or golden changes. - E3 Still: no SQL change, no DEV operation, no historical resource modified, no merge, no deployment, no V1-2.3.