chore(memory): V1-2.2 interior rule evidence, tools, LRN-105..107

This commit is contained in:
bchanot committed 2026-11-01 13:40:57 +01:00
1 parent c73415abef
commit e190dfc794
8 files changed
+233

No files matched your search

@@ -0,0 +1,51 @@
# V1-2.2 last MEDIUM, zone without interior: evidence
Owner brief « V1-2.2 : fermeture du dernier MEDIUM » (2026-11-01) on `de2dfb3`. Contract
`.claude/tasks/contracts/2026-11-01-v1-2-2-interior.md`. Commits `8dd2d78` (rule), `03be75b` (review 1: tiny arc radius), `86dce16` (review 2: f32 endpoints, arc spread),
`c73415a` (review 3 LOW: sampling skipped where unused). Final code HEAD `c73415a`.
Details RUST.md §12.14. Tools `.claude/audits/2026-11-01-v1-2-2-interior-tools/` (touch tap grid and its results).
## Rule
Polygon or path zone/trigger must fill a disc of 4 CSS px on the 320 × 568 preview (main 286 × 310, detail 254 × 191),
nonzero (the layer's rule), stroke out. Conservative widest-disc search (disc crossing no edge, chord deviation taken
off, arcs add an f32 drift bound), refuses in doubt (0.03 px band measured). Caps: 4 096 vertices, 4 096 cells, 2²⁵ edge
distances per sheet, over them refused. Arcs as browsers store them: nonzero radius below 2⁻²⁰ unreadable, endpoints equal in f32 draw no arc, the spread of
one-ulp variants added to the deviation and their extremes to the bounds. Codes
`annotation.geometry.interior_too_small` / `verification.validation.marker_interior_too_small` (proposal).
## Threshold
Equine at 320 widest disc: caudal 4.951 px, sacral 11.30, thoracic 11.47, cervical 12.17, lumbar 14.15, trigger 29.13.
4 px = the approved point threshold; equine accepted; caudal falls first past × 1.2378.
## Proofs
- cargo: `sheet_marker_visibility` (hostile refused, small legit accepted, threshold edge, projection, transforms, caps,
equine), `interior_probe` (fixture drift), interior and path unit tests (random polygons both rules, 300 random curves
within deviation, tiny and large arc radii).
- Browsers, 6 projects: `interior-clicks.spec.ts` 102 passed, `canvas-clicks.spec.ts` 99 passed. 16 probes: core never
over the browser's fill; 10 refused fill no 4 px disc; 6 accepted take real presses at the core's centre and the hit
test on a 90 % ring, fill only and as shipped; equine zones take a real press.
- Chromium touch adjustment: a tap up to ~10 px around a point's disc goes to the point (chromium-320/375, not
webkit-375); every equine zone keeps a tappable interior (320: caudal 18/21 … cervical 195/195).
- Mutations: 29 killed, 2 equivalent (Z22 prune, Z25 unreachable).
- References: no frozen oracle, golden, N-1 copy, seed or PDF digest touched; app 566 incl. PDF suites pass.
- Ignored cargo tests: one timing test (`pdf_serialize::l_report_with_real_rasters_costs_what_it_costs`) × 3 feature
runs; passed in release (5.2 s).
## Reviews
- Verifier on `8dd2d78`: ECARTS(3), all documentation, fixed in `03be75b`; I1–I4, I6 met; I5/I7 gates run here.
- Security on `8dd2d78`: PASS, MEDIUM sub-f32 arc radius (fixed `03be75b`), LOWs fixed (arc f32 drift, trace past cap,
fail-open default) or informational (libm ulp native/wasm at the exact threshold).
- Security on `03be75b`: PASS, two sibling MEDIUMs (f32-equal endpoints, ill-conditioned arc), fixed `86dce16`.
- Security on `86dce16`: PASS, no MEDIUM; LOW sampling cost fixed `c73415a`; LOWs open: arc tangent to a frame edge
refused (spread in bounds), spread an estimate (≤ 0.13 units measured on a model), refused needle hairline past the
frame, arc cost bounded by document size only (~1.8 s worst native).
## Gates on `c73415a`
check:all passed: cargo 2 350 passed, 0 failed, 3 ignored (one timing test × 3 runs); core-wasm 65, supabase 128, app 566;
e2e:ui 227 (incl. canvas-clicks 99 and interior-clicks 102, six projects); Docker app image, worker test and image.
e2e:shell 86 on the isolated sandbox. WASM 580 428 B gzip -9 native, 580 522 in the app image (margin 19 478 B).
@@ -0,0 +1,20 @@
chromium-320 caudal: 21 geometric hits, taps {"caudal":18,"-":3}
chromium-320 sacral: 67 geometric hits, taps {"sacral":51,"l6-s1":11,"-":2,"sacroiliac":2,"hip":1}
chromium-320 lumbar: 104 geometric hits, taps {"lumbar":87,"t18-l1":9,"l6-s1":8}
chromium-320 thoracic: 97 geometric hits, taps {"-":1,"thoracic":72,"c7-t1":18,"t18-l1":6}
chromium-320 cervical: 195 geometric hits, taps {"cervical":195}
chromium-320 head-trigger: 284 geometric hits, taps {"head-trigger":278,"-":6}
chromium-375 caudal: 30 geometric hits, taps {"caudal":30}
chromium-375 sacral: 97 geometric hits, taps {"sacral":77,"-":3,"l6-s1":15,"sacroiliac":2}
chromium-375 lumbar: 144 geometric hits, taps {"lumbar":120,"t18-l1":13,"l6-s1":11}
chromium-375 thoracic: 141 geometric hits, taps {"thoracic":121,"c7-t1":13,"t18-l1":7}
chromium-375 cervical: 275 geometric hits, taps {"cervical":269,"-":6}
chromium-375 head-trigger: 403 geometric hits, taps {"head-trigger":399,"-":4}
webkit-375 caudal: 30 geometric hits, taps {"caudal":29,"-":1}
webkit-375 sacral: 97 geometric hits, taps {"l6-s1":4,"-":2,"sacral":91}
webkit-375 lumbar: 144 geometric hits, taps {"lumbar":142,"t18-l1":1,"-":1}
webkit-375 thoracic: 141 geometric hits, taps {"-":10,"thoracic":130,"c7-t1":1}
webkit-375 cervical: 275 geometric hits, taps {"cervical":270,"-":5}
webkit-375 head-trigger: 403 geometric hits, taps {"-":7,"head-trigger":396}
[exited with code 0]
@@ -0,0 +1,38 @@
import { test } from '../support/browser'
test('probe zone taps', async ({ page }, info) => {
test.setTimeout(1_800_000)
await page.goto('/e2e/harness/canvas.html')
await page.locator('[data-anno-id="caudal"]').waitFor({ state: 'attached' })
const zones = ['caudal', 'sacral', 'lumbar', 'thoracic', 'cervical', 'head-trigger']
const out: string[] = []
for (const id of zones) {
const pts = await page.evaluate((id) => {
const svg = document.querySelector('[data-testid="anatomy-canvas"] svg') as SVGSVGElement
const ctm = svg.getScreenCTM()!
const z = svg.querySelector(`[data-anno-id="${id}"]`) as SVGGeometryElement
const b = z.getBBox()
const step = 2 / ctm.a
const res: { x: number; y: number; hit: string }[] = []
for (let x = b.x; x <= b.x + b.width; x += step) for (let y = b.y; y <= b.y + b.height; y += step) {
if (!z.isPointInFill(new DOMPoint(x, y))) continue
const p = new DOMPoint(x, y).matrixTransform(ctm)
const hit = document.elementFromPoint(p.x, p.y)?.closest('[data-anno-id]')?.getAttribute('data-anno-id') ?? '-'
res.push({ x: p.x, y: p.y, hit })
}
return res
}, id)
const tally: Record<string, number> = {}
let n = 0
for (const p of pts) {
if (p.hit !== id) continue
n++
const before = ((await page.getByTestId('clicks').textContent()) ?? '').split(' ').filter(Boolean).length
await page.touchscreen.tap(p.x, p.y)
await page.waitForTimeout(400)
const got = ((await page.getByTestId('clicks').textContent()) ?? '').split(' ').filter(Boolean).slice(before).join(',') || '-'
tally[got] = (tally[got] ?? 0) + 1
}
out.push(`${info.project.name} ${id}: ${n} geometric hits, taps ${JSON.stringify(tally)}`)
}
console.log(out.join('\n'))
})
@@ -0,0 +1,61 @@
# V1-2.2 last MEDIUM (brief « fermeture du dernier MEDIUM », 2026-11-01), mutation run: Z = the
# interior rule (anatomy::interior, path outline, frame placement, codes), plus the 2026-11-01
# decision mutants whose anchors this change moved (S1, S8, F16). Z23-Z25 cover the fixes after the
# security review of 8dd2d78. Each mutant is applied to its
# source file, its cargo suite runs, the file is restored. Run from the repo root.
import subprocess
F='crates/core/src/anatomy/frame.rs'
I='crates/core/src/anatomy/interior.rs'
P='crates/core/src/anatomy/path.rs'
R='crates/core/src/domain/sheet/report.rs'
V='crates/core/src/domain/sheet/verdict.rs'
VIS='sheet_marker_visibility'
muts=[
('Z1 interior never checked',F,' } else {\n interior_placement(geometry, scale, budget)\n }',' } else {\n Placement::InFrame\n }',VIS),
('Z2 any disc found accepted',F,' Some(disc) if disc.radius >= radius => Placement::InFrame,',' Some(_) => Placement::InFrame,',VIS),
('Z3 layer rule evenodd',I,'pub const LAYER_FILL_RULE: FillRule = FillRule::NonZero;','pub const LAYER_FILL_RULE: FillRule = FillRule::EvenOdd;',VIS),
('Z4 every point inside',I,' if inside { nearest } else { -nearest }',' if inside || true { nearest } else { -nearest }',VIS),
('Z5 closing edge dropped',I,' for (&a, &b) in closing.zip(subpath.iter()) {',' for (&a, &b) in closing.skip(1).zip(subpath.iter().skip(1)) {','--lib'),
('Z6 deviation not taken off',I,' let radius = clearance(outline, rule, centre) - outline.deviation;',' let radius = clearance(outline, rule, centre);','--lib'),
('Z7 chord deviation not recorded',P,' self.outline.deviation = self.outline.deviation.max(bend * step * step / 8.0);\n','','--lib'),
('Z8 one chord per curve',P,' let count = wanted.clamp(1.0, MAX_CURVE_CHORDS as f64) as usize;',' let count = wanted.clamp(1.0, 1.0) as usize;',VIS),
('Z9 budget never spent',I,' budget.work -= evaluated * edges;\n','','--lib'),
('Z10 vertex overflow ignored',I,' !outline.overflow && self.cells(edge_count(outline)) > 0',' self.cells(edge_count(outline)) > 0',VIS),
('Z11 path vertex cap ignored',P,' if self.vertices == self.max_vertices {',' if false {',VIS),
('Z12 reported as too small',R,' Placement::InteriorTooSmall => (\n INTERIOR_TOO_SMALL,',' Placement::InteriorTooSmall => (\n TOO_SMALL,',VIS),
('Z13 verdict ignores the interior',V,' if found(&[INTERIOR_TOO_SMALL]) {\n out.push(codes::MARKER_INTERIOR_TOO_SMALL);\n }\n','',VIS),
('Z14 interior counted as a rules failure',V,' TOO_SMALL,\n INTERIOR_TOO_SMALL,\n ]',' TOO_SMALL,\n ]',VIS),
('Z15 evenodd as nonzero',I,' FillRule::EvenOdd => winding % 2 != 0,',' FillRule::EvenOdd => winding != 0,','--lib'),
('Z16 tolerance in units, not px',F,' let tolerance = INTERIOR_TOLERANCE_PX / scale;',' let tolerance = INTERIOR_TOLERANCE_PX;',VIS),
('Z17 closepath keeps the subpath',P,' self.quadratic_control = None;\n self.open_subpath();\n }',' self.quadratic_control = None;\n }','--lib'),
('Z18 cubic bend underestimated',P,' let bend = 6.0\n',' let bend = 1.0\n','--lib'),
('Z19 arc bend on the smaller radius',P,' let count = self.chords(ellipse.rx.max(ellipse.ry) * ellipse.sweep * ellipse.sweep);',' let count = self.chords(ellipse.rx.min(ellipse.ry) * ellipse.sweep * ellipse.sweep);','--lib'),
('Z20 unmeasured accepted',F,' return Placement::InteriorUnmeasured;',' return Placement::InFrame;',VIS),
('Z21 cells past the cap',I,' || evaluated + 4 > affordable\n','','--lib'),
# Security review of 8dd2d78 (MEDIUM tiny arc radius, LOWs), fixed after the first run.
('Z23 tiny arc radius read',P,' if tiny(arc.rx) || tiny(arc.ry) {\n return None;\n }\n','',VIS),
('Z24 arc f32 drift dropped',P,' radius * ARC_F32_DRIFT,',' 0.0,','--lib'),
# Equivalent: bounds and outline share one reader, a path with bounds always has an outline.
('Z25 path without outline accepted (equivalent)',F,' _ => Placement::InteriorUnmeasured,',' _ => Placement::InFrame,',VIS),
# Second security review (03be75b): f32 endpoint equality, arc f32 spread.
('Z26 endpoints compared in f64',P,' if stored(arc.to) == stored(self.at) {',' if arc.to == self.at {','--lib'),
('Z27 arc spread dropped',P,' radius * ARC_F32_DRIFT + spread,',' radius * ARC_F32_DRIFT,','--lib'),
('Z28 variants out of the bounds',P,' for angle in other.extreme_angles() {\n if other.sweeps(angle) {\n self.add(other.at(angle));\n }\n }\n','','--lib'),
# Pruning only: a cell that cannot reach the floor never holds an accepted disc (equivalent).
('Z22 floor prune removed (equivalent)',I,' || cell.reach() < search.floor\n','',VIS),
('S1 size never checked (moved)',F,' if visible_size(annotation, geometry, &bounds) * scale < MIN_VISIBLE_PX {',' if false {',VIS),
('S8 too small counted as a rules failure (moved)',V,' NO_FRAME,\n TOO_SMALL,\n INTERIOR_TOO_SMALL,\n ]',' NO_FRAME,\n INTERIOR_TOO_SMALL,\n ]',VIS),
('F16 frame faults as rules failure (moved)',V,' let rule = |code: &str| {\n ![\n super::report::GEOMETRY_MISSING,\n OUT_OF_FRAME,\n NO_FRAME,\n TOO_SMALL,\n INTERIOR_TOO_SMALL,\n ]\n .contains(&code)\n };',' let rule = |code: &str| code != super::report::GEOMETRY_MISSING;','sheet_frame'),
]
for name,path,old,new,suite in muts:
src=open(path).read()
if src.count(old)!=1:
print(name,'ANCHOR NOT FOUND x',src.count(old), flush=True); continue
open(path,'w').write(src.replace(old,new))
try:
target = suite if suite.startswith('--') else f'--test {suite}'
r=subprocess.run(['bash','-c',f'. scripts/rust-env.sh && timeout 600 cargo test -q -p faunosteo-core {target} 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 or 'error[' in out else ('TIMEOUT' if r.returncode == 124 else 'SURVIVED'))}", flush=True)
finally:
open(path,'w').write(src)