Skip to content

Official Codebase of 3DCodeVerse

Python

spatial: plain imports instead of lazy()/ToolUnavailable; one AABB gap, one JSON side-car reader, one version probe

gaoypengeb4e51299043
diff --git a/harness/codeverse3d/spatial/complexity.py b/harness/codeverse3d/spatial/complexity.py
index c282dce1..46bdeeac 100644
--- a/harness/codeverse3d/spatial/complexity.py
+++ b/harness/codeverse3d/spatial/complexity.py
@@ -4,7 +4,7 @@
into a :class:`ComplexityVector`: eight measured axes plus one 0–1 ``index``
computed from documented weights. It answers "how much *thing* is actually
here?" so that a judge score can be read against the difficulty of what was
-built (docs/COMPLEXITY.md), and so a battery can state an expected complexity
+built (eval/docs/COMPLEXITY.md), and so a battery can state an expected complexity
band instead of a vibe.
The eight axes
@@ -34,7 +34,7 @@ The eight axes
``index`` is ``Σ wᵢ · normᵢ(axisᵢ)`` with the weights in
``COMPLEXITY_WEIGHTS`` and the saturating normalisers in ``_NORMALISERS`` (both
-public data; docs/COMPLEXITY.md records why each number is what it is). It is
+public data; eval/docs/COMPLEXITY.md records why each number is what it is). It is
a *difficulty* measure, never a *quality* measure: a rich broken model and a
rich good model score the same index.
"""
diff --git a/harness/codeverse3d/spatial/connectivity.py b/harness/codeverse3d/spatial/connectivity.py
index e328c566..c8922425 100644
--- a/harness/codeverse3d/spatial/connectivity.py
+++ b/harness/codeverse3d/spatial/connectivity.py
@@ -53,7 +53,7 @@ import trimesh
from codeverse3d.contracts.artifacts import GateFinding, GateReport, Severity
from codeverse3d.conventions import CONTACT_GAP_M, Frame
from codeverse3d.spatial import joints_collide as collide
-from codeverse3d.spatial.contract import frame_label, glb_vec_to_plan, language_frame
+from codeverse3d.spatial.contract import _aabb_gap, frame_label, glb_vec_to_plan, language_frame
from codeverse3d.spatial.joints_collide import fcl_collision_object, inside_island, oriented_islands
from codeverse3d.spatial.measure import GlbLoadError, fmt_vec, solid_parts
@@ -67,7 +67,7 @@ MIN_PART_SIZE_M = 0.01
#: inside each other as built". ``joint_sweep`` asks a different question on posed meshes
#: — "does moving a joint drive one link through another" — at its own thresholds. They
#: are not one check with two dials: do not align the numbers (DECISIONS.md D53, with the
-#: corpus measurement behind it in bench/penetration_thresholds.py).
+#: corpus measurement behind it in eval/bench/penetration_thresholds.py).
PENETRATION_WARN_M = 0.002
PENETRATION_ERROR_M = 0.010
#: fraction of one part's samples inside the other before we call it penetration ...
@@ -191,12 +191,6 @@ class _PartCache:
return self._thickness[name]
-def _aabb_gap(a: trimesh.Trimesh, b: trimesh.Trimesh) -> float:
- """Axis-aligned lower bound of the distance between two meshes."""
- lo = np.maximum(a.bounds[0] - b.bounds[1], b.bounds[0] - a.bounds[1])
- return float(np.linalg.norm(np.maximum(lo, 0.0)))
-
-
def pair_distance(
name_a: str,
a: trimesh.Trimesh,
@@ -520,7 +514,7 @@ def check_connectivity(
overlaps: list[tuple[str, str, Penetration]] = []
cache = _PartCache(parts) # one BVH / island split / thickness per part, shared across pairs
for a, b in itertools.combinations(big, 2):
- lower = _aabb_gap(parts[a], parts[b])
+ lower = _aabb_gap(parts[a].bounds, parts[b].bounds)
if lower > gap_m:
continue
pd = pair_distance(a, parts[a], b, parts[b], obj_a=cache.fcl(a), obj_b=cache.fcl(b))
@@ -651,7 +645,7 @@ def _nearest_supported(
"""
if not support:
return None
- ranked = sorted(support, key=lambda o: _aabb_gap(parts[n], parts[o]))[:n_candidates]
+ ranked = sorted(support, key=lambda o: _aabb_gap(parts[n].bounds, parts[o].bounds))[:n_candidates]
best: PairDistance | None = None
for o in ranked:
pd = exact.get((n, o)) or exact.get((o, n))
diff --git a/harness/codeverse3d/spatial/contract.py b/harness/codeverse3d/spatial/contract.py
index 88aea5a0..295b1ba9 100644
--- a/harness/codeverse3d/spatial/contract.py
+++ b/harness/codeverse3d/spatial/contract.py
@@ -68,7 +68,7 @@ _AXES = ("x", "y", "z")
# axis's own extent must not have moved by more than ORIENT_THIRD (sysprompt_ab
# b36_v0_01r: a table 1.38 m wide for a 0.48 m chair — wrong object, not rotated), and
# near-cubes say nothing (ORIENT_ANISO). Over every measured static_object round under
-# bench/out (629 measurements: 435 rounds + 194 final measurement.json, 217 runs) these
+# eval/bench/out (629 measurements: 435 rounds + 194 final measurement.json, 217 runs) these
# fire 0 times; on the brilliana c_clamp and gate_valve GLBs (both lying, by eye) they
# fire with the right axis.
ORIENT_FIT = float(np.log(1.25))
@@ -174,7 +174,8 @@ def planned_joins(plan: Plan | None, measurement: Measurement | None) -> list[tu
continue
parents = matched.get(pp.attach_to) or []
for child in matched.get(pp.name) or []:
- gaps = {p.name: _aabb_gap(child, p) for p in parents if p.name != child.name}
+ gaps = {p.name: _aabb_gap((child.bbox_min, child.bbox_max), (p.bbox_min, p.bbox_max))
+ for p in parents if p.name != child.name}
if not gaps:
continue
touching = [n for n, g in gaps.items() if g <= CONTACT_GAP_M]
@@ -182,10 +183,10 @@ def planned_joins(plan: Plan | None, measurement: Measurement | None) -> list[tu
return edges
-def _aabb_gap(a: PartMeasure, b: PartMeasure) -> float:
- """Euclidean distance between two axis-aligned boxes (0 when they overlap)."""
- lo_a, hi_a = np.asarray(a.bbox_min, dtype=float), np.asarray(a.bbox_max, dtype=float)
- lo_b, hi_b = np.asarray(b.bbox_min, dtype=float), np.asarray(b.bbox_max, dtype=float)
+def _aabb_gap(a: np.ndarray | tuple, b: np.ndarray | tuple) -> float:
+ """Euclidean distance between two boxes given as ``(min, max)`` corners, 0 when they
+ overlap (``connectivity`` feeds it ``trimesh.bounds``: a mesh pair's lower bound)."""
+ (lo_a, hi_a), (lo_b, hi_b) = np.asarray(a, dtype=float), np.asarray(b, dtype=float)
return float(np.linalg.norm(np.maximum(np.maximum(lo_a - hi_b, lo_b - hi_a), 0.0)))
diff --git a/harness/codeverse3d/spatial/frame_metrics.py b/harness/codeverse3d/spatial/frame_metrics.py
index 882e6047..a9a224d6 100644
--- a/harness/codeverse3d/spatial/frame_metrics.py
+++ b/harness/codeverse3d/spatial/frame_metrics.py
@@ -18,11 +18,11 @@ place them) except for the content-sparse overview, which is informational.
from __future__ import annotations
-import json
from pathlib import Path
from typing import Any
from codeverse3d.contracts.artifacts import GateFinding, GateReport, RenderSet, Severity
+from codeverse3d.proc import read_json_or_none
from codeverse3d.spatial.frame_motion import MotionRow, motion_summary_text, scene_moves
FRAME_GATE = "scene_frames"
@@ -437,11 +437,8 @@ def frame_gate_from_renders(source: RenderSet | Path | str) -> GateReport:
else:
p = Path(source)
path = p if p.is_file() else (p / "metrics.json" if (p / "metrics.json").is_file() else None)
- if path is None:
- return GateReport(gate=FRAME_GATE, passed=True, findings=[])
- try:
- metrics = json.loads(path.read_text())
- except (OSError, ValueError):
+ metrics = read_json_or_none(path) if path is not None else None
+ if metrics is None:
return GateReport(gate=FRAME_GATE, passed=True, findings=[])
return frame_findings(metrics)
diff --git a/harness/codeverse3d/spatial/frame_motion.py b/harness/codeverse3d/spatial/frame_motion.py
index 3959a1b8..34fb48d3 100644
--- a/harness/codeverse3d/spatial/frame_motion.py
+++ b/harness/codeverse3d/spatial/frame_motion.py
@@ -17,7 +17,6 @@ context and into the ``scene_frames`` gate.
from __future__ import annotations
-import json
import logging
from collections.abc import Sequence
from dataclasses import dataclass
@@ -27,6 +26,8 @@ from typing import Any
import numpy as np
from PIL import Image
+from codeverse3d.proc import read_json_or_none
+
#: per-channel 0..255 difference above which a pixel counts as changed
PIXEL_DELTA = 8
#: share of changed pixels at (or above) which a camera counts as showing motion
@@ -154,11 +155,8 @@ def motion_summary_text(rows: Sequence[MotionRow], *, max_rows: int = 10) -> str
def motion_from_dir(out_dir: Path | str) -> list[MotionRow]:
"""Convenience: read ``<out_dir>/metrics.json`` and measure it."""
d = Path(out_dir)
- try:
- metrics = json.loads((d / "metrics.json").read_text())
- except (OSError, ValueError):
- return []
- return motion_rows(metrics, d)
+ metrics = read_json_or_none(d / "metrics.json")
+ return [] if metrics is None else motion_rows(metrics, d)
def motion_text_for(out_dir: Path | str) -> str:
diff --git a/harness/codeverse3d/spatial/node.py b/harness/codeverse3d/spatial/node.py
index cfa3b39c..6002eec2 100644
--- a/harness/codeverse3d/spatial/node.py
+++ b/harness/codeverse3d/spatial/node.py
@@ -15,14 +15,13 @@ import json
import os
import re
import resource
-import subprocess
from dataclasses import dataclass
from functools import lru_cache
from pathlib import Path
from typing import Any
from codeverse3d.config import get_settings
-from codeverse3d.proc import run_subprocess, scrub_secrets
+from codeverse3d.proc import run_subprocess, scrub_secrets, version_line
TAIL_CHARS = 4000
@@ -167,12 +166,8 @@ def node_version(node_bin: str) -> tuple[int, int, int] | None:
Cached per binary: this runs at most once per interpreter per node path.
"""
- try:
- proc = subprocess.run([node_bin, "--version"], capture_output=True, text=True,
- timeout=20, check=False)
- except (OSError, subprocess.SubprocessError):
- return None
- return parse_node_version(proc.stdout or proc.stderr) if proc.returncode == 0 else None
+ rc, line = version_line([node_bin, "--version"], timeout=20)
+ return parse_node_version(line) if rc == 0 else None
def node_version_error(version: tuple[int, int, int] | None) -> str:
diff --git a/harness/codeverse3d/spatial/registry.py b/harness/codeverse3d/spatial/registry.py
index a620638c..fc6f1b3d 100644
--- a/harness/codeverse3d/spatial/registry.py
+++ b/harness/codeverse3d/spatial/registry.py
@@ -10,8 +10,7 @@ Usage::
``ToolContext`` carries the workspace and settings; tools never touch globals.
``ToolDef.call`` is the one error boundary: ``ToolUsageError`` becomes a usage
-Observation, ``ToolUnavailable`` (a missing sibling package) an "unavailable"
-one, anything else a failed Observation — a tool body never needs try/except.
+Observation, anything else a failed Observation — a tool body never needs try/except.
Observations: ``text`` (what the agent reads), ``numbers`` (machine-readable),
``images`` (paths, small PNGs the agent may view), ``ok`` (the VERDICT) and
``failed`` (the tool could not run). The two are different answers and only
@@ -77,18 +76,6 @@ class Observation(BaseModel):
return cls(ok=False, failed=True, text=text, numbers=numbers)
-class ToolUnavailable(RuntimeError):
- """A sibling package a tool depends on is not importable / not built yet.
-
- Raised by ``tool_common.lazy`` (and anything built on it) and turned into a
- ``tool <name> unavailable: ...`` Observation by :meth:`ToolDef.call` — tools
- never have to catch it themselves. The boundary is real only for
- ``codeverse3d.languages`` (the runtimes) and ``codeverse3d.texturing``; everything
- under ``codeverse3d.spatial`` is imported eagerly (2026-08-29: string paths for
- intra-package imports hid ordinary imports from go-to-definition).
- """
-
-
class ToolUsageError(ValueError):
"""Raised by tools on caller mistakes; ``fix_example`` is shown to the agent."""
@@ -155,8 +142,6 @@ class ToolDef:
obs = self.fn(ctx, args)
except ToolUsageError as e:
obs = Observation.error(f"{self.name}: {e}" + (f"\nExample: {e.fix_example}" if e.fix_example else ""))
- except ToolUnavailable as e: # a sibling package is missing → degrade, never crash
- obs = Observation.error(f"tool {self.name} unavailable: {type(e).__name__}: {e}")
except Exception as e: # never crash the agent loop
obs = Observation.error(f"{self.name} failed: {type(e).__name__}: {e}")
obs.duration_ms = int((time.time() - t0) * 1000)
@@ -216,16 +201,9 @@ _LOADED = False
def _ensure_loaded() -> None:
- """Import the modules that register tools (idempotent)."""
+ """Import the module that registers every tool (idempotent)."""
global _LOADED
if _LOADED:
return
_LOADED = True
- import importlib
-
- for mod in ("codeverse3d.spatial.tools",):
- try:
- importlib.import_module(mod)
- except ModuleNotFoundError as e: # during bootstrap only
- if mod not in str(e):
- raise
+ import codeverse3d.spatial.tools # noqa: F401 — its @tool decorators fill _REGISTRY
diff --git a/harness/codeverse3d/spatial/scene_placement.py b/harness/codeverse3d/spatial/scene_placement.py
index 6756ff27..6d64a576 100644
--- a/harness/codeverse3d/spatial/scene_placement.py
+++ b/harness/codeverse3d/spatial/scene_placement.py
@@ -373,7 +373,7 @@ 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
+ planned asset from this check: `eval/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.
"""
diff --git a/harness/codeverse3d/spatial/tool_common.py b/harness/codeverse3d/spatial/tool_common.py
index 7fb68e0e..1c82cec4 100644
--- a/harness/codeverse3d/spatial/tool_common.py
+++ b/harness/codeverse3d/spatial/tool_common.py
@@ -1,7 +1,5 @@
-"""Shared plumbing for the spatial tools: context lookups, lazy imports of the
-optional siblings (``codeverse3d.languages`` runtimes, ``codeverse3d.texturing``, the
-node renderer) with a typed ``ToolUnavailable`` failure, render-output caching
-and plan/spec loading.
+"""Shared plumbing for the spatial tools: context lookups, render-output caching and
+plan/spec loading.
Tools never touch globals: everything flows through :class:`ToolContext`.
"""
@@ -9,9 +7,8 @@ Tools never touch globals: everything flows through :class:`ToolContext`.
from __future__ import annotations
import hashlib
-import importlib
import json
-from collections.abc import Callable, Sequence
+from collections.abc import Sequence
from pathlib import Path
from typing import Any
@@ -21,11 +18,11 @@ from codeverse3d.contracts.artifacts import RENDER_MODES, RenderSet, Severity
from codeverse3d.contracts.plan import ArticulatedPlan, GraphicsPlan, Plan, ScenePlan, StaticPlan
from codeverse3d.conventions import OBJECT_VIEWS, ViewPreset
from codeverse3d.proc import read_json_or_none
-from codeverse3d.spatial.registry import ToolContext, ToolUnavailable, ToolUsageError
+from codeverse3d.spatial.registry import ToolContext, ToolUsageError
from codeverse3d.workspace import Workspace
__all__ = [
- "ToolUnavailable", "lazy", "spec_dict", "language_of",
+ "spec_dict", "language_of",
"glb_path", "reference_path", "load_plan", "resolve_views", "check_mode", "tool_out_dir", "render_cache_dir",
"cached_render_glb", "gl_metrics_summary", "VIEW_BY_NAME", "RENDER_MODES",
]
@@ -33,34 +30,12 @@ __all__ = [
VIEW_BY_NAME: dict[str, ViewPreset] = {v.name: v for v in OBJECT_VIEWS}
-#: ``ToolUnavailable`` now lives in ``registry`` (``ToolDef.call`` catches it for
-#: every tool); re-exported here because that is where tools import it from.
-
-
-def lazy(module: str, attr: str) -> Callable[..., Any]:
- """Import ``module.attr`` now; raise :class:`ToolUnavailable` with a clear reason."""
- try:
- mod = importlib.import_module(module)
- except Exception as e: # ModuleNotFoundError, SyntaxError in a sibling, ...
- raise ToolUnavailable(f"{module} not importable ({type(e).__name__}: {e})") from e
- fn = getattr(mod, attr, None)
- if fn is None:
- raise ToolUnavailable(f"{module} has no '{attr}'")
- return fn
-
-
# --------------------------------------------------------------------------- context
def spec_dict(ctx: ToolContext) -> dict[str, Any]:
spec = ctx.extra.get("spec")
if spec is not None:
return spec.model_dump(mode="json") if hasattr(spec, "model_dump") else dict(spec)
- p = ctx.workspace.spec_path
- if p.is_file():
- try:
- return json.loads(p.read_text())
- except json.JSONDecodeError:
- return {}
- return {}
+ return read_json_or_none(ctx.workspace.spec_path) or {}
def language_of(ctx: ToolContext) -> str:
@@ -217,14 +192,13 @@ def cached_render_glb(
one. ``render_glb``'s key (sha256 of the GLB + CACHE_VERSION + the rig signature)
has none of those holes, so one authority is both cheaper and correct.
"""
+ # resolved at call time: tests patch the module attribute
+ from codeverse3d.spatial.render import render_glb
+
out_dir = render_cache_dir(ctx, glb, views=[v.name for v in views], mode=mode, size=size,
isolate=list(isolate or []), explode=explode, sheet=sheet)
- render_glb = lazy("codeverse3d.spatial.render", "render_glb")
- rs = render_glb(glb, out_dir, views=list(views), mode=mode, width=size, height=size,
- isolate=list(isolate) if isolate else None, explode=explode, sheet=sheet)
- if not isinstance(rs, RenderSet):
- raise ToolUnavailable(f"render_glb returned {type(rs).__name__}, expected RenderSet")
- return rs
+ return render_glb(glb, out_dir, views=list(views), mode=mode, width=size, height=size,
+ isolate=list(isolate) if isolate else None, explode=explode, sheet=sheet)
# --------------------------------------------------------------------------- graphics metrics
@@ -237,13 +211,10 @@ def gl_metrics_summary(ws: Workspace, *, hints: bool = True, root: Path | None =
hint; ``root`` sanitises workspace paths out of the messages. Returns
``(["(no frame metrics)"], {}, True)`` when the build wrote none.
"""
+ from codeverse3d.languages._gl_common import read_metrics
from codeverse3d.spatial.observe import sanitize_text
- try:
- read_metrics = lazy("codeverse3d.languages._gl_common", "read_metrics")
- m = read_metrics(ws)
- except ToolUnavailable:
- m = None
+ m = read_metrics(ws)
if m is None:
return ["(no frame metrics)"], {}, True
stats, gate = m
diff --git a/harness/codeverse3d/spatial/tools.py b/harness/codeverse3d/spatial/tools.py
index ef685323..9ba1b639 100644
--- a/harness/codeverse3d/spatial/tools.py
+++ b/harness/codeverse3d/spatial/tools.py
@@ -69,7 +69,6 @@ from codeverse3d.spatial.tool_common import (
gl_metrics_summary,
glb_path,
language_of,
- lazy,
load_plan,
reference_path,
render_cache_dir,
@@ -213,9 +212,11 @@ def _build_failed(ctx: ToolContext, br: BuildResult, warns: list[str]) -> Observ
describe_extra=lambda: _BUILD_INCLUDES_CHECKS if fewer_turns_enabled() else "")
def build(ctx: ToolContext, args: NoArgs) -> Observation:
# ToolDef.call stamps Observation.duration_ms for every tool — no timing here
+ from codeverse3d.languages import get_runtime
+
ws = ctx.workspace
language = language_of(ctx)
- rt = lazy("codeverse3d.languages", "get_runtime")(language)
+ rt = get_runtime(language)
refused, lint_warns = _lint_gate(ctx, rt, verb="building")
if refused is not None:
return refused
@@ -366,8 +367,6 @@ class RenderViewsArgs(BaseModel):
def _render(ctx: ToolContext, *, views: list[str], mode: str, isolate: list[str], explode: float, size: int, note: str = "") -> Observation:
- # a missing renderer raises ToolUnavailable → ToolDef.call turns it into the
- # "tool <name> unavailable" Observation (one error boundary for every tool)
glb = glb_path(ctx)
presets = resolve_views(views)
check_mode(mode)
@@ -653,18 +652,16 @@ class GlFramesArgs(BaseModel):
def _runtime(ctx: ToolContext):
+ from codeverse3d.languages import get_runtime
+
lang = language_of(ctx)
if lang not in GRAPHICS_LANGS:
raise ToolUsageError(f"gl tools only apply to {GRAPHICS_LANGS}; workspace language is {lang!r}")
- get_runtime = lazy("codeverse3d.languages", "get_runtime")
return get_runtime(lang)
def _run_build(ctx: ToolContext, *, times: list[float], width: int = 0, height: int = 0) -> tuple[Observation | None, BuildResult | None, list[str]]:
- """Lint → build; returns (error observation | None, build, lint warnings).
-
- A missing runtime raises ToolUnavailable — ``ToolDef.call`` reports it.
- """
+ """Lint → build; returns (error observation | None, build, lint warnings)."""
ws = ctx.workspace
rt = _runtime(ctx)
refused, warns = _lint_gate(ctx, rt, verb="rendering")
@@ -748,9 +745,10 @@ def _spec_plan(ctx: ToolContext) -> tuple[Spec, StaticPlan]:
"analytic UVs + PBR materials → artifacts/object_textured.glb, shipped only if the judge score does not drop.",
tracks=_OBJECT_TRACKS, cost_hint="slow")
def texture_pass_tool(ctx: ToolContext, args: TexturePassArgs) -> Observation:
+ from codeverse3d.texturing.run import texture_pass, texture_requested
+
glb = glb_path(ctx)
spec, plan = _spec_plan(ctx)
- texture_requested = lazy("codeverse3d.texturing.run", "texture_requested")
if not texture_requested(spec):
# ONE owner for "does this run texture?" (codeverse3d.texturing.run.texture_requested).
# The tool is registered for every object track, so without this an agent could —
@@ -759,7 +757,6 @@ def texture_pass_tool(ctx: ToolContext, args: TexturePassArgs) -> Observation:
"this run did not ask for texturing (spec.options.texture is false), so the "
"texture pass is off; finish the geometry instead",
"3dcode make ... --texture # or `3dcode texture pass <slug>` after the run")
- texture_pass = lazy("codeverse3d.texturing.run", "texture_pass")
services = ctx.extra.get("texture_services") # the ONE injection point (TextureServices)
# update_record=False: during an agent session the control files have ONE owner
# (finalise); a mid-session record.json write is reverted by the tamper enforcement
diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.md
index c9e50f7f..aeee451c 100644
--- a/harness/docs/ARCHITECTURE.md
+++ b/harness/docs/ARCHITECTURE.md
@@ -132,8 +132,8 @@ codeverse3d/
complexity.py (objective complexity vector -> Measurement.extra, eval/docs/COMPLEXITY.md),
joints*.py + joints_collide.py (deterministic penetration), registry.py,
tools.py (every @tool registration since 2026-08-28, the joint_sweep body included;
- spatial siblings are plain imports — lazy() guards only codeverse3d.languages /
- codeverse3d.texturing and tool_common's node renderer), mcp_server.py (MCP name: 3dcode).
+ every import is a plain one — codeverse3d.languages / codeverse3d.texturing
+ are imported inside the tool bodies), mcp_server.py (MCP name: 3dcode).
Render modes are contracts.artifacts.RENDER_MODES (shaded wire normals silhouette
clay — no 'depth'); build error_type spellings are languages/_common.MISSING_ENTRY
("MissingEntryFile") and BUILD_TIMEOUT ("BuildTimeout") for every runtime
diff --git a/harness/docs/COST.md b/harness/docs/COST.md
index 0cf6916c..f1dba549 100644
--- a/harness/docs/COST.md
+++ b/harness/docs/COST.md
@@ -1444,7 +1444,7 @@ the 19 without (confounded — those are also the articulated runs — but it po
A second flag, not a threshold. `Observation.failed` is what the MCP server reports as
`is_error`; `ok` stays the verdict. `Observation.error` builds every failure caught at the
-`ToolDef.call` boundary (exception, `ToolUnavailable`, `ToolUsageError`, missing or
+`ToolDef.call` boundary (exception, `ToolUsageError`, missing or
unreadable artefact), and three tools set `failed` on a result they compose themselves,
where the failure is a fact about the result rather than an exception. Which places those
are is a property of the code, so the list lives there (`spatial/registry.Observation.error`)
diff --git a/harness/tests/spatial_tools/test_render_common.py b/harness/tests/spatial_tools/test_render_common.py
index 06551b5c..216e4470 100644
--- a/harness/tests/spatial_tools/test_render_common.py
+++ b/harness/tests/spatial_tools/test_render_common.py
@@ -1,6 +1,6 @@
"""The shared render/tool core: `spatial._render_common`, the sheet + gif writers,
-`measure.solid_parts`, `tool_common` helpers and the central ToolUnavailable
-boundary. Each test pins one merge that removed a duplicate implementation.
+`measure.solid_parts` and the `tool_common` helpers. Each test pins one merge that
+removed a duplicate implementation.
"""
from __future__ import annotations
@@ -13,7 +13,7 @@ from PIL import Image
from codeverse3d.conventions import OBJECT_VIEWS, SCENE_VIEWS
from codeverse3d.spatial import _render_common as rc
-from codeverse3d.spatial.registry import ToolContext, ToolUnavailable, get_tool
+from codeverse3d.spatial.registry import ToolContext
from codeverse3d.workspace import Workspace
@@ -136,7 +136,7 @@ def test_cached_render_glb_leaves_the_cache_to_render_glb(stool_ctx: ToolContext
png.write_bytes(b"png")
return RenderSet(views=[RenderView(name=views[0].name, path=str(png))], contact_sheet=None)
- monkeypatch.setattr(tc, "lazy", lambda module, attr: fake_render_glb)
+ monkeypatch.setattr("codeverse3d.spatial.render.render_glb", fake_render_glb)
glb = stool_ctx.workspace.artifacts / "object.glb"
preset = OBJECT_VIEWS[0]
first = tc.cached_render_glb(stool_ctx, glb, views=[preset])
@@ -222,27 +222,6 @@ def test_object_render_cache_is_keyed_by_gpu_mode(stool_glb: Path, tmp_path: Pat
assert len(runs) == 2 and c.renderer == "webgl-on", "same mode still hits the cache"
-def test_tool_unavailable_is_reported_by_the_registry(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:
- """No tool catches ToolUnavailable itself any more — ToolDef.call does it for
- all of them, with the tool's own registered name."""
- import codeverse3d.spatial.tool_common as tc
-
- def boom(module, attr):
- raise ToolUnavailable(f"{module} not importable")
-
- monkeypatch.setattr(tc, "lazy", boom)
- monkeypatch.setattr("codeverse3d.spatial.tools.lazy", boom)
- ws = stool_ctx.workspace
- (ws.artifacts / "object_textured.glb").write_bytes((ws.artifacts / "object.glb").read_bytes())
- for name in ("build", "render_views", "texture_preview"):
- obs = get_tool(name).call(stool_ctx, {})
- assert not obs.ok and obs.text.startswith(f"tool {name} unavailable:"), (name, obs.text)
- # a graphics workspace: the gl tools degrade the same way
- gl_ctx = ToolContext(workspace=stool_ctx.workspace, language="glsl_shader", track="graphics")
- obs = get_tool("gl_probe").call(gl_ctx, {})
- assert not obs.ok and obs.text.startswith("tool gl_probe unavailable:"), obs.text
-
-
def test_gl_metrics_summary_is_the_one_frame_stats_formatter(tmp_ws: Workspace, monkeypatch: pytest.MonkeyPatch) -> None:
from codeverse3d.contracts.artifacts import GateFinding, GateReport, Severity
from codeverse3d.spatial.frame_stats import FrameStat, SequenceStats
diff --git a/harness/tests/spatial_tools/test_tools.py b/harness/tests/spatial_tools/test_tools.py
index a3a6aec2..28f48b76 100644
--- a/harness/tests/spatial_tools/test_tools.py
+++ b/harness/tests/spatial_tools/test_tools.py
@@ -344,21 +344,6 @@ def test_compare_silhouette_tool(stool_ctx: ToolContext, fake_renderer) -> None:
assert not obs.ok and "out of range" in obs.text
-def test_texture_tools_degrade_when_texturing_is_unavailable(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:
- """`lazy` guards only the optional siblings (codeverse3d.languages / codeverse3d.texturing);
- spatial-on-spatial imports are ordinary imports since 2026-08-29."""
- import codeverse3d.spatial.tool_common as tc
- import codeverse3d.spatial.tools as ts
-
- def boom(module, attr):
- raise tc.ToolUnavailable(f"{module} not importable")
-
- monkeypatch.setattr(ts, "lazy", boom)
- stool_ctx.workspace.write_json(stool_ctx.workspace.plan_path, _stool_plan_with_missing_backrest())
- obs = get_tool("texture_pass").call(stool_ctx, {})
- assert not obs.ok and obs.text.startswith("tool texture_pass unavailable:"), obs.text
-
-
def test_scene_tools_with_fake_siblings(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:
import codeverse3d.spatial.tools as ts
from codeverse3d.spatial.probes import SceneProbeResult