#!/usr/bin/env python3 """Run the 16-seed composed passage and seam audits on the L138 candidate.""" 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/l138/seeds" BIN = ROOT / "Saved/Linux/l138/bin/VoxelForgeCoreHeadless-l138-clang" DATA = ROOT / "Standalone/data/owner_world.json" STAMP = "9aade4e6cb33e86c36b89440644d9ef5d440288fb6ff0af03af128291c95f93f" STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M) REQUIRED = { "passage": re.compile(r"^\[ResolvedPassageAuditSummary\].*status=PASS$", re.M), "seams": re.compile(r"^\[PassageTileSeamAudit\].*status=PASS$", re.M), "shell": re.compile(r"^\[PassageShellAuditSummary\].*status=PASS$", re.M), "naturalness": re.compile(r"^\[PassageNaturalnessSummary\].*status=PASS$", re.M), "mouth_profile": re.compile(r"^\[PassageMouthProfileSummary\].*status=PASS$", re.M), "ripple": re.compile(r"^\[PassageRippleAuditSummary\].*status=PASS$", re.M), "route_negative_control": re.compile( r"^\[TunnelNetworkBlockedRouteControl\].*expected=FAIL status=PASS$", re.M), } def main() -> int: if not BIN.is_file() or not DATA.is_file(): raise SystemExit("missing L138 Clang binary or owner fixture") OUT.mkdir(parents=True, exist_ok=True) results = [] for seed in range(16): log = OUT / f"seed{seed}.log" layout = OUT / f"seed{seed}.json" command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "1740s", str(BIN), str(DATA), "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--workers=8", "--clip-radius=3", "--max-clip-level=8", "--max-level=0", "--force-generate", f"--seed={seed}", "--recipe=surface-world", "--audit-resolved-layout-passages", "--audit-passage-tile-seams", f"--resolved-layout-output={layout}"] started = time.monotonic() with log.open("w", encoding="utf-8") as output: proc = subprocess.run(command, cwd=ROOT, stdout=output, stderr=subprocess.STDOUT, check=False, timeout=1740) content = log.read_text(encoding="utf-8", errors="replace") stamp = STAMP_RE.search(content) checks = {name: bool(pattern.search(content)) for name, pattern in REQUIRED.items()} checks["source_stamp"] = stamp is not None and stamp.group(1) == STAMP blocked = re.findall(r"^\[ResolvedPassageBlockedControl\].*detected=true$", content, re.M) checks["three_blocked_controls"] = len(blocked) == 3 passed = proc.returncode == 0 and all(checks.values()) row = {"seed": seed, "exit": proc.returncode, "passed": passed, "checks": checks, "blocked_controls": len(blocked), "elapsed_s": round(time.monotonic() - started, 3), "log": str(log.relative_to(ROOT)), "layout": str(layout.relative_to(ROOT))} results.append(row) print("[L138SeedSweep] " + json.dumps(row, sort_keys=True), flush=True) (OUT / "runs-partial.json").write_text(json.dumps(results, indent=2) + "\n") if not passed: raise SystemExit(f"seed {seed} failed composed audits; see {log}") summary = {"source_stamp": STAMP, "seeds": list(range(16)), "passed": len(results), "failed": 0, "results": results} (OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") print("[L138SeedSweepSummary] passed=16/16 status=PASS") return 0 if __name__ == "__main__": raise SystemExit(main())