Skip to content

Official Codebase of 3DCodeVerse

Python

spatial: build.json is the one build status — build_last.json goes

gaoypengba8b08e6b400
diff --git a/harness/codeverse3d/languages/scene_threejs/__init__.py b/harness/codeverse3d/languages/scene_threejs/__init__.py
index 8e16f933..d5e7ca44 100644
--- a/harness/codeverse3d/languages/scene_threejs/__init__.py
+++ b/harness/codeverse3d/languages/scene_threejs/__init__.py
@@ -760,7 +760,7 @@ class SceneThreeJsRuntime(RuntimeDocs):
# 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))
+ ws.write_json(ws.artifacts / "build.json", res)
return res
diff --git a/harness/codeverse3d/proc.py b/harness/codeverse3d/proc.py
index 8e29eedb..004312c3 100644
--- a/harness/codeverse3d/proc.py
+++ b/harness/codeverse3d/proc.py
@@ -439,7 +439,7 @@ def write_json_atomic(path: Path, data: Any) -> None:
zero-byte JSON at the published path — and B's own ``replace()`` died with
FileNotFoundError. That is not hypothetical here: the scene track fans zone agents
out over ONE workspace root and every agent's MCP ``build`` tool writes
- ``artifacts/build_last.json`` and ``artifacts/measurement.json`` through this
+ ``artifacts/build.json`` and ``artifacts/measurement.json`` through this
function, and a clobbered ``run_state.json`` is an unresumable run
(``RunState.load`` refuses to guess). Last writer to rename still wins.
"""
diff --git a/harness/codeverse3d/spatial/tool_common.py b/harness/codeverse3d/spatial/tool_common.py
index 1c82cec4..cccafc49 100644
--- a/harness/codeverse3d/spatial/tool_common.py
+++ b/harness/codeverse3d/spatial/tool_common.py
@@ -66,25 +66,6 @@ def reference_path(ctx: ToolContext, index: int, *, tool: str) -> tuple[Path, di
return p, ref
-def _latest_build_status(ws: Workspace) -> dict[str, Any] | None:
- """The newest of ``artifacts/build_last.json`` (written by the build tools) and
- ``artifacts/build.json`` (written by the language runtimes), or None when
- neither is readable — a workspace whose GLB was placed by hand (tests,
- imports, first-measure flows) stays usable."""
- cands: list[tuple[float, Path]] = []
- for name in ("build_last.json", "build.json"):
- p = ws.artifacts / name
- try:
- cands.append((p.stat().st_mtime, p))
- except OSError:
- continue
- for _, p in sorted(cands, key=lambda c: c[0], reverse=True):
- data = read_json_or_none(p)
- if data is not None:
- return data
- return None
-
-
def glb_path(ctx: ToolContext) -> Path:
"""``artifacts/object.glb``, refusing when the LATEST build did not produce it.
@@ -92,7 +73,9 @@ def glb_path(ctx: ToolContext) -> Path:
texture tools) operate on the previous round's geometry as if it were current
after a failed or lint-blocked build."""
p = ctx.workspace.artifacts / "object.glb"
- status = _latest_build_status(ctx.workspace)
+ # build.json is THE build status: every runtime publishes its final BuildResult there and
+ # a lint refusal writes one too; unreadable/absent stays permissive (a GLB placed by hand)
+ status = read_json_or_none(ctx.workspace.artifacts / "build.json")
# status FIRST: a failed build publishes nothing, so the file is missing for a
# reason the agent needs — it was told "run build first" right after its build
# failed on RestPenetration and spent the rest of its turns looking for the
diff --git a/harness/codeverse3d/spatial/tools.py b/harness/codeverse3d/spatial/tools.py
index 9ba1b639..e08786c4 100644
--- a/harness/codeverse3d/spatial/tools.py
+++ b/harness/codeverse3d/spatial/tools.py
@@ -182,15 +182,15 @@ _LINT_WARNS_SHOWN = 10
def _lint_gate(ctx: ToolContext, rt: Any, *, verb: str) -> tuple[Observation | None, list[str]]:
"""Lint before any build-running tool builds: (refusal observation | None, warning
lines). Lint ERRORs skip the build (docs/DECISIONS.md L5) and are recorded as the
- LATEST build status — without that the previous round's build_last.json (ok: true)
- + object.glb stayed readable as current."""
+ LATEST build status — without that the previous build.json (ok: true) + object.glb
+ stayed readable as current."""
ws = ctx.workspace
lint: GateReport = rt.lint(ws)
errs = lint_lines(lint, ws.root, errors_only=True)
warns = lint_lines(lint, ws.root, errors_only=False)
if not errs:
return None, warns
- ws.write_json(ws.artifacts / "build_last.json",
+ ws.write_json(ws.artifacts / "build.json",
BuildResult(ok=False, language=language_of(ctx), error_type="LintError",
error_message="\n".join(errs)[:4000]))
text = f"LINT FAILED — fix these before {verb}:\n" + "\n".join(errs)
@@ -221,7 +221,6 @@ def build(ctx: ToolContext, args: NoArgs) -> Observation:
if refused is not None:
return refused
br: BuildResult = rt.build(ws, timeout_s=get_settings().limits.build_timeout_s)
- ws.write_json(ws.artifacts / "build_last.json", br)
if not br.ok:
return _build_failed(ctx, br, lint_warns)
numbers: dict[str, Any] = {"stage": "build", "ok": br.ok, "duration_ms": br.duration_ms}
@@ -671,7 +670,6 @@ def _run_build(ctx: ToolContext, *, times: list[float], width: int = 0, height:
if width and height:
kw.update(width=width, height=height)
br: BuildResult = rt.build(ws, **kw)
- ws.write_json(ws.artifacts / "build_last.json", br)
if not br.ok:
return _build_failed(ctx, br, warns), br, warns
return None, br, warns
diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.md
index 9a4d4727..d2ef7465 100644
--- a/harness/docs/INTERFACES.md
+++ b/harness/docs/INTERFACES.md
@@ -249,9 +249,10 @@ are the pure helpers `3dcode doctor` reuses for its `node` row.
## spatial/
-`tool_common.glb_path` refuses (`ToolUsageError`) when the newest of
-`build_last.json`/`build.json` says the last build failed — tools never measure or
-texture a stale GLB; missing/unreadable status stays permissive (hand-placed GLBs).
+`tool_common.glb_path` refuses (`ToolUsageError`) when `artifacts/build.json` says the last
+build failed — the one build status: every runtime publishes its final BuildResult there and
+a tool's lint refusal writes a `LintError` one (`build_last.json` is gone, 2026-09-22). Tools
+never measure or texture a stale GLB; missing/unreadable status stays permissive (hand-placed GLBs).
```python
from codeverse3d.spatial.render import render_glb
from codeverse3d.contracts.artifacts import RENDER_MODES # ('shaded','wire','normals','silhouette','clay') — THE mode tuple (no 'depth')
diff --git a/harness/tests/agents/test_materialize.py b/harness/tests/agents/test_materialize.py
index 661d47ab..1a14e700 100644
--- a/harness/tests/agents/test_materialize.py
+++ b/harness/tests/agents/test_materialize.py
@@ -87,7 +87,7 @@ def test_ignore_files_keep_agent_facing_paths_readable(tmp_ws: Workspace):
lines = tuple(ln for ln in (tmp_ws.root / f).read_text().splitlines() if ln.strip())
assert lines == IGNORE_LINES
assert "artifacts/" not in lines and "trajectories/" not in lines
- for readable in ("artifacts/census.json", "artifacts/build_last.json", "artifacts/measurement.json",
+ for readable in ("artifacts/census.json", "artifacts/build.json", "artifacts/measurement.json",
"artifacts/gates/r00/contract_tool.json", "artifacts/tool_renders/r00_ab/sheet.png",
"trajectories/baseline_r00/task_prompt.md", "src/model.py", ".3dcode/cookbook.md"):
assert not ignored(readable, lines), readable
diff --git a/harness/tests/graphics/test_stale_invalidation.py b/harness/tests/graphics/test_stale_invalidation.py
index 5b32fc56..22e6f973 100644
--- a/harness/tests/graphics/test_stale_invalidation.py
+++ b/harness/tests/graphics/test_stale_invalidation.py
@@ -60,14 +60,14 @@ def test_missing_entry_clears_frames_and_result(tmp_ws: Workspace) -> None:
assert json.loads((tmp_ws.artifacts / "build.json").read_text())["ok"] is False
-def test_gl_tool_lint_fail_records_failed_build_last(tmp_ws: Workspace) -> None:
+def test_gl_tool_lint_fail_records_the_failed_build_status(tmp_ws: Workspace) -> None:
"""A lint refusal in the gl tools is the LATEST build status — the previous
- round's build_last.json (ok: true) must not stay readable as current."""
+ round's build.json (ok: true) must not stay readable as current."""
(tmp_ws.src / "shader.frag").write_text(
"#version 330 core\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) { fragColor = vec4(1.0); }\n")
- tmp_ws.write_json(tmp_ws.artifacts / "build_last.json", {"ok": True})
+ tmp_ws.write_json(tmp_ws.artifacts / "build.json", {"ok": True})
ctx = ToolContext(workspace=tmp_ws, language="glsl_shader", track="graphics")
obs = get_tool("gl_probe").call(ctx, {})
assert not obs.ok and "LINT FAILED" in obs.text
- last = json.loads((tmp_ws.artifacts / "build_last.json").read_text())
+ last = json.loads((tmp_ws.artifacts / "build.json").read_text())
assert last["ok"] is False and last["error_type"] == "LintError"
diff --git a/harness/tests/spatial_tools/test_tools.py b/harness/tests/spatial_tools/test_tools.py
index 28f48b76..8ee36f24 100644
--- a/harness/tests/spatial_tools/test_tools.py
+++ b/harness/tests/spatial_tools/test_tools.py
@@ -115,10 +115,14 @@ class _FakeRuntime:
return GateReport(gate="lint:blender", passed=not self.lint_errors, findings=f)
def build(self, ws, *, timeout_s=None):
+ """Publishes its result as build.json — the contract every real runtime keeps."""
if self.build_ok:
- return BuildResult(ok=True, language="blender", glb_path=str(self.glb), duration_ms=12, census={"warnings": ["[EXPORT_WARN] no materials"]})
- return BuildResult(ok=False, language="blender", error_type="NameError", error_message="name 'bpyx' is not defined",
- error_file=str(ws.src / "model.py"), error_line=7, stderr_tail="\n".join(f"l{i}" for i in range(60)) + f"\n File \"{ws.src}/model.py\", line 7")
+ res = BuildResult(ok=True, language="blender", glb_path=str(self.glb), duration_ms=12, census={"warnings": ["[EXPORT_WARN] no materials"]})
+ else:
+ res = BuildResult(ok=False, language="blender", error_type="NameError", error_message="name 'bpyx' is not defined",
+ error_file=str(ws.src / "model.py"), error_line=7, stderr_tail="\n".join(f"l{i}" for i in range(60)) + f"\n File \"{ws.src}/model.py\", line 7")
+ ws.write_json(ws.artifacts / "build.json", res)
+ return res
def contract_doc(self):
return "# Fake contract\n\n## Export\nthe harness exports.\n"
@@ -137,8 +141,7 @@ def test_build_tool_success(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPa
assert obs.ok and obs.text.startswith("BUILD OK") and "Leg ×4" in obs.text
assert "lint warnings" in obs.text and "uses bpy.ops.render" in obs.text and "build warnings" in obs.text
assert str(stool_ctx.workspace.root) not in obs.text
- assert (stool_ctx.workspace.artifacts / "build_last.json").is_file()
- assert json.loads((stool_ctx.workspace.artifacts / "build_last.json").read_text())["ok"] is True
+ assert json.loads((stool_ctx.workspace.artifacts / "build.json").read_text())["ok"] is True
assert (stool_ctx.workspace.artifacts / "measurement.json").is_file()
@@ -205,13 +208,13 @@ def test_build_that_leaves_no_readable_glb_is_a_failure(stool_ctx: ToolContext,
def test_build_failure_refuses_stale_glb(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:
"""A failed build after a success: the old object.glb survives as evidence but
- glb_path refuses to treat it as current (build_last.json says ok:false)."""
+ glb_path refuses to treat it as current (build.json says ok:false)."""
_patch_runtime(monkeypatch, _FakeRuntime(glb=stool_ctx.workspace.artifacts / "object.glb"))
assert get_tool("build").call(stool_ctx, {}).ok
assert get_tool("measure").call(stool_ctx, {}).ok # ok:true status → still usable
_patch_runtime(monkeypatch, _FakeRuntime(build_ok=False))
assert not get_tool("build").call(stool_ctx, {}).ok
- assert json.loads((stool_ctx.workspace.artifacts / "build_last.json").read_text())["ok"] is False
+ assert json.loads((stool_ctx.workspace.artifacts / "build.json").read_text())["ok"] is False
assert (stool_ctx.workspace.artifacts / "object.glb").is_file() # evidence stays on disk
for name in ("measure", "render_views", "check_connectivity"):
obs = get_tool(name).call(stool_ctx, {})
@@ -219,23 +222,23 @@ def test_build_failure_refuses_stale_glb(stool_ctx: ToolContext, monkeypatch: py
def test_build_lint_fail_refuses_stale_glb(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:
- """A lint refusal is the latest build status: the previous build_last.json
+ """A lint refusal is the latest build status: the previous build.json
(ok: true) + object.glb are no longer readable as current."""
_patch_runtime(monkeypatch, _FakeRuntime(glb=stool_ctx.workspace.artifacts / "object.glb"))
assert get_tool("build").call(stool_ctx, {}).ok
_patch_runtime(monkeypatch, _FakeRuntime(lint_errors=True))
obs = get_tool("build").call(stool_ctx, {})
assert not obs.ok and obs.text.startswith("LINT FAILED")
- last = json.loads((stool_ctx.workspace.artifacts / "build_last.json").read_text())
+ last = json.loads((stool_ctx.workspace.artifacts / "build.json").read_text())
assert last["ok"] is False and last["error_type"] == "LintError"
obs = get_tool("measure").call(stool_ctx, {})
assert not obs.ok and "build FAILED" in obs.text
def test_hand_placed_glb_without_build_status_still_measures(stool_ctx: ToolContext) -> None:
- """No build_last.json / build.json → glb_path stays permissive: first-measure
- flows and hand-assembled (test/import) workspaces keep working."""
- assert not (stool_ctx.workspace.artifacts / "build_last.json").exists()
+ """No build.json → glb_path stays permissive: first-measure flows and
+ hand-assembled (test/import) workspaces keep working."""
+ assert not (stool_ctx.workspace.artifacts / "build.json").exists()
assert get_tool("measure").call(stool_ctx, {}).ok
@@ -562,7 +565,7 @@ def test_a_failed_build_tells_the_agent_WHY_not_to_build_again(tmp_ws):
ctx = ToolContext(workspace=tmp_ws, language="urdf_blender", track="articulated_object")
tmp_ws.artifacts.mkdir(parents=True, exist_ok=True)
- tmp_ws.write_json(tmp_ws.artifacts / "build_last.json",
+ tmp_ws.write_json(tmp_ws.artifacts / "build.json",
BuildResult(ok=False, language="urdf_blender", error_type="RestPenetration",
error_message="links interpenetrate by 140.0 mm at lid/base"))
with pytest.raises(ToolUsageError) as e: