#!/usr/bin/env python3 """Compare rendered Surface World hashes for v227 and the no-op v228 bump.""" from __future__ import annotations import json import re import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l137/output-check" DATA = ROOT / "Standalone/data/owner_world.json" BINARIES = { "v227": ROOT / "Saved/Linux/l137/bin/VoxelForgeCoreHeadless-l137-aa-a", "v228": ROOT / "Saved/Linux/l137/bin/VoxelForgeCoreHeadless-l137-v228", } CAMERA = "8.000000000000,16.000000000000,-372.262695312500,0,0" HASHES = re.compile( r"^\[Pipeline(?:FullDetailHash|WholeViewHash|MaterialHash|LODHash|ExactQueryHash)\].*$", re.M) def run(version: str) -> tuple[list[str], str]: OUT.mkdir(parents=True, exist_ok=True) log = OUT / f"surface-world-{version}.log" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "1740s", str(BINARIES[version]), str(DATA), "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--workers=8", "--clip-radius=3", "--max-clip-level=8", "--max-level=8", f"--camera={CAMERA}", "--recipe=surface-world", "--stream-hash", "--stream-scheduler-policy=3", ] with log.open("w", encoding="utf-8") as output: result = subprocess.run(command, cwd=ROOT, stdout=output, stderr=subprocess.STDOUT, check=False, timeout=1740) content = log.read_text(encoding="utf-8", errors="replace") hashes = HASHES.findall(content) if result.returncode or len(hashes) < 4: raise SystemExit(f"hash run failed: {version}; exit={result.returncode}; log={log}") return hashes, str(log.relative_to(ROOT)) def main() -> int: rows = [] for version in BINARIES: hashes, log = run(version) rows.append({"version": version, "hashes": hashes, "log": log}) match = rows[0]["hashes"] == rows[1]["hashes"] summary = {"output_hashes_match": match, "rows": rows} (OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") print("[L137VersionOutput] " + json.dumps({ "output_hashes_match": match, "hash_lines": len(rows[0]["hashes"]), "v227": rows[0]["hashes"], "v228": rows[1]["hashes"]}, sort_keys=True)) return 0 if match else 1 if __name__ == "__main__": raise SystemExit(main())