feat(core): profiled heightfields, slice 1: periodicHills, mirroredRelief, flatField (L53); research R22

WorldAssemblySurfaceProfileV1 on the native SurfaceWorld recipe and plan; version 0 'natural' is omitted
from serialized identity, so the owner world is unchanged. periodicHills (seeded cosine hills, plan-time
grade <= 15 deg), mirroredRelief (cap mirrors the floor by lambda, clearance checked) and flatField share
one profile function for points, lattice classification and exact cosine-extrema intervals (0 interval
misses in brute-force audits). Style-override fixtures with planned passages. Cold whole view about 1.33 s
for each profile vs 1.74 s natural SW (Clang). Owner hashes identical to L52; fast/medium/full PASS.
Research R22: SurfaceWorld critical path to about 1 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-25 01:49:11 +02:00
1 parent 408c14baff
commit 20f6c98ec5
17 files changed
+1620 -23

No files matched your search

+303
View File
@@ -24,6 +24,7 @@ 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"
OWNER = ROOT / "Standalone/data/owner_world.json"
OUT_DEFAULT = ROOT / "Saved/Linux/l42"
@@ -60,6 +61,8 @@ 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
PROFILE_NAMES = ("periodicHills", "mirroredRelief", "flatField")
RECIPE_RE = re.compile(
r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=([^ ]+)$", re.M)
@@ -371,6 +374,12 @@ def run_hash_pairs(runner: VerificationRunner,
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
@@ -384,6 +393,21 @@ def run_hash_pairs(runner: VerificationRunner,
print(f"[{runner.tier}] {diagnostic['name']} {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):
@@ -748,6 +772,276 @@ def style_override_matrix(runner: VerificationRunner, binary: Path) -> None:
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 = LINUX53 / "captures"
_, output = runner.run_stage("capture-profiled-heightfields-l53", script,
["--out", str(OUT), "--fixture-dir", str(OUT / "fixtures"),
"--artifact-dir", str(artifacts), "--headless", str(CLANG),
"--renderer", str(RENDERER)], binary=CLANG, data=OWNER,
recipe="surface-world", style=None, env=env_for(capture=True),
script_inputs=[quality, LINUX53 / "BuildProfileFixturesL53.py"])
capture_rows = re.findall(r"^\[L53HeightfieldCapture\] profile=(\S+) view=(\S+) .*status=PASS$",
output, re.M)
quality_rows = re.findall(r"^\[CaptureQuality\].*status=PASS$", output, re.M)
expected = {(profile, view) for profile in PROFILE_NAMES for view in ("eye", "overview")}
runner.require("capture-profiled-heightfields-l53:coverage",
set(capture_rows) == expected and len(quality_rows) == 6,
f"profile_views={len(capture_rows)}/6 quality_gates={len(quality_rows)}/6")
def profile_signature(output: str) -> dict[str, object]:
serialization = re.search(
r"^\[WorldAssemblerPlanSerialization\].*canonical_round_trip=true .*"
r"plan_hash=([0-9a-f]+) manifest_hash=([0-9a-f]+) status=PASS$", output, re.M)
route = re.search(r"^\[WorldAssemblerRouteAccepted\].*$", output, re.M)
return {
"hashes": HASH_RE.findall(output),
"plan_hash": serialization.group(1) if serialization else None,
"manifest_hash": serialization.group(2) if serialization else None,
"route": route.group(0) if route else None,
}
def run_profile_determinism(runner: VerificationRunner, binary: Path, *,
compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "profile-determinism-reference.json"
if compare_reference:
try:
references = json.loads(reference_path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
raise VerificationFailure(f"missing Clang profile determinism reference: {error}")
else:
references: dict[str, dict[str, dict[str, object]]] = {}
for profile in PROFILE_NAMES:
fixture = OUT / "fixtures" / f"style-override-profile-{profile}.json"
expected_by_worker: dict[int, dict[str, object]] = {}
for workers in (1, 8, 12):
name = f"profile-determinism-{profile}-{compiler}-w{workers}"
manifest = OUT / "fixtures" / f"{name}-manifest.json"
_, output = runner.run_cpp(name, binary, fixture, "surface-world",
["--stream-hash", f"--world-assembler-manifest-output={manifest}"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
workers=workers, layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[manifest])
signature = profile_signature(output)
runner.require(f"{name}:signature-shape",
len(signature["hashes"]) == 12 and signature["plan_hash"] is not None
and signature["manifest_hash"] is not None and signature["route"] is not None,
"12 canonical pipeline hashes, recipe/plan serialization hashes, and route acceptance")
expected_by_worker[workers] = signature
if compare_reference:
reference = references.get(profile, {}).get(str(workers))
runner.require(f"{name}:clang-gcc-peer",
signature == reference,
f"Clang reference exists and matches at W{workers}")
stable = expected_by_worker[1] == expected_by_worker[8] == expected_by_worker[12]
runner.require(f"profile-determinism-{profile}-{compiler}:workers",
stable, "W1, W8, and W12 preserve profile hashes, plan identity, and accepted route")
if not compare_reference:
references[profile] = {str(workers): expected_by_worker[workers]
for workers in (1, 8, 12)}
if not compare_reference:
reference_path.write_text(json.dumps(references, indent=2) + "\n", encoding="utf-8")
def profile_camera_positions(profile: str, count: int = 5) -> list[tuple[float, float, float, float, float]]:
manifest_path = OUT / "fixtures" / f"style-override-profile-{profile}-manifest.json"
try:
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
routes = [row["route"] for row in manifest["plan"]["strates"]
if len(row.get("route", [])) >= 2]
route = routes[0]
except (OSError, KeyError, IndexError, TypeError, json.JSONDecodeError) as error:
raise VerificationFailure(f"cannot derive {profile} random cameras: {error}")
points = [tuple(float(value) / 1024.0 for value in item["position_q"])
for item in route]
center = tuple(sum(point[axis] for point in points) / len(points) for axis in range(3))
seed_salt = sum(profile.encode("ascii"))
rng = _SplitMix64(PROFILE_CAMERA_SWEEP_SEED + seed_salt)
positions = []
for _ in range(count):
x = center[0] + rng.between(-220.0, 220.0)
y = center[1] + rng.between(-220.0, 220.0)
z = center[2] + rng.between(-4.0, 4.0)
yaw = rng.between(-180.0, 180.0)
pitch = rng.between(-25.0, 25.0)
positions.append((x, y, z, yaw, pitch))
return positions
def run_profile_random_camera_sweep(runner: VerificationRunner, binary: Path, *,
compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "profile-random-camera-reference.json"
if compare_reference:
try:
references = json.loads(reference_path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
raise VerificationFailure(f"missing Clang profile camera reference: {error}")
else:
references: dict[str, dict[str, object]] = {}
for profile in PROFILE_NAMES:
fixture = OUT / "fixtures" / f"style-override-profile-{profile}.json"
positions = profile_camera_positions(profile)
for camera_index, camera in enumerate(positions):
x, y, z, yaw, pitch = camera
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
signatures: dict[int, dict[str, object]] = {}
for workers in (1, 8, 12):
name = (f"profile-random-camera-{profile}-{compiler}-"
f"s{PROFILE_CAMERA_SWEEP_SEED:06x}-p{camera_index:02d}-w{workers}")
_, output = runner.run_cpp(name, binary, fixture, "surface-world",
["--stream-hash-tiles", camera_flag, "--clip-radius=3",
"--max-clip-level=0", "--max-level=0", "--render-distance-chunks=0"],
expected_style=None, expected_strate_styles={"0": 2, "1": 1},
workers=workers, layout_path=OUT / "layouts" / f"{name}.json")
tiles = parse_tile_hashes(output)
materials = parse_tile_material_hashes(output)
whole = re.search(r"^\[PipelineWholeViewHash\] tiles=(\d+)", output, re.M)
expected_rows = int(whole.group(1)) if whole else -1
runner.require(f"{name}:tile-hash-rows",
bool(tiles) and len(tiles) == expected_rows,
f"rows={len(tiles)} expected={expected_rows}")
runner.require(f"{name}:material-hash-rows",
bool(materials) and len(materials) == expected_rows,
f"rows={len(materials)} expected={expected_rows}")
signatures[workers] = {
"tiles": {"/".join(map(str, key)): list(value)
for key, value in sorted(tiles.items())},
"materials": {"/".join(map(str, key)): value
for key, value in sorted(materials.items())},
}
stable = signatures[1] == signatures[8] == signatures[12]
key = f"{profile}/p{camera_index:02d}"
runner.require(f"profile-random-camera-{profile}-{compiler}-p{camera_index:02d}:workers",
stable, "seeded profile camera tile geometry and material hashes match at W1/W8/W12")
if compare_reference:
runner.require(f"profile-random-camera-{profile}-gcc-p{camera_index:02d}:clang-peer",
{str(worker): signatures[worker] for worker in (1, 8, 12)}
== references.get(key),
"Clang and GCC preserve exact per-tile geometry/material hashes")
else:
references[key] = {str(worker): signatures[worker]
for worker in (1, 8, 12)}
if not compare_reference:
reference_path.write_text(json.dumps(references, indent=2) + "\n", encoding="utf-8")
def run_transitions_and_invariants(runner: VerificationRunner,
binaries: tuple[Path, ...]) -> None:
for binary in binaries:
@@ -1035,6 +1329,7 @@ def run_cost_pairs(runner: VerificationRunner) -> None:
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)
@@ -1044,6 +1339,10 @@ def run_medium_suite(runner: VerificationRunner, *, both_compilers: bool = False
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)))
@@ -1054,6 +1353,10 @@ def run_gcc_supplement(runner: VerificationRunner) -> None:
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)
def _tier_deadline(_signum: int, _frame: object) -> None: