Skip to content

Official Codebase of 3DCodeVerse

Python

scene placement: a hero the asset stage could not build is not 'missing planned contents'; the hero judge sees the measurement

gaoypengfe7d15c6cf4e
diff --git a/harness/codeverse/spatial/scene_placement.py b/harness/codeverse/spatial/scene_placement.py
index af96713d..eca4944a 100644
--- a/harness/codeverse/spatial/scene_placement.py
+++ b/harness/codeverse/spatial/scene_placement.py
@@ -25,6 +25,7 @@ from __future__ import annotations
import logging
import time
+from collections.abc import Sequence
from typing import Any
from pydantic import BaseModel, ConfigDict, Field
@@ -348,10 +349,16 @@ def _row_names(row: AssetRow) -> str:
def contract_findings(census: dict[str, Any] | None, plan: Any,
- layouts: dict[str, Any] | None = None) -> list[GateFinding]:
+ layouts: dict[str, Any] | None = None, unavailable: Sequence[str] = ()) -> list[GateFinding]:
"""Deterministic plan-vs-census checks: env atmosphere present, every zone dressed
with its planned contents, plausible scale, content inside the world bounds — and,
- when the zone has an L2 layout, its density budget actually met."""
+ when the zone has an L2 layout, its density budget actually met.
+
+ ``unavailable`` = assets the asset stage could not build (the zones were told
+ "NOT AVAILABLE — do not reference"): a zone is not missing what it was told not to
+ place. Measured 2026-09-07 (ab_temple_hero): the ERROR "missing planned contents:
+ BronzeCenser" recurred every round for a hero that never existed, with the hint
+ "clone its GLB"."""
if not isinstance(census, dict) or plan is None:
return []
out: list[GateFinding] = []
@@ -427,7 +434,9 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
hint=f"build the zone group named '{zone_name}' and place its planned contents"))
continue
zone_names = " ".join(_row_names(r) for r in placed)
- missing = [c for c in contents if to_snake(c) not in zone_names and to_snake(c) not in all_names]
+ 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]
if missing:
out.append(_f(Severity.ERROR,
f"zone {zone_name} is missing planned contents: {', '.join(missing[:5])}"
@@ -510,7 +519,7 @@ def check_placement(ws: Workspace, *, indoor: bool | None = None, force_probe: b
def placement_gate_safe(census: dict[str, Any] | None, *, plan: Any = None,
- layouts: dict[str, Any] | None = None) -> GateReport | None:
+ layouts: dict[str, Any] | None = None, unavailable: Sequence[str] = ()) -> GateReport | None:
"""Round-gate entry: ``None`` when the census has no placement table (scene did not
boot, or an older driver), a WARN-only report when anything raises — never an
exception, so the placement check cannot kill a round."""
@@ -519,7 +528,7 @@ def placement_gate_safe(census: dict[str, Any] | None, *, plan: Any = None,
if not isinstance(table, dict):
return None
report = placement_findings(table, indoor=infer_indoor(setting_text(plan)))
- extra = _cap_per_kind(contract_findings(census, plan, layouts=layouts))
+ extra = _cap_per_kind(contract_findings(census, plan, layouts=layouts, unavailable=unavailable))
if extra:
findings = report.findings + extra
passed = not any(f.severity == Severity.ERROR for f in findings)
diff --git a/harness/codeverse/tracks/scene.py b/harness/codeverse/tracks/scene.py
index 94958e0b..a571f62c 100644
--- a/harness/codeverse/tracks/scene.py
+++ b/harness/codeverse/tracks/scene.py
@@ -114,7 +114,8 @@ class ScenePipeline:
try:
from codeverse.spatial.scene_placement import placement_gate_safe
- placement = placement_gate_safe(build.census, plan=ctx.plan, layouts=ctx.extra.get("layouts"))
+ placement = placement_gate_safe(build.census, plan=ctx.plan, layouts=ctx.extra.get("layouts"),
+ unavailable=[n for n, r in (ctx.extra.get("assets") or {}).items() if not getattr(r, "ok", True)])
except Exception as e: # noqa: BLE001
log.warning("scene placement gate unavailable: %s", e)
placement = GateReport(gate="scene_placement", passed=True, findings=[GateFinding(
diff --git a/harness/codeverse/tracks/scene_assets.py b/harness/codeverse/tracks/scene_assets.py
index 25e53b29..df3c2e7e 100644
--- a/harness/codeverse/tracks/scene_assets.py
+++ b/harness/codeverse/tracks/scene_assets.py
@@ -432,7 +432,8 @@ def build_blender_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> As
result.clips = glb_clip_count(dest)
return True
- result = _judge_and_fix(sub, asset, result, _render, files=files, language=Language.BLENDER, after_fix=_after_fix)
+ result = _judge_and_fix(sub, asset, result, _render, files=files, language=Language.BLENDER, after_fix=_after_fix,
+ measure_fn=lambda: ctx.services.measure(dest))
return result
@@ -533,7 +534,8 @@ def _volume_fraction(ctx: RunContext, asset: AssetPlan) -> float:
def _judge_and_fix(ctx: RunContext, asset: AssetPlan, result: AssetResult, render_fn: Any, *, files: list[str],
- language: Language, after_fix: Callable[[RunContext], bool] | None = None) -> AssetResult:
+ language: Language, after_fix: Callable[[RunContext], bool] | None = None,
+ measure_fn: Callable[[], Any] | None = None) -> AssetResult:
"""Quick-sheet judge with asset_v1 (n_samples=1); ONE fix pass when below threshold,
then the fix is checked (``after_fix(gen_ctx)``) and JUDGED AGAIN — ``score`` describes
the asset that ships, ``score_before`` the one that was fixed. The fix climbs the
@@ -554,7 +556,11 @@ def _judge_and_fix(ctx: RunContext, asset: AssetPlan, result: AssetResult, rende
d.mkdir(parents=True, exist_ok=True)
try:
renders = render_fn(d)
+ # the measurement the rubric's proportions criterion reads (a hero's quick sheet used to
+ # arrive with "MEASUREMENTS: (none available)"); re-measured after a fix
+ measurement = measure_fn() if measure_fn is not None else None
verdict: Judgment = judge.judge(JudgeInput(spec=ctx.spec, renders=renders, round_index=round_index,
+ measurement=measurement,
plan_summary=f"{asset.name}: {asset.description}",
extra_context=f"Expected size ≈ {asset.approx_size_m} m (w×h×d)."))
except Exception as e: # noqa: BLE001
diff --git a/harness/tests/scene_gates/test_zone_contents_nesting.py b/harness/tests/scene_gates/test_zone_contents_nesting.py
index 9d9a0799..497b32ea 100644
--- a/harness/tests/scene_gates/test_zone_contents_nesting.py
+++ b/harness/tests/scene_gates/test_zone_contents_nesting.py
@@ -70,3 +70,15 @@ def test_a_row_with_no_inner_list_behaves_as_before():
row = {"name": "Windmill", "zone": "WindmillIsland"}
assert _missing(contract_findings(_census(row), _plan(["Windmill"]))) == []
assert _missing(contract_findings(_census(row), _plan(["SkyPine"]))) == ["SkyPine"]
+
+
+def test_an_unavailable_hero_is_not_missing_content():
+ """A hero the asset stage could not build was withheld from the zone ("NOT AVAILABLE —
+ do not reference"); the contract check must not ERROR every round on its absence."""
+ from codeverse.spatial.scene_placement import contract_findings
+
+ plan = {"zones": [{"name": "IncenseTerrace", "contents": ["BronzeCenser", "StoneBench"]}], "assets": []}
+ census = {"placement": {"assets": [{"name": "StoneBench", "zone": "IncenseTerrace", "inner": []}]}}
+ missing = [f for f in contract_findings(census, plan) if f.data.get("kind") == "missing_content"]
+ assert missing and "BronzeCenser" in missing[0].message
+ assert not [f for f in contract_findings(census, plan, unavailable=["BronzeCenser"]) if f.data.get("kind") == "missing_content"]