feat(core): native lattice generator, slice 1 -- helix-ramp spine + small maze (L58); research R27

Core.Lattice.PrimitiveField v1, opt-in per strate (legacy Maze/VerticalShaft stay legacy): resolves the real
arrival and departure mouths first, plans a mandatory spine, then maze cells and two dead ends (9 rooms,
9 edges, stable IDs). The spine descends 20 m through four helix turns (6 m radius, 3 m clear width, 5 m
pitch, 2.6 m clearance; max grade 10.0 deg); each feature is one filleted void (0.57 m measured). Final-field
reachability passes at 883 stations; an orphaned shaft control is rejected; exact intervals (0 misses) and
a whole-surface audit with 0 flags. Whole view 1.69 s (above the 1 s target). fast/medium/full PASS.
Research R27 (self-checked): static stream-to-pool water design.

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 15:45:32 +01:00
1 parent 1e3e04bbac
commit 6c6cc37e1d
25 files changed
+280497 -117

No files matched your search

+303
View File
@@ -27,6 +27,7 @@ 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"
OWNER = ROOT / "Standalone/data/owner_world.json"
OUT_DEFAULT = ROOT / "Saved/Linux/l42"
@@ -65,6 +66,7 @@ TILE_MATERIAL_HASH_RE = re.compile(
CAMERA_SWEEP_SEED = 0x4C3434
PROFILE_CAMERA_SWEEP_SEED = 0x4C3533
CAVES_CAMERA_SWEEP_SEED = 0x4C3534
LATTICE_CAMERA_SWEEP_SEED = 0x4C3538
PROFILE_NAMES = ("periodicHills", "mirroredRelief", "flatField")
RECIPE_RE = re.compile(
r"^\[WorldAssemblerRecipeAudit\] requested=([^ ]+) actual=([^ ]+).*status=([^ ]+)$", re.M)
@@ -669,6 +671,242 @@ def run_native_caves_field_audit(runner: VerificationRunner, binary: Path) -> tu
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=0", "--render-distance-chunks=0"],
expected_style=None, expected_strate_styles=styles, workers=12,
max_level=0, layout_path=layout_path, script_inputs=inputs)
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=0", "--max-level=0",
"--render-distance-chunks=0"], expected_style=None,
expected_strate_styles=styles, workers=workers, max_level=0,
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]}")
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=4", "--max-clip-level=0",
"--max-level=0", "--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=0, layout_path=OUT / "layouts" / f"{name}.json",
script_inputs=[LINUX58 / "BuildLatticeFixtureL58.py"])
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"])
@@ -863,6 +1101,58 @@ def run_caves_surface_evidence(runner: VerificationRunner, fixture: Path,
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 = LINUX58 / "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:
@@ -1911,6 +2201,11 @@ def run_medium_suite(runner: VerificationRunner, *, both_compilers: bool = False
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)
@@ -1932,6 +2227,13 @@ def run_gcc_supplement(runner: VerificationRunner) -> None:
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)
@@ -1963,6 +2265,7 @@ def main() -> int:
run_random_camera_sweep(runner, (CLANG,), 3, ((3, 0, 0),))
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)