chore(memory): V1-2.2 reserved ids evidence, mutations, contract, TODO

This commit is contained in:
bchanot committed 2026-10-30 17:31:01 +01:00
1 parent 6ed4d21eb3
commit 81f7639c75
5 files changed
+155

No files matched your search

@@ -0,0 +1,36 @@
# V1-2.2 reserved ids (owner brief 2026-10-30), mutation run (evidence
# .claude/audits/2026-10-30-v1-2-2-reserved-ids-evidence.md §4): each mutant is applied to its source
# file, its cargo suite runs (`features` set when the suite needs them), the file is restored. Run
# from the repo root.
import subprocess
PDF='--features pdf-read,pdf-write'
muts=[
('K1 reader skips the reserved check','crates/core/src/anatomy/svg/mod.rs',' refs::check_reserved_ids(&sanitized.root)?;\n','','svg_reserved_ids',''),
('K2 cleaning skips the reserved check','crates/core/src/anatomy/svg/clean.rs','.and_then(|()| check_reserved_ids(&read.root))','','svg_reserved_ids',''),
('K3 exact case only','crates/core/src/anatomy/svg/refs.rs','.any(|reserved| id.eq_ignore_ascii_case(reserved))','.any(|reserved| id == *reserved)','svg_reserved_ids',''),
('K4 prefix instead of exact name','crates/core/src/anatomy/svg/refs.rs','.any(|reserved| id.eq_ignore_ascii_case(reserved))','.any(|reserved| id.to_ascii_lowercase().starts_with("osteo-"))','svg_reserved_ids',''),
('K5 root id not checked','crates/core/src/anatomy/svg/refs.rs',' element.attr("id").is_some_and(is_reserved_id)\n || element',' element','svg_reserved_ids',''),
('K6 descendants not checked','crates/core/src/anatomy/svg/refs.rs',' || element.element_children().any(holds_reserved_id)',' || false','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',''),
('K9 pre-fix composer restored (no guard, halo skipped when the drawing has one)','crates/core/src/anatomy/compose.rs',' if holds_reserved_id(&asset) {\n return Err(ComposeError::ReservedId);\n }\n','','svg_reserved_ids','',
(' if !append_to_first_defs(root) {',' if holds_reserved_id(root) {\n return;\n }\n if !append_to_first_defs(root) {')),
('K10 halo not written','crates/core/src/anatomy/compose.rs',' add_halo_filter(&mut asset);','','pdf_session',PDF),
('K11 reason renamed','crates/core/src/anatomy/svg/tree.rs','Self::ReservedId => "reserved_id"','Self::ReservedId => "dangling_reference"','svg_reserved_ids',''),
]
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)