Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux148/RunL148SeedSweep.py
T
Fr0zkaandClaude Opus 5.5 f21aab775f research: passage exclusion envelope at plan time (L148, 7/16; kept as patch)
Seed-2 shell carver measured: vertical-shafts route-edge-0, the layer's own connection edge from the 2-3 lower
mouth. Connection edges legitimately run beside the passage 12-20 m from the mouth, so an 8 m mouth-sphere exclusion
rejects 9/16 otherwise valid plans. Points to one continuous tube across the mouth instead of two overlapping ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
2026-11-01 14:18:19 +01:00

159 lines
8.1 KiB
Python

#!/usr/bin/env python3
"""Run the L148 composed passage gates for all 16 owner seeds."""
from __future__ import annotations
import argparse
import json
import re
import subprocess
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[4]
OUT = ROOT / "Saved/Linux/l148/seeds"
BIN = ROOT / "Standalone/bin/linux/VoxelForgeCoreHeadless-l148-clang"
DATA = ROOT / "Standalone/data/owner_world.json"
STAMP = "593551a985ec0d1acc271260e4c8f15a5261c90edb60e33a56ed6df27e269ffb"
STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M)
BASELINES = {
"tunnel-network": ROOT / "Saved/Linux/l135/optimized-seed-sweep.json",
"vertical-shafts": ROOT / "Saved/Linux/l139/seeds/summary.json",
}
DISPATCH = {
"tunnel-network": re.compile(
r"^\[DensityDispatch\] strate=2 generator=TunnelNetwork "
r"recipe=Core\.Caves\.PrimitiveField version=1 "
r"bound_path=Caves-native adapter=FCavesFieldAdapter$", re.M),
"vertical-shafts": re.compile(
r"^\[DensityDispatch\] strate=3 generator=VerticalShafts "
r"recipe=Core\.Caves\.PrimitiveField version=1 "
r"bound_path=Caves-native adapter=FCavesFieldAdapter$", re.M),
}
ROUTES = {
"tunnel-network": re.compile(
r"^\[ResolvedStrateRouteAudit\] strate=2 .*unsupported=0 "
r"grade_failures=0 .*status=PASS$", re.M),
"vertical-shafts": re.compile(
r"^\[ResolvedStrateRouteAudit\] strate=3 .*unsupported=0 "
r"grade_failures=0 .*status=PASS$", re.M),
}
CONTROLS = {
"tunnel-network": re.compile(
r"^\[TunnelNetworkBlockedRouteControl\].*expected=FAIL status=PASS$", re.M),
"vertical-shafts": re.compile(
r"^\[VerticalShaftsBlockedRouteControl\].*expected=FAIL status=PASS$", re.M),
}
REQUIRED = {
"passages": 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),
"passage_interior": re.compile(
r"^\[PassageInteriorCapsuleAuditSummary\].*status=PASS$", re.M),
}
EXCLUSION = {
strate: re.compile(
rf"^\[CavernPassageExclusionAudit\] strate={strate} primitives=\d+ "
r"outside_joint=0 mouth_joint=\d+ negative_controls=1/1 "
r"first_primitive=none first_passage=none status=PASS$", re.M)
for strate in (2, 3)
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--kind", choices=tuple(BASELINES), required=True)
args = parser.parse_args()
if not BIN.is_file() or not DATA.is_file():
raise SystemExit("missing L148 Clang binary or composed owner fixture")
baseline_path = BASELINES[args.kind]
baseline = json.loads(baseline_path.read_text(encoding="utf-8"))
baseline_results = {int(row["seed"]): row for row in baseline["results"]}
OUT.mkdir(parents=True, exist_ok=True)
mode_out = OUT / args.kind
mode_out.mkdir(parents=True, exist_ok=True)
results = []
partial = mode_out / "runs-partial.json"
for seed in range(16):
log = mode_out / f"seed{seed}.log"
layout = mode_out / f"seed{seed}.json"
old_layout = ROOT / f"Saved/Linux/l147/seeds/{args.kind}/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", "--density-dispatch-report",
"--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
checks["dispatch"] = bool(DISPATCH[args.kind].search(content))
checks["route"] = bool(ROUTES[args.kind].search(content))
checks["blocked_route_control"] = bool(CONTROLS[args.kind].search(content))
checks["strate2_exclusion_audit"] = bool(EXCLUSION[2].search(content))
checks["strate3_exclusion_audit"] = bool(EXCLUSION[3].search(content))
checks["three_passage_interiors"] = len(re.findall(
r"^\[ResolvedPassageAudit\].*interior_air=PASS", content, re.M)) == 3
checks["three_interior_negative_controls"] = len(re.findall(
r"^\[ResolvedPassageInteriorNegativeControl\].*detected=true status=PASS$",
content, re.M)) == 3
checks["three_ripple_gap_controls"] = len(re.findall(
r"^\[PassageRippleSamplingControl\].*status=PASS$", content, re.M)) == 3
checks["three_blocked_passage_controls"] = len(re.findall(
r"^\[ResolvedPassageBlockedControl\].*detected=true$", content, re.M)) == 3
checks["passage_count"] = len(re.findall(
r"^\[ResolvedPassageAudit\].*walkability=PASS$", content, re.M)) == 3
checks["layout_output"] = layout.is_file()
old_identity = None
new_identity = None
if layout.is_file():
new_identity = json.loads(layout.read_text(encoding="utf-8")).get("stable_identity")
if old_layout.is_file():
old_identity = json.loads(old_layout.read_text(encoding="utf-8")).get("stable_identity")
checks["layout_identity_matches_l147"] = (
old_identity is not None and new_identity is not None
and old_identity == new_identity)
passed = proc.returncode == 0 and all(checks.values())
prior = baseline_results.get(seed, {})
prior_passed = bool(prior.get("passed", False))
change = ("newly failing" if prior_passed and not passed else
"newly passing" if not prior_passed and passed else
"still passing" if prior_passed else "still failing")
failed_checks = [name for name, ok in checks.items() if not ok]
reason = (", ".join(failed_checks) if failed_checks else
"all gates pass and resolved identity matches L147" if passed else
f"process exit {proc.returncode}")
row = {"kind": args.kind, "seed": seed,
"prior_verdict": "PASS" if prior_passed else "FAIL",
"verdict": "PASS" if passed else "FAIL", "change": change,
"reason": reason, "exit": proc.returncode, "checks": checks,
"layout_identity": new_identity,
"elapsed_s": round(time.monotonic() - started, 3),
"log": str(log.relative_to(ROOT)), "layout": str(layout.relative_to(ROOT))}
results.append(row)
print("[L148SeedSweep] " + json.dumps(row, sort_keys=True), flush=True)
partial.write_text(json.dumps(results, indent=2) + "\n", encoding="utf-8")
passed_count = sum(row["verdict"] == "PASS" for row in results)
summary = {"kind": args.kind, "source_stamp": STAMP,
"baseline": str(baseline_path.relative_to(ROOT)), "seeds": list(range(16)),
"passed": passed_count, "failed": 16 - passed_count, "results": results}
summary_path = mode_out / "summary.json"
summary_path.write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8")
print(f"[L148SeedSweepSummary] kind={args.kind} passed={passed_count}/16 "
f"failed={16-passed_count} status={'PASS' if passed_count == 16 else 'FAIL'}",
flush=True)
return 0 if passed_count == 16 else 1
if __name__ == "__main__":
raise SystemExit(main())