#!/usr/bin/env python3 """Compare owner four-strata W12 hashes with the pinned W1/W8 cameras.""" import json import re import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l67" DATA = ROOT / "Standalone/data/owner_world.json" BINARY = OUT / "bin-final/VoxelForgeCoreHeadless-l67-final-clang" HASH_RE = re.compile(r"^\[Pipeline(?:FullDetailHash|WholeViewHash|LODHash|ExactQueryHash)\].*$", re.M) CAMERA_RE = re.compile(r"camera_m=\(([-0-9.]+),([-0-9.]+),([-0-9.]+)\)") RESULTS = [] def hashes(path): return HASH_RE.findall(path.read_text(encoding="utf-8", errors="replace")) def main(): logs = OUT / "logs" layouts = OUT / "layouts" logs.mkdir(parents=True, exist_ok=True) layouts.mkdir(parents=True, exist_ok=True) for strate in range(4): w1_path = OUT / "verify" / f"owner-new-plan-clang-strate{strate}-w1.log" w8_path = OUT / "verify" / f"owner-new-plan-clang-strate{strate}-w8.log" match = CAMERA_RE.search(w1_path.read_text(encoding="utf-8", errors="replace")) if not match: raise RuntimeError(f"camera not found in {w1_path}") camera = ",".join(match.groups()) + ",0.000000,0.000000" log_path = logs / f"owner-new-plan-clang-strate{strate}-w12-final.log" layout_path = layouts / f"owner-new-plan-clang-strate{strate}-w12-final.json" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "1800s", str(BINARY), str(DATA), "--workers=12", "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--force-generate", "--clip-radius=1", "--max-clip-level=8", "--max-level=0", "--recipe=surface-world", "--stream-hash", "--max-clip-level=0", "--render-distance-chunks=0", f"--camera={camera}", f"--resolved-layout-output={layout_path}", ] with log_path.open("w", encoding="utf-8") as stream: result = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, timeout=1800, check=False) current = hashes(log_path) w1 = hashes(w1_path) w8 = hashes(w8_path) passed = result.returncode == 0 and len(current) == 12 \ and current == w1 == w8 row = {"strate": strate, "exit_code": result.returncode, "w1_hashes": len(w1), "w8_hashes": len(w8), "w12_hashes": len(current), "w1_w8_w12_equal": passed, "log": str(log_path.relative_to(ROOT))} RESULTS.append(row) print(json.dumps(row, sort_keys=True), flush=True) summary = {"status": "PASS" if all(row["w1_w8_w12_equal"] for row in RESULTS) else "FAIL", "strata": RESULTS} (OUT / "verify" / "owner-w1-w8-w12-determinism.json").write_text( json.dumps(summary, indent=2) + "\n", encoding="utf-8") print(f"[L67OwnerW1W8W12] status={summary['status']}", flush=True) return 0 if summary["status"] == "PASS" else 1 if __name__ == "__main__": raise SystemExit(main())