KB-72D7
FIX7 Recheck-9 Packet V2 — evidence/materialize_canonicalizer.py
1 min read Revision 1
#!/usr/bin/env python3
Materialization command (P1): extract the EXACT python fence from the SSOT .md
and write it to the declared invocation filename. One canonical source (.md);
the .py is a derived materialization, not a second authority.
Usage: materialize_canonicalizer.py [src_md] [out_py]
import sys, re, hashlib
src = sys.argv[1] if len(sys.argv) > 1 else "canonicalizer-fix7-canon-v1-ssot.md"
out = sys.argv[2] if len(sys.argv) > 2 else "canonicalizer-fix7-canon-v1-ssot.py"
md = open(src, "r", encoding="utf-8").read()
m = re.search(r"python\n(.*?)\n", md, re.S)
if not m:
print("EXTRACTION_FAILED: no python fence", file=sys.stderr); sys.exit(3)
code = m.group(1) + "\n"
open(out, "w", encoding="utf-8").write(code)
print("extracted_bytes:", len(code.encode("utf-8")))
print("py_sha256:", hashlib.sha256(code.encode("utf-8")).hexdigest())
print("md_full_sha256(local copy):", hashlib.sha256(md.encode("utf-8")).hexdigest())