chore(memory): V1-2.2 reserved ids evidence, mutations, contract, TODO
This commit is contained in:
1 parent
6ed4d21eb3
commit
81f7639c75
5 files changed
+155
No files matched your search
@@ -0,0 +1,36 @@
|
||||
# V1-2.2 reserved ids (owner brief 2026-10-30), mutation run (evidence
|
||||
# .claude/audits/2026-10-30-v1-2-2-reserved-ids-evidence.md §4): each mutant is applied to its source
|
||||
# file, its cargo suite runs (`features` set when the suite needs them), the file is restored. Run
|
||||
# from the repo root.
|
||||
import subprocess
|
||||
PDF='--features pdf-read,pdf-write'
|
||||
muts=[
|
||||
('K1 reader skips the reserved check','crates/core/src/anatomy/svg/mod.rs',' refs::check_reserved_ids(&sanitized.root)?;\n','','svg_reserved_ids',''),
|
||||
('K2 cleaning skips the reserved check','crates/core/src/anatomy/svg/clean.rs','.and_then(|()| check_reserved_ids(&read.root))','','svg_reserved_ids',''),
|
||||
('K3 exact case only','crates/core/src/anatomy/svg/refs.rs','.any(|reserved| id.eq_ignore_ascii_case(reserved))','.any(|reserved| id == *reserved)','svg_reserved_ids',''),
|
||||
('K4 prefix instead of exact name','crates/core/src/anatomy/svg/refs.rs','.any(|reserved| id.eq_ignore_ascii_case(reserved))','.any(|reserved| id.to_ascii_lowercase().starts_with("osteo-"))','svg_reserved_ids',''),
|
||||
('K5 root id not checked','crates/core/src/anatomy/svg/refs.rs',' element.attr("id").is_some_and(is_reserved_id)\n || element',' element','svg_reserved_ids',''),
|
||||
('K6 descendants not checked','crates/core/src/anatomy/svg/refs.rs',' || element.element_children().any(holds_reserved_id)',' || false','svg_reserved_ids',''),
|
||||
('K7 highlight composes a reserved id','crates/core/src/anatomy/compose.rs',' if holds_reserved_id(&asset) {\n return Err(ComposeError::ReservedId);\n }\n','','svg_reserved_ids',''),
|
||||
('K8 canvas composes a reserved id','crates/core/src/anatomy/compose.rs',' if holds_reserved_id(asset) {\n return Err(ComposeError::ReservedId);\n }\n','','svg_reserved_ids',''),
|
||||
('K9 pre-fix composer restored (no guard, halo skipped when the drawing has one)','crates/core/src/anatomy/compose.rs',' if holds_reserved_id(&asset) {\n return Err(ComposeError::ReservedId);\n }\n','','svg_reserved_ids','',
|
||||
(' if !append_to_first_defs(root) {',' if holds_reserved_id(root) {\n return;\n }\n if !append_to_first_defs(root) {')),
|
||||
('K10 halo not written','crates/core/src/anatomy/compose.rs',' add_halo_filter(&mut asset);','','pdf_session',PDF),
|
||||
('K11 reason renamed','crates/core/src/anatomy/svg/tree.rs','Self::ReservedId => "reserved_id"','Self::ReservedId => "dangling_reference"','svg_reserved_ids',''),
|
||||
]
|
||||
for name,path,old,new,suite,features,*more in muts:
|
||||
src=open(path).read()
|
||||
mutant=src
|
||||
for o,n in [(old,new)]+list(more):
|
||||
if mutant.count(o)!=1:
|
||||
print(name,'ANCHOR NOT FOUND x',mutant.count(o)); mutant=None; break
|
||||
mutant=mutant.replace(o,n)
|
||||
if mutant is None:
|
||||
continue
|
||||
open(path,'w').write(mutant)
|
||||
try:
|
||||
r=subprocess.run(['bash','-c',f'. scripts/rust-env.sh && cargo test -q -p faunosteo-core {features} --test {suite} 2>&1 | tail -3'],capture_output=True,text=True)
|
||||
out=r.stdout
|
||||
print(f"{name} ({suite}): {'KILLED' if 'FAILED' in out else ('COMPILE-ERR' if 'could not compile' in out else 'SURVIVED')}", flush=True)
|
||||
finally:
|
||||
open(path,'w').write(src)
|
||||
@@ -0,0 +1,64 @@
|
||||
# V1-2.2 reserved ids: evidence (2026-10-30)
|
||||
|
||||
Owner brief « V1-2.2 : correction de sécurité PDF et poursuite A6 » on `2f1f076`. Contract
|
||||
`.claude/tasks/contracts/2026-10-30-v1-2-2-reserved-ids.md`; docs RUST.md §12.9.
|
||||
|
||||
## 1. Audit
|
||||
|
||||
- Written by the engine next to the drawing's ids: `osteo-halo` only (`compose::compose_highlight`, PDF view,
|
||||
rasterised as a document of its own, drawing ids kept). Before the fix `ensure_halo_filter` returned early when
|
||||
the drawing held a `filter#osteo-halo`; otherwise the filter went into the first `<defs>` (or a new one placed first),
|
||||
so an element holding the id earlier in document order won `url(#osteo-halo)`.
|
||||
- Not colliding: the canvas scopes every drawing id to `fv.<view>.` (page ids never start with `fv.`); the annotation
|
||||
layer writes no `id`, and its `data-*` cannot be forged (the reader removes every `data-*`); the filter's `result`
|
||||
names `haloWide` / `haloTight` resolve inside their filter only; `class="detail-zone"` styles nothing in the app CSS.
|
||||
- Historical drawings: 75 committed SVG files; `osteo-overlays` in 11 of them (legacy editor group), among them
|
||||
`supabase/seed/anatomical-sheets/equine/draft/assets/horse.svg` (sha256 `0ea5202f…`, the DEV object). `osteo-halo` in
|
||||
none but the hostile fixture `crates/core/tests/fixtures/svg/hostile/osteo-halo-id.svg`. Hence an exact reserved set,
|
||||
not an `osteo-*` namespace.
|
||||
|
||||
## 2. Pixel proof (Chromium 156.0.8078.4, Image + canvas as `browserRasterizer.ts`, 1200 × 943, main view, `hip` selected, halo on)
|
||||
|
||||
Composed SVG written by a throwaway integration test (never committed) from the equine drawing with a body injected
|
||||
after the root's opening tag; pixels within ±24 per channel of `#b85a3f` counted.
|
||||
|
||||
| Drawing | Before (`2f1f076`) | After |
|
||||
|---|---|---|
|
||||
| equine, unchanged | composed, 1602 px | composed, 1602 px, SVG byte-identical |
|
||||
| + `<filter id="osteo-halo"><feColorMatrix values="0 …0"/></filter>` | composed, **0 px** (marker erased) | refused `reserved_id` |
|
||||
| + `<g id="osteo-halo"/><defs/>` | composed, 825 px (halo lost) | refused `reserved_id` |
|
||||
|
||||
## 3. Tests
|
||||
|
||||
`svg_reserved_ids` 9 tests; `pdf_session` + 1 (`the_pdf_refuses_a_reserved_id_and_keeps_its_own_halo`);
|
||||
`anatomy_compose` R5.7 test renamed (`the_halo_filter_is_written_once_and_a_composed_root_is_refused`, ledger row
|
||||
updated); `svg_clean` corpus line and `svg_sanitiser` declared divergence for `osteo-halo-id.svg`; core-wasm
|
||||
`preview.test.ts` three spellings on the shipped module.
|
||||
|
||||
## 4. Mutations (`2026-10-30-v1-2-2-mutations-reserved-ids.py`)
|
||||
|
||||
11 of 11 killed: reader check removed, cleaning check removed, exact case only, `osteo-` prefix, root id unchecked,
|
||||
descendants unchecked, highlight guard removed, canvas guard removed, pre-fix composer restored (guard removed and halo
|
||||
skipped when the drawing holds one), halo not written, reason renamed. A first K9 (« skip the halo when the root has an
|
||||
id ») survived: no tested drawing has a root id, a mutant with no meaning for the fix; replaced by the pre-fix restore.
|
||||
|
||||
## 5. Gates
|
||||
|
||||
- `pnpm rust:check`: green (fmt, clippy `-D warnings` on every feature set, 2032 tests summed over the feature passes,
|
||||
ts-rs export, cargo deny).
|
||||
- `pnpm check`: green (typecheck, core-wasm 65, supabase 128, app 566, lint, build). First run failed on
|
||||
`r5.census.test.ts`: the ledger still named the renamed cargo test; row updated.
|
||||
- Module: 559 360 → 560 015 B gzip -9 (+655 B), 1 513 522 → 1 513 968 B raw; Node's gzip 569 350 B (budget 600 000).
|
||||
- `pnpm check:all` on the working tree (code as committed): green, e2e:ui PASSED, app image, worker sandbox tests and
|
||||
runtime image; e2e:shell not run (needs the isolated stack, no change in its scope).
|
||||
|
||||
## 6. Independent reviews (fresh, Opus: the pinned Fable model was out of credits)
|
||||
|
||||
- Verifier: ECARTS(1) LOW, C8: a doc comment in the new `pdf_session.rs` helper held the shell expansion of `id` (an
|
||||
unquoted heredoc while writing it), leaking the local uid and groups; fixed before any commit, the diff scanned for
|
||||
other expansions (none). C1-C7, C9, C10 met; floor guard clean on the diff.
|
||||
- Security: PASS, no regression or weakened control. Reported, pre-existing, owner decision: MEDIUM root `visibility`
|
||||
(a drawing `<svg visibility="hidden">` with `visibility="visible"` children reads clean and the appended marker layer
|
||||
inherits `hidden`: 0 highlight pixels in the PDF, markers gone in the canvas too); LOW root `stroke*` inheritance onto
|
||||
the point hitbox; LOW the drawing chooses which `<defs>` receives the halo (sRGB vs linearRGB, cosmetic); LOW intended
|
||||
behaviour change (re-export of an archive or a logo holding the id refused).
|
||||
@@ -489,3 +489,4 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp
|
||||
## 2026-10-30
|
||||
- V1-2.2 owner decisions on 05de816: BDR-087 canonical stored SVG, LRN-099→LRN-100 strict reference grammar. Final review (Opus, Fable out of credits): verifier ECARTS(3) = A6 open, B9 LOW f1ef6a4 glued url( reader/composer mismatch fail-closed, FLOOR prose FP; security PASS (MEDIUM per-document prefix, 5 LOW). 05de816 = f1ef6a4 code. A6 not met. No fix, STOP at checkpoint.
|
||||
- V1-2.2 finalisation 2026-10-30: Figma default Clean, ids Cleanable (g@id), pixel-identical after maskUnits/maskContentUnits/clipPathUnits allowed (BDR-088). Glued url( removed in every attribute (urls_unglued), LRN-101. check:all green 7d9ab8c. Verifier ECARTS(2): A6 Illustrator, doc drift fixed. Security PASS, pre-existing MEDIUM PDF halo id osteo-halo for owner. Not VERIFIED. STOP.
|
||||
- V1-2.2 K reserved ids 2026-10-30: drawing filter#osteo-halo erased PDF marker (0 px Chromium), g#osteo-halo before defs lost halo. Reader refuses reserved_id (exact set, ASCII case), both composers fail-closed, halo always engine's. 08efd9a. check:all green, mutations 11/11, verifier ECARTS(1) LOW leaked id expansion fixed, security PASS + pre-existing MEDIUM root visibility hides markers (owner). A6 open: Illustrator.
|
||||
@@ -587,6 +587,12 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet
|
||||
- [x] J4 FLOOR false positive: reword `.claude/audits/2026-10-29-v1-2-2-arbitrations-security.md:225`, guard kept
|
||||
- [x] J5 memory: BDR-087 checked, LRN-100 superseded after J2; per-document prefix requirement kept
|
||||
- [ ] J6 gates: full cargo, svg suites, mutations, wasm + ts-rs, size < 600 000, check:all (DEV-isolated steps only), fresh independent review; commit + push; STOP (A6 open: Illustrator). Done 7d9ab8c/f976f33: check:all green, verifier ECARTS(2) (A6 Illustrator; §12.4 drift fixed after), security PASS (new pre-existing MEDIUM: PDF halo id `osteo-halo` reusable by a drawing, owner decision); left open until Illustrator
|
||||
- [ ] K reserved ids and A6 Illustrator (brief « V1-2.2 : correction de sécurité PDF et poursuite A6 », 2026-10-30, on 2f1f076): fixtures and isolated stacks only, DEV untouched; no merge; STOP at checkpoint, no V1-2.3
|
||||
- [x] K1 audit: `osteo-halo` written by `compose_highlight` only (PDF view keeps the drawing's ids); `has_halo_filter` skips the injection when the drawing defines `filter#osteo-halo` (hijack), a non-filter `#osteo-halo` before the first `<defs>` wins resolution; historical drawings carry `osteo-overlays` (DEV equine object included) → exact reserved set, never an `osteo-*` namespace; canvas scoped `fv.<view>.`, layer writes no id, filter `result` names local to the filter
|
||||
- [x] K2 reader: `SvgRejection::ReservedId` (`reserved_id`), `refs::check_reserved_ids` (ASCII case folded, the id grammar is ASCII) in `read_svg` and in `clean_svg` after the active classification; reaches verdict, preview, loaded sheet, upload tool, PDF snapshot gate
|
||||
- [x] K3 composer fail-closed: `compose_highlight` refuses a tree holding a reserved id (`ComposeError::ReservedId`), always writes its own halo (`has_halo_filter` removed); ops mapping; TS-era "never duplicated" test becomes the refusal
|
||||
- [x] K4 tests: valid, filter + other elements (root included), references, adversarial spellings (case, entities, whitespace, `xml:id`, prefixed names, look-alikes), composition, PDF session (refusal + internal halo kept), equine + sha256, declared divergence for `osteo-halo-id.svg`, pixel proof in Chromium (before / after)
|
||||
- [ ] K5 docs (RUST.md §12, contract §9.x hard rejections, ANNOTATION-RENDERING), Illustrator `presentation` / `internal-css` owner steps; gates (cargo, svg, mutations, wasm size, check:all DEV-isolated), fresh verifier + security on final HEAD; memory; commit + push; STOP (A6 open until Illustrator). State: check:all green, verifier ECARTS(1) LOW fixed (leaked `id` expansion in a comment), security PASS + pre-existing MEDIUM root `visibility` hides every marker (owner decision), LOW root stroke, LOW halo defs placement
|
||||
- [ ] 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)
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# Contract: V1-2.2 reserved ids (PDF halo collision)
|
||||
|
||||
Owner brief « V1-2.2 : correction de sécurité PDF et poursuite A6 », 2026-10-30, on `2f1f076`
|
||||
(branch `feature/v1-2-anatomical-sheets`). Diff under review: the working tree against `2f1f076`.
|
||||
|
||||
## Problem
|
||||
|
||||
`crates/core/src/anatomy/compose.rs::compose_highlight` (PDF view) keeps the drawing's ids and
|
||||
writes its halo filter `osteo-halo` next to them. Before the fix it skipped writing its filter when
|
||||
the drawing already held a `filter#osteo-halo`, and a non-filter element holding the id before the
|
||||
first `<defs>` won `url(#osteo-halo)` resolution. A sheet drawing could thus replace, divert or hide
|
||||
the PDF markers.
|
||||
|
||||
## Criteria (each must hold on the diff)
|
||||
|
||||
- C1 The shared SVG reader (`anatomy/svg/mod.rs::read_svg`) refuses any kept element (root included)
|
||||
whose `id` is a reserved id, with a closed, stable reason `reserved_id`
|
||||
(`SvgRejection::ReservedId`).
|
||||
- C2 The decision is exact-name (reserved set, not a prefix): historical drawings holding
|
||||
`osteo-overlays` (the equine draft drawing, sha256 `0ea5202f…`, which is the DEV object) still read
|
||||
with no removal; no historical asset changes byte-wise.
|
||||
- C3 No bypass: letter case (ASCII), XML character references, whitespace, look-alike or invisible
|
||||
characters, `xml:id`, prefixed attributes or prefixed SVG elements, CSS escapes and percent-encoded
|
||||
`url(` targets either refuse the drawing or never leave a reserved id in the tree a composer
|
||||
receives.
|
||||
- C4 `clean_svg` (upload cleaning) refuses it (`reserved_id`) with no stored form, after active
|
||||
content is classified; the verdict, the preview, the loaded sheet, the upload tool and the PDF
|
||||
snapshot gate (`pdf/write/input.rs`, `snapshot_invalid` / `asset reserved_id`) answer it through
|
||||
the same reader.
|
||||
- C5 Composers are fail-closed: `compose_highlight` and `compose_canvas` refuse a tree holding a
|
||||
reserved id (`ComposeError::ReservedId`), and the highlight always writes the engine's own filter;
|
||||
no path remains where a drawing-supplied element named `osteo-halo` reaches the PDF view.
|
||||
- C6 No existing control weakened: every other reader rule, cap, reference check, scoping and the
|
||||
PDF/archive readers unchanged; frozen oracles, R4 digests, step6 goldens, N-1 copies untouched
|
||||
(declared divergences applied in tests only).
|
||||
- C7 Other internal collisions audited (ids the composition writes, canvas scope `fv.`, layer
|
||||
attributes, filter `result` names) and either covered or argued absent.
|
||||
- C8 Tests cover: a valid drawing; `filter id="osteo-halo"`; the id on other elements; references
|
||||
to it; adversarial spellings; the PDF keeping its own halo (behavioural, through the export
|
||||
session); equine non-regression and historical fingerprints; the shipped wasm module.
|
||||
- C9 Docs updated (RUST.md §12.9, V1-2 contract §9.2 table and closed codes, ANNOTATION-RENDERING);
|
||||
the R5 ledger target renamed with the test.
|
||||
- C10 A6: the owner README gives precise Illustrator steps for `…-presentation.svg` and
|
||||
`…-internal-css.svg` (names and variants unchanged), no fabricated Illustrator file, A6 not claimed.
|
||||
|
||||
## Out of scope
|
||||
|
||||
No SQL, no Supabase DEV, no worker, no merge, no V1-2.3.
|
||||
Reference in new issue
Block a user