Official Codebase of 3DCodeVerse
Python
scene_placement: a zone whose only planned content was never built is not empty
gaoypengae6d2e1d878d
diff --git a/harness/codeverse3d/spatial/scene_placement.py b/harness/codeverse3d/spatial/scene_placement.pyindex 89b9f4c5..2db1bbe0 100644--- a/harness/codeverse3d/spatial/scene_placement.py+++ b/harness/codeverse3d/spatial/scene_placement.py@@ -513,18 +513,20 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,for r in rows:by_zone.setdefault(to_snake(r.zone), []).append(r)all_names = " ".join(_row_names(r) for r in rows)+ gone = {to_snake(u) for u in unavailable}for zone_name, contents in _plan_zones(plan):zk = to_snake(zone_name)placed = by_zone.get(zk, [])- if not placed and contents:- out.append(_f(Severity.ERROR, f"zone {zone_name} placed nothing (plan lists: {', '.join(contents[:6])})",+ # what the zone was allowed to place: an asset the asset stage never built was+ # announced "NOT AVAILABLE" to it, for zone_empty exactly as for missing_content+ expected = [c for c in contents if to_snake(c) not in gone]+ if not placed and expected:+ out.append(_f(Severity.ERROR, f"zone {zone_name} placed nothing (plan lists: {', '.join(expected[:6])})",target=zone_name, kind="zone_empty",hint=f"build the zone group named '{zone_name}' and place its planned contents"))continuezone_names = " ".join(_row_names(r) for r in placed)- gone = {to_snake(u) for u in unavailable}- missing = [c for c in contents if to_snake(c) not in zone_names and to_snake(c) not in all_names- and to_snake(c) not in gone]+ missing = [c for c in expected if to_snake(c) not in zone_names and to_snake(c) not in all_names]if missing:out.append(_f(Severity.ERROR,f"zone {zone_name} is missing planned contents: {', '.join(missing[:5])}"diff --git a/harness/tests/scene_gates/test_placement.py b/harness/tests/scene_gates/test_placement.pyindex 32b3450f..e945a39d 100644--- a/harness/tests/scene_gates/test_placement.py+++ b/harness/tests/scene_gates/test_placement.py@@ -200,7 +200,8 @@ def test_check_placement_returns_the_round_gates_verdict(tmp_path):assert not obs.ok and not gate.passed and obs.numbers["errors"] == len(gate.errors)assert all(f.message in obs.text for f in gate.errors)kinds = {f.data.get("kind") for f in gate.findings}- assert {"floating", "no_fog", "zone_empty"} <= kinds and "missing_content" not in kinds # Bench was never built+ # Bench was never built: House (its only content) is neither missing it nor empty+ assert {"floating", "no_fog"} <= kinds and not {"missing_content", "zone_empty"} & kinds# --------------------------------------------------------------------- plan-aware contract checksdiff --git a/harness/tests/scene_gates/test_zone_contents_nesting.py b/harness/tests/scene_gates/test_zone_contents_nesting.pyindex 8db52f57..2bcc8d2d 100644--- a/harness/tests/scene_gates/test_zone_contents_nesting.py+++ b/harness/tests/scene_gates/test_zone_contents_nesting.py@@ -82,3 +82,16 @@ def test_an_unavailable_hero_is_not_missing_content():missing = [f for f in contract_findings(census, plan) if f.data.get("kind") == "missing_content"]assert missing and "BronzeCenser" in missing[0].messageassert not [f for f in contract_findings(census, plan, unavailable=["BronzeCenser"]) if f.data.get("kind") == "missing_content"]+++def test_a_zone_whose_only_content_was_never_built_is_not_empty():+ """zone_empty follows the same rule as missing_content: a zone told its only planned hero+ is NOT AVAILABLE placed nothing because it was told to."""+ from codeverse3d.spatial.scene_placement import contract_findings++ plan = {"zones": [{"name": "IncenseTerrace", "contents": ["BronzeCenser"]},+ {"name": "Courtyard", "contents": ["StoneBench"]}], "assets": []}+ census = {"placement": {"assets": [{"name": "StoneBench", "zone": "Courtyard", "inner": []}]}}+ empty = [f.target for f in contract_findings(census, plan) if f.data.get("kind") == "zone_empty"]+ assert empty == ["IncenseTerrace"]+ assert not [f for f in contract_findings(census, plan, unavailable=["BronzeCenser"]) if f.data.get("kind") == "zone_empty"]