Skip to content

Official Codebase of 3DCodeVerse

Python

a harness failure is never an agent repair, and a wrapper group is not a missing asset

ziyao55c9eb4a1330
diff --git a/harness/codeverse/contracts/artifacts.py b/harness/codeverse/contracts/artifacts.py
index d96ce10a..8c3f84ee 100644
--- a/harness/codeverse/contracts/artifacts.py
+++ b/harness/codeverse/contracts/artifacts.py
@@ -76,6 +76,11 @@ class BuildResult(BaseModel):
error_line: int | None = None
duration_ms: int = 0
census: dict[str, Any] = Field(default_factory=dict, description="language-native census (objects, materials ...)")
+ harness_failure: bool = Field(
+ default=False,
+ description="the build did not fail on the model's code — the harness could not run it "
+ "(driver output lost, browser gone). Never handed to the agent as a repair.",
+ )
class PartMeasure(BaseModel):
diff --git a/harness/codeverse/languages/scene_threejs/__init__.py b/harness/codeverse/languages/scene_threejs/__init__.py
index e9c57262..6044472e 100644
--- a/harness/codeverse/languages/scene_threejs/__init__.py
+++ b/harness/codeverse/languages/scene_threejs/__init__.py
@@ -738,6 +738,10 @@ class SceneThreeJsRuntime(RuntimeDocs):
error_line=_target_line(first.target) if first else None,
duration_ms=int((time.time() - t0) * 1000),
census=census,
+ # a driver that could not run is not a defect in the scene; `probes.probe_report`
+ # and `_probe_and_preflight` already mark it, and `build_with_repair` reads this
+ # so the round does not spend its repair budget rewriting working code
+ harness_failure=bool(first is not None and first.data.get("harness_failure")),
)
(ws.artifacts / "build.json").write_text(json.dumps(res.model_dump(mode="json"), indent=1))
return res
diff --git a/harness/codeverse/spatial/scene_placement.py b/harness/codeverse/spatial/scene_placement.py
index b6555ed7..af96713d 100644
--- a/harness/codeverse/spatial/scene_placement.py
+++ b/harness/codeverse/spatial/scene_placement.py
@@ -80,6 +80,12 @@ class AssetRow(BaseModel):
sunk_into: str = ""
on_water: bool = False
attached: list[str] = Field(default_factory=list)
+ inner: list[str] = Field(
+ default_factory=list,
+ description="named descendants of this row (host_placement.MAX_INNER_NAMES) — a zone "
+ "often wraps its content in one group, and the plan-contents check has to "
+ "see through it",
+ )
@property
def qualified(self) -> str:
@@ -330,6 +336,17 @@ def _layout_budget(layout: Any) -> int:
return n
+def _row_names(row: AssetRow) -> str:
+ """The row's own name plus its named descendants, snake-cased for loose matching.
+
+ A zone that wraps its content in one group ("IslandAssembly") used to hide every
+ planned asset from this check: `bench/out/scene_fixed` (2026-09-05) reported three
+ floating_islands zones as "missing planned contents: FloatingRock, Windmill, SkyPine"
+ while the zone module built each one and named it exactly that, one level down.
+ """
+ return " ".join(to_snake(n) for n in [row.name, *row.inner])
+
+
def contract_findings(census: dict[str, Any] | None, plan: Any,
layouts: dict[str, Any] | None = None) -> list[GateFinding]:
"""Deterministic plan-vs-census checks: env atmosphere present, every zone dressed
@@ -400,7 +417,7 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
by_zone: dict[str, list[AssetRow]] = {}
for r in rows:
by_zone.setdefault(to_snake(r.zone), []).append(r)
- all_names = " ".join(to_snake(r.name) for r in rows)
+ all_names = " ".join(_row_names(r) for r in rows)
for zone_name, contents in _plan_zones(plan):
zk = to_snake(zone_name)
placed = by_zone.get(zk, [])
@@ -409,14 +426,16 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
target=zone_name, kind="zone_empty",
hint=f"build the zone group named '{zone_name}' and place its planned contents"))
continue
- zone_names = " ".join(to_snake(r.name) for r in placed)
+ 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]
if missing:
out.append(_f(Severity.ERROR,
f"zone {zone_name} is missing planned contents: {', '.join(missing[:5])}"
+ (f" (+{len(missing) - 5} more)" if len(missing) > 5 else ""),
target=zone_name, kind="missing_content", missing=missing[:8],
- hint="place each listed asset (import its builder / clone its GLB) inside this zone's bbox"))
+ hint="place each listed asset (import its builder / clone its GLB) inside this "
+ "zone's bbox AND give the object the plan's name for it — every gate and the "
+ "judge find it by that name, so a lantern called 'LanternPost1' reads as absent"))
# -- plausible scale vs the plan's approx_size_m
sizes = _plan_asset_sizes(plan)
for r in rows:
diff --git a/harness/codeverse/tracks/repair.py b/harness/codeverse/tracks/repair.py
index b5008f91..c41c68da 100644
--- a/harness/codeverse/tracks/repair.py
+++ b/harness/codeverse/tracks/repair.py
@@ -26,6 +26,11 @@ from codeverse.tracks.prompting import base_prompt_context, language_system_prom
log = logging.getLogger(__name__)
+#: How many times a build that failed IN THE HARNESS is simply re-run before the round
+#: gives up. Cheap (no model call) and bounded: the node driver already retries once
+#: itself, so a failure that survives this many rebuilds is not transient.
+MAX_HARNESS_REBUILDS = 2
+
MAX_REPAIR_CONTEXT_CHARS = 40_000
_TRACEBACK_TAIL_LINES = 40
@@ -161,7 +166,30 @@ def build_with_repair(ctx: RunContext, *, round_index: int, label: str, files_hi
prev_sig = ""
repeats = 0
attempt = 0
+ rebuilds = 0
while not outcome.ok and attempt < max_attempts:
+ # A build that failed because the HARNESS could not run it is not a defect the
+ # agent can fix, and handing it over costs the round its whole repair budget on
+ # working code. Measured 2026-09-05 (scene_textures/japanese_garden): three
+ # repairs against "scene probe produced no result (driver output lost)" rewrote
+ # 5, then 14, then 3 files — the 14 included env.js and every zone — and deleted
+ # the texture use the arm existed to measure, before the fourth build passed on
+ # its own. Re-run the build instead; the driver's own retry has already fired,
+ # so this is the second line, bounded and cheap (no model call).
+ if build.harness_failure:
+ if rebuilds >= MAX_HARNESS_REBUILDS:
+ log.warning("build kept failing in the harness (%s); giving up without a repair",
+ build.error_message[:160])
+ break
+ rebuilds += 1
+ ctx.events.emit("build.harness_retry", round=round_index, attempt=rebuilds,
+ error=build.error_message[:200])
+ build, lint = build_once(ctx)
+ outcome.build, outcome.lint = build, lint
+ ctx.events.emit("build.done", round=round_index, ok=build.ok, lint_errors=len(lint.errors),
+ harness_retry=rebuilds, error=build.error_message[:200],
+ duration_ms=build.duration_ms)
+ continue
attempt += 1
sig = error_signature(build, lint)
repeats = repeats + 1 if sig == prev_sig else 0
diff --git a/harness/runtime_js/lib/host_placement.mjs b/harness/runtime_js/lib/host_placement.mjs
index 673a6948..c95d62e4 100644
--- a/harness/runtime_js/lib/host_placement.mjs
+++ b/harness/runtime_js/lib/host_placement.mjs
@@ -63,6 +63,9 @@ export const CONTACT_TOL_M = 0.02;
export const FLOATING_M = 0.05;
export const SUNK_M = 0.10;
export const OVERLAP_MIN_FRAC = 0.20;
+//: named descendants recorded per row, so the plan-contents check can see through one
+//: wrapper group without the table growing without bound
+export const MAX_INNER_NAMES = 24;
export const WATER_RE = /\b(water|ocean|sea|lake|river|pond|pool|stream|canal)\b/i;
const FOOT_BAND_MIN_M = 0.02;
const FOOT_BAND_FRAC = 0.05;
@@ -231,8 +234,15 @@ function collectAssets(scene, indices, volumetrics, contentBox) {
const meshes = [];
let instanced = 0;
let volumetric = 0;
+ // Named descendants, not just this row's own name: a zone often wraps its content in
+ // one group ("IslandAssembly"), and the plan-contents check reads names off these
+ // rows. Measured 2026-09-05 (scene_fixed/floating_islands): Windmill, FloatingRock
+ // and SkyPine were built and named correctly, added to `IslandAssembly`, and three
+ // zones were reported as "missing planned contents".
+ const inner = [];
child.traverse((o) => {
if (!o.visible) return;
+ if (o !== child && o.name && inner.length < MAX_INNER_NAMES && !inner.includes(o.name)) inner.push(o.name);
if (o.isInstancedMesh) instanced += 1;
else if (indices.has(o)) meshes.push(indices.get(o));
else if (volumetrics.has(o)) volumetric += 1;
@@ -240,7 +250,7 @@ function collectAssets(scene, indices, volumetrics, contentBox) {
if (!meshes.length && !instanced && !volumetric) continue;
total += 1;
if (assets.length >= MAX_ASSETS) continue;
- const a = { obj: child, name: child.name || `${child.type}_${total}`, zone: zone === child ? '' : (zone.name || zone.type), meshes, instanced, exempt: '' };
+ const a = { obj: child, name: child.name || `${child.type}_${total}`, zone: zone === child ? '' : (zone.name || zone.type), meshes, instanced, inner, exempt: '' };
if (isFree(zone) || isFree(child)) a.exempt = 'free';
// instanced first: an asset that is scatter PLUS a haze shell is exempt because its
// instances cannot be sampled at this budget, which is the more informative reason
@@ -396,7 +406,7 @@ export function placementTable(scene, THREE, opts = {}) {
let timeCut = false;
const rows = [];
for (const a of assets) {
- const row = { name: a.name, zone: a.zone, meshes: a.meshes.length, instanced: a.instanced, exempt: a.exempt,
+ const row = { name: a.name, zone: a.zone, meshes: a.meshes.length, instanced: a.instanced, inner: a.inner || [], exempt: a.exempt,
bbox: a.min ? boxJson(a.min, a.max) : null };
if (a.exempt) { rows.push(row); continue; }
if (Date.now() - t0 > TIME_BUDGET_MS) { row.exempt = 'time_budget'; timeCut = true; rows.push(row); continue; }
diff --git a/harness/tests/orchestrator_tracks/test_harness_failure_no_repair.py b/harness/tests/orchestrator_tracks/test_harness_failure_no_repair.py
new file mode 100644
index 00000000..4c6b868c
--- /dev/null
+++ b/harness/tests/orchestrator_tracks/test_harness_failure_no_repair.py
@@ -0,0 +1,110 @@
+"""A build that failed IN THE HARNESS never becomes an agent repair.
+
+Measured 2026-09-05 on `bench/out/scene_textures` (japanese_garden): the scene probe
+returned no summary line — a dropped stdout tail, which `probes.probe_report` already
+labels "scene probe produced no result (driver output lost)" with
+`harness_failure: True` and the hint "this is a harness/driver failure, not your code".
+`build_with_repair` never read that flag, so the round spent all three repair attempts on
+it: the agent rewrote 5 files, then **14** (env.js and every zone), then 3, and the
+fourth build passed on its own. The 14-file rewrite deleted the texture use the arm
+existed to measure — the cell scored 0.496 where the same prompt scored 0.636 without the
+detour.
+"""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+import pytest
+
+from codeverse.contracts.artifacts import BuildResult, GateReport
+from codeverse.tracks import repair as R
+
+
+def _build(*, ok: bool, harness: bool = False, msg: str = "boom") -> BuildResult:
+ return BuildResult(ok=ok, language="scene_threejs", error_message=msg, harness_failure=harness)
+
+
+def _ctx(**over):
+ base = SimpleNamespace(
+ spec=SimpleNamespace(budget=SimpleNamespace(max_repair_attempts=3)),
+ events=SimpleNamespace(emit=lambda *a, **k: None),
+ ws=None, agent_id="x", agent=None, model=None, settings=None, budget=None,
+ policy=SimpleNamespace(agent_max_turns=8, wrapup_turns=1, agent_wrapup_turns=1),
+ cookbook_text="",
+ )
+ base.__dict__.update(over)
+ return base
+
+
+def no_generate(monkeypatch):
+ """Any call to the model is a failure of the thing under test."""
+ calls: list[str] = []
+
+ def boom(*a, **k):
+ calls.append("generate")
+ raise AssertionError("the agent must not be asked to repair a harness failure")
+
+ monkeypatch.setattr(R, "generate", boom)
+ return calls
+
+
+def test_a_harness_failure_is_rebuilt_not_repaired(monkeypatch, no_generate):
+ """The build is simply re-run — no model call — and a rebuild that succeeds ends it."""
+ seq = [(_build(ok=False, harness=True, msg="scene probe produced no result (driver output lost)"),
+ GateReport(gate="lint", passed=True, findings=[])),
+ (_build(ok=True), GateReport(gate="lint", passed=True, findings=[]))]
+ calls = {"n": 0}
+
+ def fake_build_once(ctx):
+ calls["n"] += 1
+ return seq[min(calls["n"] - 1, len(seq) - 1)]
+
+ monkeypatch.setattr(R, "build_once", fake_build_once)
+ out = R.build_with_repair(_ctx(), round_index=0, label="r00")
+ assert out.ok is True
+ assert calls["n"] == 2, "one rebuild, no repair"
+ assert out.attempts == [], "no agent attempt was spent"
+
+
+def test_a_harness_failure_that_persists_gives_up_without_a_repair(monkeypatch, no_generate):
+ """Bounded: the driver already retries once itself, so a failure that survives
+ MAX_HARNESS_REBUILDS is not transient and is not the agent's to fix either."""
+ stuck = (_build(ok=False, harness=True), GateReport(gate="lint", passed=True, findings=[]))
+ calls = {"n": 0}
+
+ def fake_build_once(ctx):
+ calls["n"] += 1
+ return stuck
+
+ monkeypatch.setattr(R, "build_once", fake_build_once)
+ out = R.build_with_repair(_ctx(), round_index=0, label="r00")
+ assert out.ok is False
+ assert calls["n"] == 1 + R.MAX_HARNESS_REBUILDS
+ assert out.attempts == []
+
+
+def test_a_real_build_failure_is_still_repaired(monkeypatch):
+ """The control: an ordinary failure still reaches the agent, as it always did."""
+ seen: list[int] = []
+
+ from codeverse.contracts.common import Usage
+
+ def fake_generate(ws, **kw):
+ seen.append(1)
+ return SimpleNamespace(ok=True, files_changed=[], usage=Usage(), notes="")
+
+ monkeypatch.setattr(R, "generate", fake_generate)
+ monkeypatch.setattr(R, "make_repair_task", lambda *a, **k: SimpleNamespace(label="t"))
+ seq = [(_build(ok=False, msg="TypeError: x is not a function"), GateReport(gate="lint", passed=True, findings=[])),
+ (_build(ok=True), GateReport(gate="lint", passed=True, findings=[]))]
+ calls = {"n": 0}
+
+ def fake_build_once(ctx):
+ calls["n"] += 1
+ return seq[min(calls["n"] - 1, len(seq) - 1)]
+
+ monkeypatch.setattr(R, "build_once", fake_build_once)
+ out = R.build_with_repair(_ctx(), round_index=0, label="r00")
+ assert out.ok is True and len(seen) == 1, "a real error still gets one repair"
diff --git a/harness/tests/scene_gates/test_zone_contents_nesting.py b/harness/tests/scene_gates/test_zone_contents_nesting.py
new file mode 100644
index 00000000..7547eda4
--- /dev/null
+++ b/harness/tests/scene_gates/test_zone_contents_nesting.py
@@ -0,0 +1,68 @@
+"""A zone that wraps its content in one group has still placed it.
+
+Measured 2026-09-05 on `bench/out/scene_fixed` (floating_islands): three zones were
+reported "missing planned contents: FloatingRock, Windmill, SkyPine" while the zone
+module built each one and named it exactly that — `windmill.name = 'Windmill'`,
+`rock.name = 'FloatingRock_1'` — and added them all to a group called `IslandAssembly`.
+The placement table lists direct children of a zone, so the check saw one row named
+`IslandAssembly` and called the plan unmet.
+
+All five of arm B's remaining `scene_placement` ERRORs were this family; the other two are
+the model naming the object after its behaviour (`PineSway_0..11` for a SnowyPineTree,
+`LanternPost1/2` for a HutPorchLantern). Those stay ERRORs — naming an object after the
+plan's content IS part of the contract, because that is how every gate and the judge find
+it — but the hint now says so.
+"""
+
+from __future__ import annotations
+
+from codeverse.contracts.plan import AssetPlan, BBox, CameraPlan, ScenePlan, ZonePlan
+from codeverse.spatial.scene_placement import contract_findings
+
+
+def _plan(contents: list[str]) -> ScenePlan:
+ bb = BBox(center=(0, 0, 0), extents=(30, 20, 30))
+ return ScenePlan(title="t", summary="s", setting="sky", mood="calm", bounds=bb, environment="clear",
+ zones=[ZonePlan(name="WindmillIsland", description="d", bbox=bb, contents=contents)],
+ assets=[AssetPlan(name=c, description=f"a {c}", kind="threejs", approx_size_m=(1, 1, 1))
+ for c in contents],
+ cameras=[CameraPlan(name="overview", position=(1, 1, 1), look_at=(0, 0, 0), fov=50, purpose="p")],
+ animation=[], effects=[])
+
+
+def _census(row: dict) -> dict:
+ return {"placement": {"assets": [row], "total": 1, "checked": 1}}
+
+
+WRAPPED = {"name": "IslandAssembly", "zone": "WindmillIsland",
+ "inner": ["Windmill", "FloatingRock_1", "FloatingRock_2", "SkyPine_1"]}
+
+
+def _missing(findings) -> list[str]:
+ return [m for f in findings if f.data.get("kind") == "missing_content" for m in f.data.get("missing", [])]
+
+
+def test_content_one_group_down_is_found():
+ out = contract_findings(_census(WRAPPED), _plan(["Windmill", "FloatingRock", "SkyPine"]))
+ assert _missing(out) == [], "the zone built and named all three; only the shape differed"
+
+
+def test_content_that_really_is_absent_is_still_reported():
+ out = contract_findings(_census(WRAPPED), _plan(["Windmill", "RopeBridge"]))
+ assert _missing(out) == ["RopeBridge"]
+
+
+def test_an_object_named_after_its_behaviour_still_reads_as_missing():
+ """`buildSnowyPineTree` was called and the objects were named `PineSway_N`. The tree is
+ there, and the gate still says so — naming it for the plan is what makes it findable."""
+ row = {"name": "Trees", "zone": "WindmillIsland", "inner": ["PineSway_0", "PineSway_1"]}
+ out = contract_findings(_census(row), _plan(["SnowyPineTree"]))
+ assert _missing(out) == ["SnowyPineTree"]
+ hint = " ".join(f.fix_hint for f in out if f.data.get("kind") == "missing_content")
+ assert "give the object the plan's name" in hint
+
+
+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"]