Versioned capsule vein records (stable ID, resource ID, endpoints, radius, seeded irregularity) resolved into the snapshot only when requested, placed beside the route and away from passages, landings and landmarks (forced-passage control rejected). The bound field table gains materialAt (host + two resource IDs + Q16 weights) behind a per-tile BVH; mesh export v2 carries per-vertex materials; a measurement-only yield computes removed resource volume (0 on already-air space). With veins on, every density, mesh, payload and topology hash is unchanged; demo off: owner hashes identical to L47. fast/medium/full PASS. Research R18 (cavern-graph planner) and R19 (why FloatingIslands costs ~10x SurfaceWorld). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
1111 lines
59 KiB
Python
1111 lines
59 KiB
Python
#!/usr/bin/env python3
|
|
"""Run the reusable VoxelForge verification tiers: fast, medium, or full."""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import atexit
|
|
import hashlib
|
|
import json
|
|
import math
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import shutil
|
|
import signal
|
|
import statistics
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
import zlib
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
VERIFY_DIR = ROOT / "Standalone/Tools/verify"
|
|
LINUX37 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux37"
|
|
LINUX47 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux47"
|
|
OWNER = ROOT / "Standalone/data/owner_world.json"
|
|
OUT_DEFAULT = ROOT / "Saved/Linux/l42"
|
|
|
|
PARSER = argparse.ArgumentParser(description=__doc__)
|
|
PARSER.add_argument("tier", choices=("fast", "medium", "full"))
|
|
PARSER.add_argument("--out", type=Path, default=OUT_DEFAULT,
|
|
help="artifact directory (default: Saved/Linux/l41)")
|
|
PARSER.add_argument("--baseline", default="HEAD",
|
|
help="commit used for the full-tier cost baseline (default: HEAD)")
|
|
PARSER.add_argument("--overall-timeout", type=int, default=7200,
|
|
help="maximum tier wall time in seconds (default: 7200; each child is capped at 1800)")
|
|
ARGS = PARSER.parse_args()
|
|
OUT = ARGS.out.resolve()
|
|
ROUND_NAME = OUT.name
|
|
os.environ["VOXELFORGE_VERIFY_OUT"] = str(OUT)
|
|
os.environ["PYTHONDONTWRITEBYTECODE"] = "1"
|
|
sys.dont_write_bytecode = True
|
|
|
|
sys.path.insert(0, str(VERIFY_DIR))
|
|
from owner_step import measure as measure_owner_step
|
|
from runner import VerificationFailure, VerificationRunner, bounded_run
|
|
from source_stamp import source_stamp
|
|
|
|
|
|
CLANG = OUT / "bin" / f"VoxelForgeCoreHeadless-{ROUND_NAME}-clang"
|
|
GCC = OUT / "bin" / f"VoxelForgeCoreHeadless-{ROUND_NAME}-gcc"
|
|
RENDERER = OUT / "bin" / f"VoxelForgeOffscreenCapture-{ROUND_NAME}-clang"
|
|
HASH_RE = re.compile(r"^\[Pipeline(?:FullDetailHash|WholeViewHash|LODHash|ExactQueryHash)\].*$", re.M)
|
|
TILE_HASH_RE = re.compile(
|
|
r"^\[PipelineTileHash\] lod=(-?\d+) x=(-?\d+) y=(-?\d+) z=(-?\d+) "
|
|
r"density=(0x[0-9a-f]+) mesh=(0x[0-9a-f]+) "
|
|
r"payload=(0x[0-9a-f]+) topology=(0x[0-9a-f]+)$", re.M)
|
|
TILE_MATERIAL_HASH_RE = re.compile(
|
|
r"^\[PipelineTileMaterialHash\] lod=(-?\d+) x=(-?\d+) y=(-?\d+) z=(-?\d+) "
|
|
r"material=(0x[0-9a-f]+)$", re.M)
|
|
CAMERA_SWEEP_SEED = 0x4C3434
|
|
RECIPE_RE = re.compile(
|
|
r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=([^ ]+)$", re.M)
|
|
|
|
|
|
def compiler_name(binary: Path) -> str:
|
|
return "gcc" if "gcc" in binary.name else "clang"
|
|
|
|
|
|
def env_for(*, capture: bool = False) -> dict[str, str]:
|
|
result = os.environ.copy()
|
|
result["VOXELFORGE_VERIFY_OUT"] = str(OUT)
|
|
result["VOXELFORGE_L37_OUT"] = str(OUT)
|
|
result["VOXELFORGE_L37_CAPTURE_DIR"] = str(OUT / "captures")
|
|
result["VOXELFORGE_L37_HEADLESS"] = str(CLANG)
|
|
result["VOXELFORGE_L37_RENDERER"] = str(RENDERER)
|
|
result["VOXELFORGE_VERIFY_HEADLESS"] = str(CLANG)
|
|
if capture:
|
|
result["LP_NUM_THREADS"] = "12"
|
|
result["XDG_CACHE_HOME"] = str(OUT / "xdg-cache")
|
|
return result
|
|
|
|
|
|
def all_match(text: str, pattern: str) -> bool:
|
|
return re.search(pattern, text, re.M) is not None
|
|
|
|
|
|
def parse_ratio(text: str, name: str) -> float | None:
|
|
match = re.search(rf"(?:^| ){re.escape(name)}=(\d+)/(\d+)", text)
|
|
return int(match.group(1)) / max(1, int(match.group(2))) if match else None
|
|
|
|
|
|
def validate_passage(runner: VerificationRunner, name: str, output: str) -> None:
|
|
required = (
|
|
("strict-layout", r"^\[ResolvedLayoutStrict\] accepted=true issues=0 error=$"),
|
|
("layout-controls", r"^\[ResolvedLayoutValidatorControls\].*status=PASS$"),
|
|
("walkability", r"^\[Walkability\] PASS"),
|
|
("floor-profile", r"^\[FloorProfileBlend\].*negative_controls=step_detected/slope_detected status=PASS$"),
|
|
("mouth-profile", r"^\[PassageMouthProfileAudit\].*status=PASS$"),
|
|
("route-binding", r"^\[ResolvedStrateRouteAudit\].*mouth_binding=PASS status=PASS$"),
|
|
("naturalness", r"^\[PassageNaturalnessSummary\].*status=PASS$"),
|
|
("open-air", r"^\[PassageOpenAirAuditSummary\].*status=PASS$"),
|
|
("no-long-bridge", r"^\[PassageNoLongBridgeAudit\].*status=PASS$"),
|
|
("rock-columns", r"^\[PassageRockColumnAuditSummary\].*status=PASS$"),
|
|
("ripple-controls", r"^\[PassageRippleAuditSummary\].*status=PASS$"),
|
|
("passage-summary", r"^\[ResolvedPassageAuditSummary\].*route_binding_failures=0 .*status=PASS$"),
|
|
)
|
|
for gate, pattern in required:
|
|
runner.require(f"{name}:{gate}", all_match(output, pattern),
|
|
"required resolved-passage gate")
|
|
|
|
rows = re.findall(r"^\[PassageRippleAudit\].*$", output, re.M)
|
|
ripple_ok = bool(rows)
|
|
for line in rows:
|
|
wall = re.search(r"local_peak_amplitude_m=([-0-9.]+)", line)
|
|
if wall is None:
|
|
wall = re.search(r"amplitude_m=([-0-9.]+)", line)
|
|
wall_threshold = re.search(r"threshold_m=([-0-9.]+)", line)
|
|
floor = re.search(r"floor_amplitude_m=([-0-9.]+)", line)
|
|
floor_threshold = re.search(r"floor_threshold_m=([-0-9.]+)", line)
|
|
wall_coverage = parse_ratio(line, "coverage")
|
|
floor_coverage = parse_ratio(line, "floor_coverage")
|
|
ripple_ok &= bool(
|
|
"status=PASS" in line and wall and wall_threshold and floor and floor_threshold
|
|
and wall_coverage is not None and floor_coverage is not None
|
|
and float(wall.group(1)) <= float(wall_threshold.group(1))
|
|
and float(floor.group(1)) <= float(floor_threshold.group(1))
|
|
and wall_coverage >= 0.75 and floor_coverage >= 0.75)
|
|
runner.require(f"{name}:wall-floor-ripple-and-coverage", ripple_ok,
|
|
f"profiles={len(rows)} wall/floor amplitudes under their thresholds; coverage>=0.75")
|
|
|
|
|
|
def run_passage(runner: VerificationRunner, binary: Path, name: str,
|
|
data: Path, recipe: str, style: int, *, workers: int = 12,
|
|
flags: list[str] | None = None, max_level: int = -1,
|
|
layout_path: Path | None = None, passage_style: int | None = None,
|
|
expected_strate_styles: dict[str, int] | None = None) -> tuple[dict, str]:
|
|
layout_path = layout_path or OUT / "layouts" / f"{name}.json"
|
|
row, output = runner.run_cpp(name, binary, data, recipe,
|
|
["--audit-resolved-layout-passages", *(flags or [])],
|
|
expected_style=style if passage_style is None else passage_style,
|
|
expected_strate_styles=expected_strate_styles,
|
|
workers=workers, max_level=max_level,
|
|
layout_path=layout_path)
|
|
row["requested_style"] = style
|
|
row["expected_passage_style"] = style if passage_style is None else passage_style
|
|
row["requested_strate_styles"] = expected_strate_styles
|
|
validate_passage(runner, name, output)
|
|
return row, output
|
|
|
|
|
|
def run_owner_passages(runner: VerificationRunner, binaries: tuple[Path, ...]) -> dict[str, tuple[dict, str]]:
|
|
result: dict[str, tuple[dict, str]] = {}
|
|
expected_strate_styles = {"0": 2, "1": 1}
|
|
for binary in binaries:
|
|
compiler = compiler_name(binary)
|
|
for recipe, style in (("floating-islands", 2), ("surface-world", 1)):
|
|
name = f"owner-{recipe}-style{style}-{compiler}"
|
|
flags = ["--landmark-chamber-demo"] if recipe == "surface-world" else []
|
|
row, output = run_passage(runner, binary, name, OWNER, recipe, style,
|
|
flags=flags,
|
|
passage_style=2, expected_strate_styles=expected_strate_styles)
|
|
result[f"{compiler}:{recipe}"] = (row, output)
|
|
actual_styles = row.get("resolved_strate_styles", {})
|
|
runner.require(f"{name}:owner-style-map",
|
|
actual_styles == expected_strate_styles,
|
|
f"resolved_strate_styles={actual_styles} expected={expected_strate_styles}")
|
|
if compiler == "clang":
|
|
measured = measure_owner_step(output)
|
|
worst = measured.get("worst")
|
|
runner.require(f"{name}:adjacent-owner-step",
|
|
bool(measured["passed"]),
|
|
f"max_step_m={measured['maximum_adjacent_step_m']:.6f} "
|
|
f"limit_m=0.100 pairs={measured['adjacent_pairs']} "
|
|
f"fitted_periods_m={measured['fitted_periods_m']} "
|
|
f"period_role=diagnostic worst={worst}")
|
|
return result
|
|
|
|
|
|
def run_landmark_reachability(runner: VerificationRunner,
|
|
binaries: tuple[Path, ...]) -> None:
|
|
for binary in binaries:
|
|
compiler = compiler_name(binary)
|
|
name = f"landmark-reachability-{compiler}"
|
|
row, output = runner.run_cpp(name, binary, OWNER, "surface-world",
|
|
["--landmark-chamber-demo", "--audit-landmark-reachability",
|
|
"--max-clip-level=0", "--render-distance-chunks=0"],
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
max_level=0, layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = 1
|
|
row["expected_passage_style"] = 2
|
|
passage_name = f"landmark-demo-passages-{compiler}"
|
|
_, passage_output = runner.run_cpp(passage_name, binary, OWNER, "surface-world",
|
|
["--landmark-chamber-demo", "--audit-resolved-layout-passages",
|
|
"--max-clip-level=0", "--render-distance-chunks=0"],
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
max_level=0, layout_path=OUT / "layouts" / f"{passage_name}.json")
|
|
runner.require(f"{passage_name}:demo-enabled",
|
|
all_match(passage_output, r"^\[LandmarkCavernGraphDemo\] enabled=true .*rooms=1 edges=1 .*status=PASS$"),
|
|
"landmark demo flag resolved while running passage audits")
|
|
validate_passage(runner, passage_name, passage_output)
|
|
|
|
interface_name = f"landmark-demo-interfaces-{compiler}"
|
|
_, interface_output = runner.run_cpp(interface_name, binary, OWNER, "surface-world",
|
|
["--landmark-chamber-demo", "--audit-strate-transitions",
|
|
"--max-clip-level=0", "--render-distance-chunks=0"],
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
max_level=0, layout_path=OUT / "layouts" / f"{interface_name}.json")
|
|
runner.require(f"{interface_name}:demo-enabled",
|
|
all_match(interface_output, r"^\[LandmarkCavernGraphDemo\] enabled=true .*rooms=1 edges=1 .*status=PASS$"),
|
|
"landmark demo flag resolved while running interface audits")
|
|
runner.require(f"{interface_name}:hole-audit",
|
|
all_match(interface_output, r"^\[StrateTransitionAuditSummary\].*hole_columns=0 "
|
|
r"air_samples=0 .*status=PASS$"),
|
|
"demo-on stratum interfaces contain no holes or air columns")
|
|
runner.require(f"{interface_name}:negative-controls",
|
|
all_match(interface_output, r"^\[StrateTransitionNegativeControls\].*status=PASS$"),
|
|
"demo-on interface audit detects both thickness controls")
|
|
runner.require(f"{name}:candidate-walkability",
|
|
all_match(output, r"^\[LandmarkWalkability\] layout=L46 .*headroom_required_m=0\.300 status=PASS$"),
|
|
"demo capsule clearance, support, headroom and <=15 degree grade")
|
|
runner.require(f"{name}:headroom",
|
|
all_match(output, r"^\[LandmarkHeadroom\] minimum_m=(?:0\.[3-9][0-9][0-9]|[1-9][0-9]*\.[0-9]{3}) required_m=0\.300 status=PASS$"),
|
|
"at least 0.3 m above the capsule along the complete route")
|
|
runner.require(f"{name}:continuous-tunnel-ripple",
|
|
all_match(output, r"^\[CavernTunnelRipple\] layout=L46 .*floor_limit_m=0\.015 .*wall_limit_m=0\.035 status=PASS$"),
|
|
"floor and wall ripple remain below L36/L35 limits")
|
|
entrance_floor = re.search(
|
|
r"^\[CavernEntranceFloorAudit\] layout=L46 samples=(\d+) "
|
|
r"distance_m=0\.000\.\.10\.000 rails=3 max_step_m=([0-9.]+) "
|
|
r"step_limit_m=0\.050 ripple_peak_m=([0-9.]+) "
|
|
r"ripple_limit_m=0\.015 status=PASS$", output, re.M)
|
|
runner.require(f"{name}:entrance-floor-ripple-and-steps",
|
|
bool(entrance_floor and int(entrance_floor.group(1)) >= 150
|
|
and float(entrance_floor.group(2)) <= 0.05
|
|
and float(entrance_floor.group(3)) <= 0.015),
|
|
"three floor rails cover the first 10 m from the entrance; step<=0.05 m and ripple<=0.015 m")
|
|
runner.require(f"{name}:buried-l43-control",
|
|
all_match(output, r"^\[LandmarkReachabilityControl\] layout=L43-buried .*"
|
|
r"result=FAIL expected=FAIL status=PASS$"),
|
|
"the exact buried L43 chamber fails the same route audit")
|
|
runner.require(f"{name}:surface-to-floor-route",
|
|
all_match(output, r"^\[LandmarkSurfaceRoute\] reachable=true .*"
|
|
r"surface_points=[1-9][0-9]* grade_limit_deg=15\.000$"),
|
|
"walkable surface path from ground near the arrival mouth joins the ramp")
|
|
runner.require(f"{name}:reachability-control-summary",
|
|
all_match(output, r"^\[LandmarkReachabilityAudit\] positive=PASS "
|
|
r"control=EXPECTED_FAIL status=PASS$"),
|
|
"candidate passes and buried control fails")
|
|
ripple_control = f"landmark-l45-ramp-ripple-control-{compiler}"
|
|
_, control_output = runner.run_cpp(ripple_control, binary, OWNER, "surface-world",
|
|
["--landmark-chamber-demo", "--landmark-l45-ramp-control",
|
|
"--audit-landmark-reachability", "--max-clip-level=0",
|
|
"--render-distance-chunks=0"],
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
max_level=0, layout_path=OUT / "layouts" / f"{ripple_control}.json")
|
|
runner.require(f"{ripple_control}:negative-control",
|
|
all_match(control_output,
|
|
r"^\[CavernTunnelRippleControl\] layout=L45-ramp .*"
|
|
r"floor_limit_m=0\.015 .*observed=FAIL expected=FAIL status=PASS$"),
|
|
"the segmented L45 ramp exceeds the floor ripple threshold")
|
|
|
|
|
|
def expected_control_row(runner: VerificationRunner, name: str) -> None:
|
|
if runner.runs:
|
|
row = runner.runs[-1]
|
|
row["observed_status"] = row["status"]
|
|
row["status"] = "EXPECTED_FAIL"
|
|
row["negative_control"] = name
|
|
|
|
|
|
def run_stamp_and_input_controls(runner: VerificationRunner) -> None:
|
|
# Mutate one compiled Core input only while checking that the runner refuses it.
|
|
core_file = ROOT / "Standalone/Core/src/VoxelForgeCore.cpp"
|
|
original = core_file.read_bytes()
|
|
rejected = False
|
|
try:
|
|
core_file.write_bytes(original + b"\n// temporary L39 stale-build negative control\n")
|
|
try:
|
|
runner.probe_binary(CLANG)
|
|
except RuntimeError as error:
|
|
rejected = "source changed" in str(error)
|
|
finally:
|
|
core_file.write_bytes(original)
|
|
runner.assert_current_tree("after restoring stale-build control")
|
|
runner.require("stale-build-source-edit-control", rejected,
|
|
"runner refused the binary after a Core source edit; original bytes restored")
|
|
|
|
fixture = ROOT / "Saved/Linux/l33/fixtures/sw-upper-tunnel-network-style0.json"
|
|
mislabelled = OUT / "controls/mislabelled-owner/owner_world.json"
|
|
mislabelled.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copyfile(fixture, mislabelled)
|
|
try:
|
|
runner.run_cpp("control-mislabelled-owner-style0", CLANG, mislabelled,
|
|
"floating-islands", ["--resolved-layout-only"], expected_style=2,
|
|
layout_path=OUT / "controls/mislabelled-owner/layout-owner.json")
|
|
detected = False
|
|
except VerificationFailure:
|
|
detected = bool(runner.runs and 0 in runner.runs[-1]["resolved_style"]
|
|
and runner.runs[-1]["status"] == "FAIL")
|
|
if detected:
|
|
expected_control_row(runner, "mislabelled-style0-input")
|
|
runner.require("mislabelled-owner-style-control", detected,
|
|
"style-0 fixture named owner_world.json rejected for expected FI Style 2")
|
|
|
|
black = OUT / "controls/all-black.png"
|
|
black.parent.mkdir(parents=True, exist_ok=True)
|
|
write_black_png(black)
|
|
script = VERIFY_DIR / "capture_quality.py"
|
|
try:
|
|
runner.run_stage("control-all-black-capture", script, [str(black)],
|
|
binary=CLANG, data=None, recipe=None, style=None,
|
|
env=env_for(), script_inputs=[black])
|
|
black_rejected = False
|
|
except VerificationFailure:
|
|
black_rejected = "status=FAIL" in (OUT / "control-all-black-capture.log").read_text(
|
|
encoding="utf-8", errors="replace")
|
|
if black_rejected:
|
|
expected_control_row(runner, "all-black-capture")
|
|
runner.require("all-black-capture-control", black_rejected,
|
|
"pixel variance and coverage floor reject a valid all-black PNG")
|
|
|
|
|
|
def write_black_png(path: Path) -> None:
|
|
def chunk(tag: bytes, payload: bytes) -> bytes:
|
|
return (struct.pack(">I", len(payload)) + tag + payload
|
|
+ struct.pack(">I", zlib.crc32(tag + payload) & 0xffffffff))
|
|
pixels = b"".join(b"\0" + b"\0\0\0" * 2 for _ in range(2))
|
|
body = (b"\x89PNG\r\n\x1a\n"
|
|
+ chunk(b"IHDR", struct.pack(">IIBBBBB", 2, 2, 8, 2, 0, 0, 0))
|
|
+ chunk(b"IDAT", zlib.compress(pixels)) + chunk(b"IEND", b""))
|
|
path.write_bytes(body)
|
|
|
|
|
|
def run_regression_controls(runner: VerificationRunner) -> None:
|
|
run_stamp_and_input_controls(runner)
|
|
controls = (
|
|
("l35-wall-ribs", "wall-ribs",
|
|
ROOT / "Saved/Linux/l35/failed/passage-audit-cascade-cosine-owner-fi-style3-clang.log"),
|
|
("l36-floor-washboard", "floor-washboard",
|
|
ROOT / "Saved/Linux/l36/audit-nearest-fi-style0.log"),
|
|
)
|
|
script = VERIFY_DIR / "historical_controls.py"
|
|
for name, kind, log in controls:
|
|
runner.run_stage(f"control-{name}", script, [kind, str(log)],
|
|
binary=CLANG, data=None, recipe=None, style=None,
|
|
env=env_for(), script_inputs=[log])
|
|
|
|
l38 = ROOT / "Saved/Linux/l38/owner-fi-real-final.log"
|
|
step_script = VERIFY_DIR / "owner_step.py"
|
|
runner.run_stage("control-l38-owner-step", step_script,
|
|
[str(l38), "--expect-fail"], binary=CLANG, data=None,
|
|
recipe=None, style=None, env=env_for(), script_inputs=[l38])
|
|
|
|
|
|
def run_hash_pairs(runner: VerificationRunner,
|
|
owner_results: dict[str, tuple[dict, str]]) -> None:
|
|
for recipe, style in (("floating-islands", 2), ("surface-world", 1)):
|
|
hashes: dict[int, tuple[str, ...]] = {}
|
|
for workers in (1, 12):
|
|
name = f"owner-hash-{recipe}-style{style}-w{workers}"
|
|
row, output = runner.run_cpp(name, CLANG, OWNER, recipe,
|
|
["--stream-hash"], expected_style=2,
|
|
expected_strate_styles={"0": 2, "1": 1}, workers=workers,
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = style
|
|
row["expected_passage_style"] = 2
|
|
values = tuple(HASH_RE.findall(output))
|
|
hashes[workers] = values
|
|
runner.require(f"{name}:hash-count", len(values) == 12,
|
|
f"hashes={len(values)}/12")
|
|
same = hashes[1] == hashes[12]
|
|
baseline = ROOT / "Saved/Linux/l46" / f"owner-hash-{recipe}-style{style}-w12.log"
|
|
old_hashes = tuple(HASH_RE.findall(baseline.read_text(encoding="utf-8", errors="replace")))
|
|
same_l46 = hashes[12] == old_hashes and len(old_hashes) == 12
|
|
runner.require(f"owner-hash-{recipe}-w1-w12", same,
|
|
"W1 and W12 each produced identical 12-hash signatures")
|
|
runner.require(f"owner-hash-{recipe}-matches-l46", same_l46,
|
|
f"demo-off owner hashes match L46 {baseline.name}; hashes={len(old_hashes)}")
|
|
|
|
|
|
class _SplitMix64:
|
|
"""Small fixed-seed generator whose camera sequence is independent of Python random."""
|
|
def __init__(self, seed: int):
|
|
self.state = seed & 0xffffffffffffffff
|
|
|
|
def unit(self) -> float:
|
|
self.state = (self.state + 0x9e3779b97f4a7c15) & 0xffffffffffffffff
|
|
value = self.state
|
|
value = ((value ^ (value >> 30)) * 0xbf58476d1ce4e5b9) & 0xffffffffffffffff
|
|
value = ((value ^ (value >> 27)) * 0x94d049bb133111eb) & 0xffffffffffffffff
|
|
value ^= value >> 31
|
|
return (value >> 11) / float(1 << 53)
|
|
|
|
def between(self, low: float, high: float) -> float:
|
|
return low + (high - low) * self.unit()
|
|
|
|
|
|
def seeded_camera_positions(count: int) -> list[tuple[float, float, float, float, float]]:
|
|
rng = _SplitMix64(CAMERA_SWEEP_SEED)
|
|
positions: list[tuple[float, float, float, float, float]] = []
|
|
for index in range(count):
|
|
if index == 0:
|
|
# Stay in the known failing 8 m tile neighbourhood while still deriving the
|
|
# camera from the fixed seed. The negative Y offset keeps it below the 32 m seam.
|
|
x = -8.918 + rng.between(-0.02, 0.02)
|
|
y = 31.95 - rng.between(0.005, 0.035)
|
|
z = -513.083 + rng.between(-0.02, 0.02)
|
|
else:
|
|
x = rng.between(-900.0, 900.0)
|
|
y = rng.between(-900.0, 900.0)
|
|
while math.hypot(x + 46.45, y + 472.88) < 320.0:
|
|
x = rng.between(-900.0, 900.0)
|
|
y = rng.between(-900.0, 900.0)
|
|
if index % 2:
|
|
z = -256.0 + rng.between(-12.0, 12.0) # SurfaceWorld strate 0.
|
|
else:
|
|
z = -1536.0 + rng.between(-120.0, 120.0) # FloatingIslands strate 1.
|
|
yaw = rng.between(-180.0, 180.0)
|
|
pitch = rng.between(-35.0, 35.0)
|
|
positions.append((x, y, z, yaw, pitch))
|
|
return positions
|
|
|
|
|
|
def parse_tile_hashes(output: str) -> dict[tuple[int, int, int, int], tuple[str, ...]]:
|
|
rows: dict[tuple[int, int, int, int], tuple[str, ...]] = {}
|
|
for match in TILE_HASH_RE.finditer(output):
|
|
key = tuple(int(match.group(i)) for i in range(1, 5))
|
|
rows[key] = tuple(match.group(i) for i in range(5, 9))
|
|
return rows
|
|
|
|
|
|
def parse_tile_material_hashes(output: str) -> dict[tuple[int, int, int, int], str]:
|
|
rows: dict[tuple[int, int, int, int], str] = {}
|
|
for match in TILE_MATERIAL_HASH_RE.finditer(output):
|
|
key = tuple(int(match.group(i)) for i in range(1, 5))
|
|
rows[key] = match.group(5)
|
|
return rows
|
|
|
|
|
|
def ore_vein_audit_camera(layout_path: Path) -> tuple[float, float, float, float, float]:
|
|
layout = json.loads(layout_path.read_text(encoding="utf-8"))
|
|
core_um = int(layout["core_voxel_size_um"])
|
|
route = [anchor for strate in layout["strates"]
|
|
if strate["generator_kind"] == "SurfaceWorld"
|
|
for anchor in strate["anchors"] if anchor["kind"] == "route_point"]
|
|
route.sort(key=lambda anchor: int(anchor["stable_id"].split("/")[-1]))
|
|
records = layout.get("ore_veins", [])
|
|
vein = next((row for row in records
|
|
if row["stable_id"] == "ore/sw-arrival-route-copper-v1"), None)
|
|
if len(route) < 2 or vein is None:
|
|
raise VerificationFailure(f"cannot derive ore camera from {layout_path}")
|
|
target = [sum(value) / 2_000_000.0 for value in zip(*vein["endpoints_um"])]
|
|
points = [[value * core_um / 256_000_000.0 for value in anchor["values"][:3]]
|
|
for anchor in route]
|
|
best: tuple[float, int, float, tuple[float, float, float]] | None = None
|
|
for index, (a, b) in enumerate(zip(points, points[1:])):
|
|
dx, dy = b[0] - a[0], b[1] - a[1]
|
|
length2 = dx * dx + dy * dy
|
|
t = 0.0 if length2 <= 1.0e-12 else max(0.0, min(1.0,
|
|
((target[0] - a[0]) * dx + (target[1] - a[1]) * dy) / length2))
|
|
point = tuple(a[axis] + t * (b[axis] - a[axis]) for axis in range(3))
|
|
distance2 = (point[0] - target[0]) ** 2 + (point[1] - target[1]) ** 2
|
|
candidate = (distance2, index, t, point)
|
|
if best is None or candidate[:3] < best[:3]:
|
|
best = candidate
|
|
assert best is not None
|
|
_, _, _, floor = best
|
|
camera = (floor[0], floor[1], floor[2] + 1.6)
|
|
dx, dy = target[0] - camera[0], target[1] - camera[1]
|
|
horizontal = max(math.hypot(dx, dy), 1.0e-6)
|
|
target_z = target[2] + 1.0
|
|
yaw = math.degrees(math.atan2(dx, dy))
|
|
pitch = math.degrees(math.atan2(target_z - camera[2], horizontal))
|
|
return (*camera, yaw, pitch)
|
|
|
|
|
|
def run_ore_vein_hash_controls(runner: VerificationRunner) -> None:
|
|
camera_layout = OUT / "layouts" / "ore-vein-camera-layout.json"
|
|
row, output = runner.run_cpp("ore-vein-camera-layout", CLANG, OWNER,
|
|
"surface-world", ["--landmark-chamber-demo", "--ore-veins-demo",
|
|
"--resolved-layout-only"],
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=1,
|
|
max_level=0, layout_path=camera_layout)
|
|
audit = re.search(r"^\[ResolvedOreVeinPlacementAudit\].*status=PASS$", output, re.M)
|
|
runner.require("ore-vein-resolved-records", audit is not None,
|
|
f"layout={row['layout_id']} resolved={len(json.loads(camera_layout.read_text()).get('ore_veins', []))}/3")
|
|
x, y, z, yaw, pitch = ore_vein_audit_camera(camera_layout)
|
|
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
|
|
base_flags = ["--stream-hash-tiles", "--landmark-chamber-demo", camera_flag,
|
|
"--clip-radius=2", "--max-clip-level=0", "--max-level=0",
|
|
"--render-distance-chunks=0"]
|
|
geometry: dict[str, dict[tuple[int, int, int, int], tuple[str, ...]]] = {}
|
|
material: dict[str, dict[tuple[int, int, int, int], str]] = {}
|
|
outputs: dict[str, str] = {}
|
|
for label, enabled in (("off", False), ("on", True)):
|
|
flags = [*base_flags]
|
|
if enabled:
|
|
flags.extend(("--ore-veins-demo", "--audit-ore-vein-yield"))
|
|
_, captured = runner.run_cpp(f"ore-vein-geometry-{label}", CLANG, OWNER,
|
|
"surface-world", flags, expected_style=2,
|
|
expected_strate_styles={"0": 2, "1": 1}, workers=1,
|
|
max_level=0, layout_path=OUT / "layouts" / f"ore-vein-geometry-{label}.json")
|
|
outputs[label] = captured
|
|
geometry[label] = parse_tile_hashes(captured)
|
|
material[label] = parse_tile_material_hashes(captured)
|
|
whole = re.search(r"^\[PipelineWholeViewHash\] tiles=(\d+)", captured, re.M)
|
|
expected_rows = int(whole.group(1)) if whole else -1
|
|
runner.require(f"ore-vein-geometry-{label}:hash-rows",
|
|
bool(geometry[label]) and len(geometry[label]) == expected_rows
|
|
and len(material[label]) == expected_rows,
|
|
f"geometry_rows={len(geometry[label])} material_rows={len(material[label])} "
|
|
f"expected={expected_rows}")
|
|
cost = re.search(r"^\[MaterialQueryCost\] queries=(\d+) candidate_checks=(\d+) "
|
|
r"outside_vein_tiles=(\d+) tiles=(\d+) elapsed_ms=([0-9.]+) "
|
|
r"outside_query_ms=0 status=([^ ]+)$", captured, re.M)
|
|
cost_ok = cost is not None and int(cost.group(1)) == 0 if not enabled else (
|
|
cost is not None and int(cost.group(1)) > 0 and int(cost.group(3)) > 0
|
|
and float(cost.group(5)) >= 0.0)
|
|
runner.require(f"ore-vein-material-cost-{label}", cost_ok,
|
|
f"cost_line={cost.group(0) if cost else 'MISSING'}")
|
|
differing = [key for key in set(material["off"]) | set(material["on"])
|
|
if material["off"].get(key) != material["on"].get(key)]
|
|
runner.require("ore-vein-geometry-unchanged-with-veins",
|
|
geometry["off"] == geometry["on"],
|
|
f"camera_m=({x:.3f},{y:.3f},{z:.3f}) density/mesh/payload/topology "
|
|
f"tile_hashes_match={geometry['off']==geometry['on']} "
|
|
f"material_tiles_changed={len(differing)}")
|
|
runner.require("ore-vein-material-hash-changes",
|
|
bool(differing) and material["off"] != material["on"],
|
|
f"changed_tiles={len(differing)} camera_m=({x:.3f},{y:.3f},{z:.3f})")
|
|
mined = re.search(r"^\[OreMiningYield\].*resource_volume_m3=([0-9.]+) status=PASS$",
|
|
outputs["on"], re.M)
|
|
air = re.search(r"^\[OreMiningYieldControl\] case=already-air.*"
|
|
r"resource_volume_m3=0\.000000 status=PASS$", outputs["on"], re.M)
|
|
runner.require("ore-vein-yield-positive", mined is not None and float(mined.group(1)) > 0,
|
|
"fixed 0.25 m sample spacing measured positive removed resource volume")
|
|
runner.require("ore-vein-yield-already-air-zero", air is not None,
|
|
"the same sphere measurement on the already-air chamber tunnel returned zero")
|
|
|
|
|
|
def cavern_audit_cameras(layout_path: Path) -> list[tuple[float, float, float, float, float]]:
|
|
layout = json.loads(layout_path.read_text(encoding="utf-8"))
|
|
edges = layout.get("cavern_edges", [])
|
|
if layout.get("cavern_graph_vocabulary_version") != 1 or len(edges) != 1:
|
|
raise VerificationFailure(f"missing one resolved cavern edge in {layout_path}")
|
|
points = [[value / 1_000_000.0 for value in point]
|
|
for point in edges[0]["control_points_um"]]
|
|
|
|
def value(t: float, axis: int) -> float:
|
|
one = 1.0 - t
|
|
return (one ** 3 * points[0][axis] + 3.0 * one ** 2 * t * points[1][axis]
|
|
+ 3.0 * one * t ** 2 * points[2][axis] + t ** 3 * points[3][axis])
|
|
|
|
def derivative(t: float, axis: int) -> float:
|
|
one = 1.0 - t
|
|
return (3.0 * one ** 2 * (points[1][axis] - points[0][axis])
|
|
+ 6.0 * one * t * (points[2][axis] - points[1][axis])
|
|
+ 3.0 * t ** 2 * (points[3][axis] - points[2][axis]))
|
|
|
|
cameras = []
|
|
for t, lateral in ((0.50, 0.0), (0.32, 3.3)):
|
|
x, y, floor = value(t, 0), value(t, 1), value(t, 2)
|
|
dx, dy = derivative(t, 0), derivative(t, 1)
|
|
length = math.hypot(dx, dy)
|
|
side_x, side_y = -dy / length, dx / length
|
|
cameras.append((x + side_x * lateral, y + side_y * lateral,
|
|
floor + 1.6, math.degrees(math.atan2(dx, dy)), 0.0))
|
|
return cameras
|
|
|
|
|
|
def run_random_camera_sweep(runner: VerificationRunner, binaries: tuple[Path, ...],
|
|
camera_count: int,
|
|
configurations: tuple[tuple[int, int, int], ...]) -> None:
|
|
positions = seeded_camera_positions(camera_count)
|
|
for binary in binaries:
|
|
compiler = compiler_name(binary)
|
|
for recipe in ("surface-world", "floating-islands"):
|
|
for camera_index, camera in enumerate(positions):
|
|
x, y, z, yaw, pitch = camera
|
|
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
|
|
for clip_radius, max_clip_level, max_level in configurations:
|
|
settings = (clip_radius, max_clip_level, max_level)
|
|
label = (f"random-camera-{compiler}-{recipe}-s{CAMERA_SWEEP_SEED:06x}"
|
|
f"-p{camera_index:02d}-r{clip_radius}-c{max_clip_level}-m{max_level}")
|
|
signatures: dict[int, dict[tuple[int, int, int, int], tuple[str, ...]]] = {}
|
|
material_signatures: dict[int, dict[tuple[int, int, int, int], str]] = {}
|
|
for workers in (1, 8, 12):
|
|
name = f"{label}-w{workers}"
|
|
flags = ["--stream-hash-tiles", camera_flag,
|
|
f"--clip-radius={clip_radius}",
|
|
f"--max-clip-level={max_clip_level}",
|
|
f"--max-level={max_level}", "--render-distance-chunks=0"]
|
|
if recipe == "surface-world":
|
|
flags.extend(("--landmark-chamber-demo", "--ore-veins-demo"))
|
|
row, output = runner.run_cpp(name, binary, OWNER, recipe, flags,
|
|
expected_style=2,
|
|
expected_strate_styles={"0": 2, "1": 1},
|
|
workers=workers,
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["camera_sweep_seed"] = CAMERA_SWEEP_SEED
|
|
row["camera_position_m"] = [round(value, 6) for value in camera[:3]]
|
|
row["camera_rotation_degrees"] = [round(value, 3) for value in camera[3:]]
|
|
row["sweep_settings"] = {
|
|
"clip_radius": clip_radius,
|
|
"max_clip_level": max_clip_level,
|
|
"max_level": max_level,
|
|
}
|
|
current = parse_tile_hashes(output)
|
|
signatures[workers] = current
|
|
material_signatures[workers] = parse_tile_material_hashes(output)
|
|
whole = re.search(r"^\[PipelineWholeViewHash\] tiles=(\d+)", output, re.M)
|
|
expected_rows = int(whole.group(1)) if whole else -1
|
|
runner.require(f"{name}:tile-hash-rows",
|
|
bool(current) and len(current) == expected_rows,
|
|
f"rows={len(current)} expected={expected_rows} settings={settings}")
|
|
if recipe == "surface-world":
|
|
material_rows = material_signatures[workers]
|
|
runner.require(f"{name}:material-hash-rows",
|
|
bool(material_rows) and len(material_rows) == expected_rows,
|
|
f"rows={len(material_rows)} expected={expected_rows} settings={settings}")
|
|
camera_text = (f"seed=0x{CAMERA_SWEEP_SEED:06x} camera_m="
|
|
f"({x:.3f},{y:.3f},{z:.3f}) recipe={recipe} settings={settings}")
|
|
for left, right in ((1, 8), (1, 12), (8, 12)):
|
|
left_rows, right_rows = signatures[left], signatures[right]
|
|
keys = set(left_rows) | set(right_rows)
|
|
density_diff = [key for key in keys
|
|
if left_rows.get(key, (None,))[0] != right_rows.get(key, (None,))[0]]
|
|
mesh_diff = [key for key in keys
|
|
if left_rows.get(key, (None, None))[1]
|
|
!= right_rows.get(key, (None, None))[1]]
|
|
payload_diff = [key for key in keys
|
|
if left_rows.get(key, (None, None, None))[2]
|
|
!= right_rows.get(key, (None, None, None))[2]]
|
|
topology_diff = [key for key in keys
|
|
if left_rows.get(key, (None, None, None, None))[3]
|
|
!= right_rows.get(key, (None, None, None, None))[3]]
|
|
material_left=material_signatures[left]
|
|
material_right=material_signatures[right]
|
|
material_diff=([key for key in set(material_left)|set(material_right)
|
|
if material_left.get(key)!=material_right.get(key)]
|
|
if recipe=="surface-world" else [])
|
|
detail = (f"{camera_text} W{left}=W{right} "
|
|
f"density_tiles={len(density_diff)} mesh_tiles={len(mesh_diff)} "
|
|
f"payload_tiles={len(payload_diff)} topology_tiles={len(topology_diff)} "
|
|
f"material_tiles={len(material_diff)} "
|
|
f"sample_coords={sorted(density_diff or mesh_diff)[:6]}")
|
|
runner.require(f"{label}:W{left}-W{right}",
|
|
left_rows == right_rows and
|
|
(recipe != "surface-world" or material_left == material_right), detail)
|
|
|
|
# Keep a pair of fixed cameras on the current owner graph: one in the bore and
|
|
# one beside its curved wall. Their tile hashes join the seeded W1/W8/W12 sweep.
|
|
layout_path = OUT / "layouts" / "landmark-reachability-clang.json"
|
|
if layout_path.is_file():
|
|
graph_cameras = cavern_audit_cameras(layout_path)
|
|
for binary in binaries:
|
|
compiler = compiler_name(binary)
|
|
for camera_index, camera in enumerate(graph_cameras):
|
|
x, y, z, yaw, pitch = camera
|
|
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
|
|
label = f"cavern-camera-{compiler}-s{CAMERA_SWEEP_SEED:06x}-p{camera_index:02d}"
|
|
signatures: dict[int, dict[tuple[int, int, int, int], tuple[str, ...]]] = {}
|
|
material_signatures: dict[int, dict[tuple[int, int, int, int], str]] = {}
|
|
for workers in (1, 8, 12):
|
|
name = f"{label}-w{workers}"
|
|
row, output = runner.run_cpp(name, binary, OWNER, "surface-world",
|
|
["--stream-hash-tiles", camera_flag, "--landmark-chamber-demo",
|
|
"--ore-veins-demo",
|
|
"--clip-radius=3", "--max-clip-level=0", "--max-level=0",
|
|
"--render-distance-chunks=0"],
|
|
expected_style=2,
|
|
expected_strate_styles={"0": 2, "1": 1}, workers=workers,
|
|
max_level=0, layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["camera_position_m"] = [round(value, 6) for value in camera[:3]]
|
|
row["camera_region"] = "inside-tunnel" if camera_index == 0 else "near-tunnel-wall"
|
|
signatures[workers] = parse_tile_hashes(output)
|
|
material_signatures[workers] = parse_tile_material_hashes(output)
|
|
whole = re.search(r"^\[PipelineWholeViewHash\] tiles=(\d+)", output, re.M)
|
|
expected_rows = int(whole.group(1)) if whole else -1
|
|
runner.require(f"{name}:tile-hash-rows",
|
|
bool(signatures[workers]) and len(signatures[workers]) == expected_rows,
|
|
f"rows={len(signatures[workers])} expected={expected_rows} camera={camera[:3]}")
|
|
runner.require(f"{name}:material-hash-rows",
|
|
bool(material_signatures[workers])
|
|
and len(material_signatures[workers]) == expected_rows,
|
|
f"rows={len(material_signatures[workers])} expected={expected_rows} "
|
|
f"camera={camera[:3]}")
|
|
for left, right in ((1, 8), (1, 12), (8, 12)):
|
|
runner.require(f"{label}:W{left}-W{right}",
|
|
signatures[left] == signatures[right]
|
|
and material_signatures[left] == material_signatures[right],
|
|
f"camera_m=({x:.3f},{y:.3f},{z:.3f}) "
|
|
f"region={'inside' if camera_index == 0 else 'near'}-tunnel "
|
|
f"W{left}=W{right} density/mesh/payload/topology/material tile hashes match")
|
|
|
|
|
|
def run_ring(runner: VerificationRunner, *, full: bool) -> None:
|
|
script = LINUX37 / "RunRingAuditsL37.py"
|
|
audit_inputs = [script,
|
|
ROOT / "Standalone/Research/WorldAssemblerM3/Linux32/AuditRingTerraceL32.py",
|
|
ROOT / "Standalone/Research/WorldAssemblerM3/Linux32/AuditRingSetL32.py"]
|
|
for label, recipe, style in (("fi-floor", "floating-islands", 2),
|
|
("sw-ceiling", "surface-world", 1)):
|
|
args = ["--scene", label]
|
|
layout = OUT / "layouts" / f"ring-layout-{label}-lod0.json"
|
|
if not full:
|
|
args.append("--lod0-only")
|
|
if label == "sw-ceiling":
|
|
args.append("--skip-controls")
|
|
runner.run_stage(f"ring-{label}-{'lod0-8' if full else 'lod0'}", script, args,
|
|
binary=CLANG, data=OWNER, recipe=recipe, style=style,
|
|
layout_path=layout, env=env_for(), script_inputs=audit_inputs)
|
|
|
|
|
|
def style_override_matrix(runner: VerificationRunner, binary: Path) -> None:
|
|
sources: list[tuple[str, Path, str]] = []
|
|
for recipe in ("floating-islands", "surface-world"):
|
|
for style in range(4):
|
|
source = ROOT / f"Saved/Linux/linux25-owner-{recipe}-style{style}.json"
|
|
sources.append((f"{recipe}-style{style}", source, recipe))
|
|
for style in range(4):
|
|
source = ROOT / f"Saved/Linux/l33/fixtures/sw-upper-tunnel-network-style{style}.json"
|
|
sources.append((f"upper-sw-fixture-style{style}", source, "floating-islands"))
|
|
|
|
for fixture_name, source, recipe in sources:
|
|
label = f"style-override-{fixture_name}"
|
|
destination = OUT / "fixtures" / f"{label}.json"
|
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copyfile(source, destination)
|
|
style = int(re.search(r"style([0-3])$", fixture_name).group(1))
|
|
name = f"{label}-{compiler_name(binary)}"
|
|
if fixture_name.startswith("upper-sw-fixture-"):
|
|
expected_strate_styles = {"1": style}
|
|
else:
|
|
expected_strate_styles = {"0": style, "1": 1}
|
|
row, output = runner.run_cpp(name, binary, destination, recipe,
|
|
["--audit-resolved-layout-passages"], expected_style=None,
|
|
expected_strate_styles=expected_strate_styles,
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = style
|
|
row["requested_strate_styles"] = expected_strate_styles
|
|
validate_passage(runner, name, output)
|
|
|
|
|
|
def run_transitions_and_invariants(runner: VerificationRunner,
|
|
binaries: tuple[Path, ...]) -> None:
|
|
for binary in binaries:
|
|
compiler = compiler_name(binary)
|
|
for recipe, style in (("floating-islands", 2), ("surface-world", 1)):
|
|
for mode in ("hard", "gradient", "interleaved"):
|
|
name = f"transition-{recipe}-{mode}-{compiler}"
|
|
flags = [f"--transition-mode={mode}", "--audit-strate-transitions"]
|
|
if recipe == "surface-world":
|
|
flags.append("--landmark-chamber-demo")
|
|
row, output = runner.run_cpp(name, binary, OWNER, recipe,
|
|
flags,
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = style
|
|
row["expected_passage_style"] = 2
|
|
gates = (r"^\[StrateTransitionAuditSummary\].*hole_columns=0 air_samples=0 .*status=PASS$",
|
|
r"^\[StrateTransitionNegativeControls\].*status=PASS$")
|
|
for index, pattern in enumerate(gates):
|
|
runner.require(f"{name}:gate-{index + 1}", all_match(output, pattern), pattern)
|
|
|
|
name = f"invariant-route-proof-{recipe}-{compiler}"
|
|
flags = ["--audit-uniform-block-proofs", "--audit-route-parity"]
|
|
if recipe == "surface-world":
|
|
flags.append("--landmark-chamber-demo")
|
|
row, output = runner.run_cpp(name, binary, OWNER, recipe,
|
|
flags,
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = style
|
|
row["expected_passage_style"] = 2
|
|
runner.require(f"{name}:route-parity",
|
|
all_match(output, r"^\[RouteParityAudit\].*status=PASS$"),
|
|
"route parity L13")
|
|
runner.require(f"{name}:uniform-block-proof",
|
|
all_match(output, r"^\[UniformBlockProofAudit\].*violations=0(?:\s|$)"),
|
|
"uniform-block proof L9")
|
|
|
|
|
|
def run_captures_and_mesh_audits(runner: VerificationRunner) -> None:
|
|
capture_script = LINUX37 / "CapturePassageStandardSetL37.py"
|
|
capture_inputs = [capture_script, VERIFY_DIR / "capture_quality.py",
|
|
ROOT / "Standalone/Research/WorldAssemblerM3/Linux32/AuditRingTerraceL32.py"]
|
|
capture_rows: dict[str, tuple[dict, str]] = {}
|
|
for scene, recipe, style in (("owner-fi", "floating-islands", 2),
|
|
("owner-sw", "surface-world", 1)):
|
|
layout_path = OUT / f"layout-{scene}.json"
|
|
name = f"capture-standard-{scene}-style{style}"
|
|
row, output = runner.run_stage(name, capture_script,
|
|
["--scene", scene], binary=CLANG, data=OWNER, recipe=recipe,
|
|
style=style, layout_path=layout_path, env=env_for(capture=True),
|
|
script_inputs=capture_inputs)
|
|
resolved_strate_styles = row.get("resolved_strate_styles", {})
|
|
target_strate = "0" if scene == "owner-fi" else "1"
|
|
style_ok = (resolved_strate_styles == {"0": 2, "1": 1}
|
|
and resolved_strate_styles.get(target_strate) == style)
|
|
runner.require(f"{name}:resolved-style", style_ok,
|
|
f"resolved_strate_styles={resolved_strate_styles} "
|
|
f"target_strate={target_strate} expected_style={style}")
|
|
capture_rows[scene] = (row, output)
|
|
|
|
shape_script = LINUX37 / "AuditMouthShapeL37.py"
|
|
baseline = ROOT / "Saved/Linux/l37/no-tread-control"
|
|
controls = [ROOT / "Saved/Linux/l36/owner-fi-ground-mouth.vfmesh"]
|
|
for scene, recipe, style in (("owner-fi", "floating-islands", 2),
|
|
("owner-sw", "surface-world", 1)):
|
|
name = f"mouth-shape-{scene}-style{style}"
|
|
runner.run_stage(name, shape_script,
|
|
[f"--out={OUT}", f"--baseline-out={baseline}",
|
|
"--control-out=Saved/Linux/l36", "--scene", scene],
|
|
binary=CLANG, data=OWNER, recipe=recipe, style=style,
|
|
layout_path=OUT / f"layout-{scene}.json", env=env_for(),
|
|
script_inputs=[shape_script, *controls])
|
|
|
|
crease_script = LINUX37 / "RunMouthCreaseAuditL37.py"
|
|
sw_capture_log = OUT / "capture-standard-owner-sw-style1.log"
|
|
crease_args = [
|
|
f"--candidate={OUT / 'owner-fi-ground-mouth.vfmesh'}",
|
|
f"--candidate-sw={OUT / 'owner-sw-ground-mouth.vfmesh'}",
|
|
f"--layout-sw={OUT / 'layout-owner-sw.json'}",
|
|
f"--capture-log-sw={sw_capture_log}"]
|
|
control_meshes = [ROOT / f"Saved/Linux/{round_name}/owner-fi-ground-mouth.vfmesh"
|
|
for round_name in ("l35", "l36")]
|
|
runner.run_stage("mouth-crease-fragments-owner-fi2-sw1", crease_script,
|
|
crease_args, binary=CLANG, data=OWNER, recipe="floating-islands", style=2,
|
|
layout_path=OUT / "layout-owner-fi.json", env=env_for(),
|
|
script_inputs=[crease_script,
|
|
LINUX37 / "RunMouthFragmentAuditL37.py", *control_meshes,
|
|
OUT / "owner-fi-ground-mouth.vfmesh", OUT / "owner-sw-ground-mouth.vfmesh",
|
|
OUT / "layout-owner-sw.json", sw_capture_log])
|
|
|
|
overview_script = LINUX37 / "CaptureMouthOverviewL37.py"
|
|
runner.run_stage("capture-fi-overview-style2", overview_script, [],
|
|
binary=CLANG, data=OWNER, recipe="floating-islands", style=2,
|
|
layout_path=OUT / "layout-owner-fi.json", env=env_for(capture=True),
|
|
script_inputs=[overview_script, VERIFY_DIR / "capture_quality.py",
|
|
OUT / "owner-fi-ground-mouth.vfmesh"])
|
|
|
|
landmark_script = LINUX47 / "CaptureLandmarkL47.py"
|
|
landmark_layout = OUT / "layouts" / "landmark-reachability-clang.json"
|
|
runner.run_stage("capture-landmark-l47", landmark_script,
|
|
["--layout", str(landmark_layout), "--artifact-dir", str(OUT),
|
|
"--capture-dir", str(LINUX47 / "captures"),
|
|
"--data", str(OWNER)],
|
|
binary=CLANG, data=OWNER, recipe="surface-world", style=1,
|
|
layout_path=landmark_layout, env=env_for(capture=True),
|
|
script_inputs=[landmark_script, LINUX47 / "MeasureEntranceL47.py",
|
|
VERIFY_DIR / "capture_quality.py",
|
|
LINUX37 / "AuditMouthShapeL37.py",
|
|
ROOT / "Standalone/Research/WorldAssemblerM3/Linux32/AuditRingTerraceL32.py"])
|
|
|
|
|
|
def verify_determinism_cell(runner: VerificationRunner, binary: Path,
|
|
kind: str, recipe: str, style: int, workers: int,
|
|
reference: dict[tuple[str, str], tuple[str, ...]]) -> None:
|
|
name = f"determinism-{kind}-{recipe}-{compiler_name(binary)}-w{workers}"
|
|
flags = ["--stream-hash"]
|
|
if kind == "crossing24":
|
|
flags.extend(("--camera-step=24,0,0", "--region-crossing"))
|
|
row, output = runner.run_cpp(name, binary, OWNER, recipe, flags,
|
|
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
|
|
workers=workers,
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = style
|
|
row["expected_passage_style"] = 2
|
|
values = tuple(HASH_RE.findall(output))
|
|
key = (kind, recipe)
|
|
expected = reference.get(key)
|
|
stable = expected is None or values == expected
|
|
if expected is None and values:
|
|
reference[key] = values
|
|
runner.require(f"{name}:stable-hashes", len(values) == 12 and stable,
|
|
f"hashes={len(values)}/12 stable={stable}")
|
|
|
|
|
|
def run_30_cell_determinism(runner: VerificationRunner) -> None:
|
|
references: dict[tuple[str, str], tuple[str, ...]] = {}
|
|
count = 0
|
|
for kind in ("l25", "crossing24"):
|
|
for recipe, style in (("surface-world", 1), ("floating-islands", 2)):
|
|
for binary in (CLANG, GCC):
|
|
for workers in (1, 8, 12):
|
|
verify_determinism_cell(runner, binary, kind, recipe, style,
|
|
workers, references)
|
|
count += 1
|
|
|
|
fixture_source = ROOT / "Saved/Linux/l33/fixtures/sw-upper-tunnel-network-style0.json"
|
|
fixture = OUT / "fixtures/style-override-upper-sw-fixture-style0.json"
|
|
fixture.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copyfile(fixture_source, fixture)
|
|
signatures = None
|
|
for binary in (CLANG, GCC):
|
|
for workers in (1, 8, 12):
|
|
name = f"determinism-style-override-upper-sw-fixture-style0-{compiler_name(binary)}-w{workers}"
|
|
row, output = runner.run_cpp(name, binary, fixture, "floating-islands",
|
|
["--audit-resolved-layout-passages"], expected_style=None,
|
|
expected_strate_styles={"1": 0}, workers=workers,
|
|
layout_path=OUT / "layouts" / f"{name}.json")
|
|
row["requested_style"] = 0
|
|
row["requested_strate_styles"] = {"1": 0}
|
|
validate_passage(runner, name, output)
|
|
current = tuple(re.findall(
|
|
r"^\[ResolvedLayoutSnapshot\].*stable_identity=([^ ]+)", output, re.M)
|
|
+ re.findall(r"^\[WorldAssemblyPlanSerialization\].*plan_hash=([0-9a-f]+)", output, re.M)
|
|
+ re.findall(r"^\[WorldAssemblerRouteAccepted\].*$", output, re.M))
|
|
stable = signatures is None or current == signatures
|
|
if signatures is None and current:
|
|
signatures = current
|
|
runner.require(f"{name}:stable-plan-route", bool(current) and stable,
|
|
f"snapshot-plan-route_records={len(current)} stable={stable}")
|
|
count += 1
|
|
runner.require("determinism-30-cell-count", count == 30, f"cells={count}/30")
|
|
|
|
|
|
def prepare_cost_baseline(runner: VerificationRunner) -> tuple[Path, str]:
|
|
resolved = bounded_run(["git", "rev-parse", "--verify", f"{ARGS.baseline}^{{commit}}"], timeout=120)
|
|
if resolved is None or resolved.returncode != 0:
|
|
raise VerificationFailure(f"could not resolve cost baseline commit {ARGS.baseline!r}")
|
|
baseline_commit = resolved.stdout.strip()
|
|
if not re.fullmatch(r"[0-9a-f]{40,64}", baseline_commit):
|
|
raise VerificationFailure(f"git returned an invalid baseline commit: {baseline_commit!r}")
|
|
temp = OUT / f"baseline-{baseline_commit}"
|
|
if temp.exists():
|
|
shutil.rmtree(temp)
|
|
temp.mkdir(parents=True)
|
|
atexit.register(shutil.rmtree, temp, ignore_errors=True)
|
|
tarball = temp / "baseline.tar"
|
|
archive = bounded_run(["git", "archive", "-o", str(tarball),
|
|
baseline_commit, "Standalone/Core", "Standalone/Source",
|
|
"Standalone/Compat"], timeout=120)
|
|
if archive is None or archive.returncode != 0 or not tarball.is_file():
|
|
raise VerificationFailure(
|
|
f"could not export build inputs from cost baseline commit {baseline_commit}")
|
|
extract = bounded_run(["tar", "-xf", str(tarball), "-C", str(temp)], timeout=120)
|
|
if extract is None or extract.returncode != 0:
|
|
raise VerificationFailure("cost baseline source extraction failed")
|
|
tarball.unlink(missing_ok=True)
|
|
|
|
base = temp / "Standalone"
|
|
(base / "Tools/verify").mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(ROOT / "Standalone/Build.ps1", base / "Build.ps1")
|
|
shutil.copy2(ROOT / "Standalone/BuildLinux.sh", base / "BuildLinux.sh")
|
|
shutil.copy2(VERIFY_DIR / "source_stamp.py", base / "Tools/verify/source_stamp.py")
|
|
shutil.copy2(ROOT / "Standalone/Source/SourceStamp.h", base / "Source/SourceStamp.h")
|
|
legacy_main = base / "Source/StreamBenchmarkHeadless.cpp"
|
|
text = legacy_main.read_text(encoding="utf-8")
|
|
if "VoxelForgePrintSourceStamp" not in text:
|
|
text = text.replace("#include \"OwnerWorldLoader.h\"",
|
|
"#include \"SourceStamp.h\"\n#include <cstring>\n#include \"OwnerWorldLoader.h\"", 1)
|
|
anchor = re.search(r"int main\(int argc,\s*char\*\*\s*argv\)\s*\{", text)
|
|
if anchor is None:
|
|
raise VerificationFailure("cannot instrument cost-baseline headless entry point")
|
|
injected = ("\n VoxelForgePrintSourceStamp();\n"
|
|
" if(argc==2&&std::strcmp(argv[1],\"--print-source-stamp\")==0)return 0;")
|
|
text = text[:anchor.end()] + injected + text[anchor.end():]
|
|
legacy_main.write_text(text, encoding="utf-8")
|
|
|
|
baseline_stamp = source_stamp(temp)
|
|
baseline_variant = f"baseline-{baseline_commit[:12]}-stamped"
|
|
binary = OUT / "historical-bin" / f"VoxelForgeCoreHeadless-{baseline_variant}"
|
|
env = os.environ.copy()
|
|
env["VOXELFORGE_BUILD_ROOT"] = str(temp / "build")
|
|
env["VOXELFORGE_BIN_DIR"] = str(binary.parent)
|
|
command = ["bash", str(base / "BuildLinux.sh"), "--compiler=clang++-19",
|
|
f"--variant={baseline_variant}", "--fp-contract=off", "--jobs=12"]
|
|
log = OUT / "cost-baseline-build.log"
|
|
log.parent.mkdir(parents=True, exist_ok=True)
|
|
started = time.monotonic()
|
|
with log.open("w", encoding="utf-8") as stream:
|
|
proc = bounded_run(command, timeout=1800, env=env, stdout=stream)
|
|
elapsed = time.monotonic() - started
|
|
runner.require("cost-baseline-build",
|
|
proc is not None and proc.returncode == 0 and binary.is_file(),
|
|
f"baseline={baseline_commit} source_stamp={baseline_stamp} "
|
|
f"elapsed_seconds={elapsed:.1f} log={log}")
|
|
runner.binary_stamp_overrides[str(binary)] = baseline_stamp
|
|
return binary, baseline_stamp
|
|
|
|
|
|
def run_cost_pairs(runner: VerificationRunner) -> None:
|
|
baseline, baseline_stamp = prepare_cost_baseline(runner)
|
|
candidate = CLANG
|
|
orders = (("baseline", "candidate"), ("candidate", "baseline"),
|
|
("baseline", "candidate"), ("candidate", "baseline"),
|
|
("baseline", "candidate"))
|
|
by_recipe: dict[str, dict[str, list[float]]] = {
|
|
"floating-islands": {"baseline": [], "candidate": []},
|
|
"surface-world": {"baseline": [], "candidate": []}}
|
|
by_pair: dict[tuple[str, int], dict[str, float]] = {}
|
|
for recipe, style in (("floating-islands", 2), ("surface-world", 1)):
|
|
for pair, order in enumerate(orders, 1):
|
|
for build in order:
|
|
binary = baseline if build == "baseline" else candidate
|
|
name = f"cost-{recipe}-pair{pair}-{build}"
|
|
expected_stamp = baseline_stamp if build == "baseline" else None
|
|
row, output = runner.run_cpp(name, binary, OWNER, recipe, [],
|
|
expected_style=2 if build == "candidate" else None,
|
|
expected_strate_styles={"0": 2, "1": 1} if build == "candidate" else None,
|
|
layout_path=OUT / "layouts" / f"{name}.json",
|
|
expected_stamp=expected_stamp)
|
|
row["requested_style"] = style
|
|
row["expected_passage_style"] = 2 if build == "candidate" else None
|
|
ready = re.findall(r"\bwhole_view_ready=([0-9.]+)s", output)
|
|
ok = (len(ready) == 1 and "hash=off" in output
|
|
and "cache_hits=0" in output
|
|
and RECIPE_RE.findall(output) == [(recipe, recipe, "PASS")])
|
|
runner.require(f"{name}:cost-record", ok,
|
|
f"whole_view_ready={ready[0] if ready else 'MISSING'}s "
|
|
f"source_stamp={row['source_stamp']}")
|
|
by_recipe[recipe][build].append(float(ready[0]))
|
|
by_pair.setdefault((recipe, pair), {})[build] = float(ready[0])
|
|
for recipe, values in by_recipe.items():
|
|
old = statistics.median(values["baseline"])
|
|
new = statistics.median(values["candidate"])
|
|
paired = [((by_pair[(recipe, pair)]["candidate"] - by_pair[(recipe, pair)]["baseline"])
|
|
/ by_pair[(recipe, pair)]["baseline"] * 100.0)
|
|
for pair in range(1, 6)]
|
|
runner.require(f"cost-{recipe}-five-pairs",
|
|
len(values["baseline"]) == len(values["candidate"]) == 5,
|
|
f"median_baseline_s={old:.3f} median_candidate_s={new:.3f} "
|
|
f"median_change_pct={(new / old - 1.0) * 100.0:+.2f} "
|
|
f"paired_change_pct={','.join(f'{value:+.2f}' for value in paired)}")
|
|
|
|
|
|
def run_medium_suite(runner: VerificationRunner, *, both_compilers: bool = False) -> None:
|
|
binaries = (CLANG, GCC) if both_compilers else (CLANG,)
|
|
run_owner_passages(runner, binaries)
|
|
run_landmark_reachability(runner, binaries)
|
|
run_regression_controls(runner)
|
|
style_override_matrix(runner, CLANG)
|
|
if both_compilers:
|
|
style_override_matrix(runner, GCC)
|
|
run_transitions_and_invariants(runner, binaries)
|
|
run_ring(runner, full=True)
|
|
run_captures_and_mesh_audits(runner)
|
|
run_ore_vein_hash_controls(runner)
|
|
run_random_camera_sweep(runner, (CLANG,), 5,
|
|
((3, 0, 0), (2, 1, 1), (3, 2, 1)))
|
|
|
|
|
|
def run_gcc_supplement(runner: VerificationRunner) -> None:
|
|
"""Add GCC evidence to a stamped, already-passed Clang medium tier."""
|
|
run_owner_passages(runner, (GCC,))
|
|
run_landmark_reachability(runner, (GCC,))
|
|
style_override_matrix(runner, GCC)
|
|
run_transitions_and_invariants(runner, (GCC,))
|
|
|
|
|
|
def _tier_deadline(_signum: int, _frame: object) -> None:
|
|
raise VerificationFailure(
|
|
f"{ARGS.tier} tier exceeded its {ARGS.overall_timeout}s overall timeout")
|
|
|
|
|
|
def main() -> int:
|
|
runner = VerificationRunner(ARGS.tier)
|
|
started = time.monotonic()
|
|
if ARGS.overall_timeout <= 0:
|
|
raise VerificationFailure("--overall-timeout must be a positive number of seconds")
|
|
signal.signal(signal.SIGALRM, _tier_deadline)
|
|
signal.setitimer(signal.ITIMER_REAL, ARGS.overall_timeout)
|
|
try:
|
|
if not OWNER.is_file():
|
|
raise VerificationFailure(f"canonical owner input is missing: {OWNER}")
|
|
for binary in (CLANG, GCC, RENDERER):
|
|
if binary.is_file():
|
|
runner.probe_binary(binary)
|
|
if ARGS.tier == "fast":
|
|
owners = run_owner_passages(runner, (CLANG,))
|
|
run_landmark_reachability(runner, (CLANG,))
|
|
run_regression_controls(runner)
|
|
run_hash_pairs(runner, owners)
|
|
run_ore_vein_hash_controls(runner)
|
|
run_random_camera_sweep(runner, (CLANG,), 3, ((3, 0, 0),))
|
|
run_ring(runner, full=False)
|
|
elif ARGS.tier == "medium":
|
|
run_medium_suite(runner, both_compilers=False)
|
|
else:
|
|
medium_summary = OUT / "medium-summary.json"
|
|
if not runner.reuse_passed_tier(medium_summary, "medium"):
|
|
run_medium_suite(runner, both_compilers=False)
|
|
run_gcc_supplement(runner)
|
|
run_random_camera_sweep(runner, (GCC,), 5,
|
|
((3, 0, 0), (2, 1, 1), (3, 2, 1)))
|
|
run_30_cell_determinism(runner)
|
|
run_cost_pairs(runner)
|
|
# The validated medium summary carries the final canonical capture set.
|
|
|
|
runner.assert_binaries_current()
|
|
runner.assert_current_tree("at tier completion")
|
|
elapsed = time.monotonic() - started
|
|
runner.save_summary("PASS")
|
|
print(f"[{ARGS.tier}] DONE PASS elapsed={elapsed:.1f}s", flush=True)
|
|
return 0
|
|
except Exception as error:
|
|
elapsed = time.monotonic() - started
|
|
runner.save_summary("FAIL", str(error))
|
|
print(f"[{ARGS.tier}] DONE FAIL elapsed={elapsed:.1f}s error={error}", flush=True)
|
|
return 1
|
|
finally:
|
|
signal.setitimer(signal.ITIMER_REAL, 0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|