#!/usr/bin/env python3 """Run the L13 route parity and L9 uniform-block proof audits on L34.""" import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l34" BINARIES = { "clang": OUT / "bin/VoxelForgeCoreHeadless-l34-clang", "gcc": OUT / "bin/VoxelForgeCoreHeadless-l34-gcc", } RECIPES = ("floating-islands", "surface-world") rows = [] failed = False for recipe in RECIPES: for compiler, binary in BINARIES.items(): name = f"legacy-route-proof-{recipe}-{compiler}" logfile = OUT / f"{name}.log" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "900s", str(binary), str(ROOT / "Standalone/data/owner_world.json"), "--workers=12", "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--stream-hash", "--force-generate", "--clip-radius=3", "--max-clip-level=8", "--max-level=-1", f"--recipe={recipe}", "--audit-uniform-block-proofs", "--audit-route-parity", ] started = time.monotonic() try: with logfile.open("w", encoding="utf-8") as stream: result = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, timeout=900, check=False) except subprocess.TimeoutExpired: result = None elapsed = time.monotonic() - started output = logfile.read_text(encoding="utf-8", errors="replace") stamp = re.findall( r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=([^ ]+)$", output, re.M) route = re.findall(r"^\[RouteParityAudit\].*$", output, re.M) proofs = re.findall(r"^\[UniformBlockProofAudit\].*$", output, re.M) stamp_ok = stamp == [(recipe, recipe, "PASS")] route_ok = len(route) == 1 and route[0].endswith("status=PASS") proof_ok = len(proofs) == 1 and bool( re.search(r"violations=0(?:\s|$)", proofs[0])) ok = (result is not None and result.returncode == 0 and stamp_ok and route_ok and proof_ok) code = result.returncode if result is not None else "TIMEOUT" rows.append((name, recipe, compiler, elapsed, code, route_ok, bool(proof_ok), ok)) failed |= not ok print(f"[L34LegacyAuditRun] case={name} elapsed={elapsed:.1f}s exit={code} " f"recipe_stamp={'PASS' if stamp_ok else 'FAIL'} " f"L13={'PASS' if route_ok else 'FAIL'} L9={'PASS' if proof_ok else 'FAIL'} " f"{'PASS' if ok else 'FAIL'}", flush=True) summary = OUT / "legacy-audits.csv" summary.write_text( "case,recipe,compiler,elapsed_seconds,exit_code,l13,l9,status\n" + "".join(f"{name},{recipe},{compiler},{elapsed:.3f},{code}," f"{'PASS' if l13 else 'FAIL'},{'PASS' if l9 else 'FAIL'}," f"{'PASS' if ok else 'FAIL'}\n" for name, recipe, compiler, elapsed, code, l13, l9, ok in rows), encoding="utf-8") print(f"[L34LegacyAuditSummary] runs={len(rows)} pass={sum(row[-1] for row in rows)} " f"fail={sum(not row[-1] for row in rows)} summary={summary}", flush=True) raise SystemExit(1 if failed or len(rows) != 4 else 0)