Skip to content

Official Codebase of 3DCodeVerse

Python

scene_placement: a census box of nulls skips its check instead of crashing the gate

gaoypeng4a81b31d6353
diff --git a/harness/codeverse3d/spatial/scene_placement.py b/harness/codeverse3d/spatial/scene_placement.py
index 4fd82a54..89b9f4c5 100644
--- a/harness/codeverse3d/spatial/scene_placement.py
+++ b/harness/codeverse3d/spatial/scene_placement.py
@@ -65,6 +65,17 @@ PARTIAL_OK_WORDS = frozenset({
})
+def _nums(v: object) -> list[float] | None:
+ """Three numbers, or None: a census group with no geometry measures its box as nulls
+ (sota_sydney_opera's HarbourBridgeZone), which must skip a check, not crash the gate."""
+ if not isinstance(v, list | tuple) or len(v) != 3:
+ return None
+ try:
+ return [float(x) for x in v]
+ except (TypeError, ValueError):
+ return None
+
+
class AssetRow(BaseModel):
"""One row of the census placement table (``host_placement.mjs``)."""
@@ -109,7 +120,8 @@ class AssetRow(BaseModel):
@property
def height(self) -> float:
- return float(self.bbox["size"][1]) if self.bbox and self.bbox.get("size") else 0.0
+ size = _nums((self.bbox or {}).get("size"))
+ return size[1] if size else 0.0
class Interpenetration(BaseModel):
@@ -477,13 +489,12 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
reach = 0.0
for g in groups:
b = g.get("bbox") if isinstance(g, dict) else None
- if not (isinstance(b, dict) and b.get("min") and b.get("max")):
- continue
- if g.get("kind") not in ("content", "ground"):
+ bmin, bmax = (_nums(b.get("min")), _nums(b.get("max"))) if isinstance(b, dict) else (None, None)
+ if bmin is None or bmax is None or g.get("kind") not in ("content", "ground"):
continue
- if (b["max"][1] - b["min"][1]) < BACKDROP_MIN_HEIGHT_M:
+ if (bmax[1] - bmin[1]) < BACKDROP_MIN_HEIGHT_M:
continue
- r = max(abs(b["min"][0] - cx), abs(b["max"][0] - cx), abs(b["min"][2] - cz), abs(b["max"][2] - cz))
+ r = max(abs(bmin[0] - cx), abs(bmax[0] - cx), abs(bmin[2] - cz), abs(bmax[2] - cz))
reach = max(reach, r)
if 0 < reach < need:
out.append(_f(Severity.ERROR,
@@ -525,7 +536,8 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
# -- plausible scale vs the plan's approx_size_m
sizes = _plan_asset_sizes(plan)
for r in rows:
- if r.exempt or not r.bbox or not r.bbox.get("size"):
+ size = _nums((r.bbox or {}).get("size"))
+ if r.exempt or size is None:
continue
rk = to_snake(r.name)
key = next((k for k in sizes if k in rk), "")
@@ -536,7 +548,7 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
n, measured = r.instance_size(key)
what = f"each of the {n} {key} instances in {r.qualified}" if n else r.qualified
if not n:
- measured = max(float(v) for v in r.bbox["size"])
+ measured = max(size)
f = measured / sizes[key]
if f > SCALE_ERROR or f < 1 / SCALE_ERROR:
sev = Severity.ERROR
@@ -553,9 +565,9 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
lo, hi = bounds
margin = max(BOUNDS_MARGIN_MIN_M, 0.05 * max(hi[0] - lo[0], hi[2] - lo[2]))
for r in rows:
- if r.exempt or not r.bbox or not r.bbox.get("min"):
+ bmin, bmax = _nums((r.bbox or {}).get("min")), _nums((r.bbox or {}).get("max"))
+ if r.exempt or bmin is None or bmax is None:
continue
- bmin, bmax = r.bbox["min"], r.bbox["max"]
fully_out = (bmin[0] > hi[0] + margin or bmax[0] < lo[0] - margin
or bmin[2] > hi[2] + margin or bmax[2] < lo[2] - margin)
if fully_out:
diff --git a/harness/tests/scene_gates/test_placement.py b/harness/tests/scene_gates/test_placement.py
index 15c18428..32b3450f 100644
--- a/harness/tests/scene_gates/test_placement.py
+++ b/harness/tests/scene_gates/test_placement.py
@@ -351,6 +351,21 @@ def test_no_backdrop_fires_outdoors_and_stays_quiet_with_a_ring_or_indoors():
+def test_a_group_or_row_with_a_null_box_is_skipped_not_a_crash():
+ """sota_sydney_opera: a zone group with no geometry measures min/max/size as nulls, and
+ the backdrop reach did None - None — the whole placement gate degraded to one WARN."""
+ null_box = {"min": [None, None, None], "max": [None, None, None], "size": [None, None, None]}
+ ghost = _row("Bench")
+ ghost["bbox"] = null_box
+ census = {"fog": None, "background": "#aabbcc", "placement": _table(_row("Lantern", h=3.0), ghost),
+ "groups": [{"name": "HarbourBridgeZone", "kind": "content", "bbox": null_box},
+ {"name": "Yard", "kind": "content", "bbox": {"min": [-10, 0, -10], "max": [10, 4, 10]}}]}
+ rep = placement_gate_safe(census, plan=_contract_plan())
+ kinds = {f.data.get("kind") for f in rep.findings}
+ assert {"no_fog", "scale", "no_backdrop"} <= kinds # every check still ran around the null box
+ assert not [f for f in rep.findings if "failed" in f.message.lower()]
+
+
def test_a_ring_of_identical_copies_round_the_world_is_warned_but_not_a_rotunda():
"""2026-09-09, five of six exteriors: "a ring of identical cones stamped round the perimeter"
— the census measures the ring (host_census `stamps`); columns round a rotunda sit inside