From f1bb19b30b2843f762535ffd4659d528971dc8c2 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 31 Oct 2026 23:39:40 +0100 Subject: [PATCH] chore(memory): V1-2.2 three MEDIUM evidence, lot B patch, contract, TODO, journal --- .../2026-10-30-v1-2-2-lot-b-isolation.patch | 1293 +++++++++++++++++ ...026-10-30-v1-2-2-mutations-three-medium.py | 56 + ...2026-10-30-v1-2-2-three-medium-evidence.md | 82 ++ .../pixel2.mjs | 47 + .../zz-junction.spec.ts | 44 + .../zz-real-pdf.test.ts | 59 + .claude/memory/journal.md | 3 + .claude/tasks/TODO.md | 8 + .../2026-10-30-v1-2-2-three-medium.md | 60 + 9 files changed, 1652 insertions(+) create mode 100644 .claude/audits/2026-10-30-v1-2-2-lot-b-isolation.patch create mode 100644 .claude/audits/2026-10-30-v1-2-2-mutations-three-medium.py create mode 100644 .claude/audits/2026-10-30-v1-2-2-three-medium-evidence.md create mode 100644 .claude/audits/2026-10-30-v1-2-2-three-medium-tools/pixel2.mjs create mode 100644 .claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-junction.spec.ts create mode 100644 .claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-real-pdf.test.ts create mode 100644 .claude/tasks/contracts/2026-10-30-v1-2-2-three-medium.md diff --git a/.claude/audits/2026-10-30-v1-2-2-lot-b-isolation.patch b/.claude/audits/2026-10-30-v1-2-2-lot-b-isolation.patch new file mode 100644 index 00000000..78591c53 --- /dev/null +++ b/.claude/audits/2026-10-30-v1-2-2-lot-b-isolation.patch @@ -0,0 +1,1293 @@ +diff --git a/apps/app/e2e/harness/canvas.html b/apps/app/e2e/harness/canvas.html +new file mode 100644 +index 0000000..86ee85f +--- /dev/null ++++ b/apps/app/e2e/harness/canvas.html +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ Canvas harness ++ ++ ++
++ ++ ++ +diff --git a/apps/app/e2e/harness/canvas.tsx b/apps/app/e2e/harness/canvas.tsx +new file mode 100644 +index 0000000..8f033c0 +--- /dev/null ++++ b/apps/app/e2e/harness/canvas.tsx +@@ -0,0 +1,73 @@ ++/** ++ * Test page for the editor canvas in a real browser (e2e/ui/canvas-clicks.spec.ts): the ++ * bundled equine sheet in AnatomyCanvas, its drawing's root given the attributes of the ++ * chosen `?drawing=` case, every click recorded. Served by the Vite dev server only ++ * (`/e2e/harness/canvas.html`); the build has a single entry, index.html, so this page ++ * never ships. ++ */ ++import { StrictMode, useState } from 'react' ++import { createRoot } from 'react-dom/client' ++import '@/styles/index.css' ++import AnatomyCanvas from '@/components/canvas/AnatomyCanvas' ++import { bundledSheetProvider } from '@/sheets/provider' ++import { setSheetProvider, useSheet } from '@/sheets/useSheet' ++ ++/** ++ * Root attributes of the drawing per case (V1-2.2 owner brief 2026-10-30, defect 2): the ++ * reported giant stroke, the same width with no stroke paint (an invisible enlarged ++ * surface), and the hiding stroke properties. ++ */ ++const DRAWINGS: Record = { ++ plain: '', ++ 'giant-stroke': 'stroke="#ff00ff" stroke-width="2000"', ++ 'invisible-stroke': 'stroke-width="2000"', ++ 'hidden-stroke': 'stroke="#ff00ff" stroke-width="2000" stroke-opacity="0"', ++} ++ ++const params = new URLSearchParams(location.search) ++const rootAttrs = DRAWINGS[params.get('drawing') ?? 'plain'] ?? '' ++const viewId = params.get('view') ?? 'main' ++ ++setSheetProvider({ ++ async getReferenceSheet(speciesId) { ++ const sheet = await bundledSheetProvider.getReferenceSheet(speciesId) ++ if (!sheet || rootAttrs === '') return sheet ++ const assets = Object.fromEntries( ++ Object.entries(sheet.assets).map(([id, text]) => [ ++ id, ++ text.replace('([]) ++ return ( ++
++

Canvas harness

++ {/* A fixed height: the canvas never moves when the first click is listed. */} ++ ++ {clicks.join(' ')} ++ ++
++ {sheet.status === 'ready' && ( ++ setClicks((all) => [...all, id])} ++ /> ++ )} ++
++ ++ ) ++} ++ ++createRoot(document.getElementById('root') as HTMLElement).render( ++ ++ ++ , ++) +diff --git a/apps/app/e2e/playwright.ui.config.ts b/apps/app/e2e/playwright.ui.config.ts +index 4b61a06..4ed2c31 100644 +--- a/apps/app/e2e/playwright.ui.config.ts ++++ b/apps/app/e2e/playwright.ui.config.ts +@@ -1,11 +1,12 @@ + /** + * `pnpm e2e:ui`: Chromium against a Vite dev server with no backend, on a + * loopback port of its own (never the owner's `pnpm dev` on 5173, never +- * reused): the Dialog test page and the local tool. docs/development/BROWSER_TESTS.md. ++ * reused): the Dialog test page, the local tool and the canvas click proof (also on ++ * Firefox and WebKit when installed). docs/development/BROWSER_TESTS.md. + */ + import { defineConfig } from '@playwright/test' + import type { GuardOptions } from './support/browser' +-import { PROJECTS } from './support/browser' ++import { CLICK_PROJECTS, PROJECTS } from './support/browser' + + const ORIGIN = 'http://127.0.0.1:5191' + +@@ -27,7 +28,7 @@ export default defineConfig({ + trace: 'retain-on-failure', + screenshot: 'only-on-failure', + }, +- projects: PROJECTS, ++ projects: [...PROJECTS, ...CLICK_PROJECTS], + webServer: { + command: 'node_modules/.bin/vite --host 127.0.0.1 --port 5191 --strictPort', + cwd: '..', +diff --git a/apps/app/e2e/support/browser.ts b/apps/app/e2e/support/browser.ts +index 674c418..fa5e182 100644 +--- a/apps/app/e2e/support/browser.ts ++++ b/apps/app/e2e/support/browser.ts +@@ -3,11 +3,14 @@ + * the two Chromium projects, the request guard every test runs under, the axe + * gate, and the focus and layout probes. + */ ++import { existsSync } from 'node:fs' + import AxeBuilder from '@axe-core/playwright' + import { + devices, + expect, ++ firefox, + test as base, ++ webkit, + type Page, + type Project, + } from '@playwright/test' +@@ -37,6 +40,51 @@ export const PROJECTS: Project[] = [ + }, + ] + ++/** ++ * The canvas click proof (V1-2.2, e2e/ui/canvas-clicks.spec.ts) also runs on Firefox and ++ * WebKit, desktop, and on the WebKit phone, when the pinned engine is installed ++ * (`playwright install firefox webkit`, no sudo, never `--with-deps`). A missing engine is ++ * named in the run's output, never passed silently. ++ */ ++const CANVAS_CLICKS = /canvas-clicks\.spec\.ts$/ ++ ++function installed(name: string, executable: string): boolean { ++ const present = existsSync(executable) ++ if (!present) console.warn(`canvas clicks: ${name} is not installed, its projects do not run`) ++ return present ++} ++ ++export const CLICK_PROJECTS: Project[] = [ ++ ...(installed('firefox', firefox.executablePath()) ++ ? [ ++ { ++ name: 'firefox-desktop', ++ testMatch: CANVAS_CLICKS, ++ grepInvert: /@phone/, ++ use: { ...devices['Desktop Firefox'], viewport: { width: 1280, height: 800 } }, ++ }, ++ ] ++ : []), ++ ...(installed('webkit', webkit.executablePath()) ++ ? [ ++ { ++ name: 'webkit-desktop', ++ testMatch: CANVAS_CLICKS, ++ grepInvert: /@phone/, ++ use: { ...devices['Desktop Safari'], viewport: { width: 1280, height: 800 } }, ++ }, ++ { ++ name: 'webkit-375', ++ testMatch: CANVAS_CLICKS, ++ use: { ++ ...devices['iPhone SE'], ++ viewport: { width: 375, height: 667 }, ++ }, ++ }, ++ ] ++ : []), ++] ++ + export interface GuardOptions { + /** Origins the page may reach; every other request is aborted and fails the test. */ + allowedOrigins: string[] +diff --git a/apps/app/e2e/tsconfig.json b/apps/app/e2e/tsconfig.json +index ea6716e..3bae59f 100644 +--- a/apps/app/e2e/tsconfig.json ++++ b/apps/app/e2e/tsconfig.json +@@ -7,5 +7,5 @@ + "@/*": ["src/*"] + } + }, +- "include": ["."] ++ "include": [".", "../src/sheets/virtual-sheet.d.ts"] + } +diff --git a/apps/app/e2e/ui/canvas-clicks.spec.ts b/apps/app/e2e/ui/canvas-clicks.spec.ts +new file mode 100644 +index 0000000..848f59d +--- /dev/null ++++ b/apps/app/e2e/ui/canvas-clicks.spec.ts +@@ -0,0 +1,133 @@ ++import { expect, test } from '../support/browser' ++import type { Page } from '@playwright/test' ++ ++// V1-2.2 owner brief 2026-10-30, defect 2: a click on the editor canvas records the marker ++// under the pointer, never another one, whatever stroke the drawing's root sets. Real ++// clicks (taps on the phone project) on the bundled equine sheet in AnatomyCanvas ++// (e2e/harness/canvas.tsx); run on Chromium, Firefox and WebKit when installed. ++ ++/** ++ * The points of the equine main view whose visible disc no other marker covers, in document ++ * order. The three vertebral junctions sit on the edge of a zone painted after them: part of ++ * their disc records the zone (pre-existing, owner decision, see the fixme below). ++ */ ++const POINTS = [ ++ 'hind-fetlock', ++ 'hock', ++ 'stifle', ++ 'hip', ++ 'sacroiliac', ++ 'shoulder', ++ 'elbow', ++ 'carpus', ++ 'fore-fetlock', ++ 'fore-sesamoids', ++] ++const JUNCTIONS = ['l6-s1', 't18-l1', 'c7-t1'] ++const DRAWINGS = ['plain', 'giant-stroke', 'invisible-stroke', 'hidden-stroke'] ++ ++type Point = { x: number; y: number } ++ ++async function open(page: Page, drawing: string) { ++ await page.goto(`/e2e/harness/canvas.html?drawing=${drawing}`) ++ await expect( ++ page.locator('[data-testid="anatomy-canvas"] [data-anno-id="hock"]').first(), ++ ).toBeAttached() ++} ++ ++/** The centre of a marker's visible shape on screen (a point's twin shares its hitbox's). */ ++async function centreOf(page: Page, id: string): Promise { ++ const box = await page ++ .locator(`[data-testid="anatomy-canvas"] [data-anno-id="${id}"]`) ++ .last() ++ .boundingBox() ++ if (!box) throw new Error(`${id} has no box`) ++ return { x: box.x + box.width / 2, y: box.y + box.height / 2 } ++} ++ ++async function press(page: Page, at: Point, touch: boolean) { ++ if (touch) await page.touchscreen.tap(at.x, at.y) ++ else await page.mouse.click(at.x, at.y) ++} ++ ++/** The ids recorded by the clicks so far. */ ++async function recorded(page: Page): Promise { ++ const text = (await page.getByTestId('clicks').textContent()) ?? '' ++ return text.split(' ').filter(Boolean) ++} ++ ++async function clickRecords(page: Page, at: Point, touch = false) { ++ const before = (await recorded(page)).length ++ await press(page, at, touch) ++ // A click that records nothing leaves the list as it was; wait out the handler. ++ await page.waitForTimeout(50) ++ return (await recorded(page)).slice(before) ++} ++ ++test.describe('canvas clicks', () => { ++ for (const drawing of DRAWINGS) { ++ test(`a click on the hock records the hock (${drawing})`, async ({ page }, info) => { ++ await open(page, drawing) ++ const touch = info.project.use.hasTouch === true ++ expect(await clickRecords(page, await centreOf(page, 'hock'), touch)).toEqual(['hock']) ++ }) ++ ++ test(`every point clear of the zones records itself (${drawing})`, async ({ page }) => { ++ await open(page, drawing) ++ for (const id of POINTS) { ++ expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([id]) ++ } ++ }) ++ ++ test(`a click on the drawing away from the markers records nothing (${drawing})`, async ({ ++ page, ++ }) => { ++ await open(page, drawing) ++ const box = await page.getByTestId('anatomy-canvas').boundingBox() ++ if (!box) throw new Error('no canvas') ++ // The top left corner and the middle of the belly hold no marker. ++ for (const [fx, fy] of [ ++ [0.03, 0.05], ++ [0.5, 0.55], ++ ] as const) { ++ const at = { x: box.x + box.width * fx, y: box.y + box.height * fy } ++ expect(await clickRecords(page, at), `${fx},${fy}`).toEqual([]) ++ } ++ }) ++ } ++ ++ test('two close points each record themselves, their shared edge goes to the later one', async ({ ++ page, ++ }) => { ++ await open(page, 'giant-stroke') ++ const fetlock = await centreOf(page, 'fore-fetlock') ++ const sesamoids = await centreOf(page, 'fore-sesamoids') ++ expect(await clickRecords(page, fetlock)).toEqual(['fore-fetlock']) ++ expect(await clickRecords(page, sesamoids)).toEqual(['fore-sesamoids']) ++ // Halfway, outside both visible discs and inside both hitboxes: document order, the ++ // later marker is on top. One id, never two. ++ const half = { x: (fetlock.x + sesamoids.x) / 2, y: (fetlock.y + sesamoids.y) / 2 } ++ expect(await clickRecords(page, half)).toEqual(['fore-sesamoids']) ++ }) ++ ++ test('a click on a vertebral junction records the junction', async ({ page }) => { ++ test.fixme( ++ true, ++ 'V1-2.2 finding: the zones are painted and hit after the points; c7-t1 records « thoracic » at its centre in Firefox and WebKit, and up to half of each junction disc records a zone in every engine (owner decision on the capture order)', ++ ) ++ await open(page, 'plain') ++ for (const id of JUNCTIONS) { ++ expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([id]) ++ } ++ }) ++ ++ // @phone: the desktop projects leave it out (grepInvert), the touch projects run it. ++ test('a tap on the hock records the hock @phone', async ({ page }) => { ++ for (const drawing of DRAWINGS) { ++ await open(page, drawing) ++ expect(await clickRecords(page, await centreOf(page, 'hock'), true), drawing).toEqual([ ++ 'hock', ++ ]) ++ } ++ }) ++}) +diff --git a/apps/app/tests/helpers/svgTree.ts b/apps/app/tests/helpers/svgTree.ts +index 990e7e0..acf678c 100644 +--- a/apps/app/tests/helpers/svgTree.ts ++++ b/apps/app/tests/helpers/svgTree.ts +@@ -126,3 +126,49 @@ export function withIdsScopedPerView(tree: unknown, viewId: string): unknown { + visit(copy) + return copy + } ++ ++const HITBOX_DECLARED = { stroke: 'none', 'pointer-events': 'visibleFill' } ++ ++/** A point hitbox of the R3 layer: a circle capturing on `all` with no stroke of its own. */ ++function isR3Hitbox(node: unknown): node is { name: string; attrs: Record } { ++ const n = node as { name?: string; attrs?: Record } ++ return n.name === 'circle' && n.attrs?.['pointer-events'] === 'all' && !('stroke' in n.attrs) ++} ++ ++/** ++ * Owner brief 2026-10-30 (V1-2.2, three MEDIUM): each point hitbox the composers draw declares ++ * `stroke="none"` and `pointer-events="visibleFill"`. Applied to a frozen layer (a deep copy). ++ * Mirrors `crates/core/tests/common/svg_tree.rs`. ++ */ ++export function withDeclaredHitboxes(layer: unknown): unknown { ++ const copy = structuredClone(layer) as { children?: unknown[] } ++ for (const child of copy.children ?? []) { ++ if (isR3Hitbox(child)) Object.assign(child.attrs, HITBOX_DECLARED) ++ } ++ return copy ++} ++ ++/** ++ * Owner brief 2026-10-30 (V1-2.2, three MEDIUM): the composition root is the engine's. Applied ++ * to a frozen canvas tree (a deep copy): the root keeps its namespaces and `viewBox`; its other ++ * attributes and every child before the layer go into a `` of the drawing; the layer's ++ * hitboxes are declared (`withDeclaredHitboxes`). Mirrors `crates/core/tests/common/svg_tree.rs`. ++ */ ++export function withIsolatedLayer(tree: unknown): unknown { ++ const root = structuredClone(tree) as { ++ ns: string ++ attrs: Record ++ children: unknown[] ++ } ++ const layer = root.children.pop() ++ const kept: Record = {} ++ const moved: Record = {} ++ for (const [name, value] of Object.entries(root.attrs)) { ++ if (name === 'xmlns' || name === 'xmlns:xlink' || name === 'viewBox') kept[name] = value ++ else moved[name] = value ++ } ++ const group = { ns: root.ns, name: 'g', attrs: moved, children: root.children } ++ root.attrs = kept ++ root.children = [group, withDeclaredHitboxes(layer)] ++ return root ++} +diff --git a/apps/app/tests/unit/canvas.trees.test.tsx b/apps/app/tests/unit/canvas.trees.test.tsx +index 93426a8..8482cd4 100644 +--- a/apps/app/tests/unit/canvas.trees.test.tsx ++++ b/apps/app/tests/unit/canvas.trees.test.tsx +@@ -21,7 +21,9 @@ import { + import { + checkR3Golden, + treeOf, ++ withDeclaredHitboxes, + withIdsScopedPerView, ++ withIsolatedLayer, + withTriggerNamesPerLanguage, + type TreeNode, + } from '../helpers/svgTree' +@@ -82,9 +84,10 @@ describe.each(VIEWS)('the %s canvas', (viewId) => { + it('builds the frozen tree with no state', () => { + const build = buildViewSvg(sheet, viewId) + if (!build.ok) throw new Error(`canvas ${viewId}: ${build.failure}`) +- // and the owner's decision 2026-10-29: the drawing's ids scoped to the view ++ // and the owner's decision 2026-10-29: the drawing's ids scoped to the view; the brief ++ // 2026-10-30: the composition root is the engine's, the hitboxes declared + checkR3Golden(`canvas.${viewId}.json`, treeOf(build.svg), (frozen) => +- withIdsScopedPerView(declared(frozen), viewId), ++ withIsolatedLayer(withIdsScopedPerView(declared(frozen), viewId)), + ) + }) + +@@ -94,6 +97,13 @@ describe.each(VIEWS)('the %s canvas', (viewId) => { + layers[name] = await mountedLayer(viewId, states) + } + expect(Object.keys(layers).length).toBeGreaterThan(8) +- checkR3Golden(`canvas.${viewId}.layers.json`, layers, declared) ++ checkR3Golden(`canvas.${viewId}.layers.json`, layers, (frozen) => ++ Object.fromEntries( ++ Object.entries(declared(frozen) as Record).map(([name, layer]) => [ ++ name, ++ withDeclaredHitboxes(layer), ++ ]), ++ ), ++ ) + }) + }) +diff --git a/crates/core/src/anatomy/compose.rs b/crates/core/src/anatomy/compose.rs +index 457f4b0..ca990c7 100644 +--- a/crates/core/src/anatomy/compose.rs ++++ b/crates/core/src/anatomy/compose.rs +@@ -1,9 +1,9 @@ + //! Composition of one view (`docs/ANNOTATION-RENDERING.md`): the sanitised drawing framed on + //! the view, with its annotation layer last. Two forms, as the TypeScript has them: the +-//! editor canvas (`apps/app/src/anatomy/drawing.ts`: a fresh root, `0 0 100 100` when no box +-//! is known, the interactive layer) and the PDF highlight (`packages/anatomy/src/render/ +-//! compose.ts`: the asset's root framed in place, the selected markers only, recoloured, the +-//! halo filter on request). Both take a sanitised tree, never text. ++//! editor canvas (`apps/app/src/anatomy/drawing.ts`: `0 0 100 100` when no frame is known, the ++//! interactive layer) and the PDF highlight (`packages/anatomy/src/render/compose.ts`: no ++//! `viewBox` when no frame is known, the selected markers only, recoloured, the halo filter on ++//! request). Both take a sanitised tree, never text. + //! + //! The canvas is inlined into the page, where `#id` resolves against the whole document: its + //! ids and the references to them are scoped to the view (`fv..`, owner decision +@@ -13,19 +13,23 @@ + //! own and keeps the drawing's ids, so it never holds one the composition writes + //! (`svg::refs::RESERVED_IDS`, the halo filter): the reader refuses such a drawing and both + //! composers refuse such a tree. +-//! Both forms append the marker layer as the root's last child, so the root never hides it: a +-//! root `visibility` other than `visible` is refused by the reader and by both composers. +-//! Both frame the view on `frame::view_frame` (the view's box, else the drawing's `viewBox` read +-//! as a browser reads it), the frame the verdict and the preview measure the annotations against +-//! (V1-2.2 owner brief 2026-10-30, defect 3); the canvas falls back to `0 0 100 100`, the PDF +-//! view to no `viewBox`. The drawing's `preserveAspectRatio` is dropped: the default +-//! `xMidYMid meet` shows the whole frame whatever the box (a `slice` would crop it where the +-//! raster's aspect is clamped or the canvas box is not the frame's). ++//! ++//! The composition root is the engine's (V1-2.2 owner brief 2026-10-30): the namespaces and the ++//! frame only. The frame is `frame::view_frame` (the view's box, else the drawing's `viewBox` read ++//! as a browser reads it), the one the verdict and the preview measure the annotations against; ++//! with no `preserveAspectRatio` the default `xMidYMid meet` shows the whole frame whatever the ++//! box. The drawing's root becomes a ++//! `` keeping its other attributes and its children, and the marker layer (and the PDF's halo ++//! filter, in a `` of the engine) are appended as that group's siblings: no property the ++//! drawing sets, inherited (`stroke-width`, `stroke-opacity`, `stroke-dasharray`, `fill-rule`, ++//! `visibility`…) or acting on a whole group (`opacity`, `display`), reaches a marker or the ++//! halo. A root `visibility` other than `visible` stays refused by the reader and by both ++//! composers (accepted fix of 2026-10-30). + + use std::collections::HashSet; + + use super::frame::view_frame; +-use super::layer::{LayerError, find_view, render_layer}; ++use super::layer::{LayerError, find_view, render_composed_layer}; + pub use super::svg::refs::HALO_FILTER_ID; + use super::svg::refs::holds_reserved_id; + use super::svg::sanitize::check_root_visibility; +@@ -54,8 +58,9 @@ pub enum ComposeError { + /// composes it. Fail-closed: the reader refuses it (`reserved_id`), so only a tree that did + /// not come out of `read_svg` reaches it, a composed view given back included. + ReservedId, +- /// The drawing's root carries a `visibility` other than `visible`, which the marker layer +- /// would inherit. Fail-closed: the reader refuses it (`root_visibility`). ++ /// The drawing's root carries a `visibility` other than `visible` (the marker layer inherited ++ /// it before the root became the engine's). Fail-closed: the reader refuses it ++ /// (`root_visibility`). + RootVisibility, + } + +@@ -98,32 +103,62 @@ pub fn compose_canvas( + if check_root_visibility(asset).is_err() { + return Err(ComposeError::RootVisibility); + } +- let mut root = Element { +- qname: "svg".to_owned(), +- namespace: asset.namespace.clone(), +- attrs: asset +- .attrs +- .iter() +- .filter(|a| !matches!(a.qname.as_str(), "width" | "height" | "preserveAspectRatio")) +- .cloned() +- .collect(), +- children: asset.children.clone(), +- }; + let view_box = view_frame(view, asset).map_or_else( + || CANVAS_FALLBACK_VIEW_BOX.to_owned(), + |frame| frame.view_box(), + ); +- root.set_attr("viewBox", view_box); ++ let mut root = isolated(asset.clone(), Some(view_box)); + let scope = id_scope(view_id); + scope_ids(&mut root, &scope); + if !references_scoped(&root, &scope) { + return Err(ComposeError::UnscopedReference); + } +- let layer = render_layer(document, view_id, &HashSet::new())?; ++ let layer = render_composed_layer(document, view_id, &HashSet::new())?; + root.children.push(Node::Element(checked(layer)?)); + Ok(root) + } + ++/// Root attributes with no meaning on a ``: the frame is the engine's, the size is the ++/// page's or the raster's. ++const ROOT_ONLY: [&str; 7] = [ ++ "viewBox", ++ "preserveAspectRatio", ++ "version", ++ "width", ++ "height", ++ "x", ++ "y", ++]; ++ ++/// The composition root framed on `view_box`, holding the drawing as its one child: a `` ++/// with the drawing root's attributes (namespace declarations and `ROOT_ONLY` aside) and its ++/// children. The caller appends the engine's elements after it. ++fn isolated(asset: Element, view_box: Option) -> Element { ++ let (namespaces, attrs): (Vec<_>, Vec<_>) = asset ++ .attrs ++ .into_iter() ++ .partition(|a| a.qname == "xmlns" || a.qname == "xmlns:xlink"); ++ let drawing = Element { ++ qname: "g".to_owned(), ++ namespace: asset.namespace.clone(), ++ attrs: attrs ++ .into_iter() ++ .filter(|a| !ROOT_ONLY.contains(&a.qname.as_str())) ++ .collect(), ++ children: asset.children, ++ }; ++ let mut root = Element { ++ qname: "svg".to_owned(), ++ namespace: asset.namespace, ++ attrs: namespaces, ++ children: vec![Node::Element(drawing)], ++ }; ++ if let Some(view_box) = view_box { ++ root.set_attr("viewBox", view_box); ++ } ++ root ++} ++ + /// The prefix of a view's ids in its canvas. Stable ids hold no `.`, so the scope of one view + /// is never the start of another's, and no page id starts with `fv.`. + pub fn id_scope(view_id: &str) -> String { +@@ -180,7 +215,7 @@ fn scope_ids(element: &mut Element, scope: &str) { + pub fn compose_highlight( + document: &AnatomicalSheetDocument, + view_id: &str, +- mut asset: Element, ++ asset: Element, + annotation_ids: &HashSet<&str>, + halo: bool, + ) -> Result { +@@ -191,20 +226,16 @@ pub fn compose_highlight( + if check_root_visibility(&asset).is_err() { + return Err(ComposeError::RootVisibility); + } +- match view_frame(view, &asset) { +- Some(frame) => asset.set_attr("viewBox", frame.view_box()), +- None => asset.remove_attr("viewBox"), +- } +- asset.remove_attr("width"); +- asset.remove_attr("height"); +- asset.remove_attr("preserveAspectRatio"); ++ let view_box = view_frame(view, &asset).map(|frame| frame.view_box()); ++ let mut root = isolated(asset, view_box); + if halo { +- add_halo_filter(&mut asset); ++ let defs = Element::svg("defs", Vec::new(), vec![Node::Element(halo_filter())]); ++ root.children.push(Node::Element(defs)); + } +- let layer = render_layer(document, view_id, &HashSet::new())?; ++ let layer = render_composed_layer(document, view_id, &HashSet::new())?; + let layer = highlight_layer(layer, annotation_ids, halo); +- asset.children.push(Node::Element(checked(layer)?)); +- Ok(asset) ++ root.children.push(Node::Element(checked(layer)?)); ++ Ok(root) + } + + /// The layer reduced to the selected annotations, recoloured, every `data-*` dropped. +@@ -235,31 +266,6 @@ fn highlight_element(mut element: Element, halo: bool) -> Element { + element + } + +-/// The halo filter in the first `` of the drawing, else in a new `` placed first. +-fn add_halo_filter(root: &mut Element) { +- if !append_to_first_defs(root) { +- let defs = Element::svg("defs", Vec::new(), vec![Node::Element(halo_filter())]); +- root.children.insert(0, Node::Element(defs)); +- } +-} +- +-/// Appends the halo to the first `` below `element` (document order). +-fn append_to_first_defs(element: &mut Element) -> bool { +- for child in &mut element.children { +- let Node::Element(child) = child else { +- continue; +- }; +- if child.qname == "defs" { +- child.children.push(Node::Element(halo_filter())); +- return true; +- } +- if append_to_first_defs(child) { +- return true; +- } +- } +- false +-} +- + fn halo_filter() -> Element { + let blur = |std: &str, result: &str| { + Node::Element(Element::svg( +diff --git a/crates/core/src/anatomy/layer.rs b/crates/core/src/anatomy/layer.rs +index 407efeb..0e4bb77 100644 +--- a/crates/core/src/anatomy/layer.rs ++++ b/crates/core/src/anatomy/layer.rs +@@ -27,14 +27,38 @@ pub fn find_view<'a>( + } + + /// `renderAnnotationLayer({ document, viewId, states })`: `states` holds the ids marked +-/// `data-state="current"`. ++/// `data-state="current"`. The R3 tree, kept for the seed review drawings ++/// (`curation::draft::app_review`); the composers draw `render_composed_layer`. + pub fn render_layer( + document: &AnatomicalSheetDocument, + view_id: &str, + states: &HashSet<&str>, ++) -> Result { ++ layer(document, view_id, states, false) ++} ++ ++/// The layer the composers draw (V1-2.2 owner brief 2026-10-30): the R3 tree with each point ++/// hitbox declaring its paint and its capture rule, `stroke="none"` and ++/// `pointer-events="visibleFill"`, so its clickable area is its circle whatever stroke the page ++/// or a drawing would give it (under `pointer-events="all"` a stroke widens the hit area even ++/// when nothing paints it). The zones and the trigger already declare theirs. ++pub fn render_composed_layer( ++ document: &AnatomicalSheetDocument, ++ view_id: &str, ++ states: &HashSet<&str>, ++) -> Result { ++ layer(document, view_id, states, true) ++} ++ ++fn layer( ++ document: &AnatomicalSheetDocument, ++ view_id: &str, ++ states: &HashSet<&str>, ++ declared_hitbox: bool, + ) -> Result { + let view = find_view(document, view_id).ok_or(LayerError::UnknownView)?; + let context = Context { ++ declared_hitbox, + twin_opacity: if view.is_main() { "0.65" } else { "0.5" }, + categories: document + .categories +@@ -59,6 +83,8 @@ pub fn render_layer( + } + + struct Context<'a> { ++ /// The hitbox declares `stroke="none"` and captures on its circle only (composed form). ++ declared_hitbox: bool, + twin_opacity: &'static str, + /// Last duplicate wins, as a JavaScript `Map` built from the list. + categories: HashMap<&'a str, Option<&'a str>>, +@@ -154,9 +180,14 @@ impl Context<'_> { + ("cy", js_number(cy)), + ("r", js_number(r)), + ("fill", "transparent".to_owned()), +- ("pointer-events", "all".to_owned()), +- ("style", "cursor:pointer".to_owned()), + ]; ++ if self.declared_hitbox { ++ hitbox.push(("stroke", "none".to_owned())); ++ hitbox.push(("pointer-events", "visibleFill".to_owned())); ++ } else { ++ hitbox.push(("pointer-events", "all".to_owned())); ++ } ++ hitbox.push(("style", "cursor:pointer".to_owned())); + hitbox.extend(data.iter().cloned()); + let mut visible: Attrs = vec![ + ("cx", js_number(cx)), +diff --git a/crates/core/src/anatomy/svg/mod.rs b/crates/core/src/anatomy/svg/mod.rs +index f499619..85bea93 100644 +--- a/crates/core/src/anatomy/svg/mod.rs ++++ b/crates/core/src/anatomy/svg/mod.rs +@@ -14,7 +14,7 @@ pub use tree::{Element, Node, SvgRejection}; + + /// Bounds, parses, sanitises and checks the references of an SVG text: no cycle, within the + /// expansion budget, each naming an id the drawing defines; no id the composition writes and +-/// no root `visibility` the marker layer would inherit. ++/// no root `visibility` other than `visible`. + pub fn read_svg(text: &str) -> Result { + let root = tree::parse_svg(text)?; + let sanitized = sanitize::sanitize(root)?; +diff --git a/crates/core/src/anatomy/svg/refs.rs b/crates/core/src/anatomy/svg/refs.rs +index 95f3248..dc99a3d 100644 +--- a/crates/core/src/anatomy/svg/refs.rs ++++ b/crates/core/src/anatomy/svg/refs.rs +@@ -18,8 +18,8 @@ use super::tree::{Element, Node, SvgRejection}; + /// Expanded elements a drawing may instantiate (the product's drawing: a few thousand). + pub const MAX_EXPANDED_ELEMENTS: u64 = 50_000; + +-/// The PDF highlight's filter (`compose::compose_highlight`), written into the drawing's own +-/// document: the PDF view keeps the drawing's ids. ++/// The PDF highlight's filter (`compose::compose_highlight`), written in an engine `` of ++/// the composed document next to the drawing: the PDF view keeps the drawing's ids. + pub const HALO_FILTER_ID: &str = "osteo-halo"; + + /// Every id the composition writes next to the drawing's ids. A drawing defining one would +diff --git a/crates/core/src/anatomy/svg/sanitize.rs b/crates/core/src/anatomy/svg/sanitize.rs +index b4cbd24..dfd8836 100644 +--- a/crates/core/src/anatomy/svg/sanitize.rs ++++ b/crates/core/src/anatomy/svg/sanitize.rs +@@ -435,10 +435,10 @@ fn value_acceptable(qname: &str, value: &str) -> bool { + } + + /// The root lets the engine's marker layer show: no `visibility`, or `visible` (CSS whitespace +-/// and letter case aside). Both composers append the layer as the root's last child, so it +-/// inherits the root's `visibility`, which the drawing's own children can set back to +-/// `visible`: any other value, `hidden`, `collapse`, a CSS-wide keyword or an unreadable one, +-/// is refused (V1-2.2 security review, owner brief 2026-10-30). The root's `style` and `class` ++/// and letter case aside). Until the composition root became the engine's, the layer inherited ++/// the root's `visibility`, which the drawing's own children can set back to `visible`: any ++/// other value, `hidden`, `collapse`, a CSS-wide keyword or an unreadable one, stays refused ++/// (V1-2.2 security review, owner brief 2026-10-30), the composers checking it too. The root's `style` and `class` + /// are removed by `sanitize`, so this attribute is the one way left to set it. + pub fn check_root_visibility(root: &Element) -> Result<(), SvgRejection> { + let visible = root.attr("visibility").is_none_or(|value| { +diff --git a/crates/core/src/anatomy/svg/tree.rs b/crates/core/src/anatomy/svg/tree.rs +index 91c3886..545943d 100644 +--- a/crates/core/src/anatomy/svg/tree.rs ++++ b/crates/core/src/anatomy/svg/tree.rs +@@ -111,9 +111,9 @@ pub enum SvgRejection { + /// An id the composition writes into the drawing's own document (`refs::RESERVED_IDS`): + /// the drawing's element would stand in for the engine's (V1-2.2, owner brief 2026-10-30). + ReservedId, +- /// A `visibility` on the root other than `visible`: the engine's marker layer, appended as +- /// the root's last child, inherits it, while the drawing's own children can set `visible` +- /// back (V1-2.2 security review, owner brief 2026-10-30). ++ /// A `visibility` on the root other than `visible`: until the composition root became the ++ /// engine's, the marker layer inherited it while the drawing's own children set `visible` ++ /// back (V1-2.2 security review, owner brief 2026-10-30); kept as a reader rule. + RootVisibility, + } + +diff --git a/crates/core/src/curation/draft/app_review.rs b/crates/core/src/curation/draft/app_review.rs +index bca7882..aaad006 100644 +--- a/crates/core/src/curation/draft/app_review.rs ++++ b/crates/core/src/curation/draft/app_review.rs +@@ -4,6 +4,11 @@ + //! uses. Written under `draft/review/app-.svg` so the markers and the framing can be + //! compared outside the browser. + //! ++//! Declared difference (V1-2.2, owner brief 2026-10-30): the application draws the drawing in a ++//! group of its own under an engine root and declares each point hitbox's stroke and capture ++//! (`compose`, `layer::render_composed_layer`); this review drawing keeps the R5 form, a seed ++//! resource never regenerated without the owner. ++//! + //! Declared difference: the R3 owner decision (2026-10-15) gives a trigger without a name of + //! its own the opened view's name in each language; the TypeScript renderer wrote the French + //! name twice (`svg_compare::TriggerNames`). +diff --git a/crates/core/tests/anatomy_canvas_op.rs b/crates/core/tests/anatomy_canvas_op.rs +index 50e2799..e9ad406 100644 +--- a/crates/core/tests/anatomy_canvas_op.rs ++++ b/crates/core/tests/anatomy_canvas_op.rs +@@ -5,7 +5,8 @@ + mod common; + + use common::svg_tree::{ +- tree_value, view_names, with_ids_scoped_per_view, with_trigger_names_per_language, ++ tree_value, view_names, with_ids_scoped_per_view, with_isolated_layer, ++ with_trigger_names_per_language, + }; + use faunosteo_core::anatomy::svg::tree::parse_svg; + use faunosteo_core::domain::js::parse_json; +@@ -44,6 +45,7 @@ fn golden(view: &str, sheet: &LoadedSheet) -> Value { + let mut frozen: Value = serde_json::from_str(&text).unwrap(); + with_trigger_names_per_language(&mut frozen, &view_names(&sheet.document)); + with_ids_scoped_per_view(&mut frozen, view); ++ with_isolated_layer(&mut frozen); + frozen + } + +diff --git a/crates/core/tests/anatomy_compose.rs b/crates/core/tests/anatomy_compose.rs +index 6809da5..873a860 100644 +--- a/crates/core/tests/anatomy_compose.rs ++++ b/crates/core/tests/anatomy_compose.rs +@@ -12,7 +12,8 @@ mod common; + use std::collections::HashSet; + + use common::svg_tree::{ +- reread, tree_value, view_names, with_ids_scoped_per_view, with_trigger_names_per_language, ++ reread, tree_value, view_names, with_ids_scoped_per_view, with_isolated_layer, ++ with_trigger_names_per_language, + }; + use faunosteo_core::anatomy::compose::{ + ComposeError, asset_id_of_view, compose_canvas, compose_highlight, +@@ -96,6 +97,7 @@ fn every_highlighted_view_equals_the_engine_tree() { + let label = format!("{} {} {view}", case["sheet"], case["observation"]["id"]); + let mut frozen = expected(case, &oracle); + with_trigger_names_per_language(&mut frozen, &view_names(document)); ++ with_isolated_layer(&mut frozen); + assert_eq!(reread(&composed), frozen, "{label}"); + } + } +@@ -109,6 +111,7 @@ fn canvas_golden(view: &str) -> Value { + let mut frozen: Value = serde_json::from_str(&text).unwrap(); + with_trigger_names_per_language(&mut frozen, &view_names(&draft())); + with_ids_scoped_per_view(&mut frozen, view); ++ with_isolated_layer(&mut frozen); + frozen + } + +diff --git a/crates/core/tests/common/svg_tree.rs b/crates/core/tests/common/svg_tree.rs +index b430111..119647d 100644 +--- a/crates/core/tests/common/svg_tree.rs ++++ b/crates/core/tests/common/svg_tree.rs +@@ -101,3 +101,77 @@ pub fn view_names( + .map(|v| (v.id().to_owned(), v.name().fr.clone(), v.name().en.clone())) + .collect() + } ++ ++/// Owner brief 2026-10-30 (V1-2.2, three MEDIUM): the composition root is the engine's. Applied ++/// to a frozen view tree before comparing, written apart from the core: the root keeps its ++/// namespaces and `viewBox`; its other attributes and every child before the layer go into a ++/// ``; the halo filter leaves the drawing for an engine `` placed before the layer; ++/// each point hitbox (a circle capturing on `all` with no stroke of its own) declares ++/// `stroke="none"` and `pointer-events="visibleFill"`. ++pub fn with_isolated_layer(tree: &mut Value) { ++ let root = tree.as_object_mut().unwrap(); ++ let mut children = root["children"].as_array().unwrap().clone(); ++ let mut layer = children.pop().unwrap(); ++ let halo = take_halo(&mut children); ++ let attrs = root["attrs"].as_object().unwrap().clone(); ++ let (kept, moved): (Vec<_>, Vec<_>) = attrs ++ .into_iter() ++ .partition(|(name, _)| ["xmlns", "xmlns:xlink", "viewBox"].contains(&name.as_str())); ++ let group = json!({ ++ "ns": root["ns"], "name": "g", ++ "attrs": moved.into_iter().collect::>(), ++ "children": children, ++ }); ++ let mut out = vec![group]; ++ if let Some(halo) = halo { ++ out.push(json!({ "ns": SVG_NS, "name": "defs", "attrs": {}, "children": [halo] })); ++ } ++ for marker in layer["children"].as_array_mut().unwrap() { ++ let circle = marker["name"] == "circle"; ++ let attrs = marker["attrs"].as_object_mut().unwrap(); ++ let hitbox = circle ++ && attrs.get("pointer-events") == Some(&json!("all")) ++ && !attrs.contains_key("stroke"); ++ if hitbox { ++ attrs.insert("stroke".to_owned(), json!("none")); ++ attrs.insert("pointer-events".to_owned(), json!("visibleFill")); ++ } ++ } ++ out.push(layer); ++ root.insert( ++ "attrs".to_owned(), ++ Value::Object(kept.into_iter().collect()), ++ ); ++ root.insert("children".to_owned(), Value::Array(out)); ++} ++ ++/// Removes `filter#osteo-halo` from the frozen drawing (and the `` the engine created for ++/// it alone, placed first), answering it. ++fn take_halo(children: &mut Vec) -> Option { ++ let first_is_engine_defs = children.first().is_some_and(|c| { ++ c["name"] == "defs" ++ && c["children"] ++ .as_array() ++ .is_some_and(|k| k.len() == 1 && k[0]["attrs"]["id"] == "osteo-halo") ++ }); ++ if first_is_engine_defs { ++ return Some(children.remove(0)["children"][0].clone()); ++ } ++ for child in children.iter_mut() { ++ if let Some(found) = take_from(child) { ++ return Some(found); ++ } ++ } ++ None ++} ++ ++fn take_from(node: &mut Value) -> Option { ++ let kids = node.get_mut("children")?.as_array_mut()?; ++ if let Some(at) = kids ++ .iter() ++ .position(|k| k["name"] == "filter" && k["attrs"]["id"] == "osteo-halo") ++ { ++ return Some(kids.remove(at)); ++ } ++ kids.iter_mut().find_map(take_from) ++} +diff --git a/crates/core/tests/svg_marker_isolation.rs b/crates/core/tests/svg_marker_isolation.rs +new file mode 100644 +index 0000000..783d0f0 +--- /dev/null ++++ b/crates/core/tests/svg_marker_isolation.rs +@@ -0,0 +1,193 @@ ++//! V1-2.2 owner brief « arbitrages propriétaire sur les trois MEDIUM » (2026-10-30), defects 1 ++//! and 2: nothing the drawing sets reaches the engine's markers. Until then both composers ++//! appended the marker layer to the drawing's own root, so the root's presentation attributes ++//! reached every marker: inherited ones (`stroke-opacity="0"` or `stroke-dasharray` erased the ++//! zone outlines and the detail trigger, `stroke-width` widened the point hitbox until the last ++//! one took 13 of the 19 equine clicks) and whole-group ones (`opacity`, `display`). The ++//! composition root is now the engine's (namespaces and frame only), the drawing sits in a ++//! group of its own, and the layer and the halo filter are that group's siblings. The point ++//! hitbox declares its paint and its capture rule (`stroke="none"`, `pointer-events= ++//! "visibleFill"`), so its clickable area is its circle, whatever the page or the drawing set. ++#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)] ++ ++mod common; ++ ++use std::collections::HashSet; ++ ++use common::sheet_readers::{OPEN, sheet}; ++use faunosteo_core::anatomy::compose::{compose_canvas, compose_highlight}; ++use faunosteo_core::anatomy::svg::{Element, read_svg}; ++use faunosteo_core::domain::sheet::AnatomicalSheetDocument; ++use serde::Deserialize; ++ ++/// The attributes the composition root may carry: namespaces and the frame. ++const ROOT_ATTRIBUTES: [&str; 3] = ["xmlns", "xmlns:xlink", "viewBox"]; ++ ++/// Every presentation attribute the reader keeps on a drawing's root, with a value that would ++/// change a marker if it reached one (the reader removes `class`, `style`, `transform`, ++/// `filter`, `mask` and `clip-path` from the root, and refuses a root `visibility` other than ++/// `visible`). ++const ROOT_PROPERTIES: [&str; 22] = [ ++ "stroke=\"#ff00ff\"", ++ "stroke-width=\"400\"", ++ "stroke-opacity=\"0\"", ++ "stroke-dasharray=\"0 1000\"", ++ "stroke-dashoffset=\"7\"", ++ "stroke-linecap=\"square\"", ++ "stroke-linejoin=\"miter\"", ++ "stroke-miterlimit=\"100\"", ++ "fill=\"none\"", ++ "fill-opacity=\"0\"", ++ "fill-rule=\"evenodd\"", ++ "opacity=\"0\"", ++ "display=\"none\"", ++ "visibility=\"visible\"", ++ "color=\"#00ff00\"", ++ "clip-rule=\"evenodd\"", ++ "color-interpolation-filters=\"sRGB\"", ++ "font-family=\"serif\"", ++ "font-size=\"90\"", ++ "font-weight=\"bold\"", ++ "systemLanguage=\"xx\"", ++ "id=\"drawing\"", ++]; ++ ++const BODY: &str = ""; ++ ++fn rooted(attrs: &str) -> String { ++ let root = OPEN.replace("viewBox", &format!("{attrs} viewBox")); ++ format!("{root}{BODY}") ++} ++ ++fn horse() -> Element { ++ let text = common::repo_file("supabase/seed/anatomical-sheets/equine/draft/assets/horse.svg"); ++ read_svg(&text).unwrap().root ++} ++ ++fn draft() -> AnatomicalSheetDocument { ++ let text = common::repo_file("supabase/seed/anatomical-sheets/equine/draft/document.json"); ++ AnatomicalSheetDocument::deserialize(serde_json::from_str::(&text).unwrap()) ++ .unwrap() ++} ++ ++/// The composed views of `tree`'s `main` view: the canvas, and the PDF view of `hock`. ++fn composed(tree: &Element) -> [Element; 2] { ++ let ids: HashSet<&str> = ["hock"].into_iter().collect(); ++ [ ++ compose_canvas(&sheet(), "main", tree).unwrap(), ++ compose_highlight(&sheet(), "main", tree.clone(), &ids, true).unwrap(), ++ ] ++} ++ ++fn names(element: &Element) -> Vec<&str> { ++ element.attrs.iter().map(|a| a.qname.as_str()).collect() ++} ++ ++/// The marker layer is a child of the composition root, which carries no drawing attribute; ++/// the drawing's root attributes and children live in a group the layer is not part of. ++fn assert_isolated(composed: &Element, drawing: &Element, label: &str) { ++ let root_names = names(composed); ++ assert!( ++ root_names.iter().all(|n| ROOT_ATTRIBUTES.contains(n)), ++ "{label}: composition root carries {root_names:?}" ++ ); ++ let layer = composed.element_children().last().unwrap(); ++ assert_eq!(layer.qname, "g", "{label}"); ++ assert!(layer.element_children().count() > 0, "{label}"); ++ let group = composed.element_children().next().unwrap(); ++ assert_eq!(group.qname, "g", "{label}: the drawing's group comes first"); ++ assert!(!std::ptr::eq(group, layer), "{label}"); ++ for attr in &drawing.attrs { ++ let framing = ["xmlns", "xmlns:xlink", "viewBox"].contains(&attr.qname.as_str()); ++ if !framing && attr.qname != "id" { ++ assert_eq!( ++ group.attr(&attr.qname), ++ Some(attr.value.as_str()), ++ "{label}: the drawing keeps its own {}", ++ attr.qname ++ ); ++ } ++ } ++ assert_eq!( ++ group.element_children().count(), ++ drawing.element_children().count(), ++ "{label}: the drawing's children stay in its group" ++ ); ++} ++ ++#[test] ++fn no_root_property_of_the_drawing_reaches_a_marker() { ++ for property in ROOT_PROPERTIES { ++ let read = read_svg(&rooted(property)).unwrap_or_else(|e| panic!("{property}: {e:?}")); ++ assert!(read.removed.is_empty(), "{property}: {:?}", read.removed); ++ let [canvas, highlight] = composed(&read.root); ++ assert_isolated(&canvas, &read.root, &format!("canvas {property}")); ++ assert_isolated(&highlight, &read.root, &format!("pdf {property}")); ++ } ++} ++ ++#[test] ++fn every_root_property_at_once_stays_with_the_drawing() { ++ let all = ROOT_PROPERTIES.join(" "); ++ let read = read_svg(&rooted(&all)).unwrap(); ++ let [canvas, highlight] = composed(&read.root); ++ assert_isolated(&canvas, &read.root, "canvas"); ++ assert_isolated(&highlight, &read.root, "pdf"); ++} ++ ++/// The equine drawing keeps its root attributes (`font-family`, `font-size`) on its group and ++/// its frame on the composition root, in both forms. ++#[test] ++fn the_equine_drawing_is_isolated_in_both_forms() { ++ let horse = horse(); ++ let draft = draft(); ++ let ids: HashSet<&str> = ["hock", "hip"].into_iter().collect(); ++ let canvas = compose_canvas(&draft, "main", &horse).unwrap(); ++ let highlight = compose_highlight(&draft, "main", horse.clone(), &ids, true).unwrap(); ++ for (label, view) in [("canvas", &canvas), ("pdf", &highlight)] { ++ assert_isolated(view, &horse, label); ++ assert_eq!(view.attr("viewBox"), Some("0 0 2073.4 1629.4"), "{label}"); ++ } ++} ++ ++/// The halo filter is the engine's: outside the drawing's group, so no property of the ++/// drawing (`color-interpolation-filters` on its root or its ``) changes the halo. ++#[test] ++fn the_halo_filter_lives_outside_the_drawing() { ++ let read = read_svg(&rooted( ++ "color-interpolation-filters=\"sRGB\" stroke-width=\"400\"", ++ )) ++ .unwrap(); ++ let [_, highlight] = composed(&read.root); ++ let group = highlight.element_children().next().unwrap(); ++ let mut inside = Vec::new(); ++ common::sheet_readers::holders(group, "osteo-halo", &mut inside); ++ assert!(inside.is_empty(), "the halo is not in the drawing's group"); ++ let mut everywhere = Vec::new(); ++ common::sheet_readers::holders(&highlight, "osteo-halo", &mut everywhere); ++ assert_eq!(everywhere.len(), 1); ++} ++ ++/// Every interactive surface of the canvas: the point hitboxes declare `stroke="none"` and ++/// capture on their circle only (`visibleFill`), the zones and the trigger declare their ++/// stroke width; the visible twins never capture. ++#[test] ++fn every_interactive_surface_declares_its_geometry_and_capture() { ++ let draft = draft(); ++ let canvas = compose_canvas(&draft, "main", &horse()).unwrap(); ++ let layer = canvas.element_children().last().unwrap(); ++ let mut hitboxes = 0; ++ for marker in layer.element_children() { ++ match (marker.attr("fill"), marker.attr("pointer-events")) { ++ (Some("transparent"), capture) => { ++ hitboxes += 1; ++ assert_eq!(marker.attr("stroke"), Some("none"), "{marker:?}"); ++ assert_eq!(capture, Some("visibleFill"), "{marker:?}"); ++ } ++ (_, Some("none")) => {} ++ (_, Some("all")) => assert!(marker.attr("stroke-width").is_some(), "{marker:?}"), ++ other => panic!("unexpected capture {other:?}"), ++ } ++ } ++ assert_eq!(hitboxes, 13, "the 13 points of the main view"); ++} +diff --git a/crates/core/tests/svg_root_visibility.rs b/crates/core/tests/svg_root_visibility.rs +index 34369a9..d9b0a38 100644 +--- a/crates/core/tests/svg_root_visibility.rs ++++ b/crates/core/tests/svg_root_visibility.rs +@@ -1,7 +1,7 @@ + //! V1-2.2 owner brief 2026-10-30: the drawing's root never decides whether the engine's markers +-//! show. Both composers append the marker layer as the root's last child (the PDF view keeps the +-//! drawing's root, the canvas copies its attributes), so the layer inherits the root's +-//! `visibility`; a drawing `` whose children set `visible` back read ++//! show. Both composers appended the marker layer as the root's last child, so the layer ++//! inherited the root's `visibility` (the composition root is the engine's since the three-MEDIUM ++//! brief, `svg_marker_isolation`); a drawing `` whose children set `visible` back read + //! clean before and showed its drawing without a single marker (security review, MEDIUM). The + //! reader refuses a root `visibility` other than `visible` (`root_visibility`); the cleaning, + //! the preview, the verdict and the PDF snapshot gate answer it; both composers refuse such a +@@ -189,12 +189,10 @@ fn equivalent_styles_never_hide_the_layer() { + assert!(layer_shows(&canvas.unwrap()) && layer_shows(&highlight.unwrap())); + } + +-/// The other root properties that reach the layer. Removed by the reader before V1-2.2: the +-/// paint servers and effects (`filter`, `mask`, `clip-path`), `transform`, `class`, `style`. +-/// Kept: `opacity` and `display` act on the whole root, drawing and markers alike (the +-/// browser proofs of RUST.md §12.10 show both); `fill` and `fill-opacity` are set on every PDF +-/// marker. The stroke properties no marker sets (`stroke-opacity`, `stroke-dasharray`, +-/// `stroke-width` on the hitbox) are an open owner decision, not covered here. ++/// The other root properties. Removed by the reader before V1-2.2: the paint servers and ++/// effects (`filter`, `mask`, `clip-path`), `transform`, `class`, `style`. Kept: `opacity`, ++/// `display` and the paint, which since the three-MEDIUM brief stay on the drawing's group and ++/// never reach a marker (`svg_marker_isolation`); every PDF marker still sets its fill. + #[test] + fn other_root_properties_are_removed_or_act_on_the_whole_view() { + for name in ["filter", "mask", "clip-path"] { +diff --git a/docs/ANNOTATION-RENDERING.md b/docs/ANNOTATION-RENDERING.md +index a18e915..9c1439a 100644 +--- a/docs/ANNOTATION-RENDERING.md ++++ b/docs/ANNOTATION-RENDERING.md +@@ -23,7 +23,7 @@ trigger. + | Annotation | Elements | + |---|---| + | `detail_trigger`, any geometry | one dashed shape: fill and stroke = the colour, `fill-opacity` 0.06, `stroke-width` 2, `stroke-dasharray` `8,4`, `pointer-events` all, `style` `cursor:pointer`, class `detail-zone` | +-| `point` or `zone` with a circle | a transparent hitbox (the geometry's `r`, `fill` transparent, `pointer-events` all, `style` `cursor:pointer`) then a visible twin on top (radius `max(2, r − 12)`, the colour, `fill-opacity` 0.65 on the main view / 0.5 on a detail view, stroke `#000` 1.5, `pointer-events` none) | ++| `point` or `zone` with a circle | a transparent hitbox (the geometry's `r`, `fill` transparent, `stroke` none, `pointer-events` visibleFill, `style` `cursor:pointer`; the R3 form kept for the seed review drawings has no `stroke` and `pointer-events` all) then a visible twin on top (radius `max(2, r − 12)`, the colour, `fill-opacity` 0.65 on the main view / 0.5 on a detail view, stroke `#000` 1.5, `pointer-events` none) | + | `point` or `zone` with a polygon or a path | one filled shape: fill and stroke = the colour, `fill-opacity` 0.3, `stroke-width` 2, `pointer-events` all, `style` `cursor:pointer` | + + Annotations without geometry draw nothing. Annotations follow the document +@@ -111,22 +111,23 @@ a pointer cursor and brightens on hover. + The engine composes the observation's zones of one view: the markers of the + other annotations are dropped (not hidden), every `data-*` attribute is + removed, the kept elements get fill `#b85a3f` at 0.85 and, on the main view, +-the `osteo-halo` filter (two Gaussian blurs merged with the source), added to +-the first `` of the drawing or to a new `` placed first. The PDF ++the `osteo-halo` filter (two Gaussian blurs merged with the source), in a ++`` of the engine placed after the drawing's group, before the layer. The PDF + view keeps the drawing's ids, so `osteo-halo` is reserved (V1-2.2, owner brief + 2026-10-30): the reader refuses a drawing holding it in any letter case + (`reserved_id`) and both composers refuse such a tree, so the halo the markers + name is always the engine's. + +-Both forms append the layer as the root's last child, so it inherits the +-root's `visibility`. A root `visibility` other than `visible` is refused by +-the reader (`root_visibility`) and by both composers: a drawing could +-otherwise hide every marker while its own children set `visible` back. The +-root's `class`, `style`, `transform`, `filter`, `mask` and `clip-path` are +-removed by the reader; `opacity` and `display` on the root act on the drawing +-and the markers alike. Still open (RUST.md §12.10): `stroke-opacity`, +-`stroke-dasharray` and `stroke-width` on the root reach the markers, which do +-not set them (the frame of a view: see Views, RUST.md §12.11). ++The composition root is the engine's (V1-2.2, owner brief 2026-10-30, RUST.md ++§12.12): `xmlns`, `xmlns:xlink` and the frame only. The drawing's root becomes ++a `` holding its other attributes and its children; the layer (and the ++halo's ``) are that group's siblings, so no property the drawing sets, ++inherited (`stroke-*`, `fill*`, `visibility`…) or acting on a whole group ++(`opacity`, `display`), reaches a marker: a root `opacity="0"` or ++`display="none"` hides the drawing alone. A root `visibility` other than ++`visible` stays refused by the reader (`root_visibility`) and by both ++composers. The R3 trees stay frozen; the tests apply this declared change ++(`withIsolatedLayer`, `withDeclaredHitboxes`, `with_isolated_layer`). + + ## Checking the look + +diff --git a/docs/development/BROWSER_TESTS.md b/docs/development/BROWSER_TESTS.md +index 2b1c962..39c55c3 100644 +--- a/docs/development/BROWSER_TESTS.md ++++ b/docs/development/BROWSER_TESTS.md +@@ -1,7 +1,9 @@ + # Browser tests (Playwright and axe) + + Status: V1-1.3, 2026-10-25 (decision D14, `V1-1_OWNERS_ANIMALS.md` §12.5). +-Chromium only until V1-5. The suites live in `apps/app/e2e`. ++Chromium only until V1-5, except the canvas click proof (V1-2.2), which also ++runs on Firefox and WebKit, desktop and the WebKit phone, when the pinned ++engines are installed. The suites live in `apps/app/e2e`. + + ## 1. Suites + +@@ -110,7 +112,12 @@ suite needs Docker in the runner for the sandbox. + + ## 6. Limits + +-- Chromium only. Firefox, WebKit and the 412 × 915 viewport join at V1-5 ++- Chromium only, but `e2e/ui/canvas-clicks.spec.ts` (V1-2.2: projects ++ `firefox-desktop`, `webkit-desktop`, `webkit-375`, added when ++ `playwright install firefox webkit` has put the pinned engines in the cache; ++ a missing one is named in the run's output and its projects do not run; ++ harness `e2e/harness/canvas.{html,tsx}`, dev server only). Firefox, WebKit ++ and the 412 × 915 viewport join every suite at V1-5 + (contract §12.5). WebKit's system libraries may need `sudo` (owner action). + Desktop WebKit is not iOS Safari: the owner's manual check on a real iPhone + and on a computer over the LAN stays a validation criterion of every mobile +diff --git a/docs/development/RUST.md b/docs/development/RUST.md +index 6a0cf21..02c1ab0 100644 +--- a/docs/development/RUST.md ++++ b/docs/development/RUST.md +@@ -4198,3 +4198,46 @@ Oracles: none changed by this rule; the R3 canvas and highlight trees, the R4 di + frozen (no committed drawing carries a `preserveAspectRatio` or a `viewBox` in another spelling). + Module: 560 377 → 572 993 B gzip -9 (+12 616 B, the curve and arc measure), 1 515 246 → 1 544 834 B raw; Node's gzip + 582 919 B (budget 600 000). ++ ++### 12.12 Marker isolation and the hitbox capture (owner, 2026-10-30, defects 1 and 2) ++ ++Brief « V1-2.2 : arbitrages propriétaire sur les trois MEDIUM », points 1 and 2 (open items (1) and (2) of §12.10). A ++structural fix in the composition, common to both forms, not a list of refused attributes. ++ ++| Point | Built | Where | ++|---|---|---| ++| Composition root | the engine's own ``: `xmlns`, `xmlns:xlink`, the frame (§12.11). The drawing's root becomes a `` holding its other attributes (`viewBox`, `preserveAspectRatio`, `version`, `width`, `height`, `x`, `y` dropped) and its children; the marker layer, and in the PDF view an engine `` holding the halo filter, are that group's siblings | `anatomy/compose.rs` (`isolated`) | ++| Layer | the composers draw `render_composed_layer`: the R3 tree with each point hitbox declaring `stroke="none"` and `pointer-events="visibleFill"` (its clickable area is its circle: under `all` a stroke widens the hit area even unpainted); the zones and the trigger already declare their stroke width; the R3 `render_layer` stays for the seed review drawings, unchanged | `anatomy/layer.rs` | ++| Kept | the reader rules of §12.9 and §12.10 (`reserved_id`, `root_visibility`) and both composers' fail-closed checks | | ++ ++What reached a marker before, and why the structure ends it: inherited properties (`stroke`, `stroke-width`, ++`stroke-opacity`, `stroke-dasharray`, `stroke-dashoffset`, `stroke-linecap`, `stroke-linejoin`, `stroke-miterlimit`, ++`fill`, `fill-opacity`, `fill-rule`, `visibility`, `color`, `clip-rule`, `color-interpolation-filters`, the font ++properties) pass from an ancestor to a child, which a child's own attribute overrides only for the properties it sets; ++`opacity`, `display` and the conditional `systemLanguage` act on the element and its whole subtree, which no child can ++undo. The reader already removes the root's `class`, `style`, `transform`, `filter`, `mask` and `clip-path`, refuses a ++root `visibility` other than `visible`, keeps no `pointer-events` or `cursor` attribute and no `'); await work.addScriptTag({ content: LIB }) + console.log(`== ${name} ${browser.version()}`) + const load = async (key, form, svg) => { + if (form === 'pdf') return work.evaluate(([k, s]) => window.pdf(k, s), [key, svg]) + await shot.setContent(`
${svg.replace(/^`) + const b64 = (await shot.locator('#h').screenshot()).toString('base64') + return work.evaluate(([k, b]) => window.png(k, b), [key, b64]) + } + for (const form of ['pdf', 'canvas']) { + await load('base', form, read('new', 'plain', form, 'layer')) + for (const v of variants) { + for (const side of ['old', 'new']) for (const part of ['full', 'layer']) await load(`${side}.${part}`, form, read(side, v, form, part)) + const row = await work.evaluate(() => ({ + full_old_vs_new: window.diff('old.full', 'new.full'), + markers_old_vs_plain: window.diff('old.layer', 'base'), + markers_new_vs_plain: window.diff('new.layer', 'base'), + marker_ink_old: window.ink('old.layer'), marker_ink_new: window.ink('new.layer'), + highlight_old: window.hl('old.full'), highlight_new: window.hl('new.full'), + })) + console.log(form.padEnd(6), v.padEnd(15), JSON.stringify(row)) + } + } + await browser.close() +} diff --git a/.claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-junction.spec.ts b/.claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-junction.spec.ts new file mode 100644 index 00000000..3ba32d33 --- /dev/null +++ b/.claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-junction.spec.ts @@ -0,0 +1,44 @@ +// THROWAWAY (never committed): capture of each visible shape under three layer orders. +import { test } from '../support/browser' +test('junction options @phone', async ({ page }, info) => { + await page.goto('/e2e/harness/canvas.html?drawing=plain') + await page.locator('[data-anno-id="hock"]').first().waitFor({ state: 'attached' }) + for (const option of ['current', 'points-above-zones', 'visible-wins']) { + const out = await page.evaluate((option) => { + const svg = document.querySelector('[data-testid="anatomy-canvas"] svg') as SVGSVGElement + const layer = svg.lastElementChild as SVGGElement + const kids = Array.from(layer.children) as SVGGeometryElement[] + const hit = kids.filter((k) => k.getAttribute('fill') === 'transparent') + const twins = kids.filter((k) => k.getAttribute('pointer-events') === 'none') + const shapes = kids.filter((k) => !hit.includes(k) && !twins.includes(k)) + if (option === 'points-above-zones') { + const points = kids.filter((k) => hit.includes(k) || twins.includes(k)) + layer.replaceChildren(...shapes, ...points) + } + if (option === 'visible-wins') { + twins.forEach((t) => t.setAttribute('pointer-events', 'visibleFill')) + layer.replaceChildren(...hit, ...shapes, ...twins) + } + const ctm = svg.getScreenCTM()! + const who = (x: number, y: number) => { const p = new DOMPoint(x, y).matrixTransform(ctm); return document.elementFromPoint(p.x, p.y)?.closest('[data-anno-id]')?.getAttribute('data-anno-id') ?? '-' } + const rows: Record = {} + for (const t of twins) { + const id = t.getAttribute('data-anno-id')! + const cx = +t.getAttribute('cx')!, cy = +t.getAttribute('cy')!, r = +t.getAttribute('r')! + let n = 0, own = 0 + for (let dx = -r; dx <= r; dx += 2) for (let dy = -r; dy <= r; dy += 2) { if (Math.hypot(dx, dy) > r) continue; n++; if (who(cx + dx, cy + dy) === id) own++ } + if (own < n) rows[id] = `disc ${own}/${n}` + } + for (const z of shapes) { + const id = z.getAttribute('data-anno-id')! + const b = z.getBBox() + let n = 0, own = 0 + for (let x = b.x; x <= b.x + b.width; x += 6) for (let y = b.y; y <= b.y + b.height; y += 6) { if (!z.isPointInFill(new DOMPoint(x, y))) continue; n++; if (who(x, y) === id) own++ } + if (own < n) rows[id] = `area ${own}/${n}` + } + return rows + }, option) + console.log(`JUNCTION ${info.project.name} ${option} ${JSON.stringify(out)}`) + await page.reload(); await page.locator('[data-anno-id="hock"]').first().waitFor({ state: 'attached' }) + } +}) diff --git a/.claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-real-pdf.test.ts b/.claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-real-pdf.test.ts new file mode 100644 index 00000000..3109b0c9 --- /dev/null +++ b/.claude/audits/2026-10-30-v1-2-2-three-medium-tools/zz-real-pdf.test.ts @@ -0,0 +1,59 @@ +// THROWAWAY (never committed): a real PDF export, every view rasterised by Chromium as +// apps/app/src/pdf/browserRasterizer.ts does, written to REAL_PDF_OUT. +import { createRequire } from 'node:module' +import { readFileSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { openExportSession } from '../src/index' +import { nodeCoreRuntime } from '../src/node' +import { readAttachedDocument } from './n-1/scanner/attachment/read' + +const ROOT = fileURLToPath(new URL('../../../', import.meta.url)) +const FIXTURES = join(ROOT, 'apps/app/tests/fixtures') +const OUT = process.env.REAL_PDF_OUT + +function unwrap(o: { ok: true; value: T } | { ok: false; kind: string; detail?: string }, what: string): T { + if (!o.ok) throw new Error(`${what}: ${o.kind} ${o.detail ?? ''}`) + return o.value +} + +it.runIf(OUT)('real pdf', async () => { + const require = createRequire(join(ROOT, 'apps/app/package.json')) + const { chromium } = require('@playwright/test') + const browser = await chromium.launch() + const page = await browser.newPage() + await page.setContent('') + const runtime = await nodeCoreRuntime('pkg') + for (const name of ['demo.fr.logos', 'v2full.fr.logos', 'v2unresolved.fr.nologos']) { + const env = (await readAttachedDocument(new Uint8Array(readFileSync(join(FIXTURES, `pdf/r3/${name}.pdf`))))) as Record + const input = JSON.stringify({ report: env.report, sheetSnapshot: env.sheetSnapshot, branding: env.branding, labels: env.labels, locale: env.locale, exportedAt: env.exportedAt }) + const session = unwrap(openExportSession(runtime, input), name) + const svgs: string[] = [] + try { + for (;;) { + const step = unwrap(session.next(), 'next') + if (step.step === 'done') break + for (const r of step.requests) { + svgs.push(r.svg) + const b64: string = await page.evaluate(async ([svg, w, h]: [string, number, number]) => { + const root = new DOMParser().parseFromString(svg, 'image/svg+xml').documentElement + if (root.namespaceURI !== 'http://www.w3.org/2000/svg') root.setAttribute('xmlns', 'http://www.w3.org/2000/svg') + root.setAttribute('width', String(w)); root.setAttribute('height', String(h)) + const url = URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(root)], { type: 'image/svg+xml;charset=utf-8' })) + const img = new Image(); img.decoding = 'sync'; img.src = url; await img.decode() + const c = document.createElement('canvas'); c.width = w; c.height = h + const ctx = c.getContext('2d')!; ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, w, h); ctx.drawImage(img, 0, 0, w, h) + return c.toDataURL('image/png').split(',')[1] + }, [r.svg, r.widthPx, r.heightPx]) + unwrap(session.addRaster(r.key, new Uint8Array(Buffer.from(b64, 'base64'))), r.key) + } + } + const parts = unwrap(session.finish(), 'finish') + writeFileSync(join(OUT!, `${name}.pdf`), Buffer.concat(parts)) + writeFileSync(join(OUT!, `${name}.views.json`), JSON.stringify(svgs.length)) + } finally { + session.free() + } + } + await browser.close() +}, 600_000) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 488d1d06..ff8d9944 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -491,3 +491,6 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp - 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. - V1-2.2 L 2026-10-30: A6 final = Figma, Inkscape, cairo, ImageMagick; Illustrator/Affinity optional (BDR-090, BDR-088 amended). Root visibility≠visible refused (root_visibility) reader+cleaning+composers, red-first, 3 browsers, mutations 20/20, check:all green. BDR-089, LRN-102. Security PASS but 3 pre-existing MEDIUM marker-hiding vectors open (root viewBox frame, inherited stroke-opacity/dasharray, hitbox stroke-width click hijack): class fix changes R3/R4 oracles, owner decision. + +## 2026-10-31 +- V1-2.2 three MEDIUM: lot A frame rule committed 0c87c7f..9e49ed1 (check:all green faa53c7); lot B isolation+hitbox built, uncommitted, patch in audits, R3 oracles pass under declared transforms, R4.1 manifest digest fails. Security PASS + MEDIUM scale bypass, verifier ECARTS(2) fixed. Junction-point overlap found. STOP: owner authorisation. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 46434404..c9ae9bc8 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -599,6 +599,14 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [x] L3 fix: reader refuses a root `visibility` other than `visible` (`root_visibility`), cleaning after active content, composers fail-closed; same check everywhere - [x] L4 browser proof before / after (Chromium, Firefox, WebKit from the Playwright cache) incl. opacity, display, stroke on the root - [ ] L5 BDR reserved ids + LRN heredoc expansion (owner go); docs; gates (cargo, fixtures, mutations, wasm + ts-rs, size, check:all), fresh verifier + security on final HEAD; commit + push; checkpoint + - [ ] M three MEDIUM (brief « V1-2.2 : arbitrages propriétaire sur les trois MEDIUM », on 958228a): isolated stacks only, DEV untouched, no merge, no V1-2.3; STOP before any R3/R4/step6 reference change + - [x] M1 audit: inherited vs group-wide properties reaching the layer (root presentation attributes, page CSS), what the reader already removes, hit rules of each marker, frame of each view (canvas, PDF, raster size), equine margins and hit winners + - [x] M2 tests first (red on 958228a): marker isolation (stroke, stroke-opacity, dasharray, width, fill, fill-opacity, fill-rule, opacity, display, visibility, linejoin/miterlimit) in canvas and PDF; hitbox capture rule; offset viewBox + compensating translate refused by verdict and preview (19 main markers), limits, secondary views, no view_box, invalid coordinates, legit transforms + - [x] M3 engine (lot B, uncommitted, patch in .claude/audits): composition root owned by the engine (frame + namespaces), drawing in a group of its own, layer and halo defs its siblings; composed layer hitbox `stroke="none"` + explicit capture rule; R3 layer form kept for the seed review drawings + - [x] M4 frame: one frame definition (view box, else drawing viewBox read strictly) for both composers, verdict and PreviewSheet; annotation bounds (circle, polygon, path data with curves and arcs); closed code + - [x] M5 browser click proofs (Chromium, Firefox, WebKit from the cache, touch where testable): normal hock click, giant root stroke before / after, close points, invisible and overlapping surfaces + - [x] M6 oracle inventory (evidence 2026-10-30-v1-2-2-three-medium-evidence.md): failing R3 / R4 / step6 references, before / after diff, equine render, SVG source digests, N-1 and PDF consequences → STOP for owner authorisation before any reference change + - [ ] M7 after authorisation only: references, docs, gates (cargo, mutations, wasm size, check:all DEV-isolated), fresh verifier + security, commit + push, checkpoint - [ ] 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) diff --git a/.claude/tasks/contracts/2026-10-30-v1-2-2-three-medium.md b/.claude/tasks/contracts/2026-10-30-v1-2-2-three-medium.md new file mode 100644 index 00000000..94c3a5dc --- /dev/null +++ b/.claude/tasks/contracts/2026-10-30-v1-2-2-three-medium.md @@ -0,0 +1,60 @@ +# Contract: V1-2.2 three MEDIUM (marker isolation, click hijack, view frame) + +Owner brief « V1-2.2 : arbitrages propriétaire sur les trois MEDIUM », 2026-10-30, on `958228a` +(branch `feature/v1-2-anatomical-sheets`). Two lots: + +- Lot A (committed): the frame rule, defect 3. +- Lot B (working tree, NOT committed, awaiting the owner's authorisation because it changes the + frozen R3 references): marker isolation and hitbox capture, defects 1 and 2, with the click proofs. + +Diff under review: the working tree (lot A + lot B) against `958228a`. + +## Problems + +1. Both composers (`crates/core/src/anatomy/compose.rs`) appended the engine's marker layer to the + drawing's own root: every presentation attribute the reader keeps on that root reached the markers, + inherited (`stroke-opacity`, `stroke-dasharray`, `stroke-width`, `stroke-linejoin`, `fill-rule`, + `color-interpolation-filters` on the halo…) or acting on a whole group (`opacity`, `display`). +2. The point hitbox (`pointer-events="all"`, no stroke of its own) inherited a root `stroke-width`: a + giant stroke widened every hitbox and the last one took the clicks meant for other markers. +3. A view without `view_box` was framed by the drawing's `viewBox`: moving it and translating the + drawing back left the horse identical and every marker out of frame, accepted. + +## Criteria + +- C1 Structural isolation, common to the canvas and the PDF view: no attribute of the drawing's root + reaches the layer or the halo filter, inherited or group-wide; the drawing keeps its own attributes + and renders as before; not a denylist of attributes. +- C2 Interactive surfaces declare their geometry and capture rule: the point hitbox `stroke="none"` and + a capture on its circle only; ergonomic sizes unchanged; zones and trigger keep their declared stroke. +- C3 Real click tests in Chromium, Firefox and WebKit (installed engines), touch where testable: normal + hock click, giant root stroke, hock after the fix, two close points, invisible and overlapping + surfaces; red on `958228a`, green after. A missing engine is named, never passed silently. +- C4 Frame rule in the Rust core, one definition for both composers, the verdict and PreviewSheet: the + view's `view_box`, else the drawing's `viewBox` read as a browser reads it; `preserveAspectRatio` + handled; annotations entirely in frame, edges included; curves, arcs, invalid coordinates, secondary + views, views without `view_box`, legitimate transforms; explicit refusal with a closed code; the + document never rewritten. +- C5 The reported drawing (horse, offset `viewBox`, compensating translate) is refused with its 19 + main-view markers, the historical annotations unchanged. +- C6 No frozen reference (R3 oracles, R3 canvas goldens, R4 digests, R4.1 real-raster manifest, step6 + goldens, N-1 copies, seed review drawings, equine drawing and fingerprint) rewritten or regenerated; + where lot B changes what a reference compares, the change is identified, explained and left for the + owner (no updated expectation committed). +- C7 `osteo-halo` and `root_visibility` protections intact; the A6 perimeter unchanged. +- C8 Gates: cargo on every feature set, clippy `-D warnings`, mutations, wasm module under 600 000 B + gzip, check:all DEV-isolated (lot A), browser proofs. +- C9 Docs describe only what is implemented (lot A in RUST.md §12.11, V1-2 contract §6.7, + ANNOTATION-RENDERING); lot B documented in its patch and the evidence file, not as shipped. + +## Out of scope + +No SQL, no Supabase DEV, no worker DEV, no historical resource change, no merge, no V1-2.3. + +## Clarifications + +- The junction-point overlap (zones painted and hit after the vertebral junction points, part of their + disc records the zone, on the historical sheet in every engine) is pre-existing and needs an owner + decision on the capture order: reported, marked `fixme` in the click spec, not fixed. +- `with_isolated_layer` (tests/common/svg_tree.rs, lot B) is the proposed declared change applied to + the frozen R3 trees; it is not committed.