Files
faunosteo/.claude/audits/2026-11-01-v1-2-2-mutations-interior.py
T

64 lines
6.7 KiB
Python

# 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. Z7, Z19, Z24 re-anchored on the final code c73415a (verifier
# 2026-11-01: their first anchors left with 03be75b and 86dce16); Z23 run on the unit suite since 86dce16, whose
# f32 spread refuses the same arcs on its own in sheet_marker_visibility. 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(deviation);\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 radius = ellipse.rx.max(ellipse.ry);\n let spread',' let radius = ellipse.rx.min(ellipse.ry);\n let spread','--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','','--lib'),
('Z24 arc f32 drift dropped',P,' radius * ARC_F32_DRIFT + spread,',' spread,','--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)