feat(core): native Core caves generator, slice 1 -- spine + room, whole view 0.73 s (L54); research R23

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-25 04:10:19 +01:00
1 parent 20f6c98ec5
commit 9458217d34
24 files changed
+471136 -59

No files matched your search

+276 -2
View File
@@ -25,6 +25,7 @@ VERIFY_DIR = ROOT / "Standalone/Tools/verify"
LINUX37 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux37"
LINUX47 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux47"
LINUX53 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux53"
LINUX54 = ROOT / "Standalone/Research/WorldAssemblerM3/Linux54"
OWNER = ROOT / "Standalone/data/owner_world.json"
OUT_DEFAULT = ROOT / "Saved/Linux/l42"
@@ -62,6 +63,7 @@ TILE_MATERIAL_HASH_RE = re.compile(
r"material=(0x[0-9a-f]+)$", re.M)
CAMERA_SWEEP_SEED = 0x4C3434
PROFILE_CAMERA_SWEEP_SEED = 0x4C3533
CAVES_CAMERA_SWEEP_SEED = 0x4C3534
PROFILE_NAMES = ("periodicHills", "mirroredRelief", "flatField")
RECIPE_RE = re.compile(
r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=([^ ]+)$", re.M)
@@ -391,6 +393,16 @@ def run_hash_pairs(runner: VerificationRunner,
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:
@@ -598,6 +610,258 @@ def cavern_audit_cameras(layout_path: Path) -> list[tuple[float, float, float, f
return cameras
def build_caves_fixture(runner: VerificationRunner, binary: Path) -> Path:
fixture = OUT / "fixtures" / "caves.json"
builder = LINUX54 / "BuildCaveFixtureL54.py"
runner.run_stage("build-native-caves-fixture-l54", builder,
["--owner", str(OWNER), "--out", str(fixture)], binary=binary,
data=OWNER, recipe="caves", style=None, env=env_for(),
script_inputs=[builder, OWNER])
return fixture
def run_native_caves_field_audit(runner: VerificationRunner, binary: Path) -> tuple[Path, Path]:
fixture = build_caves_fixture(runner, binary)
compiler = compiler_name(binary)
layout_path = OUT / "layouts" / f"native-caves-field-{compiler}.json"
row, output = runner.run_cpp(f"native-caves-field-{compiler}", binary, fixture,
"caves", ["--audit-native-caves", "--max-clip-level=0",
"--render-distance-chunks=0"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=12,
max_level=0, layout_path=layout_path,
script_inputs=[LINUX54 / "BuildCaveFixtureL54.py"])
plan = re.search(r"^\[CavesSpinePlan\] .*recipe=Core\.Caves\.PrimitiveField version=1 "
r"density_sign=negative_solid_positive_air .*edges=2 .*bore_radius_m=4\.500 "
r"bore_height_m=4\.500 .*floor_blend_width_m=([0-9.]+) "
r"ideal_fillet_radius_m=([0-9.]+) .*shared_layer=shared-bedrock status=PASS$",
output, re.M)
runner.require(f"native-caves-field-{compiler}:version-and-binding", bool(plan),
"native caves recipe v1, negative-solid/positive-air, two spine edges, shared layer")
fillet = re.search(r"^\[CavesFilletAudit\].*measured_composed_radius_m=([0-9.]+) "
r".*status=PASS$", output, re.M)
runner.require(f"native-caves-field-{compiler}:measured-fillet",
bool(fillet and float(fillet.group(1)) >= 0.5),
f"measured_composed_radius_m={fillet.group(1) if fillet else 'MISSING'} required>=0.500")
flood = re.search(r"^\[CavesCapsuleFloodFill\].*min_headroom_m=([0-9.]+) "
r"required_headroom_m=0\.300 reachable=yes status=PASS$", output, re.M)
runner.require(f"native-caves-field-{compiler}:arrival-to-departure",
bool(flood and float(flood.group(1)) >= 0.3),
f"reachable={bool(flood)} min_headroom_m={flood.group(1) if flood else 'MISSING'}")
runner.require(f"native-caves-field-{compiler}:interval-oracle-and-controls",
all_match(output, r"^\[CavesIntervalOracle\] .*misses=0 "
r"false_all_air=REJECTED false_all_solid=REJECTED .*status=PASS$"),
"brute-force interval proofs have zero misses and reject both false-proof controls")
layout = json.loads(layout_path.read_text(encoding="utf-8"))
graph_ok = (layout.get("cavern_graph_vocabulary_version") == 1
and len(layout.get("cavern_rooms", [])) == 1
and len(layout.get("cavern_edges", [])) == 2)
runner.require(f"native-caves-field-{compiler}:resolved-graph", graph_ok,
f"vocabulary={layout.get('cavern_graph_vocabulary_version')} "
f"rooms={len(layout.get('cavern_rooms', []))} edges={len(layout.get('cavern_edges', []))}")
if plan:
row["floor_blend_width_m"] = float(plan.group(1))
row["ideal_fillet_radius_m"] = float(plan.group(2))
if fillet:
row["measured_composed_fillet_radius_m"] = float(fillet.group(1))
if flood:
row["minimum_headroom_m"] = float(flood.group(1))
return fixture, layout_path
def cave_camera_positions(layout_path: Path, count: int = 4) -> list[tuple[float, float, float, float, float]]:
layout = json.loads(layout_path.read_text(encoding="utf-8"))
edges = sorted(layout.get("cavern_edges", []), key=lambda edge: edge["stable_id"])
if layout.get("cavern_graph_vocabulary_version") != 1 or len(edges) != 2:
raise VerificationFailure(f"missing two resolved cave spine edges in {layout_path}")
rng = _SplitMix64(CAVES_CAMERA_SWEEP_SEED)
cameras = []
for index in range(count):
edge = edges[index % len(edges)]
points = [[value / 1_000_000.0 for value in point]
for point in edge["control_points_um"]]
t = rng.between(0.30, 0.72)
one = 1.0 - t
position = [one ** 3 * points[0][axis]
+ 3.0 * one ** 2 * t * points[1][axis]
+ 3.0 * one * t ** 2 * points[2][axis]
+ t ** 3 * points[3][axis] for axis in range(3)]
tangent = [3.0 * one ** 2 * (points[1][axis] - points[0][axis])
+ 6.0 * one * t * (points[2][axis] - points[1][axis])
+ 3.0 * t ** 2 * (points[3][axis] - points[2][axis])
for axis in range(3)]
horizontal = math.hypot(tangent[0], tangent[1])
if horizontal <= 1.0e-9:
raise VerificationFailure(f"degenerate cave camera tangent in {layout_path}")
side = (-tangent[1] / horizontal, tangent[0] / horizontal)
lateral = rng.between(-1.0, 1.0)
x = position[0] + side[0] * lateral
y = position[1] + side[1] * lateral
z = position[2] + rng.between(1.40, 1.60)
yaw = math.degrees(math.atan2(tangent[0], tangent[1])) + rng.between(-18.0, 18.0)
pitch = rng.between(-8.0, 8.0)
cameras.append((x, y, z, yaw, pitch))
return cameras
def run_caves_determinism(runner: VerificationRunner, binary: Path, fixture: Path,
layout_path: Path, *, compare_reference: bool) -> None:
compiler = compiler_name(binary)
reference_path = OUT / "caves-determinism-reference.json"
if compare_reference:
try:
reference = json.loads(reference_path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
raise VerificationFailure(f"missing Clang cave camera reference: {error}")
else:
reference = None
current: dict[str, dict[str, dict[str, list[str]]]] = {}
for camera_index, camera in enumerate(cave_camera_positions(layout_path)):
x, y, z, yaw, pitch = camera
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
signatures: dict[int, dict[tuple[int, int, int, int], tuple[str, ...]]] = {}
key = f"p{camera_index:02d}"
current[key] = {}
for workers in (1, 8, 12):
name = (f"caves-camera-{compiler}-s{CAVES_CAMERA_SWEEP_SEED:06x}-"
f"p{camera_index:02d}-w{workers}")
row, output = runner.run_cpp(name, binary, fixture, "caves",
["--stream-hash-tiles", camera_flag, "--clip-radius=3",
"--max-clip-level=0", "--max-level=0", "--render-distance-chunks=0"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1},
workers=workers, max_level=0,
layout_path=OUT / "layouts" / f"{name}.json")
row["camera_seed"] = f"0x{CAVES_CAMERA_SWEEP_SEED:06x}"
row["camera_index"] = camera_index
row["camera_position_m"] = [round(value, 6) for value in camera[:3]]
row["camera_region"] = "inside-native-caves-spine"
tiles = parse_tile_hashes(output)
whole = re.search(r"^\[PipelineWholeViewHash\] tiles=(\d+)", output, re.M)
expected_rows = int(whole.group(1)) if whole else -1
runner.require(f"{name}:tile-hash-rows",
bool(tiles) and len(tiles) == expected_rows,
f"rows={len(tiles)} expected={expected_rows} camera_m={camera[:3]}")
signatures[workers] = tiles
current[key][str(workers)] = {
"/".join(map(str, tile)): list(value)
for tile, value in sorted(tiles.items())}
for left, right in ((1, 8), (1, 12), (8, 12)):
runner.require(f"caves-camera-{compiler}-{key}:W{left}-W{right}",
signatures[left] == signatures[right],
f"camera_m=({x:.3f},{y:.3f},{z:.3f}) W{left}=W{right} "
"density/mesh/payload/topology tile hashes match")
if compare_reference:
runner.require("caves-camera-gcc:matches-clang-peers", current == reference,
"random cave camera tile hashes match Clang at W1/W8/W12")
else:
reference_path.write_text(json.dumps(current, indent=2, sort_keys=True) + "\n",
encoding="utf-8")
def run_caves_performance(runner: VerificationRunner, binary: Path,
fixture: Path, layout_path: Path) -> None:
compiler = compiler_name(binary)
camera = cave_camera_positions(layout_path, count=1)[0]
x, y, z, yaw, pitch = camera
camera_flag = f"--camera={x:.6f},{y:.6f},{z:.6f},{yaw:.3f},{pitch:.3f}"
row, output = runner.run_cpp(f"caves-speed-{compiler}-w12", binary, fixture,
"caves", [camera_flag, "--clip-radius=4", "--max-clip-level=0",
"--max-level=0", "--render-distance-chunks=0",
"--camera-step=24,0,0", "--region-crossing"],
expected_style=2, expected_strate_styles={"0": 2, "1": 1}, workers=12,
max_level=0, layout_path=OUT / "layouts" / f"caves-speed-{compiler}-w12.json")
stream = re.search(r"^\[StreamPipeline\] .*first_tile_ready=([0-9.]+)s "
r".*neighborhood_ready=([0-9.]+)s .*whole_view_ready=([0-9.]+)s "
r".*cache_hits=0", output, re.M)
moving = re.search(r"^\[MovingTileLatency\] entering_tiles=(\d+) "
r"p50_ms=([0-9.]+) p95_ms=([0-9.]+) metric=submit_to_completion_observed$",
output, re.M)
runner.require(f"caves-speed-{compiler}:cold-and-moving-records",
bool(stream and moving and int(moving.group(1)) > 0),
f"cold_first_tile_s={stream.group(1) if stream else 'MISSING'} "
f"near_ring_s={stream.group(2) if stream else 'MISSING'} "
f"cold_whole_view_s={stream.group(3) if stream else 'MISSING'} "
f"moving_p50_ms={moving.group(2) if moving else 'MISSING'} "
f"moving_p95_ms={moving.group(3) if moving else 'MISSING'}")
if stream and moving:
row["speed_metrics"] = {
"cold_first_tile_seconds": float(stream.group(1)),
"near_ring_seconds": float(stream.group(2)),
"cold_whole_view_seconds": float(stream.group(3)),
"moving_entering_tiles": int(moving.group(1)),
"moving_p50_ms": float(moving.group(2)),
"moving_p95_ms": float(moving.group(3)),
"workers": 12,
"camera_m": [round(value, 6) for value in camera[:3]],
}
def run_caves_surface_evidence(runner: VerificationRunner, fixture: Path,
layout_path: Path) -> None:
capture_script = LINUX54 / "CaptureNativeCavesL54.py"
artifact_dir = OUT / "captures"
_, capture_output = runner.run_stage("capture-native-caves-l54", capture_script,
["--out", str(OUT), "--fixture", str(fixture), "--layout", str(layout_path),
"--headless", str(CLANG), "--renderer", str(RENDERER),
"--artifact-dir", str(artifact_dir)], binary=CLANG, data=fixture,
recipe="caves", style=2, env=env_for(capture=True),
script_inputs=[capture_script, VERIFY_DIR / "capture_quality.py"])
capture_rows = re.findall(r"^\[L54CavesCapture\] view=([^ ]+) .*status=PASS$",
capture_output, re.M)
runner.require("capture-native-caves-l54:coverage",
set(capture_rows) == {"spine-eye", "room-from-entrance", "cutaway-overview"}
and len(capture_rows) == 3,
f"views={capture_rows}")
script = LINUX54 / "AuditWholeSurfaceL54.py"
audit_layout = ROOT / "Saved/Linux/l48/layouts/landmark-reachability-clang.json"
controls = (
("L45-ramp-control", ROOT / "Saved/Linux/l45/landmark-l45.vfmesh", "fail"),
("L46-entrance-control", ROOT / "Saved/Linux/l46/landmark-l46.vfmesh", "fail"),
("L47-wall-foot-control", ROOT / "Saved/Linux/l47/landmark-l47.vfmesh", "fail"),
("plain-native-control", ROOT / "Saved/Linux/l48/control-plain-native.vfmesh", "pass"),
)
mesh = OUT / "caves-meshes" / "caves-whole-view.vfmesh"
cases = [("caves-base", mesh, layout_path, "measure", "whole")]
cases.extend((name, control_mesh, audit_layout, expect, "whole")
for name, control_mesh, expect in controls)
svg_dir = artifact_dir
base_args = ["--json", str(OUT / "whole-surface-caves-base.json"),
"--svg-dir", str(svg_dir)]
for label, case_mesh, case_layout, expect, focus in cases:
base_args.extend(("--case", label, str(case_mesh), str(case_layout), expect, focus))
_, base_output = runner.run_stage("whole-surface-caves-base-l54", script, base_args,
binary=CLANG, data=fixture, recipe="caves", style=2,
layout_path=layout_path, env=env_for(),
script_inputs=[script, mesh, layout_path, audit_layout,
*(item[1] for item in controls)])
candidate = re.search(r"^\[WholeSurfaceAudit\] label=caves-base .*"
r"observed=(PASS|FAIL) expected=MEASURE status=PASS$", base_output, re.M)
runner.require("whole-surface-caves-base-l54:pass",
bool(candidate and candidate.group(1) == "PASS"),
f"observed={candidate.group(1) if candidate else 'MISSING'}")
for label, _control_mesh, expectation in controls:
match = re.search(rf"^\[WholeSurfaceAudit\] label={re.escape(label)} .*"
rf"observed=(PASS|FAIL) expected={expectation.upper()} status=PASS$",
base_output, re.M)
runner.require(f"whole-surface-caves-base-l54:{label}", bool(match),
f"control_expectation={expectation} observed={match.group(1) if match else 'MISSING'}")
for phase, label in ((-0.5, "minus-half"), (0.5, "plus-half")):
phase_args = ["--json", str(OUT / f"whole-surface-caves-{label}.json"),
"--svg-dir", str(svg_dir), "--phase", str(phase),
"--case", f"caves-{label}", str(mesh), str(layout_path), "measure", "whole"]
_, phase_output = runner.run_stage(f"whole-surface-caves-{label}-l54", script,
phase_args, binary=CLANG, data=fixture, recipe="caves", style=2,
layout_path=layout_path, env=env_for(),
script_inputs=[script, mesh, layout_path])
match = re.search(r"^\[WholeSurfaceAudit\] label=caves-" + label + r" .*"
r"phase_h=[+-]0\.5 .*observed=(PASS|FAIL) expected=MEASURE status=PASS$",
phase_output, re.M)
runner.require(f"whole-surface-caves-{label}-l54:pass",
bool(match and match.group(1) == "PASS"),
f"observed={match.group(1) if match else 'MISSING'}")
def run_random_camera_sweep(runner: VerificationRunner, binaries: tuple[Path, ...],
camera_count: int,
configurations: tuple[tuple[int, int, int], ...]) -> None:
@@ -885,7 +1149,7 @@ def run_profile_fixtures(runner: VerificationRunner, binary: Path) -> dict[str,
def run_profile_captures(runner: VerificationRunner) -> None:
script = LINUX53 / "CaptureHeightfieldProfilesL53.py"
quality = VERIFY_DIR / "capture_quality.py"
artifacts = LINUX53 / "captures"
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),
@@ -1144,7 +1408,7 @@ def run_captures_and_mesh_audits(runner: VerificationRunner) -> None:
landmark_layout = OUT / "layouts" / "landmark-reachability-clang.json"
runner.run_stage("capture-landmark-l47", landmark_script,
["--layout", str(landmark_layout), "--artifact-dir", str(OUT),
"--capture-dir", str(LINUX47 / "captures"),
"--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),
@@ -1345,6 +1609,10 @@ def run_medium_suite(runner: VerificationRunner, *, both_compilers: bool = False
run_profile_random_camera_sweep(runner, CLANG, compare_reference=False)
run_random_camera_sweep(runner, (CLANG,), 5,
((3, 0, 0), (2, 1, 1), (3, 2, 1)))
fixture, layout_path = run_native_caves_field_audit(runner, CLANG)
run_caves_determinism(runner, CLANG, fixture, layout_path, compare_reference=False)
run_caves_performance(runner, CLANG, fixture, layout_path)
run_caves_surface_evidence(runner, fixture, layout_path)
def run_gcc_supplement(runner: VerificationRunner) -> None:
@@ -1357,6 +1625,11 @@ def run_gcc_supplement(runner: VerificationRunner) -> None:
run_profile_fixtures(runner, GCC)
run_profile_determinism(runner, GCC, compare_reference=True)
run_profile_random_camera_sweep(runner, GCC, compare_reference=True)
fixture = OUT / "fixtures" / "caves.json"
layout_path = OUT / "layouts" / "native-caves-field-clang.json"
if not fixture.is_file() or not layout_path.is_file():
fixture, layout_path = run_native_caves_field_audit(runner, CLANG)
run_caves_determinism(runner, GCC, fixture, layout_path, compare_reference=True)
def _tier_deadline(_signum: int, _frame: object) -> None:
@@ -1385,6 +1658,7 @@ def main() -> int:
run_ore_vein_hash_controls(runner)
run_random_camera_sweep(runner, (CLANG,), 3, ((3, 0, 0),))
run_ring(runner, full=False)
run_native_caves_field_audit(runner, CLANG)
elif ARGS.tier == "medium":
run_medium_suite(runner, both_compilers=False)
else: