#!/usr/bin/env python3 """Verify the supplied manifest, then rerun both recovered cubature packages.""" import argparse from datetime import datetime, timezone import hashlib import json from pathlib import Path import subprocess import sys import time def main(): if not __debug__ or sys.flags.optimize: raise SystemExit("REFUSED: run this combined launcher without optimization; the f23/f24 original uses assertions.") if sys.version_info < (3, 11): raise SystemExit("Python 3.11 or newer is required by the recovered f23/f24 source.") root = Path(__file__).resolve().parent parser = argparse.ArgumentParser() parser.add_argument("--output", type=Path, default=root / "rerun_evidence") args = parser.parse_args() for line in (root / "SHA256SUMS").read_text().splitlines(): expected, name = line.split(" ", 1) relative = Path(name) if relative.is_absolute() or ".." in relative.parts: raise SystemExit("Invalid manifest path") if hashlib.sha256((root / relative).read_bytes()).hexdigest() != expected: raise SystemExit("SHA-256 mismatch: " + name) output = args.output.resolve() output.mkdir(parents=True, exist_ok=True) commands = [ ("f2_f21", [sys.executable, "-u", str(root / "omega_f2_f21_recovered/verify_classI_f2_f21.r2.py"), str(root / "omega_f2_f21_recovered/classI_exact_certificates_f2_f21.json"), "--ledger", str(output / "f2_f21_ledger.json")]), ("f23_f24", [sys.executable, "-u", str(root / "omega_recovery_package/replay_recovered.py")]), ] report = [] for label, command in commands: started = datetime.now(timezone.utc).isoformat() start = time.monotonic() result = subprocess.run(command, cwd=output, capture_output=True) (output / (label + ".stdout.txt")).write_bytes(result.stdout) (output / (label + ".stderr.txt")).write_bytes(result.stderr) report.append({"component": label, "command": command, "started_utc": started, "duration_seconds": time.monotonic()-start, "exit_code": result.returncode}) (output / "runs.json").write_text(json.dumps(report, indent=2) + "\n") print(result.stdout.decode(), end="", flush=True) if result.returncode: raise SystemExit(result.stderr.decode() or f"{label} failed") print("COMBINED PASS: f2-21 and f23-24 recovered packages; 492 exact moment identities.") if __name__ == "__main__": main()