#!/usr/bin/env python3 """Standalone integrity check for this published bundle. Imports none of CAIN-42's code. python3 verify_e37.py . Reads manifest.json and re-hashes every listed file. Prints INTACT or BROKEN with a count. """ import hashlib, json, pathlib, sys d = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else ".") m = json.loads((d / "manifest.json").read_text()) bad, n = [], 0 for rel, h in m["files"].items(): p = d / rel if not p.exists(): bad.append(rel + ":MISSING"); continue n += 1 if hashlib.sha256(p.read_bytes()).hexdigest() != h: bad.append(rel + ":HASH") print(json.dumps({"result": "INTACT" if not bad else "BROKEN", "checks": n, "passed": n - len(bad), "problems": bad}, indent=2)) sys.exit(0 if not bad else 1)