Files
VoxelForge/Standalone/Tools/verify/verify.py
T
Fr0zkaandClaude Opus 5.5 c0c204ba50 fix: signed-overflow UB in VoxelHash made cave placement compiler-dependent; all generators LOD0-8; speed matrix (L60)
VoxelHash::Cell/Pair, legacy Cellular3D and the shared Core cellular hash added 0x7FFFFFFF to a signed
int32 before casting to uint32; overflow is undefined, so Clang and GCC placed cave passage 1 differently
(first differing sample at LOD1 tile (0,64,-512)). The bias is now done in unsigned arithmetic, in both the
standalone copy and the Unreal plugin header (Source/VoxelForge/Public/VoxelCaveMorphology.h). Native
caves, motifs and lattice now stream LOD0-8 with skirts and cross-level transitions. New verify.py
--speed-matrix runs every generator on one asserted-identical view (5 interleaved runs): motifs 1.33,
profiles 1.30-1.32, caves 1.41, natural SW 1.67, lattice 1.70, FI 4.93 s whole view. fast/medium/full PASS,
Clang/GCC peer hashes equal. Research R29 (open-edge ledge) and R30 (compiler-divergence suspects).

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

2614 lines
145 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"
LINUX56 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux56"
LINUX58 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux58"
LINUX60 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux60"
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)")
PARSER.add_argument("--speed-matrix", action="store_true",
help="run five interleaved full-view timings for every generator")
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
LATTICE_CAMERA_SWEEP_SEED = 0x4C3538
PROFILE_NAMES = ("periodicHills", "mirroredRelief", "flatField")
SPEED_MATRIX_REPETITIONS = 5
SPEED_MATRIX_TILE_RANGE = (1800, 2500)
SPEED_MATRIX_LOD_TILE_RANGES = (
(400, 560), (350, 500), (250, 450), (150, 350), (100, 300),
(60, 220), (48, 180), (24, 160), (16, 100),
)
SPEED_MATRIX_CAMERA_M = (-12.0, -118.0, -20.0, 0.0, 0.0)
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 full_lod_stream_rows(output: str) -> dict[int, dict[str, int]]:
rows: dict[int, dict[str, int]] = {}
pattern = re.compile(r"^\[WorldAssemblerLODWorker\] lod=(\d+) tiles=(\d+) "
r".*?skirt_triangles=(\d+)(?:\s|$)", re.M)
for match in pattern.finditer(output):
rows[int(match.group(1))] = {
"tiles": int(match.group(2)),
"skirt_triangles": int(match.group(3)),
}
return rows
def require_full_lod_stream(runner: VerificationRunner, name: str,
output: str) -> tuple[int, dict[int, dict[str, int]]]:
stream = re.search(r"^\[StreamPipeline\].*?whole_tiles=(\d+)/(\d+) "
r"stream_wall=([0-9.]+)s .*cache_hits=0", output, re.M)
rows = full_lod_stream_rows(output)
count = int(stream.group(2)) if stream else -1
counts_match = (set(rows) == set(range(9))
and all(rows[level]["tiles"] > 0 for level in range(9))
and sum(row["tiles"] for row in rows.values()) == count)
far_skirts = {level: rows[level]["skirt_triangles"]
for level in range(1, 9) if level in rows}
skirt_match = any(value > 0 for value in far_skirts.values())
passed = bool(stream and int(stream.group(1)) == count
and counts_match and skirt_match)
levels = ",".join(f"{level}:{rows.get(level, {}).get('tiles', 0)}"
for level in range(9))
runner.require(f"{name}:full-lod-stream-and-skirts", passed,
f"whole_tiles={count} levels={levels} "
f"far_skirt_triangles={sum(far_skirts.values())} "
"all LOD0-8 streamed with near and far transition skirts")
return count, rows
def require_feature_lod_transition(runner: VerificationRunner, name: str,
feature: str, output: str) -> None:
count, rows = require_full_lod_stream(runner, name, output)
moving = re.search(r"^\[MovingTileLatency\] entering_tiles=(\d+) "
r"p50_ms=([0-9.]+) p95_ms=([0-9.]+) "
r"metric=submit_to_completion_observed$", output, re.M)
entered = int(moving.group(1)) if moving else 0
runner.require(f"{name}:{feature}-lod-transition",
bool(moving and entered > 0 and set(rows) == set(range(9)) and count > 0),
f"feature_camera_crossing=true entering_tiles={entered} levels=0..8")
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=8",
"--render-distance-chunks=0"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=12,
max_level=-1, layout_path=layout_path,
script_inputs=[LINUX54 / "BuildCaveFixtureL54.py"])
requested_volume = re.search(r"^\[PipelineVolume\] tiles=(\d+) lod=0\.\.8 ",
output, re.M)
runner.require(f"native-caves-field-{compiler}:full-lod-requested",
bool(requested_volume and int(requested_volume.group(1)) > 0),
f"tiles={requested_volume.group(1) if requested_volume else 'MISSING'} lod=0..8")
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 build_lattice_fixture(runner: VerificationRunner, binary: Path) -> Path:
fixture = OUT / "fixtures" / "lattice-l58.json"
builder = LINUX58 / "BuildLatticeFixtureL58.py"
runner.run_stage("build-native-lattice-fixture-l58", builder,
["--owner", str(OWNER), "--out", str(fixture)], binary=binary,
data=OWNER, recipe="lattice", style=None, env=env_for(),
script_inputs=[builder, OWNER])
return fixture
def run_native_lattice_field_audit(runner: VerificationRunner, binary: Path) -> tuple[Path, Path]:
fixture = build_lattice_fixture(runner, binary)
compiler = compiler_name(binary)
layout_path = OUT / "layouts" / f"native-lattice-field-{compiler}.json"
styles = {"0": 2, "1": 1, "2": 1}
inputs = [LINUX58 / "BuildLatticeFixtureL58.py"]
row, output = runner.run_cpp(f"native-lattice-field-{compiler}", binary, fixture,
"lattice", ["--lattice-strate=1", "--audit-native-lattice",
"--max-clip-level=8", "--render-distance-chunks=0"],
expected_style=None, expected_strate_styles=styles, workers=12,
max_level=-1, layout_path=layout_path, script_inputs=inputs)
requested_volume = re.search(r"^\[PipelineVolume\] tiles=(\d+) lod=0\.\.8 ",
output, re.M)
runner.require(f"native-lattice-field-{compiler}:full-lod-requested",
bool(requested_volume and int(requested_volume.group(1)) > 0),
f"tiles={requested_volume.group(1) if requested_volume else 'MISSING'} lod=0..8")
plan = re.search(r"^\[LatticeSpinePlan\] .*recipe=Core\.Lattice\.PrimitiveField version=1 "
r"strate=1 .*spine_first=true .*centerline_radius_m=6\.000 clear_width_m=3\.000 "
r"pitch_m=5\.000 turns=4 floor_to_soffit_m=2\.600 .*inner_edge_grade_deg=([0-9.]+) "
r"floor_blend_m=1\.900 union_envelope_m=0\.050 maze_cells=([0-9]+) dead_ends=2 .*status=PASS$",
output, re.M)
runner.require(f"native-lattice-field-{compiler}:recipe-and-spine", bool(plan),
"native opt-in version-1 lattice, actual mouths first, four-turn ramp and two branches")
fillet = re.search(r"^\[LatticeFilletAudit\].*measured_radius_m=([0-9.]+) .*status=PASS$",
output, re.M)
runner.require(f"native-lattice-field-{compiler}:measured-fillet",
bool(fillet and float(fillet.group(1)) >= 0.5),
f"measured_radius_m={fillet.group(1) if fillet else 'MISSING'} required>=0.500")
reach = re.search(r"^\[LatticeCapsuleReachability\].*max_grade_deg=([0-9.]+) "
r"min_headroom_m=([0-9.]+) required_headroom_m=2\.200 .*reachable=yes status=PASS$",
output, re.M)
runner.require(f"native-lattice-field-{compiler}:mouth-to-mouth-reachability",
bool(reach and float(reach.group(1)) <= 15.0 and float(reach.group(2)) >= 2.2),
f"grade_deg={reach.group(1) if reach else 'MISSING'} "
f"headroom_m={reach.group(2) if reach else 'MISSING'}")
runner.require(f"native-lattice-field-{compiler}:interval-oracle-and-shape-free",
all_match(output, r"^\[LatticeIntervalOracle\].*misses=0 "
r"false_all_air=REJECTED false_all_solid=REJECTED .*isTileShapeFree=BLOCKED .*status=PASS$"),
"BVH intervals match brute-force samples, reject both false proofs and block occupied tiles")
orphan_name = f"native-lattice-orphan-control-{compiler}"
orphan_layout = OUT / "layouts" / f"{orphan_name}.json"
_, orphan_output = runner.run_cpp(orphan_name, binary, fixture, "lattice",
["--lattice-strate=1", "--audit-native-lattice", "--lattice-orphan-control",
"--max-clip-level=0", "--render-distance-chunks=0"],
expected_style=None, expected_strate_styles=styles, workers=12,
max_level=0, layout_path=orphan_layout, script_inputs=inputs)
runner.require(f"{orphan_name}:disconnect-rejected",
all_match(orphan_output, r"^\[LatticeReachabilityControl\] orphaned_shaft=true "
r"result=FAIL expected=FAIL status=PASS$"),
"a helix shaft shifted off both spine junctions fails final-field reachability")
layout = json.loads(layout_path.read_text(encoding="utf-8"))
edges = layout.get("cavern_edges", [])
rooms = layout.get("cavern_rooms", [])
lattice_rows = [row for row in layout.get("strates", [])
if row.get("strate_index") == 1]
graph_ok = (layout.get("cavern_graph_vocabulary_version") == 1
and len(edges) >= 9 and len(rooms) >= 8
and len(lattice_rows) == 1
and lattice_rows[0].get("generator_kind") == "Maze"
and lattice_rows[0].get("recipe_id") == "Core.Lattice.PrimitiveField"
and all(len(edge.get("polyline_um", [])) >= 2 for edge in edges))
runner.require(f"native-lattice-field-{compiler}:resolved-records", graph_ok,
f"vocabulary={layout.get('cavern_graph_vocabulary_version')} "
f"rooms={len(rooms)} edges={len(edges)} maze_recipe="
f"{lattice_rows[0].get('recipe_id') if lattice_rows else 'MISSING'}")
if plan:
row["helix_inner_edge_grade_degrees"] = float(plan.group(1))
row["maze_cells"] = int(plan.group(2))
if fillet:
row["measured_fillet_radius_m"] = float(fillet.group(1))
if reach:
row["max_route_grade_degrees"] = float(reach.group(1))
row["minimum_headroom_m"] = float(reach.group(2))
return fixture, layout_path
def lattice_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"])
helix = next((edge for edge in edges
if edge["stable_id"] == "lattice/spine/01-helix-ramp-v1"), None)
if layout.get("cavern_graph_vocabulary_version") != 1 or helix is None:
raise VerificationFailure(f"missing resolved lattice helix in {layout_path}")
helix_points = [[value / 1_000_000.0 for value in point]
for point in helix.get("polyline_um", [])]
if len(helix_points) < 4:
raise VerificationFailure(f"lattice helix polyline is missing in {layout_path}")
rng = _SplitMix64(LATTICE_CAMERA_SWEEP_SEED)
cameras: list[tuple[float, float, float, float, float]] = []
for camera_index in range(count):
if camera_index == 0:
index = len(helix_points) // 2
point = helix_points[index]
tangent = [helix_points[index + 1][axis] - helix_points[index - 1][axis]
for axis in range(3)]
lateral = rng.between(-0.35, 0.35)
horizontal = max(1.0e-9, math.hypot(tangent[0], tangent[1]))
x = point[0] - tangent[1] / horizontal * lateral
y = point[1] + tangent[0] / horizontal * lateral
z = point[2] + rng.between(1.35, 1.55)
else:
route_edges = [edge for edge in edges if edge["stable_id"].startswith(
"lattice/spine/maze-edge-")]
edge = route_edges[min(len(route_edges) - 1,
int(rng.unit() * len(route_edges)))]
points = [[value / 1_000_000.0 for value in point]
for point in edge.get("polyline_um", [])]
index = min(len(points) - 2, int(rng.unit() * (len(points) - 1)))
t = rng.between(0.25, 0.75)
point = [points[index][axis] + (points[index + 1][axis] - points[index][axis]) * t
for axis in range(3)]
tangent = [points[index + 1][axis] - points[index][axis] for axis in range(3)]
horizontal = max(1.0e-9, math.hypot(tangent[0], tangent[1]))
side = rng.between(-0.45, 0.45)
x = point[0] - tangent[1] / horizontal * side
y = point[1] + tangent[0] / horizontal * side
z = point[2] + rng.between(1.35, 1.55)
yaw = math.degrees(math.atan2(tangent[0], tangent[1])) + rng.between(-14.0, 14.0)
pitch = rng.between(-6.0, 6.0)
cameras.append((x, y, z, yaw, pitch))
return cameras
def lattice_graph_digest(layout_path: Path) -> str:
layout = json.loads(layout_path.read_text(encoding="utf-8"))
graph = {key: layout.get(key) for key in (
"cavern_graph_vocabulary_version", "cavern_rooms", "cavern_edges")}
encoded = json.dumps(graph, sort_keys=True, separators=(",", ":")).encode("utf-8")
return hashlib.sha256(encoded).hexdigest()
def run_lattice_determinism(runner: VerificationRunner, binary: Path,
fixture: Path, layout_path: Path, *,
compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "lattice-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 lattice peer reference: {error}")
else:
reference = None
current: dict[str, dict[str, object]] = {}
styles = {"0": 2, "1": 1, "2": 1}
for camera_index, camera in enumerate(lattice_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, ...]]] = {}
peer_layouts: dict[int, str] = {}
key = f"p{camera_index:02d}"
current[key] = {"camera_m": [round(value, 6) for value in camera[:3]],
"inside_helix": camera_index == 0}
for workers in (1, 8, 12):
name = (f"lattice-camera-{compiler}-s{LATTICE_CAMERA_SWEEP_SEED:06x}-"
f"p{camera_index:02d}-w{workers}")
run_layout = OUT / "layouts" / f"{name}.json"
_, output = runner.run_cpp(name, binary, fixture, "lattice",
["--lattice-strate=1", "--stream-hash-tiles", camera_flag,
"--clip-radius=3", "--max-clip-level=8",
"--render-distance-chunks=0"], expected_style=None,
expected_strate_styles=styles, workers=workers, max_level=-1,
layout_path=run_layout,
script_inputs=[LINUX58 / "BuildLatticeFixtureL58.py"])
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]}")
require_full_lod_stream(runner, name, output)
signatures[workers] = tiles
peer_layouts[workers] = lattice_graph_digest(run_layout)
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"lattice-camera-{compiler}-{key}:W{left}-W{right}",
signatures[left] == signatures[right],
f"camera_m=({x:.3f},{y:.3f},{z:.3f}) W{left}=W{right} tile hashes match")
runner.require(f"lattice-camera-{compiler}-{key}:record-peers",
len(set(peer_layouts.values())) == 1,
f"canonical room/edge records match across W1/W8/W12: {peer_layouts}")
current[key]["graph_sha256"] = next(iter(peer_layouts.values()))
if compare_reference:
runner.require("lattice-camera-gcc:matches-clang-peers", current == reference,
"GCC random-camera tile hashes and canonical lattice records match Clang")
else:
reference_path.write_text(json.dumps(current, indent=2, sort_keys=True) + "\n",
encoding="utf-8")
def run_lattice_performance(runner: VerificationRunner, binary: Path,
fixture: Path, layout_path: Path) -> None:
compiler = compiler_name(binary)
camera = lattice_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}"
name = f"lattice-speed-{compiler}-w12"
row, output = runner.run_cpp(name, binary, fixture, "lattice",
["--lattice-strate=1", camera_flag, "--clip-radius=3", "--max-clip-level=8",
"--render-distance-chunks=0", "--camera-step=24,0,0",
"--region-crossing"], expected_style=None,
expected_strate_styles={"0": 2, "1": 1, "2": 1}, workers=12,
max_level=-1, layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[LINUX58 / "BuildLatticeFixtureL58.py"])
require_feature_lod_transition(runner, name, "helix", output)
stream = re.search(r"^\[StreamPipeline\] .*first_tile_ready=([0-9.]+)s "
r".*neighborhood_ready=([0-9.]+)s .*whole_view_ready=([0-9.]+)s .*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"{name}:cold-and-moving-records",
bool(stream and moving and int(moving.group(1)) > 0),
f"first_tile_s={stream.group(1) if stream else 'MISSING'} "
f"near_ring_s={stream.group(2) if stream else 'MISSING'} "
f"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 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=8", "--render-distance-chunks=0"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
workers=workers, max_level=-1,
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]}")
require_full_lod_stream(runner, name, output)
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=3", "--max-clip-level=8",
"--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=-1, layout_path=OUT / "layouts" / f"caves-speed-{compiler}-w12.json")
require_feature_lod_transition(runner, f"caves-speed-{compiler}", "cave-mouth", output)
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_lattice_surface_evidence(runner: VerificationRunner, fixture: Path,
layout_path: Path) -> None:
capture_script = LINUX58 / "CaptureNativeLatticeL58.py"
artifact_dir = OUT / "captures"
_, capture_output = runner.run_stage("capture-native-lattice-l58", 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="lattice", style=2, env=env_for(capture=True),
script_inputs=[capture_script, LINUX54 / "CaptureNativeCavesL54.py",
VERIFY_DIR / "capture_quality.py"])
capture_rows = re.findall(r"^\[L58LatticeCapture\] view=([^ ]+) file=(\S+) "
r"bytes=(\d+) sha256=([0-9a-f]{64}) status=PASS$", capture_output, re.M)
expected_views = {"helix-top-down", "ramp-eye-next-turn", "maze-eye-level",
"cutaway-overview"}
runner.require("capture-native-lattice-l58:coverage-and-size",
{row[0] for row in capture_rows} == expected_views and len(capture_rows) == 4
and all(int(row[2]) <= 300_000 for row in capture_rows),
f"views={[(row[0], int(row[2])) for row in capture_rows]}")
surface_script = LINUX58 / "AuditLatticeSurfaceL58.py"
audit_layout = ROOT / "Saved/Linux/l48/layouts/landmark-reachability-clang.json"
candidate_mesh = OUT / "lattice-meshes" / "lattice-whole-view.vfmesh"
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"),
)
args = ["--json", str(OUT / "whole-surface-lattice-l58.json"),
"--svg-dir", str(artifact_dir), "--case", "lattice-whole",
str(candidate_mesh), str(layout_path), "measure", "whole"]
for label, mesh, expectation in controls:
args.extend(("--case", label, str(mesh), str(audit_layout), expectation, "whole"))
_, audit_output = runner.run_stage("whole-surface-lattice-l58", surface_script,
args, binary=CLANG, data=fixture, recipe="lattice", style=2,
layout_path=layout_path, env=env_for(),
script_inputs=[surface_script, LINUX54 / "AuditWholeSurfaceL54.py",
candidate_mesh, layout_path, audit_layout, *(item[1] for item in controls)])
candidate = re.search(r"^\[WholeSurfaceAudit\] label=lattice-whole .*"
r"observed=(PASS|FAIL) expected=MEASURE status=PASS$", audit_output, re.M)
runner.require("whole-surface-lattice-l58:helix-and-maze",
bool(candidate and candidate.group(1) == "PASS"),
f"observed={candidate.group(1) if candidate else 'MISSING'} over helix ramp edges and maze wall feet")
for label, _mesh, expectation in controls:
match = re.search(rf"^\[WholeSurfaceAudit\] label={re.escape(label)} .*"
rf"observed=(PASS|FAIL) expected={expectation.upper()} status=PASS$",
audit_output, re.M)
runner.require(f"whole-surface-lattice-l58:{label}", bool(match),
f"control_expectation={expectation} 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")
if max_clip_level == 8 and max_level < 0:
require_full_lod_stream(runner, name, output)
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=8", "--render-distance-chunks=0"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
workers=workers, max_level=-1,
layout_path=OUT / "layouts" / f"{name}.json")
require_full_lod_stream(runner, name, output)
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 build_motif_fixture(runner: VerificationRunner) -> Path:
script = LINUX56 / "BuildMotifFixtureR24.py"
fixture_dir = OUT / "fixtures"
runner.run_stage("build-style-override-motifs-slice1-r24", script,
["--out", str(fixture_dir)], binary=CLANG, data=OWNER,
recipe="surface-world", style=None,
script_inputs=[OWNER])
fixture = fixture_dir / "style-override-motifs-slice1.json"
runner.require("motif-fixture:exists", fixture.is_file(),
"versioned flatField and two fixed-count sparse motifs are present")
return fixture
def motif_camera_rows(layout_path: Path) -> list[tuple[str, tuple[float, float, float, float, float]]]:
try:
layout = json.loads(layout_path.read_text(encoding="utf-8"))
motifs = layout["stamps"]
monolith = next(row for row in motifs if row["kind"] == 5)
routes = [anchor["values"] for strate in layout["strates"]
for anchor in strate.get("anchors", [])
if anchor.get("kind") == "route_point" and len(anchor.get("values", [])) >= 3]
except (OSError, KeyError, StopIteration, TypeError, json.JSONDecodeError) as error:
raise VerificationFailure(f"cannot derive motif cameras from {layout_path}: {error}")
mono = tuple(value / 1_000_000.0 for value in monolith["position_um"])
floor = monolith["floor_um"] / 1_000_000.0
cameras: list[tuple[str, tuple[float, float, float, float, float]]] = []
camera = (mono[0] - 10.0, mono[1], floor + 1.65)
target = (mono[0], mono[1], floor + 12.0)
dx, dy, dz = (target[i] - camera[i] for i in range(3))
cameras.append(("monolith", (*camera, math.degrees(math.atan2(dx, dy)),
math.degrees(math.atan2(dz, math.hypot(dx, dy))))))
if len(routes) < 2:
raise VerificationFailure("resolved motif layout has no planned surface route")
points = [tuple(float(value) / 1024.0 for value in row[:3]) for row in routes]
center = tuple(sum(point[axis] for point in points) / len(points) for axis in range(3))
rng = _SplitMix64(0x4C353600 + sum(b"motifs-slice1"))
for index in range(2):
x = center[0] + rng.between(-36.0, 36.0)
y = center[1] + rng.between(-36.0, 36.0)
z = center[2] + rng.between(-2.0, 3.0)
yaw = rng.between(-180.0, 180.0)
pitch = rng.between(-18.0, 18.0)
cameras.append((f"random{index}", (x, y, z, yaw, pitch)))
return cameras
def validate_motif_layout(runner: VerificationRunner, name: str,
layout_path: Path, manifest_path: Path) -> dict:
try:
layout = json.loads(layout_path.read_text(encoding="utf-8"))
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
motifs = layout["stamps"]
profile = manifest["recipe"]["surface_profile"]
monolith = next(record for record in motifs if record["kind"] == 5)
platform = next(record for record in motifs if record["kind"] == 6)
strate = next(row for row in layout["strates"]
if row["strate_index"] == monolith["strate_index"])
ids = [record["stable_id"] for record in motifs]
gap_squared = 0
for axis in range(3):
gap = max(0, monolith["bounds_min_um"][axis]
- platform["bounds_max_um"][axis],
platform["bounds_min_um"][axis]
- monolith["bounds_max_um"][axis])
gap_squared += gap * gap
min_spacing = max(monolith["minimum_spacing_um"],
platform["minimum_spacing_um"])
spacing_ok = gap_squared >= min_spacing * min_spacing
floor_ok = all(record["attachment_policy"] == 1
and record["position_um"][2]
== record["floor_um"] + record["half_extents_um"][2]
and record["bounds_min_um"][2] > strate["content"]["bottom_um"]
and record["bounds_max_um"][2] < strate["content"]["top_um"]
for record in motifs)
valid = (layout["stamp_vocabulary_version"] == 3 and len(motifs) == 2
and ids == sorted(ids) and profile["version"] == 1
and profile["kind"] == "flatField" and spacing_ok and floor_ok
and monolith["half_extents_um"][0] == monolith["half_extents_um"][1]
and monolith["rounding_radius_um"] >= 500_000
and platform["rounding_radius_um"] >= 500_000)
except (OSError, KeyError, StopIteration, TypeError, ValueError,
json.JSONDecodeError):
valid = False
motifs = []
profile = {}
spacing_ok = floor_ok = False
runner.require(f"{name}:versioned-records", valid,
f"vocabulary=3 profile={profile.get('kind', 'MISSING')} records={len(motifs)} "
f"stable_ids_sorted={valid} floor_attachment={floor_ok} pairwise_spacing={spacing_ok}")
return layout
def run_motif_fixture_audits(runner: VerificationRunner, binary: Path = CLANG) -> tuple[Path, Path]:
compiler = compiler_name(binary)
fixture = build_motif_fixture(runner)
manifest = OUT / "fixtures" / "style-override-motifs-slice1-manifest.json"
layout_path = OUT / "layouts" / f"motif-slice1-capsule-reachability-{compiler}.json"
name = f"motif-slice1-capsule-reachability-{compiler}"
row, output = runner.run_cpp(name, binary, fixture, "surface-world",
["--audit-resolved-layout-passages",
f"--world-assembler-manifest-output={manifest}"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
layout_path=layout_path,
script_inputs=[LINUX56 / "BuildMotifFixtureR24.py"])
validate_passage(runner, name, output)
runner.require(f"{name}:motif-record-output",
all_match(output, r"^\[ResolvedMotifFamily\] vocabulary=3 records=2 "
r"placement=seed,strate,stable_id route_keepout=PASS band_clearance=PASS "
r"pairwise_spacing=PASS status=PASS$"),
"two stable motif records resolve outside passage, route and band keepouts")
layout = validate_motif_layout(runner, name, layout_path, manifest)
interval_name = f"motif-slice1-interval-oracle-{compiler}"
interval_layout = OUT / "layouts" / f"{interval_name}.json"
_, interval_output = runner.run_cpp(interval_name, binary, fixture,
"surface-world", ["--audit-motif-intervals",
f"--world-assembler-manifest-output={manifest}"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
layout_path=interval_layout,
script_inputs=[LINUX56 / "BuildMotifFixtureR24.py"])
oracle = re.search(r"^\[ResolvedMotifIntervalOracle\] .*status=PASS$",
interval_output, re.M)
runner.require(f"{interval_name}:intervals-and-controls", oracle is not None,
"feature-bound intervals cover brute-force samples; false all-air/all-solid controls reject")
return fixture, layout_path
def motif_signature(output: str, row: dict) -> 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)
return {
"tiles": {"/".join(map(str, key)): list(value)
for key, value in sorted(parse_tile_hashes(output).items())},
"materials": {"/".join(map(str, key)): value
for key, value in sorted(parse_tile_material_hashes(output).items())},
"whole_hashes": HASH_RE.findall(output),
"plan_hash": serialization.group(1) if serialization else None,
"manifest_hash": serialization.group(2) if serialization else None,
"layout_id": row.get("layout_id"),
}
def run_motif_determinism(runner: VerificationRunner, binary: Path, *,
compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "motif-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 motif reference: {error}")
else:
references: dict[str, dict[str, dict[str, object]]] = {}
fixture = OUT / "fixtures" / "style-override-motifs-slice1.json"
layout_path = OUT / "layouts" / "motif-slice1-capsule-reachability-clang.json"
cameras = motif_camera_rows(layout_path)
for camera_index, (label, camera) in enumerate(cameras):
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"motif-camera-{label}-{compiler}-w{workers}"
manifest = OUT / "fixtures" / f"{name}-manifest.json"
row, output = runner.run_cpp(name, binary, fixture, "surface-world",
["--stream-hash-tiles", camera_flag, "--clip-radius=3",
"--max-clip-level=8", "--render-distance-chunks=0",
f"--world-assembler-manifest-output={manifest}"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
workers=workers, max_level=-1,
layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[LINUX56 / "BuildMotifFixtureR24.py"])
signature = motif_signature(output, row)
whole = re.search(r"^\[PipelineWholeViewHash\] tiles=(\d+)", output, re.M)
expected_tiles = int(whole.group(1)) if whole else -1
runner.require(f"{name}:tile-hash-coverage",
len(signature["tiles"]) == expected_tiles
and len(signature["materials"]) == expected_tiles,
f"geometry_tiles={len(signature['tiles'])}/{expected_tiles} "
f"material_tiles={len(signature['materials'])}/{expected_tiles}")
require_full_lod_stream(runner, name, output)
signatures[workers] = signature
stable = signatures[1] == signatures[8] == signatures[12]
runner.require(f"motif-camera-{label}-{compiler}:workers", stable,
"W1, W8 and W12 preserve plan, motif and tile geometry/material hashes")
key = f"p{camera_index:02d}/{label}"
if compare_reference:
runner.require(f"motif-camera-{label}-gcc:clang-peer",
{str(worker): signatures[worker] for worker in (1, 8, 12)}
== references.get(key),
"Clang and GCC preserve the random-camera motif hashes at W1/W8/W12")
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_motif_timing(runner: VerificationRunner, binary: Path,
layout_path: Path) -> dict[str, float]:
camera = motif_camera_rows(layout_path)[0][1]
camera_flag = "--camera=" + ",".join(f"{value:.6f}" for value in camera)
name = f"motif-slice1-cold-view-{compiler_name(binary)}"
manifest = OUT / "fixtures" / f"{name}-manifest.json"
row, output = runner.run_cpp(name, binary,
OUT / "fixtures" / "style-override-motifs-slice1.json", "surface-world",
[camera_flag, "--stream-hash", "--instrument-tile-drain", "--clip-radius=3",
"--max-clip-level=8", "--render-distance-chunks=0",
"--camera-step=24,0,0", "--region-crossing",
f"--world-assembler-manifest-output={manifest}"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1}, workers=12,
max_level=-1, layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[LINUX56 / "BuildMotifFixtureR24.py"])
require_feature_lod_transition(runner, name, "monolith", output)
summary = re.search(r"^\[StreamPipeline\] workers=12 .*?first_tile_ready=([0-9.]+)s "
r"neighborhood_mesh=([0-9.]+)s neighborhood_ready=([0-9.]+)s "
r".*?whole_view_ready=([0-9.]+)s", output, re.M)
runner.require(f"{name}:timing", summary is not None,
"cold first tile, near ring and whole view timings are recorded")
values = ({"first_tile_seconds": float(summary.group(1)),
"near_ring_seconds": float(summary.group(3)),
"whole_view_seconds": float(summary.group(4))}
if summary else {"first_tile_seconds": float("inf"),
"near_ring_seconds": float("inf"), "whole_view_seconds": float("inf")})
row.update(values)
(OUT / "motif-timing.json").write_text(json.dumps(values, indent=2) + "\n",
encoding="utf-8")
return values
def run_motif_captures_and_surface_audit(runner: VerificationRunner) -> None:
script = LINUX56 / "CaptureMotifsR24.py"
quality = VERIFY_DIR / "capture_quality.py"
auditor = LINUX56 / "AuditMotifSurfaceR24.py"
_, output = runner.run_stage("capture-and-audit-motifs-slice1-r24", script,
["--out", str(OUT), "--fixture-dir", str(OUT / "fixtures"),
"--artifact-dir", str(OUT / "captures"), "--headless", str(CLANG),
"--renderer", str(RENDERER), "--auditor", str(auditor)],
binary=CLANG, data=OWNER, recipe="surface-world", style=None,
env=env_for(capture=True),
script_inputs=[quality, auditor, LINUX56 / "BuildMotifFixtureR24.py"])
capture_rows = re.findall(r"^\[L56MotifCapture\] view=(\S+) .*status=PASS$",
output, re.M)
runner.require("capture-and-audit-motifs-slice1-r24:views",
set(capture_rows) == {"eye", "overview"} and len(capture_rows) == 2,
f"views={','.join(capture_rows)}")
surface = re.search(r"^\[MotifSurfaceAudit\] .*status=PASS$", output, re.M)
runner.require("capture-and-audit-motifs-slice1-r24:whole-surface",
surface is not None,
"whole LOD0 surface has covered monolith foot/cap and platform-edge ROIs; controls reject")
def run_far_lod_captures(runner: VerificationRunner) -> None:
script = LINUX60 / "CaptureFarLODsL60.py"
rows = OUT / "fixtures"
artifact_dir = OUT / "captures"
_, output = runner.run_stage("capture-far-lod-features-l60", script,
["--out", str(OUT), "--fixture-dir", str(rows),
"--layout-dir", str(OUT / "layouts"), "--headless", str(CLANG),
"--renderer", str(RENDERER), "--artifact-dir", str(artifact_dir)],
binary=CLANG, data=OWNER, recipe=None, style=None,
env=env_for(capture=True), script_inputs=[script,
LINUX54 / "CaptureNativeCavesL54.py", VERIFY_DIR / "capture_quality.py",
OUT / "fixtures" / "caves.json",
OUT / "fixtures" / "style-override-motifs-slice1.json",
OUT / "fixtures" / "lattice-l58.json",
OUT / "layouts" / "native-caves-field-clang.json",
OUT / "layouts" / "motif-slice1-capsule-reachability-clang.json",
OUT / "layouts" / "native-lattice-field-clang.json"])
captures = re.findall(r"^\[L60FarLODCapture\] generator=(\S+) feature=(.*?) "
r"file=(\S+) bytes=(\d+) sha256=([0-9a-f]{64}) .*status=PASS$", output, re.M)
runner.require("capture-far-lod-features-l60:views",
{row[0] for row in captures} == {"caves", "motifs", "lattice"}
and len(captures) == 3 and all(0 < int(row[3]) <= 300_000 for row in captures),
f"captures={[(row[0], row[3], row[4]) for row in captures]}")
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"))
caves_layout = OUT / "layouts" / "native-caves-field-clang.json"
caves_camera = cave_camera_positions(caves_layout, count=1)[0]
caves_camera_flag = "--camera=" + ",".join(f"{value:.6f}" for value in caves_camera)
motif_layout = OUT / "layouts" / "motif-slice1-capsule-reachability-clang.json"
motif_camera = motif_camera_rows(motif_layout)[0][1]
motif_camera_flag = "--camera=" + ",".join(f"{value:.6f}" for value in motif_camera)
owner_styles = {"0": 2, "1": 1}
contexts = (
("floating-islands", OWNER, "floating-islands", [], 2, owner_styles, -1),
# The resolved passage uses the TunnelNetwork-side style (strate 0 = 2);
# the separate owner-style check below still verifies SurfaceWorld strate 1 = 1.
("surface-world", OWNER, "surface-world", [], 2, owner_styles, -1),
("caves", OUT / "fixtures" / "caves.json", "caves",
[caves_camera_flag, "--clip-radius=3", "--max-clip-level=8",
"--render-distance-chunks=0"],
2, owner_styles, -1),
("motifs", OUT / "fixtures" / "style-override-motifs-slice1.json", "surface-world",
[motif_camera_flag, "--clip-radius=3", "--max-clip-level=8",
"--render-distance-chunks=0"],
2, owner_styles, -1),
)
by_recipe: dict[str, dict[str, dict[str, list[float]]]] = {
name: {build: {metric: [] for metric in
("whole_view_seconds", "first_tile_seconds", "near_ring_seconds",
"moving_p50_ms", "moving_p95_ms")}
for build in ("baseline", "candidate")}
for name, *_ in contexts}
by_pair: dict[tuple[str, int], dict[str, dict[str, float]]] = {}
for name, data, recipe, base_flags, style, expected_styles, max_level in contexts:
flags = [*base_flags, "--camera-step=24,0,0", "--region-crossing"]
for pair, order in enumerate(orders, 1):
for build in order:
binary = baseline if build == "baseline" else candidate
run_name = f"cost-{name}-pair{pair}-{build}"
expected_stamp = baseline_stamp if build == "baseline" else None
row, output = runner.run_cpp(run_name, binary, data, recipe, flags,
expected_style=style if build == "candidate" else None,
expected_strate_styles=expected_styles if build == "candidate" else None,
max_level=max_level,
layout_path=OUT / "layouts" / f"{run_name}.json",
expected_stamp=expected_stamp)
row["requested_style"] = style
row["expected_passage_style"] = style if build == "candidate" else None
stream = re.search(r"^\[StreamPipeline\].*?first_tile_ready=([0-9.]+)s "
r".*?neighborhood_ready=([0-9.]+)s .*?whole_view_ready=([0-9.]+)s",
output, re.M)
moving = re.search(r"^\[MovingTileLatency\] entering_tiles=(\d+) "
r"p50_ms=([0-9.]+) p95_ms=([0-9.]+) "
r"metric=submit_to_completion_observed$", output, re.M)
metrics = ({"first_tile_seconds": float(stream.group(1)),
"near_ring_seconds": float(stream.group(2)),
"whole_view_seconds": float(stream.group(3)),
"moving_p50_ms": float(moving.group(2)),
"moving_p95_ms": float(moving.group(3))}
if stream and moving and int(moving.group(1)) > 0 else {})
row["cost_metrics"] = metrics
ok = (len(metrics) == 5 and "hash=off" in output
and "cache_hits=0" in output
and RECIPE_RE.findall(output) == [(recipe, recipe, "PASS")])
runner.require(f"{run_name}:cost-record", ok,
f"metrics={metrics if metrics else 'MISSING'} "
f"source_stamp={row['source_stamp']}")
for metric, value in metrics.items():
by_recipe[name][build][metric].append(value)
by_pair.setdefault((name, pair), {})[build] = metrics
for name, values in by_recipe.items():
for metric in values["baseline"]:
old_values = values["baseline"][metric]
new_values = values["candidate"][metric]
old = statistics.median(old_values) if old_values else float("inf")
new = statistics.median(new_values) if new_values else float("inf")
paired = [((by_pair[(name, pair)]["candidate"][metric]
- by_pair[(name, pair)]["baseline"][metric])
/ by_pair[(name, pair)]["baseline"][metric] * 100.0)
for pair in range(1, 6)
if (name, pair) in by_pair
and len(by_pair[(name, pair)].get("baseline", {})) == 5
and len(by_pair[(name, pair)].get("candidate", {})) == 5]
runner.require(f"cost-{name}-{metric}-five-pairs",
len(old_values) == len(new_values) == len(paired) == 5,
f"median_baseline={old:.3f} median_candidate={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 parse_headless_config(output: str) -> dict[str, str]:
match = re.search(r"^\[HeadlessConfig\] (.*)$", output, re.M)
if not match:
return {}
return dict(re.findall(r"([A-Za-z_]+)=([^\s]+)", match.group(1)))
def ensure_speed_matrix_fixtures(runner: VerificationRunner) -> dict[str, Path]:
fixture_dir = OUT / "fixtures"
profiles = {name: fixture_dir / f"style-override-profile-{name}.json"
for name in PROFILE_NAMES}
if not all(path.is_file() for path in profiles.values()):
builder = LINUX53 / "BuildProfileFixturesL53.py"
runner.run_stage("build-speed-matrix-profile-fixtures", builder,
["--out", str(fixture_dir)], binary=CLANG, data=OWNER,
recipe="surface-world", style=None, env=env_for(),
script_inputs=[builder, OWNER])
caves = build_caves_fixture(runner, CLANG)
lattice = build_lattice_fixture(runner, CLANG)
motifs = build_motif_fixture(runner)
return {"surface-world": OWNER, "floating-islands": OWNER,
**{f"profile-{name}": path for name, path in profiles.items()},
"caves": caves, "lattice": lattice, "motifs": motifs}
def run_speed_matrix(runner: VerificationRunner) -> None:
fixtures = ensure_speed_matrix_fixtures(runner)
owner_styles = {"0": 2, "1": 1}
contexts = [
("natural-sw", fixtures["surface-world"], "surface-world", [], 2, owner_styles, -1),
*((f"profile-{profile}", fixtures[f"profile-{profile}"], "surface-world",
[], 2, owner_styles, -1) for profile in PROFILE_NAMES),
("floating-islands", fixtures["floating-islands"], "floating-islands", [],
2, owner_styles, -1),
("caves", fixtures["caves"], "caves", [], 2, owner_styles, -1),
("motifs", fixtures["motifs"], "surface-world", [], 2, owner_styles, -1),
("lattice", fixtures["lattice"], "lattice", ["--lattice-strate=1"],
None, {"0": 2, "1": 1, "2": 1}, -1),
]
camera = ",".join(f"{value:.6f}" for value in SPEED_MATRIX_CAMERA_M[:3])
rotation = ",".join(f"{value:.3f}" for value in SPEED_MATRIX_CAMERA_M[3:])
camera_flag = f"--camera={camera},{rotation}"
common_flags = [camera_flag, "--clip-radius=3", "--max-clip-level=8",
"--render-distance-chunks=0", "--camera-step=24,0,0", "--region-crossing"]
expected_common_config = {
"workers": "12", "clip_radius": "3", "max_clip_level": "8",
"max_level": "-1", "hash": "off", "column_overlap": "off",
"force_generate": "on", "shared_column_cache": "on",
"camera_step_m": "(24.000,0.000,0.000)", "camera_override": "yes",
"camera_m": f"({camera})", "camera_rotation_deg": f"({rotation})",
"seed_override": "no", "render_distance_override": "yes",
}
rows_by_generator: dict[str, list[dict[str, object]]] = {
context[0]: [] for context in contexts}
reference_config: dict[str, str] | None = None
canonical_order = [context[0] for context in contexts]
context_by_name = {context[0]: context for context in contexts}
for repetition in range(SPEED_MATRIX_REPETITIONS):
offset = repetition % len(canonical_order)
interleaved = canonical_order[offset:] + canonical_order[:offset]
for generator in interleaved:
name, data, recipe, generator_flags, style, styles, max_level = \
context_by_name[generator]
run_name = f"speed-matrix-{name}-run{repetition + 1}"
row, output = runner.run_cpp(run_name, CLANG, data, recipe,
[*common_flags, *generator_flags], expected_style=style,
expected_strate_styles=styles, workers=12, max_level=max_level,
layout_path=OUT / "layouts" / f"{run_name}.json",
script_inputs=([LINUX53 / "BuildProfileFixturesL53.py"]
if name.startswith("profile-") else []))
config = parse_headless_config(output)
runner.require(f"{run_name}:headless-config-fields",
set(config) == set(expected_common_config) | {"data", "recipe", "lattice_strate"}
and all(config.get(key) == value
for key, value in expected_common_config.items())
and config.get("data") == str(data)
and config.get("recipe") == recipe
and config.get("lattice_strate") == ("1" if name == "lattice" else "-1"),
f"config={config}")
command_camera = [value for value in row["command"]
if value.startswith("--camera=")]
runner.require(f"{run_name}:shared-camera",
command_camera == [camera_flag],
f"camera={command_camera} expected={camera_flag}")
stream = re.search(r"^\[StreamPipeline\].*?first_tile_ready=([0-9.]+)s "
r".*?neighborhood_ready=([0-9.]+)s .*?whole_view_ready=([0-9.]+)s "
r".*?neighborhood_tiles=(\d+)/(\d+) full_detail_tiles=(\d+)/(\d+) "
r"whole_tiles=(\d+)/(\d+) .*cache_hits=0", output, re.M)
moving = re.search(r"^\[MovingTileLatency\] entering_tiles=(\d+) "
r"p50_ms=([0-9.]+) p95_ms=([0-9.]+) "
r"metric=submit_to_completion_observed$", output, re.M)
tile_count, lod_rows = require_full_lod_stream(runner, run_name, output)
lod_tiles = {level: lod_rows.get(level, {}).get("tiles", 0)
for level in range(9)}
lod_ranges_ok = all(
SPEED_MATRIX_LOD_TILE_RANGES[level][0] <= lod_tiles[level]
<= SPEED_MATRIX_LOD_TILE_RANGES[level][1]
for level in range(9))
metrics_ok = bool(stream and moving and int(moving.group(1)) > 0
and int(stream.group(9)) == tile_count
and SPEED_MATRIX_TILE_RANGE[0] <= tile_count <= SPEED_MATRIX_TILE_RANGE[1]
and lod_ranges_ok)
runner.require(f"{run_name}:complete-speed-record", metrics_ok,
f"tiles={tile_count} range={SPEED_MATRIX_TILE_RANGE} "
f"lod_tiles={','.join(f'{level}:{lod_tiles[level]}' for level in range(9))} "
f"lod_ranges={lod_ranges_ok} "
f"first={stream.group(1) if stream else 'MISSING'} "
f"near_ring={stream.group(2) if stream else 'MISSING'} "
f"whole={stream.group(3) if stream else 'MISSING'} "
f"moving={moving.group(1) if moving else 'MISSING'}")
if reference_config is None:
reference_config = {key: value for key, value in config.items()
if key not in ("data", "recipe", "lattice_strate")}
config_without_generator = {key: value for key, value in config.items()
if key not in ("data", "recipe", "lattice_strate")}
lod_text = ",".join(f"{level}:{lod_rows[level]['tiles']}"
for level in range(9) if level in lod_rows)
runner.require(f"{run_name}:same-headless-view-config",
config_without_generator == reference_config
and SPEED_MATRIX_TILE_RANGE[0] <= tile_count <= SPEED_MATRIX_TILE_RANGE[1]
and lod_ranges_ok,
f"tiles={tile_count} common_range={SPEED_MATRIX_TILE_RANGE} "
f"lods={lod_text} lod_ranges_ok={lod_ranges_ok}")
values = {
"run": repetition + 1, "tiles": tile_count,
"lod_tiles": {str(level): lod_tiles[level] for level in range(9)},
"lod_skirt_triangles": {str(level): lod_rows.get(level, {}).get(
"skirt_triangles", 0) for level in range(9)},
"first_tile_seconds": float(stream.group(1)),
"near_ring_seconds": float(stream.group(2)),
"whole_view_seconds": float(stream.group(3)),
"moving_p50_ms": float(moving.group(2)),
"moving_p95_ms": float(moving.group(3)),
"moving_entering_tiles": int(moving.group(1)),
"headless_config": config,
}
row["speed_matrix"] = values
rows_by_generator[name].append(values)
summary_rows: list[dict[str, object]] = []
for generator in canonical_order:
runs = rows_by_generator[generator]
runner.require(f"speed-matrix:{generator}:five-interleaved-runs",
len(runs) == SPEED_MATRIX_REPETITIONS,
f"runs={len(runs)} expected={SPEED_MATRIX_REPETITIONS}")
tile_counts = [int(row["tiles"]) for row in runs]
lod_signatures = [tuple(int(row["lod_tiles"][str(level)])
for level in range(9)) for row in runs]
stable_view = (len(tile_counts) == SPEED_MATRIX_REPETITIONS
and len(set(tile_counts)) == 1
and len(set(lod_signatures)) == 1)
runner.require(f"speed-matrix:{generator}:stable-view-counts",
stable_view,
f"tiles={tile_counts} lod_distributions={lod_signatures}")
lod_count_ranges = {
str(level): [
min(int(row["lod_tiles"][str(level)]) for row in runs),
max(int(row["lod_tiles"][str(level)]) for row in runs),
] for level in range(9)
} if runs else {}
summary: dict[str, object] = {"generator": generator,
"tile_count_range": [min(tile_counts), max(tile_counts)] if runs else [],
"tile_count": int(runs[0]["tiles"]) if runs else 0,
"lod_tile_count_ranges": lod_count_ranges, "runs": runs}
for metric in ("whole_view_seconds", "first_tile_seconds", "near_ring_seconds",
"moving_p50_ms", "moving_p95_ms"):
summary[f"median_{metric}"] = statistics.median(
float(row[metric]) for row in runs)
summary_rows.append(summary)
print(f"[SpeedMatrixMedian] generator={generator} "
f"tiles={summary['tile_count_range'][0]}..{summary['tile_count_range'][-1]} "
f"whole_s={summary['median_whole_view_seconds']:.3f} "
f"first_tile_s={summary['median_first_tile_seconds']:.3f} "
f"near_ring_s={summary['median_near_ring_seconds']:.3f} "
f"moving_p50_ms={summary['median_moving_p50_ms']:.3f} "
f"moving_p95_ms={summary['median_moving_p95_ms']:.3f}", flush=True)
runner.require("speed-matrix:all-generators-use-same-full-view",
len(summary_rows) == len(contexts)
and all(len(row["runs"]) == SPEED_MATRIX_REPETITIONS
and row["tile_count_range"]
and SPEED_MATRIX_TILE_RANGE[0] <= row["tile_count_range"][0]
<= row["tile_count_range"][1] <= SPEED_MATRIX_TILE_RANGE[1]
and all(bounds[0] <= bounds[1]
and SPEED_MATRIX_LOD_TILE_RANGES[int(level)][0] <= bounds[0]
<= bounds[1] <= SPEED_MATRIX_LOD_TILE_RANGES[int(level)][1]
for level, bounds in row["lod_tile_count_ranges"].items())
for row in summary_rows),
f"generators={len(summary_rows)}/{len(contexts)} "
f"common_tile_range={SPEED_MATRIX_TILE_RANGE} "
f"common_lod_tile_ranges={SPEED_MATRIX_LOD_TILE_RANGES}")
(OUT / "speed-matrix.json").write_text(json.dumps({
"camera_m": SPEED_MATRIX_CAMERA_M[:3],
"camera_rotation_degrees": SPEED_MATRIX_CAMERA_M[3:],
"clip_radius": 3, "max_clip_level": 8, "effective_lods": list(range(9)),
"runs_per_generator": SPEED_MATRIX_REPETITIONS,
"tile_count_range": list(SPEED_MATRIX_TILE_RANGE),
"lod_tile_count_ranges": {
str(level): list(bounds)
for level, bounds in enumerate(SPEED_MATRIX_LOD_TILE_RANGES)},
"common_headless_config": expected_common_config,
"interleaving": "generator order rotates by one each repetition",
"summary": summary_rows,
}, indent=2) + "\n", encoding="utf-8")
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), (3, 8, -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)
lattice_fixture, lattice_layout = run_native_lattice_field_audit(runner, CLANG)
run_lattice_determinism(runner, CLANG, lattice_fixture, lattice_layout,
compare_reference=False)
run_lattice_performance(runner, CLANG, lattice_fixture, lattice_layout)
run_lattice_surface_evidence(runner, lattice_fixture, lattice_layout)
_motif_fixture, motif_layout = run_motif_fixture_audits(runner, CLANG)
run_motif_determinism(runner, CLANG, compare_reference=False)
run_motif_timing(runner, CLANG, motif_layout)
run_motif_captures_and_surface_audit(runner)
run_far_lod_captures(runner)
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)
lattice_fixture = OUT / "fixtures" / "lattice-l58.json"
lattice_layout = OUT / "layouts" / "native-lattice-field-clang.json"
if not lattice_fixture.is_file() or not lattice_layout.is_file():
lattice_fixture, lattice_layout = run_native_lattice_field_audit(runner, CLANG)
run_native_lattice_field_audit(runner, GCC)
run_lattice_determinism(runner, GCC, lattice_fixture, lattice_layout,
compare_reference=True)
run_motif_fixture_audits(runner, GCC)
run_motif_determinism(runner, GCC, 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), (3, 8, -1)))
run_ring(runner, full=False)
run_native_caves_field_audit(runner, CLANG)
run_native_lattice_field_audit(runner, CLANG)
run_motif_fixture_audits(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), (3, 8, -1)))
run_30_cell_determinism(runner)
run_cost_pairs(runner)
# The validated medium summary carries the final canonical capture set.
if ARGS.speed_matrix:
run_speed_matrix(runner)
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())