#!/usr/bin/env python3 """Fail-closed source, axiom-log, and checksum audit for the 011 closure.""" from __future__ import annotations import argparse from pathlib import Path import sys from compile_lean_011 import CORE_TARGETS, SMOOTH_TARGETS, TARGET, closure from verify_lean_010s import verify_hashes, verify_logs, verify_sources ROOT = Path(__file__).resolve().parents[1] PINNED = [ "proofs/RootFieldLift011a.lean", "proofs/SutureSignature011b.lean", "proofs/SmoothSuture011c.lean", "proofs/SutureCovariance011c.lean", "proofs/SutureRegular011c.lean", "proofs/SutureOpenBranch011c.lean", "proofs/SutureActualMinor011c.lean", "proofs/SutureLDU011c.lean", "proofs/SutureLDUCertificate011c.lean", "proofs/SutureLDUWitness011c.lean", "proofs/SutureLDUEntries011c.lean", "proofs/SutureClassical011d.lean", "proofs/SutureS02Unconditional011e.lean", "proofs/HiggsMass.lean", "proofs/GaugeMatterTrunk011f.lean", "proofs/QuantumStateBoundary011g.lean", "proofs/ObservableExposure011h.lean", "proofs/GlobalCoverage011i.lean", "proofs/RootToPhysicsManifest011j.lean", "proofs/011_ROOT_TO_PHYSICS_INDEX.md", "lakefile.lean", "lake-manifest.json", "lean-toolchain", "scripts/compile_lean_011.py", "scripts/verify_lean_011.py", ".github/workflows/lean-root-to-physics-011.yml", ] def sources() -> list[str]: names = closure(TARGET) for core_target in CORE_TARGETS: for name in closure(core_target): if name not in names: names.append(name) names += list(SMOOTH_TARGETS) return [str(ROOT / "proofs" / f"{name}.lean") for name in names] def main() -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--log", action="append", default=[]) args = parser.parse_args() try: source_count = verify_sources(sources()) hash_count = verify_hashes(str(ROOT / "SHA256SUMS"), PINNED) if args.log: log_count = verify_logs(args.log) print( "011 PASS: " f"{source_count} closure sources scanned; " f"{log_count} theorem audits checked; " f"{hash_count} pinned hashes verified" ) else: print( "011 SOURCE PASS: " f"{source_count} closure sources scanned; " f"{hash_count} pinned hashes verified" ) except (OSError, ValueError) as error: print(f"011 FAIL: {error}", file=sys.stderr) return 1 return 0 if __name__ == "__main__": raise SystemExit(main())