Files
faunosteo/.claude/audits/2026-11-01-v1-2-2-mutations-decisions.py
T
bchanot 76ead9567c fix(anatomy): V1-2.2 path numbers bounded by the frame magnitude
Fresh security review and verifier (MEDIUM): browsers read path data in
f32 and draw nothing for an arc radius or rotation past f32::MAX (WebKit
from 1e30) while the endpoints kept the verdict green. Every path and
viewBox number is now read within 2^20, else the path is unreadable.
Docs: section 12.12 transform table, mutation record, open zone finding.
2026-11-01 01:49:49 +01:00

59 lines
6.9 KiB
Python

# V1-2.2 owner decisions (brief « décisions et poursuite des corrections », 2026-11-01), mutation
# run: J = junctions « the visible wins » (canvas passes), S = visible size on the phone preview,
# N = frame range rules (f32), plus the frame and isolation mutants of 2026-10-30 whose anchors
# moved (F5, I2, I6, I7). Each mutant is applied to its source file, its cargo suite runs, the
# file is restored. Run from the repo root; the 2026-10-30 script runs the other mutants as is.
import subprocess
F='crates/core/src/anatomy/frame.rs'
L='crates/core/src/anatomy/layer.rs'
C='crates/core/src/anatomy/compose.rs'
R='crates/core/src/domain/sheet/report.rs'
V='crates/core/src/domain/sheet/verdict.rs'
VIS='sheet_marker_visibility'
muts=[
('J1 canvas draws the PDF layer (document order)',C,' let layer = render_canvas_layer(document, view_id, &HashSet::new())?;',' let layer = render_composed_layer(document, view_id, &HashSet::new())?;','svg_marker_isolation'),
('J2 canvas twins never capture',L,' Form::Canvas => "visiblePainted",',' Form::Canvas => "none",','svg_marker_isolation'),
('J3 shapes before hitboxes',L,' passes[pass as usize].push(Node::Element(element));',' passes[[1, 0, 2][pass as usize]].push(Node::Element(element));','svg_marker_isolation'),
('J4 PDF view in canvas passes',L,' layer(document, view_id, states, Form::Highlight)',' layer(document, view_id, states, Form::Canvas)','anatomy_compose'),
('J5 canvas passes, frozen canvas compared',L,' let children = if form == Form::Canvas {',' let children = if false {','anatomy_canvas_op'),
('S1 size never checked',F,' if shown >= MIN_VISIBLE_PX {',' if true || shown >= MIN_VISIBLE_PX {',VIS),
('S2 point measured on its hitbox',F,' Geometry::Circle(c) if annotation.trigger().is_none() => 2.0 * twin_radius(c.r),',' Geometry::Circle(c) if annotation.trigger().is_none() => 2.0 * c.r,',VIS),
('S3 every view on the main box',F,' let (w, h) = if main_view {',' let (w, h) = if true || main_view {',VIS),
('S4 width-only scale',F,' (w / self.width).min(h / self.height)',' w / self.width',VIS),
('S5 shapes measured on their larger side',F,' _ => (bounds.max_x - bounds.min_x).min(bounds.max_y - bounds.min_y),',' _ => (bounds.max_x - bounds.min_x).max(bounds.max_y - bounds.min_y),',VIS),
('S6 too small reported as out of frame',R,' Placement::TooSmall => (TOO_SMALL, "shows too small on the phone preview"),',' Placement::TooSmall => (OUT_OF_FRAME, "shows too small on the phone preview"),',VIS),
('S7 verdict ignores too small',V,' if found(&[TOO_SMALL]) {\n out.push(codes::MARKER_TOO_SMALL);\n }\n','',VIS),
('S8 too small counted as a rules failure',V,' NO_FRAME,\n TOO_SMALL,\n ]',' NO_FRAME,\n ]',VIS),
('S9 threshold 3 px',F,'pub const MIN_VISIBLE_PX: f64 = 4.0;','pub const MIN_VISIBLE_PX: f64 = 3.0;',VIS),
('S10 threshold 5 px',F,'pub const MIN_VISIBLE_PX: f64 = 4.0;','pub const MIN_VISIBLE_PX: f64 = 5.0;',VIS),
('N1 magnitude unchecked',F,' && reach <= MAX_FRAME_MAGNITUDE\n','',VIS),
('N2 span floor unchecked',F,' && short >= MIN_FRAME_SPAN\n',' && short > 0.0\n',VIS),
('N3 aspect unchecked',F,' && long <= short * MAX_FRAME_ASPECT\n','',VIS),
('N4 offset ratio unchecked',F,' && reach <= short * MAX_FRAME_OFFSET_RATIO;',' ;',VIS),
('N5 reach on the near edges only',F,' let reach = [min_x, min_y, min_x + width, min_y + height]',' let reach = [min_x, min_y]',VIS),
('N6 reach without abs',F,' .fold(0.0_f64, |m, v| m.max(v.abs()));',' .fold(0.0_f64, |m, v| m.max(*v));',VIS),
('N8 path numbers past 2^20 read',"crates/core/src/anatomy/path.rs",' .filter(|n| n.abs() <= super::frame::MAX_FRAME_MAGNITUDE)',' .filter(|n| n.is_finite())',VIS),
('N7 non-finite accepted',F,' let usable = finite\n',' let usable = true\n','--lib'),
# Equivalent: the aspect rule (long <= short * 100) refuses a zero or negative span already.
('F5 zero width accepted (moved, equivalent)',F,' && short >= MIN_FRAME_SPAN\n',' && short >= -1.0\n','sheet_frame'),
('F8 unreadable path accepted (moved)',F,' None => (Placement::Unreadable, None),',' None => (Placement::InFrame, None),','sheet_frame'),
('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 ]\n .contains(&code)\n };',' let rule = |code: &str| code != super::report::GEOMETRY_MISSING;','sheet_frame'),
('F17 slack follows the offset (rerun, test tightened)',F,' let slack = EDGE_TOLERANCE * self.width.max(self.height);',' let slack = EDGE_TOLERANCE * (self.width.max(self.height) + self.min_x.abs());','sheet_frame'),
('I2 layer inside the drawing group (canvas, moved)',C,' let layer = render_canvas_layer(document, view_id, &HashSet::new())?;\n root.children.push(Node::Element(checked(layer)?));',' let layer = render_canvas_layer(document, view_id, &HashSet::new())?;\n if let Some(Node::Element(group)) = root.children.first_mut() {\n group.children.push(Node::Element(checked(layer)?));\n }','svg_marker_isolation'),
('I6 PDF view draws the R3 layer (moved)',L,' layer(document, view_id, states, Form::Highlight)',' layer(document, view_id, states, Form::Review)','anatomy_compose'),
('I7 R3 layer gets the declared hitbox (moved)',L,' layer(document, view_id, states, Form::Review)',' layer(document, view_id, states, Form::Highlight)','anatomy_layer'),
('C1 census: a root attribute reaches the layer',C,' let mut root = Element {\n qname: "svg".to_owned(),\n namespace: asset.namespace,\n attrs: namespaces,',' let mut root = Element {\n qname: "svg".to_owned(),\n namespace: asset.namespace,\n attrs: namespaces.into_iter().chain(std::iter::once(super::svg::tree::Attribute { qname: "stroke-width".to_owned(), namespace: None, value: "9".to_owned() })).collect(),','svg_marker_isolation'),
]
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 && 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 'SURVIVED')}", flush=True)
finally:
open(path,'w').write(src)