#!/usr/bin/env python3 """Recipe-stamped resolved-passage audits for the L33 upper-SurfaceWorld stack.""" import os import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l33" TAG = os.environ.get("VOXELFORGE_L33_AUDIT_TAG", "clang").strip() or "clang" BINARY = Path(os.environ.get("VOXELFORGE_L33_AUDIT_BINARY", str(OUT / f"bin/VoxelForgeCoreHeadless-{TAG}-l33-final"))) ROWS = [] FAILED = False for style in range(4): name = f"upper-sw-three-strata-{TAG}-style{style}" fixture = OUT / f"fixtures/sw-upper-tunnel-network-style{style}.json" logfile = OUT / f"{name}.log" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", str(BINARY), str(fixture), "--workers=12", "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--force-generate", "--clip-radius=3", "--max-clip-level=8", "--max-level=-1", "--recipe=floating-islands", "--audit-resolved-layout-passages", ] started = time.monotonic() try: with logfile.open("w", encoding="utf-8") as stream: result = subprocess.run(command, stdout=stream, stderr=subprocess.STDOUT, timeout=1800, check=False) except subprocess.TimeoutExpired: result = None elapsed = time.monotonic() - started text = logfile.read_text(encoding="utf-8", errors="replace") stamp_ok = re.findall( r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=([^ ]+)$", text, re.M) == [("floating-islands", "floating-islands", "PASS")] summary = re.search(r"^\[ResolvedPassageAuditSummary\].*$", text, re.M) summary_ok = bool(summary and "interfaces=2 passed=2 natural=2/2" in summary.group() and "route_walkable=2" in summary.group() and "route_binding_failures=0" in summary.group() and "status=PASS" in summary.group()) markers = ( r"^\[PassageOpenAirAuditSummary\].*violations=0.*status=PASS$", r"^\[PassageNoLongBridgeAudit\].*status=PASS$", r"^\[PassageRockColumnAuditSummary\].*wall_or_support_failures=0.*status=PASS$", r"^\[PassageNaturalnessSummary\].*status=PASS$", ) markers_ok = all(re.search(pattern, text, re.M) for pattern in markers) passage_rows = re.findall( r"^\[ResolvedPassageAudit\].*blocked=0 support_samples=\d+ unsupported=0 " r"grade_failures=0 mouth_content=2/2 mouth_radius=2/2 walkability=PASS$", text, re.M) floor_rows = re.findall(r"^\[FloorProfileBlend\].*status=PASS$", text, re.M) route_rows = re.findall( r"^\[ResolvedStrateRouteAudit\].*blocked=0 support_samples=\d+ unsupported=0 " r"grade_failures=0 mouth_binding=PASS status=PASS$", text, re.M) ok = (result is not None and result.returncode == 0 and stamp_ok and summary_ok and markers_ok and len(passage_rows) == 2 and len(route_rows) == 2 and len(floor_rows) >= 1 and "[Walkability] PASS" in text) FAILED |= not ok ROWS.append((style, elapsed, result.returncode if result else "TIMEOUT", ok)) print(f"{name} elapsed={elapsed:.1f}s exit={result.returncode if result else 'TIMEOUT'} " f"recipe={'PASS' if stamp_ok else 'FAIL'} passages={len(passage_rows)}/2 " f"routes={len(route_rows)}/2 floor_blend_rows={len(floor_rows)} " f"{'PASS' if ok else 'FAIL'}", flush=True) summary_path = OUT / f"upper-sw-three-strata-{TAG}-audits.csv" summary_path.write_text( "style,elapsed_seconds,exit_code,status\n" + "".join(f"{style},{elapsed:.3f},{code},{'PASS' if ok else 'FAIL'}\n" for style, elapsed, code, ok in ROWS), encoding="utf-8") print(f"[L33UpperSurfaceFixtureAudit] compiler={TAG} runs={len(ROWS)} pass={sum(row[-1] for row in ROWS)} " f"fail={sum(not row[-1] for row in ROWS)} summary={summary_path}", flush=True) raise SystemExit(1 if FAILED or len(ROWS) != 4 else 0)