Files
VoxelForge/Standalone/Tools/verify/verify.py
T
Fr0zkaandClaude Opus 5.5 9458217d34 feat(core): native Core caves generator, slice 1 -- spine + room, whole view 0.73 s (L54); research R23
Core.Caves.PrimitiveField v1, opt-in per strate (legacy TunnelNetwork assets stay legacy): solid host rock
and one smooth union of two elliptical spine tubes and an ellipsoid room, each intersected with its rising
floor by cubic smooth-max (W 2.4 m, measured fillet 0.70 m, no trailing floor cap). Bound in the L40 field
table and L42 capabilities, BVH feature candidates, isTileShapeFree aware, exact interval boxes (0 misses).
Capsule flood fill arrival -> departure passes (headroom >= 0.3 m, grade <= 15 deg); the generalized
whole-surface audit passes with its controls failing. Cold whole view 0.727 s, near ring 0.19 s. Graph
ordering/serialization changes are scoped to native caves (the flagged L47 demo is unchanged); verify
tiers write captures under --out only. fast/medium/full PASS, Clang and GCC.
Research R23 (deepened): per-tile LOD0 kernel speed plan.

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

1692 lines
93 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"
LINUX53 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux53"
LINUX54 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux54"
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
PROFILE_CAMERA_SWEEP_SEED = 0x4C3533
CAVES_CAMERA_SWEEP_SEED = 0x4C3534
PROFILE_NAMES = ("periodicHills", "mirroredRelief", "flatField")
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]
l52_baseline = ROOT / "Saved/Linux/l52" / f"owner-hash-{recipe}-style{style}-w12.log"
l52_hashes = tuple(HASH_RE.findall(l52_baseline.read_text(
encoding="utf-8", errors="replace")))
same_l52 = hashes[12] == l52_hashes and len(l52_hashes) == 12
runner.require(f"owner-hash-{recipe}-w12-matches-L52", same_l52,
f"current={len(hashes[12])} L52={len(l52_hashes)} exact canonical hash rows")
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")
diagnostic = {"name": f"owner-hash-{recipe}-matches-l46-diagnostic",
"status": "DIAGNOSTIC",
"detail": f"matches={same_l46} baseline={baseline.name} "
f"baseline_hashes={len(old_hashes)}; worker determinism is gated"}
runner.steps.append(diagnostic)
print(f"[{runner.tier}] {diagnostic['name']} {diagnostic['detail']}", flush=True)
l53_baseline = ROOT / "Saved/Linux/l53" / f"owner-hash-{recipe}-style{style}-w12.log"
l53_hashes = tuple(HASH_RE.findall(l53_baseline.read_text(
encoding="utf-8", errors="replace")))
same_l53 = hashes[12] == l53_hashes and len(l53_hashes) == 12
l53_diagnostic = {"name": f"owner-hash-{recipe}-matches-L53-diagnostic",
"status": "DIAGNOSTIC", "detail": f"matches={same_l53} "
f"baseline={l53_baseline.name} baseline_hashes={len(l53_hashes)}"}
runner.steps.append(l53_diagnostic)
print(f"[{runner.tier}] {l53_diagnostic['name']} {l53_diagnostic['detail']}",
flush=True)
def run_default_profile_identity(runner: VerificationRunner, binary: Path) -> None:
compiler = compiler_name(binary)
for recipe, style in (("floating-islands", 2), ("surface-world", 1)):
name = f"owner-default-profile-hash-{recipe}-{compiler}-w12"
_, output = runner.run_cpp(name, binary, OWNER, recipe, ["--stream-hash"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=12,
layout_path=OUT / "layouts" / f"{name}.json")
values = tuple(HASH_RE.findall(output))
baseline = ROOT / "Saved/Linux/l52" / f"owner-hash-{recipe}-style{style}-w12.log"
expected = tuple(HASH_RE.findall(baseline.read_text(
encoding="utf-8", errors="replace")))
runner.require(f"{name}:matches-L52", len(values) == 12 and values == expected,
f"current={len(values)} L52={len(expected)} exact canonical hash rows")
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 build_caves_fixture(runner: VerificationRunner, binary: Path) -> Path:
fixture = OUT / "fixtures" / "caves.json"
builder = LINUX54 / "BuildCaveFixtureL54.py"
runner.run_stage("build-native-caves-fixture-l54", builder,
["--owner", str(OWNER), "--out", str(fixture)], binary=binary,
data=OWNER, recipe="caves", style=None, env=env_for(),
script_inputs=[builder, OWNER])
return fixture
def run_native_caves_field_audit(runner: VerificationRunner, binary: Path) -> tuple[Path, Path]:
fixture = build_caves_fixture(runner, binary)
compiler = compiler_name(binary)
layout_path = OUT / "layouts" / f"native-caves-field-{compiler}.json"
row, output = runner.run_cpp(f"native-caves-field-{compiler}", binary, fixture,
"caves", ["--audit-native-caves", "--max-clip-level=0",
"--render-distance-chunks=0"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=12,
max_level=0, layout_path=layout_path,
script_inputs=[LINUX54 / "BuildCaveFixtureL54.py"])
plan = re.search(r"^\[CavesSpinePlan\] .*recipe=Core\.Caves\.PrimitiveField version=1 "
r"density_sign=negative_solid_positive_air .*edges=2 .*bore_radius_m=4\.500 "
r"bore_height_m=4\.500 .*floor_blend_width_m=([0-9.]+) "
r"ideal_fillet_radius_m=([0-9.]+) .*shared_layer=shared-bedrock status=PASS$",
output, re.M)
runner.require(f"native-caves-field-{compiler}:version-and-binding", bool(plan),
"native caves recipe v1, negative-solid/positive-air, two spine edges, shared layer")
fillet = re.search(r"^\[CavesFilletAudit\].*measured_composed_radius_m=([0-9.]+) "
r".*status=PASS$", output, re.M)
runner.require(f"native-caves-field-{compiler}:measured-fillet",
bool(fillet and float(fillet.group(1)) >= 0.5),
f"measured_composed_radius_m={fillet.group(1) if fillet else 'MISSING'} required>=0.500")
flood = re.search(r"^\[CavesCapsuleFloodFill\].*min_headroom_m=([0-9.]+) "
r"required_headroom_m=0\.300 reachable=yes status=PASS$", output, re.M)
runner.require(f"native-caves-field-{compiler}:arrival-to-departure",
bool(flood and float(flood.group(1)) >= 0.3),
f"reachable={bool(flood)} min_headroom_m={flood.group(1) if flood else 'MISSING'}")
runner.require(f"native-caves-field-{compiler}:interval-oracle-and-controls",
all_match(output, r"^\[CavesIntervalOracle\] .*misses=0 "
r"false_all_air=REJECTED false_all_solid=REJECTED .*status=PASS$"),
"brute-force interval proofs have zero misses and reject both false-proof controls")
layout = json.loads(layout_path.read_text(encoding="utf-8"))
graph_ok = (layout.get("cavern_graph_vocabulary_version") == 1
and len(layout.get("cavern_rooms", [])) == 1
and len(layout.get("cavern_edges", [])) == 2)
runner.require(f"native-caves-field-{compiler}:resolved-graph", graph_ok,
f"vocabulary={layout.get('cavern_graph_vocabulary_version')} "
f"rooms={len(layout.get('cavern_rooms', []))} edges={len(layout.get('cavern_edges', []))}")
if plan:
row["floor_blend_width_m"] = float(plan.group(1))
row["ideal_fillet_radius_m"] = float(plan.group(2))
if fillet:
row["measured_composed_fillet_radius_m"] = float(fillet.group(1))
if flood:
row["minimum_headroom_m"] = float(flood.group(1))
return fixture, layout_path
def cave_camera_positions(layout_path: Path, count: int = 4) -> list[tuple[float, float, float, float, float]]:
layout = json.loads(layout_path.read_text(encoding="utf-8"))
edges = sorted(layout.get("cavern_edges", []), key=lambda edge: edge["stable_id"])
if layout.get("cavern_graph_vocabulary_version") != 1 or len(edges) != 2:
raise VerificationFailure(f"missing two resolved cave spine edges in {layout_path}")
rng = _SplitMix64(CAVES_CAMERA_SWEEP_SEED)
cameras = []
for index in range(count):
edge = edges[index % len(edges)]
points = [[value / 1_000_000.0 for value in point]
for point in edge["control_points_um"]]
t = rng.between(0.30, 0.72)
one = 1.0 - t
position = [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] for axis in range(3)]
tangent = [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])
for axis in range(3)]
horizontal = math.hypot(tangent[0], tangent[1])
if horizontal <= 1.0e-9:
raise VerificationFailure(f"degenerate cave camera tangent in {layout_path}")
side = (-tangent[1] / horizontal, tangent[0] / horizontal)
lateral = rng.between(-1.0, 1.0)
x = position[0] + side[0] * lateral
y = position[1] + side[1] * lateral
z = position[2] + rng.between(1.40, 1.60)
yaw = math.degrees(math.atan2(tangent[0], tangent[1])) + rng.between(-18.0, 18.0)
pitch = rng.between(-8.0, 8.0)
cameras.append((x, y, z, yaw, pitch))
return cameras
def run_caves_determinism(runner: VerificationRunner, binary: Path, fixture: Path,
layout_path: Path, *, compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "caves-determinism-reference.json"
if compare_reference:
try:
reference = json.loads(reference_path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
raise VerificationFailure(f"missing Clang cave camera reference: {error}")
else:
reference = None
current: dict[str, dict[str, dict[str, list[str]]]] = {}
for camera_index, camera in enumerate(cave_camera_positions(layout_path)):
x, y, z, yaw, pitch = camera
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
signatures: dict[int, dict[tuple[int, int, int, int], tuple[str, ...]]] = {}
key = f"p{camera_index:02d}"
current[key] = {}
for workers in (1, 8, 12):
name = (f"caves-camera-{compiler}-s{CAVES_CAMERA_SWEEP_SEED:06x}-"
f"p{camera_index:02d}-w{workers}")
row, output = runner.run_cpp(name, binary, fixture, "caves",
["--stream-hash-tiles", camera_flag, "--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_seed"] = f"0x{CAVES_CAMERA_SWEEP_SEED:06x}"
row["camera_index"] = camera_index
row["camera_position_m"] = [round(value, 6) for value in camera[:3]]
row["camera_region"] = "inside-native-caves-spine"
tiles = parse_tile_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(tiles) and len(tiles) == expected_rows,
f"rows={len(tiles)} expected={expected_rows} camera_m={camera[:3]}")
signatures[workers] = tiles
current[key][str(workers)] = {
"/".join(map(str, tile)): list(value)
for tile, value in sorted(tiles.items())}
for left, right in ((1, 8), (1, 12), (8, 12)):
runner.require(f"caves-camera-{compiler}-{key}:W{left}-W{right}",
signatures[left] == signatures[right],
f"camera_m=({x:.3f},{y:.3f},{z:.3f}) W{left}=W{right} "
"density/mesh/payload/topology tile hashes match")
if compare_reference:
runner.require("caves-camera-gcc:matches-clang-peers", current == reference,
"random cave camera tile hashes match Clang at W1/W8/W12")
else:
reference_path.write_text(json.dumps(current, indent=2, sort_keys=True) + "\n",
encoding="utf-8")
def run_caves_performance(runner: VerificationRunner, binary: Path,
fixture: Path, layout_path: Path) -> None:
compiler = compiler_name(binary)
camera = cave_camera_positions(layout_path, count=1)[0]
x, y, z, yaw, pitch = camera
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
row, output = runner.run_cpp(f"caves-speed-{compiler}-w12", binary, fixture,
"caves", [camera_flag, "--clip-radius=4", "--max-clip-level=0",
"--max-level=0", "--render-distance-chunks=0",
"--camera-step=24,0,0", "--region-crossing"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=12,
max_level=0, layout_path=OUT / "layouts" / f"caves-speed-{compiler}-w12.json")
stream = re.search(r"^\[StreamPipeline\] .*first_tile_ready=([0-9.]+)s "
r".*neighborhood_ready=([0-9.]+)s .*whole_view_ready=([0-9.]+)s "
r".*cache_hits=0", output, re.M)
moving = re.search(r"^\[MovingTileLatency\] entering_tiles=(\d+) "
r"p50_ms=([0-9.]+) p95_ms=([0-9.]+) metric=submit_to_completion_observed$",
output, re.M)
runner.require(f"caves-speed-{compiler}:cold-and-moving-records",
bool(stream and moving and int(moving.group(1)) > 0),
f"cold_first_tile_s={stream.group(1) if stream else 'MISSING'} "
f"near_ring_s={stream.group(2) if stream else 'MISSING'} "
f"cold_whole_view_s={stream.group(3) if stream else 'MISSING'} "
f"moving_p50_ms={moving.group(2) if moving else 'MISSING'} "
f"moving_p95_ms={moving.group(3) if moving else 'MISSING'}")
if stream and moving:
row["speed_metrics"] = {
"cold_first_tile_seconds": float(stream.group(1)),
"near_ring_seconds": float(stream.group(2)),
"cold_whole_view_seconds": float(stream.group(3)),
"moving_entering_tiles": int(moving.group(1)),
"moving_p50_ms": float(moving.group(2)),
"moving_p95_ms": float(moving.group(3)),
"workers": 12,
"camera_m": [round(value, 6) for value in camera[:3]],
}
def run_caves_surface_evidence(runner: VerificationRunner, fixture: Path,
layout_path: Path) -> None:
capture_script = LINUX54 / "CaptureNativeCavesL54.py"
artifact_dir = OUT / "captures"
_, capture_output = runner.run_stage("capture-native-caves-l54", capture_script,
["--out", str(OUT), "--fixture", str(fixture), "--layout", str(layout_path),
"--headless", str(CLANG), "--renderer", str(RENDERER),
"--artifact-dir", str(artifact_dir)], binary=CLANG, data=fixture,
recipe="caves", style=2, env=env_for(capture=True),
script_inputs=[capture_script, VERIFY_DIR / "capture_quality.py"])
capture_rows = re.findall(r"^\[L54CavesCapture\] view=([^ ]+) .*status=PASS$",
capture_output, re.M)
runner.require("capture-native-caves-l54:coverage",
set(capture_rows) == {"spine-eye", "room-from-entrance", "cutaway-overview"}
and len(capture_rows) == 3,
f"views={capture_rows}")
script = LINUX54 / "AuditWholeSurfaceL54.py"
audit_layout = ROOT / "Saved/Linux/l48/layouts/landmark-reachability-clang.json"
controls = (
("L45-ramp-control", ROOT / "Saved/Linux/l45/landmark-l45.vfmesh", "fail"),
("L46-entrance-control", ROOT / "Saved/Linux/l46/landmark-l46.vfmesh", "fail"),
("L47-wall-foot-control", ROOT / "Saved/Linux/l47/landmark-l47.vfmesh", "fail"),
("plain-native-control", ROOT / "Saved/Linux/l48/control-plain-native.vfmesh", "pass"),
)
mesh = OUT / "caves-meshes" / "caves-whole-view.vfmesh"
cases = [("caves-base", mesh, layout_path, "measure", "whole")]
cases.extend((name, control_mesh, audit_layout, expect, "whole")
for name, control_mesh, expect in controls)
svg_dir = artifact_dir
base_args = ["--json", str(OUT / "whole-surface-caves-base.json"),
"--svg-dir", str(svg_dir)]
for label, case_mesh, case_layout, expect, focus in cases:
base_args.extend(("--case", label, str(case_mesh), str(case_layout), expect, focus))
_, base_output = runner.run_stage("whole-surface-caves-base-l54", script, base_args,
binary=CLANG, data=fixture, recipe="caves", style=2,
layout_path=layout_path, env=env_for(),
script_inputs=[script, mesh, layout_path, audit_layout,
*(item[1] for item in controls)])
candidate = re.search(r"^\[WholeSurfaceAudit\] label=caves-base .*"
r"observed=(PASS|FAIL) expected=MEASURE status=PASS$", base_output, re.M)
runner.require("whole-surface-caves-base-l54:pass",
bool(candidate and candidate.group(1) == "PASS"),
f"observed={candidate.group(1) if candidate else 'MISSING'}")
for label, _control_mesh, expectation in controls:
match = re.search(rf"^\[WholeSurfaceAudit\] label={re.escape(label)} .*"
rf"observed=(PASS|FAIL) expected={expectation.upper()} status=PASS$",
base_output, re.M)
runner.require(f"whole-surface-caves-base-l54:{label}", bool(match),
f"control_expectation={expectation} observed={match.group(1) if match else 'MISSING'}")
for phase, label in ((-0.5, "minus-half"), (0.5, "plus-half")):
phase_args = ["--json", str(OUT / f"whole-surface-caves-{label}.json"),
"--svg-dir", str(svg_dir), "--phase", str(phase),
"--case", f"caves-{label}", str(mesh), str(layout_path), "measure", "whole"]
_, phase_output = runner.run_stage(f"whole-surface-caves-{label}-l54", script,
phase_args, binary=CLANG, data=fixture, recipe="caves", style=2,
layout_path=layout_path, env=env_for(),
script_inputs=[script, mesh, layout_path])
match = re.search(r"^\[WholeSurfaceAudit\] label=caves-" + label + r" .*"
r"phase_h=[+-]0\.5 .*observed=(PASS|FAIL) expected=MEASURE status=PASS$",
phase_output, re.M)
runner.require(f"whole-surface-caves-{label}-l54:pass",
bool(match and match.group(1) == "PASS"),
f"observed={match.group(1) if match else 'MISSING'}")
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_profile_fixtures(runner: VerificationRunner, binary: Path) -> dict[str, float]:
compiler = compiler_name(binary)
builder = LINUX53 / "BuildProfileFixturesL53.py"
runner.run_stage("build-style-override-profile-fixtures-l53", builder,
["--out", str(OUT / "fixtures")], binary=binary, data=OWNER,
recipe="surface-world", style=None, env=env_for(),
script_inputs=[OWNER])
baseline_name = f"profile-natural-sw-baseline-{compiler}"
baseline_manifest = OUT / "fixtures" / f"profile-natural-sw-baseline-{compiler}-manifest.json"
_, baseline_output = runner.run_cpp(baseline_name, binary, OWNER, "surface-world",
["--stream-hash", f"--world-assembler-manifest-output={baseline_manifest}"], expected_style=None,
expected_strate_styles={"0": 2, "1": 1},
layout_path=OUT / "layouts" / f"{baseline_name}.json",
script_inputs=[baseline_manifest])
baseline_match = re.search(r"\bwhole_view_ready=([0-9.]+)s", baseline_output)
runner.require(f"{baseline_name}:whole-view-timing", baseline_match is not None,
"natural SurfaceWorld emitted a cold whole-view readiness time")
baseline_seconds = float(baseline_match.group(1)) if baseline_match else float("inf")
timings = {"natural_surface_world_seconds": baseline_seconds}
try:
baseline_recipe = json.loads(baseline_manifest.read_text(encoding="utf-8"))["recipe"]
baseline_plan = json.loads(baseline_manifest.read_text(encoding="utf-8"))["plan"]
natural_omitted = ("surface_profile" not in baseline_recipe
and all("surface_profile" not in item for item in baseline_plan["strates"]))
except (OSError, KeyError, TypeError, ValueError, json.JSONDecodeError):
natural_omitted = False
runner.require(f"{baseline_name}:default-profile-omitted", natural_omitted,
"natural remains the implicit version-0 profile in recipe and plan JSON")
for profile in PROFILE_NAMES:
label = f"style-override-profile-{profile}"
fixture = OUT / "fixtures" / f"{label}.json"
manifest = OUT / "fixtures" / f"{label}-manifest.json"
name = f"{label}-{compiler}"
flags = ["--audit-resolved-layout-passages", "--audit-uniform-block-proofs",
"--audit-route-parity",
"--audit-heightfield-profile",
f"--world-assembler-manifest-output={manifest}"]
row, output = runner.run_cpp(name, binary, fixture, "surface-world", flags,
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[builder, manifest])
validate_passage(runner, name, output)
transition_name = f"{label}-transition-{compiler}"
_, transition_output = runner.run_cpp(transition_name, binary, fixture, "surface-world",
["--audit-strate-transitions"], expected_style=None,
expected_strate_styles={"0": 2, "1": 1},
layout_path=OUT / "layouts" / f"{transition_name}.json")
runner.require(f"{transition_name}:bands-and-holes",
all_match(transition_output, r"^\[StrateTransitionAuditSummary\].*hole_columns=0 air_samples=0 .*status=PASS$")
and all_match(transition_output, r"^\[StrateTransitionNegativeControls\].*status=PASS$"),
"arrival/departure interfaces have sealed bands and reject both thickness controls")
runner.require(f"{name}:uniform-block-proofs",
all_match(output, r"^\[UniformBlockProofAudit\].*violations=0(?:\s|$)"),
"profile interval blocks contain every brute-force density sample")
runner.require(f"{name}:passage-landing-approach",
all_match(output, r"^\[ResolvedPassageLowerApproach\] id=passage/0-1/0 "
r"direction=(?:forward|reverse) alignment_q16=[1-9][0-9]* status=PASS$"),
"the planned inter-strate approach joins the profile route without overlap")
proof = re.search(rf"^\[HeightfieldProfileProofAudit\] kind={re.escape(profile)} .*status=PASS$",
output, re.M)
runner.require(f"{name}:analytic-bounds-and-route", proof is not None,
"profile intervals, lattice classification, seeded route and capsule support pass")
try:
encoded = json.loads(manifest.read_text(encoding="utf-8"))
recipe_profile = encoded["recipe"]["surface_profile"]
plan_profiles = [entry["surface_profile"] for entry in encoded["plan"]["strates"]]
serialized = (recipe_profile["version"] == 1
and recipe_profile["kind"] == profile
and plan_profiles
and all(item == recipe_profile for item in plan_profiles)
and 0 <= recipe_profile["phase_x_turns_q32"] <= 0xFFFFFFFF
and 0 <= recipe_profile["phase_y_turns_q32"] <= 0xFFFFFFFF)
except (OSError, KeyError, TypeError, ValueError, json.JSONDecodeError):
serialized = False
runner.require(f"{name}:recipe-plan-serialization", bool(serialized),
f"versioned {profile} selector and seeded phases appear identically in recipe and plan")
timing_name = f"profile-cold-view-{profile}-{compiler}"
timing_row, timing_output = runner.run_cpp(timing_name, binary, fixture,
"surface-world", ["--stream-hash"], expected_style=None,
expected_strate_styles={"0": 2, "1": 1},
layout_path=OUT / "layouts" / f"{timing_name}.json")
ready = re.search(r"\bwhole_view_ready=([0-9.]+)s", timing_output)
seconds = float(ready.group(1)) if ready else float("inf")
timings[f"{profile}_seconds"] = seconds
runner.require(f"{timing_name}:cold-whole-view-budget", seconds <= 1.75,
f"whole_view_ready={seconds:.3f}s budget=1.750s SW_reference={baseline_seconds:.3f}s")
if profile in ("periodicHills", "flatField"):
runner.require(f"{timing_name}:analytic-profile-speedup", seconds < baseline_seconds,
f"whole_view_ready={seconds:.3f}s natural_SW={baseline_seconds:.3f}s")
row["profile_kind"] = profile
row["whole_view_ready_seconds"] = seconds
timing_row["profile_kind"] = profile
timing_row["whole_view_ready_seconds"] = seconds
timing_path = OUT / "profile-whole-view-timings.json"
existing: dict = {}
if timing_path.is_file():
try:
existing = json.loads(timing_path.read_text(encoding="utf-8"))
except json.JSONDecodeError:
existing = {}
existing[compiler] = timings
timing_path.write_text(json.dumps(existing, indent=2) + "\n", encoding="utf-8")
return timings
def run_profile_captures(runner: VerificationRunner) -> None:
script = LINUX53 / "CaptureHeightfieldProfilesL53.py"
quality = VERIFY_DIR / "capture_quality.py"
artifacts = OUT / "captures"
_, output = runner.run_stage("capture-profiled-heightfields-l53", script,
["--out", str(OUT), "--fixture-dir", str(OUT / "fixtures"),
"--artifact-dir", str(artifacts), "--headless", str(CLANG),
"--renderer", str(RENDERER)], binary=CLANG, data=OWNER,
recipe="surface-world", style=None, env=env_for(capture=True),
script_inputs=[quality, LINUX53 / "BuildProfileFixturesL53.py"])
capture_rows = re.findall(r"^\[L53HeightfieldCapture\] profile=(\S+) view=(\S+) .*status=PASS$",
output, re.M)
quality_rows = re.findall(r"^\[CaptureQuality\].*status=PASS$", output, re.M)
expected = {(profile, view) for profile in PROFILE_NAMES for view in ("eye", "overview")}
runner.require("capture-profiled-heightfields-l53:coverage",
set(capture_rows) == expected and len(quality_rows) == 6,
f"profile_views={len(capture_rows)}/6 quality_gates={len(quality_rows)}/6")
def profile_signature(output: str) -> dict[str, object]:
serialization = re.search(
r"^\[WorldAssemblerPlanSerialization\].*canonical_round_trip=true .*"
r"plan_hash=([0-9a-f]+) manifest_hash=([0-9a-f]+) status=PASS$", output, re.M)
route = re.search(r"^\[WorldAssemblerRouteAccepted\].*$", output, re.M)
return {
"hashes": HASH_RE.findall(output),
"plan_hash": serialization.group(1) if serialization else None,
"manifest_hash": serialization.group(2) if serialization else None,
"route": route.group(0) if route else None,
}
def run_profile_determinism(runner: VerificationRunner, binary: Path, *,
compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "profile-determinism-reference.json"
if compare_reference:
try:
references = json.loads(reference_path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
raise VerificationFailure(f"missing Clang profile determinism reference: {error}")
else:
references: dict[str, dict[str, dict[str, object]]] = {}
for profile in PROFILE_NAMES:
fixture = OUT / "fixtures" / f"style-override-profile-{profile}.json"
expected_by_worker: dict[int, dict[str, object]] = {}
for workers in (1, 8, 12):
name = f"profile-determinism-{profile}-{compiler}-w{workers}"
manifest = OUT / "fixtures" / f"{name}-manifest.json"
_, output = runner.run_cpp(name, binary, fixture, "surface-world",
["--stream-hash", f"--world-assembler-manifest-output={manifest}"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
workers=workers, layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[manifest])
signature = profile_signature(output)
runner.require(f"{name}:signature-shape",
len(signature["hashes"]) == 12 and signature["plan_hash"] is not None
and signature["manifest_hash"] is not None and signature["route"] is not None,
"12 canonical pipeline hashes, recipe/plan serialization hashes, and route acceptance")
expected_by_worker[workers] = signature
if compare_reference:
reference = references.get(profile, {}).get(str(workers))
runner.require(f"{name}:clang-gcc-peer",
signature == reference,
f"Clang reference exists and matches at W{workers}")
stable = expected_by_worker[1] == expected_by_worker[8] == expected_by_worker[12]
runner.require(f"profile-determinism-{profile}-{compiler}:workers",
stable, "W1, W8, and W12 preserve profile hashes, plan identity, and accepted route")
if not compare_reference:
references[profile] = {str(workers): expected_by_worker[workers]
for workers in (1, 8, 12)}
if not compare_reference:
reference_path.write_text(json.dumps(references, indent=2) + "\n", encoding="utf-8")
def profile_camera_positions(profile: str, count: int = 5) -> list[tuple[float, float, float, float, float]]:
manifest_path = OUT / "fixtures" / f"style-override-profile-{profile}-manifest.json"
try:
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
routes = [row["route"] for row in manifest["plan"]["strates"]
if len(row.get("route", [])) >= 2]
route = routes[0]
except (OSError, KeyError, IndexError, TypeError, json.JSONDecodeError) as error:
raise VerificationFailure(f"cannot derive {profile} random cameras: {error}")
points = [tuple(float(value) / 1024.0 for value in item["position_q"])
for item in route]
center = tuple(sum(point[axis] for point in points) / len(points) for axis in range(3))
seed_salt = sum(profile.encode("ascii"))
rng = _SplitMix64(PROFILE_CAMERA_SWEEP_SEED + seed_salt)
positions = []
for _ in range(count):
x = center[0] + rng.between(-220.0, 220.0)
y = center[1] + rng.between(-220.0, 220.0)
z = center[2] + rng.between(-4.0, 4.0)
yaw = rng.between(-180.0, 180.0)
pitch = rng.between(-25.0, 25.0)
positions.append((x, y, z, yaw, pitch))
return positions
def run_profile_random_camera_sweep(runner: VerificationRunner, binary: Path, *,
compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "profile-random-camera-reference.json"
if compare_reference:
try:
references = json.loads(reference_path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
raise VerificationFailure(f"missing Clang profile camera reference: {error}")
else:
references: dict[str, dict[str, object]] = {}
for profile in PROFILE_NAMES:
fixture = OUT / "fixtures" / f"style-override-profile-{profile}.json"
positions = profile_camera_positions(profile)
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}"
signatures: dict[int, dict[str, object]] = {}
for workers in (1, 8, 12):
name = (f"profile-random-camera-{profile}-{compiler}-"
f"s{PROFILE_CAMERA_SWEEP_SEED:06x}-p{camera_index:02d}-w{workers}")
_, output = runner.run_cpp(name, binary, fixture, "surface-world",
["--stream-hash-tiles", camera_flag, "--clip-radius=3",
"--max-clip-level=0", "--max-level=0", "--render-distance-chunks=0"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
workers=workers, layout_path=OUT / "layouts" / f"{name}.json")
tiles = parse_tile_hashes(output)
materials = 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(tiles) and len(tiles) == expected_rows,
f"rows={len(tiles)} expected={expected_rows}")
runner.require(f"{name}:material-hash-rows",
bool(materials) and len(materials) == expected_rows,
f"rows={len(materials)} expected={expected_rows}")
signatures[workers] = {
"tiles": {"/".join(map(str, key)): list(value)
for key, value in sorted(tiles.items())},
"materials": {"/".join(map(str, key)): value
for key, value in sorted(materials.items())},
}
stable = signatures[1] == signatures[8] == signatures[12]
key = f"{profile}/p{camera_index:02d}"
runner.require(f"profile-random-camera-{profile}-{compiler}-p{camera_index:02d}:workers",
stable, "seeded profile camera tile geometry and material hashes match at W1/W8/W12")
if compare_reference:
runner.require(f"profile-random-camera-{profile}-gcc-p{camera_index:02d}:clang-peer",
{str(worker): signatures[worker] for worker in (1, 8, 12)}
== references.get(key),
"Clang and GCC preserve exact per-tile geometry/material hashes")
else:
references[key] = {str(worker): signatures[worker]
for worker in (1, 8, 12)}
if not compare_reference:
reference_path.write_text(json.dumps(references, indent=2) + "\n", encoding="utf-8")
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(OUT / "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_default_profile_identity(runner, CLANG)
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_profile_fixtures(runner, CLANG)
run_profile_captures(runner)
run_profile_determinism(runner, CLANG, compare_reference=False)
run_profile_random_camera_sweep(runner, CLANG, compare_reference=False)
run_random_camera_sweep(runner, (CLANG,), 5,
((3, 0, 0), (2, 1, 1), (3, 2, 1)))
fixture, layout_path = run_native_caves_field_audit(runner, CLANG)
run_caves_determinism(runner, CLANG, fixture, layout_path, compare_reference=False)
run_caves_performance(runner, CLANG, fixture, layout_path)
run_caves_surface_evidence(runner, fixture, layout_path)
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,))
run_default_profile_identity(runner, GCC)
run_profile_fixtures(runner, GCC)
run_profile_determinism(runner, GCC, compare_reference=True)
run_profile_random_camera_sweep(runner, GCC, compare_reference=True)
fixture = OUT / "fixtures" / "caves.json"
layout_path = OUT / "layouts" / "native-caves-field-clang.json"
if not fixture.is_file() or not layout_path.is_file():
fixture, layout_path = run_native_caves_field_audit(runner, CLANG)
run_caves_determinism(runner, GCC, fixture, layout_path, compare_reference=True)
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)
run_native_caves_field_audit(runner, CLANG)
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())