tools: per-strate density dispatch report in the fast tier (L132)

--density-dispatch-report prints each strate's bound path and tile shares. Owner world: SW native heightfield;
FI, TN, VS on compiled-analytic legacy fallback (FI lacks an imported FloatingIslandPlan; TN/VS have legacy recipes).
A native FI candidate broke the composed owner walk/shell gates, so the owner stays on its path. Output unchanged.

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-31 02:40:58 +01:00
1 parent ebae71b142
commit 0065ee68e6
5 files changed
+277 -7

No files matched your search

+115
View File
@@ -89,6 +89,9 @@ 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)
DENSITY_DISPATCH_RE = re.compile(
r"^\[DensityDispatch\] strate=(\d+) generator=([^ ]+) recipe=([^ ]+) "
r"version=(\d+) bound_path=([^ ]+) adapter=([^ ]+)$", 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)
@@ -493,6 +496,117 @@ def run_new_owner_plan_stage(runner: VerificationRunner, binary: Path) -> None:
+ ", ".join(deferred_failures))
def run_density_dispatch_report(runner: VerificationRunner, binary: Path) -> None:
"""Report selected owner density paths and generated tile shares by path."""
cameras = {
0: (8.0, 16.0, -372.2626953125),
1: (25.8369140625, 3.19921875, -737.0),
2: (19.166015625, -14.2001953125, -753.3740234375),
3: (-20.0625, -5.068359375, -900.353515625),
}
aggregate: dict[int, dict[str, int]] = {}
bound_paths: dict[int, tuple[str, str, str, int, str]] = {}
failures: list[str] = []
for focus_strate, position in cameras.items():
name = f"owner-density-dispatch-s{focus_strate}-clang"
camera = "--camera=" + ",".join(
f"{value:.12f}" for value in (*position, 0.0, 0.0))
layout_path = OUT / "layouts" / f"{name}.json"
try:
row, output = runner.run_cpp(name, binary, OWNER_NEW, "surface-world",
["--density-dispatch-report", "--render-distance-chunks=0", camera],
expected_style=1, workers=8, max_level=8, clip_radius=3,
layout_path=layout_path)
except VerificationFailure as error:
failures.append(f"{name}: {error}")
continue
dispatch_rows = DENSITY_DISPATCH_RE.findall(output)
dispatch = {int(index): (path, generator, recipe, int(version), adapter)
for index, generator, recipe, version, path, adapter in dispatch_rows}
if len(dispatch_rows) != 4 or set(dispatch) != {0, 1, 2, 3}:
failures.append(f"{name}: expected four unique dispatch rows, got {dispatch_rows}")
continue
if not layout_path.is_file():
failures.append(f"{name}: resolved layout missing at {layout_path}")
continue
try:
layout = json.loads(layout_path.read_text(encoding="utf-8"))
strata = {int(value["strate_index"]): value for value in layout.get("strates", [])}
if set(strata) != {0, 1, 2, 3}:
raise ValueError(f"expected four strata, got {sorted(strata)}")
voxel_size_um = int(strata[0]["voxel_size_um"])
if voxel_size_um <= 0:
raise ValueError(f"invalid voxel_size_um={voxel_size_um}")
except (OSError, json.JSONDecodeError, KeyError, TypeError, ValueError) as error:
failures.append(f"{name}: cannot classify tiles from resolved layout: {error}")
continue
tile_rows = TILE_HASH_RE.findall(output)
camera_counts = {index: 0 for index in strata}
for lod_text, _x, _y, z_text, *_hashes in tile_rows:
lod, z = int(lod_text), int(z_text)
if lod < 0 or lod > 30:
failures.append(f"{name}: invalid tile lod={lod}")
continue
extent_voxels = 32 << lod
center_um = (z * extent_voxels + extent_voxels // 2) * voxel_size_um
matches = [index for index, stratum in strata.items()
if int(stratum["interior_bottom_um"]) <= center_um
< int(stratum["interior_top_um"])]
if len(matches) == 1:
index = matches[0]
camera_counts[index] += 1
aggregate.setdefault(index, {}).setdefault(dispatch[index][0], 0)
aggregate[index][dispatch[index][0]] += 1
if not tile_rows:
failures.append(f"{name}: --density-dispatch-report emitted no tile hashes")
observed = sum(camera_counts.values())
print(f"[DensityDispatchView] focus_strate={focus_strate} tiles={len(tile_rows)} "
f"classified_by_center={observed} status={'PASS' if observed else 'FAIL'}",
flush=True)
runner.require(f"{name}:dispatch-and-tile-counts",
observed > 0 and row["status"] == "PASS",
f"dispatch={dispatch} center_attributed_tiles={camera_counts} "
f"hashed_tiles={len(tile_rows)}")
for index, value in dispatch.items():
previous = bound_paths.get(index)
if previous is not None and previous != value:
failures.append(f"strate {index}: bound path changed between views: "
f"{previous} vs {value}")
bound_paths[index] = value
global_path_counts: dict[str, int] = {}
for index in range(4):
path, generator, recipe, version, adapter = bound_paths.get(
index, ("MISSING", "?", "?", 0, "?"))
path_counts = aggregate.get(index, {})
total = sum(path_counts.values())
for path_name, count in path_counts.items():
global_path_counts[path_name] = global_path_counts.get(path_name, 0) + count
details = ",".join(
f"{key}:{value}/{total} ({100.0 * value / max(1, total):.1f}%)"
for key, value in sorted(path_counts.items())) or "no tile centers observed"
print(f"[DensityDispatchStrate] strate={index} generator={generator} recipe={recipe} "
f"version={version} bound_path={path} adapter={adapter} "
f"tile_centers={total} path_shares={details}", flush=True)
if path == "MISSING" or total == 0:
failures.append(f"strate {index}: dispatch path or tile-center share missing")
else:
runner.require(f"owner-density-dispatch-strate-{index}", True,
f"bound_path={path} tile_center_path_shares={details}")
all_tiles = sum(global_path_counts.values())
for path_name, count in sorted(global_path_counts.items()):
share = 100.0 * count / max(1, all_tiles)
print(f"[DensityDispatchPathShare] path={path_name} tiles={count}/{all_tiles} "
f"share={share:.1f}%", flush=True)
if not all_tiles:
failures.append("no tile centers were attributed to any bound path")
runner.require("owner-density-dispatch-report", not failures,
"; ".join(failures) if failures else
"four owner poses reported per-strate bound paths and tile-center path shares")
def run_landmark_reachability(runner: VerificationRunner,
binaries: tuple[Path, ...]) -> None:
for binary in binaries:
@@ -3144,6 +3258,7 @@ def main() -> int:
except VerificationFailure as error:
new_plan_failure = str(error)
print(f"[{runner.tier}] new-owner-plan-stage FAIL {error}", flush=True)
run_density_dispatch_report(runner, CLANG)
run_landmark_reachability(runner, (CLANG,))
run_regression_controls(runner)
run_hash_pairs(runner, owners)