Files
faunosteo/.claude/audits/2026-10-30-v1-2-2-mutations-three-medium.py

57 lines
7.5 KiB
Python

# V1-2.2 three MEDIUM (owner brief « arbitrages propriétaire sur les trois MEDIUM », 2026-10-30),
# mutation run: F = frame (defect 3), I = isolation and hitbox (defects 1, 2), K/V = the reserved-id
# and root-visibility protections re-checked on the new composer. Each mutant is applied to its
# source file, its cargo suite runs, the file is restored. Run from the repo root.
import subprocess
PDF='--features pdf-read,pdf-write'
muts=[
('F1 every bound in frame','crates/core/src/anatomy/frame.rs',' bounds.min_x >= self.min_x - slack\n',' true || bounds.min_x >= self.min_x - slack\n','sheet_frame',''),
('F2 right edge unchecked','crates/core/src/anatomy/frame.rs',' && bounds.max_x <= self.min_x + self.width + slack\n','','sheet_frame',''),
('F3 bottom edge unchecked','crates/core/src/anatomy/frame.rs',' && bounds.max_y <= self.min_y + self.height + slack\n','','sheet_frame',''),
('F4 view_box ignored, drawing frame always','crates/core/src/anatomy/frame.rs',' match view.view_box() {',' match None::<&crate::domain::sheet::ViewBox> {','sheet_frame',''),
('F5 zero width accepted','crates/core/src/anatomy/frame.rs',' && width > 0.0\n','','sheet_frame',''),
('F6 trailing numbers accepted','crates/core/src/anatomy/frame.rs',' [min_x, min_y, width, height] =>',' [min_x, min_y, width, height, ..] =>','sheet_frame',''),
('F7 circle radius ignored','crates/core/src/anatomy/frame.rs',' min_x: c.cx - c.r,',' min_x: c.cx,','sheet_frame',''),
('F8 unreadable path accepted','crates/core/src/anatomy/frame.rs',' None => Placement::Unreadable,',' None => Placement::InFrame,','sheet_frame',''),
('F9 cubic extremes skipped','crates/core/src/anatomy/path.rs',' let a = -p0 + 3.0 * p1 - 3.0 * p2 + p3;\n',' return [None, None];\n let a = -p0 + 3.0 * p1 - 3.0 * p2 + p3;\n','sheet_frame',''),
('F9b quadratic extreme skipped','crates/core/src/anatomy/path.rs',' let denominator = p0 - 2.0 * p1 + p2;\n',' return None;\n let denominator = p0 - 2.0 * p1 + p2;\n','sheet_frame',''),
('F10 arc extremes skipped','crates/core/src/anatomy/path.rs',' if ellipse.sweeps(angle) {',' if false && ellipse.sweeps(angle) {','sheet_frame',''),
('F11 trailing garbage accepted','crates/core/src/anatomy/path.rs',' if !cursor.done() {\n return None;\n }\n pen.bounds',' pen.bounds','sheet_frame',''),
('F12 missing drawing frame not reported','crates/core/src/anatomy/frame.rs',' faults.push(FrameFault::NoFrame { view_index });\n','','sheet_frame',''),
('F13 verdict ignores frame issues','crates/core/src/domain/sheet/verdict.rs',' .chain(frame_failures(&report))\n','','sheet_frame',''),
('F14 verdict measures nothing','crates/core/src/domain/sheet/verdict.rs',' report\n .issues\n .extend(frame_issues(&document.typed, |id| roots.get(id).copied()));\n','','sheet_frame',''),
('F15 preview measures nothing','crates/core/src/domain/sheet/preview.rs',' report.issues.extend(frame_issues(&self.document, |id| {\n self.drawing(id).and_then(|d| d.as_ref().ok())\n }));\n','','sheet_frame',''),
('F16 frame faults as rules failure','crates/core/src/domain/sheet/verdict.rs',' let rule =\n |code: &str| ![super::report::GEOMETRY_MISSING, OUT_OF_FRAME, NO_FRAME].contains(&code);',' let rule = |code: &str| code != super::report::GEOMETRY_MISSING;','sheet_frame',''),
('F17 slack follows the offset','crates/core/src/anatomy/frame.rs',' let slack = EDGE_TOLERANCE * self.width.max(self.height);',' let slack = EDGE_TOLERANCE * (self.width.max(self.height) + self.min_x.abs());','sheet_frame',''),
('I1 drawing attributes back on the root','crates/core/src/anatomy/compose.rs',' .partition(|a| a.qname == "xmlns" || a.qname == "xmlns:xlink");',' .partition(|_| true);','svg_marker_isolation',''),
('I2 layer inside the drawing group (canvas)','crates/core/src/anatomy/compose.rs',' let layer = render_composed_layer(document, view_id, &HashSet::new())?;\n root.children.push(Node::Element(checked(layer)?));\n Ok(root)\n}\n\n/// Root attributes',' let layer = render_composed_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 }\n Ok(root)\n}\n\n/// Root attributes','svg_marker_isolation',''),
('I3 halo in the drawing group','crates/core/src/anatomy/compose.rs',' root.children.push(Node::Element(defs));',' if let Some(Node::Element(group)) = root.children.first_mut() {\n group.children.insert(0, Node::Element(defs));\n }','svg_marker_isolation',''),
('I4 hitbox stroke not declared','crates/core/src/anatomy/layer.rs',' hitbox.push(("stroke", "none".to_owned()));\n','','svg_marker_isolation',''),
('I5 hitbox captures on all','crates/core/src/anatomy/layer.rs',' hitbox.push(("pointer-events", "visibleFill".to_owned()));',' hitbox.push(("pointer-events", "all".to_owned()));','svg_marker_isolation',''),
('I6 composers draw the R3 layer','crates/core/src/anatomy/layer.rs',' layer(document, view_id, states, true)',' layer(document, view_id, states, false)','svg_marker_isolation',''),
('I7 R3 layer gets the declared hitbox (seed review drawings would change)','crates/core/src/anatomy/layer.rs',' layer(document, view_id, states, false)',' layer(document, view_id, states, true)','anatomy_layer',''),
('K1 reader skips the reserved check','crates/core/src/anatomy/svg/mod.rs',' refs::check_reserved_ids(&sanitized.root)?;\n','','svg_reserved_ids',''),
('K7 highlight composes a reserved id','crates/core/src/anatomy/compose.rs',' if holds_reserved_id(&asset) {\n return Err(ComposeError::ReservedId);\n }\n','','svg_reserved_ids',''),
('K8 canvas composes a reserved id','crates/core/src/anatomy/compose.rs',' if holds_reserved_id(asset) {\n return Err(ComposeError::ReservedId);\n }\n','','svg_reserved_ids',''),
('K10 halo not written','crates/core/src/anatomy/compose.rs',' root.children.push(Node::Element(defs));','','pdf_session',PDF),
('V1 reader skips the root visibility check','crates/core/src/anatomy/svg/mod.rs',' sanitize::check_root_visibility(&sanitized.root)?;\n','','svg_root_visibility',''),
('V6 canvas composes a hidden root','crates/core/src/anatomy/compose.rs',' if check_root_visibility(asset).is_err() {\n return Err(ComposeError::RootVisibility);\n }\n','','svg_root_visibility',''),
('V7 highlight composes a hidden root','crates/core/src/anatomy/compose.rs',' if check_root_visibility(&asset).is_err() {\n return Err(ComposeError::RootVisibility);\n }\n','','svg_root_visibility',''),
]
for name,path,old,new,suite,features,*more in muts:
src=open(path).read()
mutant=src
for o,n in [(old,new)]+list(more):
if mutant.count(o)!=1:
print(name,'ANCHOR NOT FOUND x',mutant.count(o)); mutant=None; break
mutant=mutant.replace(o,n)
if mutant is None:
continue
open(path,'w').write(mutant)
try:
r=subprocess.run(['bash','-c',f'. scripts/rust-env.sh && cargo test -q -p faunosteo-core {features} --test {suite} 2>&1 | tail -3'],capture_output=True,text=True)
out=r.stdout
print(f"{name} ({suite}): {'KILLED' if 'FAILED' in out else ('COMPILE-ERR' if 'could not compile' in out else 'SURVIVED')}", flush=True)
finally:
open(path,'w').write(src)