#!/usr/bin/env python3 """Run the resolved owner passage audit for both owner recipes.""" from __future__ import annotations import json import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l81/audits" DATA = ROOT / "Standalone/data/owner_world.json" BINARY = ROOT / "Saved/Linux/l81/bin/VoxelForgeCoreHeadless-l81-clang" RECIPE = re.compile(r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=PASS$", re.M) PASSAGE = re.compile(r"^\[ResolvedPassageAudit\].*walkability=PASS$", re.M) MOUTH = re.compile(r"^\[PassageMouthProfileAudit\].*status=PASS$", re.M) SUMMARY = re.compile(r"^\[ResolvedPassageAuditSummary\].*status=PASS$", re.M) def run(recipe: str) -> dict: OUT.mkdir(parents=True, exist_ok=True) log = OUT / f"owner-{recipe}.log" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "env", "VOXELFORGE_L81_PASSAGE_BOUND_PADDING_VOXELS=0", "timeout", "1740s", str(BINARY), str(DATA), "--workers=12", "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--force-generate", "--clip-radius=3", "--max-clip-level=8", "--max-level=-1", f"--recipe={recipe}", "--audit-resolved-layout-passages", ] start = time.monotonic() try: with log.open("w", encoding="utf-8") as stream: proc = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, check=False, timeout=1740) except subprocess.TimeoutExpired as exc: raise RuntimeError(f"passage audit exceeded 1,740 seconds: {log}") from exc content = log.read_text(encoding="utf-8", errors="replace") passages = len(PASSAGE.findall(content)) mouths = len(MOUTH.findall(content)) passed = (proc.returncode == 0 and RECIPE.findall(content) == [(recipe, recipe)] and passages >= 1 and mouths == passages and SUMMARY.search(content) is not None) row = {"recipe": recipe, "exit_code": proc.returncode, "passages": passages, "mouth_profiles": mouths, "status": "PASS" if passed else "FAIL", "wall_s": round(time.monotonic() - start, 3), "log": str(log.relative_to(ROOT))} print("[L81PassageAuditRun] " + json.dumps(row, sort_keys=True), flush=True) if not passed: raise RuntimeError(f"owner passage audit failed: {log}") return row def main() -> int: if not BINARY.is_file() or not DATA.is_file(): raise SystemExit(f"missing input: {BINARY} or {DATA}") rows = [run(recipe) for recipe in ("surface-world", "floating-islands")] (OUT / "summary.json").write_text(json.dumps(rows, indent=2) + "\n", encoding="utf-8") return 0 if __name__ == "__main__": raise SystemExit(main())