Official Codebase of 3DCodeVerse
Python
the scene track reaches its language only through SceneRuntime: no stage, service, tool or evaluator imports scene_threejs (D101)
gaoypeng915757840284
diff --git a/eval/bench/_fixed_eval.py b/eval/bench/_fixed_eval.pyindex 347ce981..57805177 100644--- a/eval/bench/_fixed_eval.py+++ b/eval/bench/_fixed_eval.py@@ -162,9 +162,8 @@ class FixedEvaluator:out.renders = frames_render_set(ws, build, 0)elif spec.track is Track.SCENE:from codeverse3d.spatial.frame_metrics import frame_gate_from_renders- from codeverse3d.spatial.render_scene import render_scene- out.renders = render_scene(ws, ws.renders_dir(0), orbit=True, times=(0.0, 1.5), sheet=True)+ out.renders = self.runtime(spec.language).render_scene(ws, ws.renders_dir(0), orbit=True, times=(0.0, 1.5), sheet=True)out.gates.append(frame_gate_from_renders(ws.renders_dir(0)))else:out.measurement, gate, out.renders, geometry = glb_evidence(diff --git a/eval/tests/test_fixed_eval_language.py b/eval/tests/test_fixed_eval_language.pyindex 8a603fcc..1a25d5ed 100644--- a/eval/tests/test_fixed_eval_language.py+++ b/eval/tests/test_fixed_eval_language.py@@ -82,13 +82,14 @@ def test_scene_cells_are_judged_on_their_cameras_and_orbit_frames(monkeypatch, tpng.write_bytes(b"\x89PNG\r\n\x1a\n" + b"\x00" * 16)build = BuildResult(ok=True, language="scene_threejs", glb_path=None)ev = FixedEvaluator("fake:judge", n_samples=1)- ev._runtimes[Language.SCENE_THREEJS] = SimpleNamespace(lint=lambda ws: GateReport(gate="lint", passed=True), build=lambda ws, timeout_s: build)+ seen: dict[str, object] = {}+ # the cell renders through ITS runtime (SceneRuntime.render_scene, D101), never a language module+ ev._runtimes[Language.SCENE_THREEJS] = SimpleNamespace(+ lint=lambda ws: GateReport(gate="lint", passed=True), build=lambda ws, timeout_s: build,+ render_scene=lambda ws, out, **kw: (seen.__setitem__("kw", kw),+ RenderSet(views=[RenderView(name="Establishing_t0", path=str(png))], renderer="fake"))[1])import bench._fixed_eval as feimport codeverse3d.spatial.frame_metrics as fm- import codeverse3d.spatial.render_scene as rs- seen: dict[str, object] = {}- monkeypatch.setattr(rs, "render_scene", lambda ws, out, **kw: (seen.__setitem__("kw", kw),- RenderSet(views=[RenderView(name="Establishing_t0", path=str(png))], renderer="fake"))[1])monkeypatch.setattr(fm, "frame_gate_from_renders", lambda src: GateReport(gate="scene_frames", passed=True))class _J:diff --git a/harness/codeverse3d/cli/inspect_cmd.py b/harness/codeverse3d/cli/inspect_cmd.pyindex fa172244..1c78dafb 100644--- a/harness/codeverse3d/cli/inspect_cmd.py+++ b/harness/codeverse3d/cli/inspect_cmd.py@@ -64,15 +64,16 @@ def render(# rendering, so a CLI render did not match the one the judge sawr = get_settings().renderif spec.track is Track.SCENE:- from codeverse3d.spatial.render_scene import render_scene+ from codeverse3d.languages import get_runtimefrom codeverse3d.spatial.tool_common import load_planfrom codeverse3d.tracks.scene import SCENE_TIMES# the in-run rig (tracks/scene.ScenePipeline.render): the plan's cameras at the judged# times — not the cameras createScene() authored, which the judge never saw on their ownplan = load_plan(ws.plan_path) if ws.plan_path.is_file() else None- rs = render_scene(ws, out_dir, cameras=list(plan.cameras) if isinstance(plan, ScenePlan) else None,- times=SCENE_TIMES, width=width or r.scene_width, height=height or r.scene_height)+ rs = get_runtime(spec.language).render_scene( # a scene language's runtime is a SceneRuntime (D101)+ ws, out_dir, cameras=list(plan.cameras) if isinstance(plan, ScenePlan) else None,+ times=SCENE_TIMES, width=width or r.scene_width, height=height or r.scene_height)else:glb = ws.artifacts / "object.glb"if not glb.is_file():diff --git a/harness/codeverse3d/languages/base.py b/harness/codeverse3d/languages/base.pyindex 4cce3411..3b272740 100644--- a/harness/codeverse3d/languages/base.py+++ b/harness/codeverse3d/languages/base.py@@ -10,17 +10,22 @@ Runtimes never import agent code into the harness process.from __future__ import annotations-from collections.abc import Callable+from collections.abc import Callable, Sequencefrom importlib import import_modulefrom pathlib import Path-from typing import Protocol, runtime_checkable+from typing import TYPE_CHECKING, Protocol, runtime_checkable-from codeverse3d.contracts.artifacts import BuildResult, GateReport+from pydantic import BaseModel++from codeverse3d.contracts.artifacts import BuildResult, GateReport, RenderSetfrom codeverse3d.contracts.common import ENTRY_FILE, Language-from codeverse3d.contracts.plan import Plan+from codeverse3d.contracts.plan import AssetPlan, CameraPlan, Plan, ScenePlanfrom codeverse3d.conventions import to_snakefrom codeverse3d.workspace import Workspace+if TYPE_CHECKING:+ from codeverse3d.spatial.probes import SceneProbeResult+@runtime_checkableclass LanguageRuntime(Protocol):@@ -50,6 +55,36 @@ class LanguageRuntime(Protocol):...+@runtime_checkable+class SceneRuntime(LanguageRuntime, Protocol):+ """What the scene track asks of its language (D101): where a zone / asset lives, how the+ entry is assembled from the zones, how the built scene is probed and rendered. The scene+ stages, ``Services`` and the scene tools reach a scene language only through this."""++ def zone_file(self, name: str) -> str:+ """The module that builds zone ``name`` (``src/zones/<snake>.<ext>``)."""+ ...++ def asset_file(self, asset: AssetPlan) -> str:+ """The file an asset ships as: its factory module, or a hero's GLB."""+ ...++ def assemble(self, ws: Workspace, plan: ScenePlan) -> BaseModel:+ """Write the entry file from the zones that load (the plan's cameras, else derived ones);+ the result lands in ``artifacts/assemble.json``."""+ ...++ def probe(self, ws: Workspace, *, timeout_s: float = 60.0) -> SceneProbeResult:+ """Load the built scene headlessly: the ``scene_probe`` gate + the census (``census.json``)."""+ ...++ def render_scene(self, ws: Workspace, out_dir: Path, *, cameras: list[CameraPlan] | None = None, orbit: bool = True,+ times: Sequence[float] = (0.0, 1.5), width: int = 1024, height: int = 576,+ sheet: bool = True) -> RenderSet:+ """Authored cameras (+ the orbit rig) × ``times`` → views, metrics.json, the contact sheet."""+ ...++class RuntimeLayout:"""``expected_files`` / ``files_for`` for a runtime whose entry file (+ ``extra_files``) ownsthe whole artifact — or, when it sets ``part_file``, one file per plan part too. The scenediff --git a/harness/codeverse3d/languages/scene_threejs/__init__.py b/harness/codeverse3d/languages/scene_threejs/__init__.pyindex aa967d4d..7ac3e69c 100644--- a/harness/codeverse3d/languages/scene_threejs/__init__.py+++ b/harness/codeverse3d/languages/scene_threejs/__init__.py@@ -4,8 +4,9 @@ from __future__ import annotationsimport reimport time+from collections.abc import Sequencefrom pathlib import Path-from typing import Any+from typing import TYPE_CHECKING, Anyfrom pydantic import BaseModel, Field@@ -32,6 +33,9 @@ from codeverse3d.languages._js_lint import ()from codeverse3d.workspace import Workspace+if TYPE_CHECKING:+ from codeverse3d.spatial.probes import SceneProbeResult+# ===================================================================== lintGATE = "lint:scene_threejs"MAX_LINES = 800@@ -699,9 +703,27 @@ class SceneThreeJsRuntime:language = Language.SCENE_THREEJSentry_globs: tuple[str, ...] = (ENTRY_FILE[Language.SCENE_THREEJS], "src/zones/*.js", "src/assets/*.js", "src/env.js", "src/shaders/*.js")+ zone_file = staticmethod(zone_file)+ asset_file = staticmethod(asset_file)+def expected_files(self, plan: Plan | None) -> list[str]:return list(SCENE_FILES)+ def assemble(self, ws: Workspace, plan: ScenePlan) -> AssembleResult:+ return assemble(ws, plan, cameras="plan" if getattr(plan, "cameras", None) else "derive")++ def probe(self, ws: Workspace, *, timeout_s: float = 60.0) -> SceneProbeResult:+ from codeverse3d.spatial.probes import probe_scene++ return probe_scene(ws, timeout_s=timeout_s)++ def render_scene(self, ws: Workspace, out_dir: Path, *, cameras: list[CameraPlan] | None = None, orbit: bool = True,+ times: Sequence[float] = (0.0, 1.5), width: int = 1024, height: int = 576,+ sheet: bool = True) -> RenderSet:+ from codeverse3d.spatial.render_scene import render_scene++ return render_scene(ws, out_dir, cameras=cameras, orbit=orbit, times=tuple(times), width=width, height=height, sheet=sheet)+def files_for(self, plan: Plan | None, target: str, *, alias: dict[str, str] | None = None) -> list[str]:return scene_files_for(plan, target, alias=alias)diff --git a/harness/codeverse3d/spatial/scene_placement.py b/harness/codeverse3d/spatial/scene_placement.pyindex b77c82b6..d81a757a 100644--- a/harness/codeverse3d/spatial/scene_placement.py+++ b/harness/codeverse3d/spatial/scene_placement.py@@ -25,8 +25,8 @@ from __future__ import annotationsimport functoolsimport logging-from collections.abc import Sequence-from typing import Any+from collections.abc import Callable, Sequence+from typing import TYPE_CHECKING, Anyfrom pydantic import BaseModel, ConfigDict, Field@@ -36,6 +36,9 @@ from codeverse3d.proc import read_json_or_nonefrom codeverse3d.spatial.node import runtime_js_dirfrom codeverse3d.workspace import Workspace+if TYPE_CHECKING:+ from codeverse3d.spatial.probes import SceneProbeResult+log = logging.getLogger(__name__)GATE = "scene_placement"@@ -588,15 +591,15 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,return out-def placement_census(ws: Workspace, *, force_probe: bool = False, timeout_s: float = 60.0) -> dict[str, Any]:+def placement_census(ws: Workspace, probe: Callable[..., SceneProbeResult], *, force_probe: bool = False,+ timeout_s: float = 60.0) -> dict[str, Any]:"""The census dict carrying ``placement``: the last build's ``artifacts/census.json``,- or a fresh ``probe_scene`` when it is missing / predates the table / ``force_probe``."""+ or a fresh ``probe`` (the language's ``SceneRuntime.probe``) when it is missing / predates+ the table / ``force_probe``."""census = None if force_probe else read_json_or_none(ws.artifacts / "census.json")if isinstance(census, dict) and isinstance(census.get("placement"), dict):return census- from codeverse3d.spatial.probes import probe_scene-- res = probe_scene(ws, timeout_s=timeout_s)+ res = probe(ws, timeout_s=timeout_s)if res.errors:return {"placement": {"error": res.errors[0]}}census = res.census or {}diff --git a/harness/codeverse3d/spatial/tools.py b/harness/codeverse3d/spatial/tools.pyindex 44b75172..70958e26 100644--- a/harness/codeverse3d/spatial/tools.py+++ b/harness/codeverse3d/spatial/tools.py@@ -11,7 +11,7 @@ from __future__ import annotationsimport timefrom pathlib import Path-from typing import Any+from typing import TYPE_CHECKING, Anyfrom pydantic import BaseModel, Field@@ -41,9 +41,8 @@ from codeverse3d.spatial.observe import (text_observation,truncate,)-from codeverse3d.spatial.probes import probe_scene, run_probe+from codeverse3d.spatial.probes import run_probefrom codeverse3d.spatial.registry import NoArgs, Observation, ToolContext, ToolUsageError, tool-from codeverse3d.spatial.render_scene import render_scenefrom codeverse3d.spatial.scene_placement import placement_census as _placement_censusfrom codeverse3d.spatial.scene_placement import placement_gate, placement_table_textfrom codeverse3d.spatial.sections import cross_section as _cross_section@@ -63,6 +62,9 @@ from codeverse3d.spatial.tool_common import (tool_out_dir,)+if TYPE_CHECKING:+ from codeverse3d.languages.base import SceneRuntime+# --------------------------------------------------------------------------- builddef _measure_after_build(ctx: ToolContext, br: BuildResult) -> tuple[Measurement | None, str]:@@ -77,8 +79,9 @@ def _measure_after_build(ctx: ToolContext, br: BuildResult) -> tuple[Measurement#: languages whose build has no GLB deliverable — build ok is reported through-#: the language's own artifacts instead of 'no GLB path'-_SCENE_LANGS = tuple(lang.value for lang in TRACK_LANGUAGES[Track.SCENE])+#: the language's own artifacts instead of 'no GLB path'; the scene tools serve every+#: scene language through its ``SceneRuntime`` (D101)+SCENE_LANGUAGES = tuple(lang.value for lang in TRACK_LANGUAGES[Track.SCENE])GRAPHICS_LANGS = tuple(lang.value for lang in TRACK_LANGUAGES[Track.GRAPHICS])@@ -167,7 +170,7 @@ def build(ctx: ToolContext, args: NoArgs) -> Observation:return _build_failed(ctx, br, lint_warns)numbers: dict[str, Any] = {"stage": "build", "ok": br.ok, "duration_ms": br.duration_ms}broken = False- if not br.glb_path and language in _SCENE_LANGS + GRAPHICS_LANGS:+ if not br.glb_path and language in SCENE_LANGUAGES + GRAPHICS_LANGS:# languages without a GLB deliverable: report the language's own artifactsok, extra_lines, extra_numbers = _no_glb_summary(ctx, br, language)lines = _gl_gate_verdict(extra_numbers) + [f"BUILD OK ({br.duration_ms} ms)"] + extra_lines@@ -409,6 +412,15 @@ def joint_sweep(ctx: ToolContext, args: JointSweepArgs) -> Observation:# ===================================================================== scenes+def _scene_runtime(ctx: ToolContext) -> SceneRuntime:+ from codeverse3d.languages import get_runtime++ lang = language_of(ctx)+ if lang not in SCENE_LANGUAGES:+ raise ToolUsageError(f"scene tools only apply to {SCENE_LANGUAGES}; workspace language is {lang!r}")+ return get_runtime(lang) # type: ignore[return-value] # every scene language's runtime is one++@tool("shader_probe", NoArgs, "Compile every GLSL/ShaderMaterial in the scene headlessly and report shader errors with ""line numbers — the build's own probe + preflight, so the verdict is the build's.",languages=(Language.SCENE_THREEJS.value,), cost_hint="slow")@@ -427,9 +439,9 @@ def shader_probe(ctx: ToolContext, args: NoArgs) -> Observation:@tool("scene_probe", NoArgs, "Load the scene headlessly: object/material/light census, draw and triangle counts, console errors.",- languages=(Language.SCENE_THREEJS.value,), cost_hint="slow")+ languages=SCENE_LANGUAGES, cost_hint="slow")def scene_probe(ctx: ToolContext, args: NoArgs) -> Observation:- res = probe_scene(ctx.workspace)+ res = _scene_runtime(ctx).probe(ctx.workspace)# ok = the gate verdict; failed = the probe TOOL could not run (SceneProbeResult# semantics): agent-fixable findings are a FAIL the agent must read, not an errorobs = gate_observation(res.gate, title="scene probe", failed=bool(res.errors))@@ -448,7 +460,7 @@ class SceneViewsArgs(BaseModel):@tool("scene_views", SceneViewsArgs, "Render the scene from its authored cameras and/or the overview rig at given times (contact sheet + views).",- languages=(Language.SCENE_THREEJS.value,), cost_hint="slow")+ languages=SCENE_LANGUAGES, cost_hint="slow")def scene_views(ctx: ToolContext, args: SceneViewsArgs) -> Observation:if args.cameras not in ("authored", "orbit", "all"):raise ToolUsageError("cameras must be authored | orbit | all", "scene_views(cameras='authored')")@@ -464,7 +476,7 @@ def scene_views(ctx: ToolContext, args: SceneViewsArgs) -> Observation:orbit = args.cameras in ("orbit", "all") or (args.cameras == "authored" and cams is None)key = f"{args.cameras}_{'_'.join(f'{t:g}' for t in args.times)}".replace(".", "p")out_dir = tool_out_dir(ctx, f"scene_{key}")- rs = render_scene(ctx.workspace, out_dir, cameras=cams, orbit=orbit, times=tuple(args.times), sheet=True)+ rs = _scene_runtime(ctx).render_scene(ctx.workspace, out_dir, cameras=cams, orbit=orbit, times=tuple(args.times), sheet=True)obs = render_observation(rs, ctx.workspace.root, note=f"scene views ({args.cameras}, t={args.times})")table = _frame_table(out_dir)return obs.model_copy(update={"text": truncate(obs.text + "\n\n" + table)}) if table else obs@@ -491,10 +503,10 @@ class CheckPlacementArgs(BaseModel):"'floating / sunken / unsupported / interpenetration' with 'lower X by 0.23 m onto Terrain' hints — and the ""plan checks (fog, backdrop, zone contents, scale, bounds). Reads the census of the last build/scene_probe; ""rebuild=true probes again. Tag a deliberately airborne thing with obj.userData.placement = 'free'.",- languages=(Language.SCENE_THREEJS.value,), cost_hint="fast")+ languages=SCENE_LANGUAGES, cost_hint="fast")def check_placement(ctx: ToolContext, args: CheckPlacementArgs) -> Observation:ws = ctx.workspace- census = _placement_census(ws, force_probe=args.rebuild)+ census = _placement_census(ws, _scene_runtime(ctx).probe, force_probe=args.rebuild)plan = Noneif ws.plan_path.is_file():try:diff --git a/harness/codeverse3d/tracks/common.py b/harness/codeverse3d/tracks/common.pyindex cb0329bf..85ebfdcd 100644--- a/harness/codeverse3d/tracks/common.py+++ b/harness/codeverse3d/tracks/common.py@@ -16,12 +16,12 @@ import loggingfrom collections.abc import Sequencefrom dataclasses import dataclass, field, replacefrom pathlib import Path-from typing import Any+from typing import TYPE_CHECKING, Anyfrom codeverse3d.config import Settingsfrom codeverse3d.contracts.artifacts import GateReport, Measurement, RenderSet, RenderViewfrom codeverse3d.contracts.common import Language, Track-from codeverse3d.contracts.plan import CameraPlan, Plan+from codeverse3d.contracts.plan import CameraPlan, Plan, ScenePlanfrom codeverse3d.contracts.run import RunRecordfrom codeverse3d.conventions import ViewPresetfrom codeverse3d.orchestrator import BudgetGuard, RoundPolicy, RunState@@ -36,6 +36,9 @@ from codeverse3d.tracks.generation import ()from codeverse3d.workspace import Workspace+if TYPE_CHECKING:+ from codeverse3d.languages.base import SceneRuntime+log = logging.getLogger(__name__)@@ -85,10 +88,9 @@ class Services:def render_object(self, glb: Path, out_dir: Path, *, views: Sequence[ViewPreset], width: int, height: int) -> RenderSet:return _import("codeverse3d.spatial.render", "render_glb")(glb, out_dir, views=list(views), width=width, height=height, sheet=True)- def render_scene(self, ws: Workspace, out_dir: Path, *, cameras: list[CameraPlan] | None, times: Sequence[float],- width: int, height: int) -> RenderSet:- return _import("codeverse3d.spatial.render_scene", "render_scene")(ws, out_dir, cameras=cameras, orbit=True, times=tuple(times),- width=width, height=height, sheet=True)+ def render_scene(self, runtime: SceneRuntime, ws: Workspace, out_dir: Path, *, cameras: list[CameraPlan] | None,+ times: Sequence[float], width: int, height: int) -> RenderSet:+ return runtime.render_scene(ws, out_dir, cameras=cameras, orbit=True, times=tuple(times), width=width, height=height, sheet=True)def render_geometry(self, glb: Path, out_dir: Path, *, views: Sequence[ViewPreset]) -> RenderSet:"""Clay renders (no materials/textures) exposing holes/intersections for the judge's@@ -124,9 +126,8 @@ class Services:return ""# ---- scene assembly + record- def assemble_scene(self, ws: Workspace, plan: Plan) -> Any:- fn = _import("codeverse3d.languages.scene_threejs", "assemble")- return fn(ws, plan, cameras="plan" if getattr(plan, "cameras", None) else "derive")+ def assemble_scene(self, runtime: SceneRuntime, ws: Workspace, plan: ScenePlan) -> Any:+ return runtime.assemble(ws, plan)def finalize_record(self, ws: Workspace, record: RunRecord) -> None:_import("codeverse3d.record.record", "finalize_record")(ws, record)diff --git a/harness/codeverse3d/tracks/scene.py b/harness/codeverse3d/tracks/scene.pyindex fcb781aa..8477ba68 100644--- a/harness/codeverse3d/tracks/scene.py+++ b/harness/codeverse3d/tracks/scene.py@@ -1,6 +1,6 @@"""SceneTrack: the plan, the pre-round stages (``SceneTrack.stages``: the whole baseline), rounds.-Language: scene_threejs. Generation is staged (each stage cached by+Languages: every scene language, through its ``SceneRuntime`` (D101). Generation is staged (each stage cached by``StageRunner`` for resume); the round loop then builds (probe + shaders — thebuild's two gate reports join the round's gates),renders authored cameras + orbit at t=0 and t=1.5, judges with ``scene_v1``@@ -39,7 +39,6 @@ from codeverse3d.contracts.plan import Plan, ScenePlan, ZonePlanfrom codeverse3d.contracts.run import RoundRecordfrom codeverse3d.conventions import to_snakefrom codeverse3d.judges.base import judged_subset-from codeverse3d.languages.scene_threejs import zone_filefrom codeverse3d.models import get_chat_modelfrom codeverse3d.orchestrator import BudgetExceeded, TaskGroup, compact_instructionsfrom codeverse3d.prompts import render@@ -111,7 +110,7 @@ class ScenePipeline:def render(self, ctx: RunContext, round_index: int, build: BuildResult, measurement: Measurement | None) -> RenderSet:r = ctx.settings.renderplan: ScenePlan = ctx.plan # type: ignore[assignment]- return ctx.services.render_scene(ctx.ws, ctx.ws.renders_dir(round_index), cameras=list(plan.cameras), times=SCENE_TIMES,+ return ctx.services.render_scene(ctx.runtime, ctx.ws, ctx.ws.renders_dir(round_index), cameras=list(plan.cameras), times=SCENE_TIMES,width=r.scene_width, height=r.scene_height)def post_render_gates(self, ctx: RunContext, round_index: int, renders: RenderSet) -> list[GateReport]:@@ -312,14 +311,14 @@ class SceneTrack(BaseTrack):stopped = isinstance(e, BudgetExceeded)out = {}for zone in zones:- done = stopped and _touched(ctx.ws.root / zone_file(zone.name), t0)- out[zone.name] = {"ok": done, "files": [zone_file(zone.name)] if done else [],+ done = stopped and _touched(ctx.ws.root / ctx.runtime.zone_file(zone.name), t0)+ out[zone.name] = {"ok": done, "files": [ctx.runtime.zone_file(zone.name)] if done else [],"notes": f"{type(e).__name__}: {e}"}else:written = {c.path for c in r.files_changed}out = {}for zone in zones:- rel = zone_file(zone.name)+ rel = ctx.runtime.zone_file(zone.name)# a session that owns several zones must have produced EVERY file; the skeleton# left a stub at every zone path, so existence proves nothing — the file# must have been reported as changed or actually rewritten in this stage@@ -335,7 +334,7 @@ class SceneTrack(BaseTrack):attribution and the refine fan-out stay file-disjoint."""plan: ScenePlan = ctx.plan # type: ignore[assignment]names = [z.name for z in batch]- files = [zone_file(z.name) for z in batch]+ files = [ctx.runtime.zone_file(z.name) for z in batch]recipes = cookbook_sections(ctx, ZONE_RECIPES)briefs = []for i, zone in enumerate(batch):@@ -343,7 +342,7 @@ class SceneTrack(BaseTrack):# a batched session reads ONE copy of the recipes (they are identical per zone)briefs.append(render("tracks/scene_zone.j2", **self._ctx(ctx, recipes=recipes if i == 0 else "", zone_name=zone.name, zone_description=zone.description,zone_bbox=bbox_line(zone.bbox), zone_contents=zone.contents,- zone_file=zone_file(zone.name), neighbours=neighbours,+ zone_file=ctx.runtime.zone_file(zone.name), neighbours=neighbours,layout=layout_block(ctx.extra.get("layouts", {}).get(zone.name)))))if len(batch) == 1:prompt, label = briefs[0], f"zone_{to_snake(names[0])}"@@ -369,7 +368,7 @@ class SceneTrack(BaseTrack):timeout_s=ctx.budget.timeout_s(ZONE_TIMEOUT_S * max(1, len(batch)), floor_s=180))def _assemble_stage(self, ctx: RunContext) -> dict[str, Any]:- result = ctx.services.assemble_scene(ctx.ws, ctx.plan)+ result = ctx.services.assemble_scene(ctx.runtime, ctx.ws, ctx.plan)ctx.ws.commit("assemble")ctx.events.emit("assemble.done", deterministic=True)return {"ok": True, "deterministic": True, "result": result} # StageRunner.stage jsonables it@@ -379,7 +378,7 @@ class SceneTrack(BaseTrack):write (the skeleton guarantees a stub per zone) so the run still delivers abuilt, rendered, judged scene instead of no score at all."""plan: ScenePlan = ctx.plan # type: ignore[assignment]- zones = [z for z in plan.zones if (ctx.ws.root / zone_file(z.name)).is_file()]+ zones = [z for z in plan.zones if (ctx.ws.root / ctx.runtime.zone_file(z.name)).is_file()]if not zones:return Falsectx.extra.setdefault("asset_api", asset_api_summary(plan, ctx.extra.get("assets") or {}, ctx.extra.get("asset_alias")))diff --git a/harness/codeverse3d/tracks/scene_assets.py b/harness/codeverse3d/tracks/scene_assets.pyindex be7d86dc..74324982 100644--- a/harness/codeverse3d/tracks/scene_assets.py+++ b/harness/codeverse3d/tracks/scene_assets.py@@ -35,7 +35,6 @@ from codeverse3d.contracts.common import ENTRY_FILE, Language, Trackfrom codeverse3d.contracts.plan import AssetPlan, BBox, PartPlan, ScenePlan, StaticPlanfrom codeverse3d.contracts.spec import Constraints, Specfrom codeverse3d.conventions import MAX_TRIS_OBJECT, OBJECT_VIEWS_QUICK, to_pascal, to_snake-from codeverse3d.languages.scene_threejs import asset_filefrom codeverse3d.orchestrator import BudgetExceededfrom codeverse3d.proc import fan_out, read_json_or_none, write_json_atomicfrom codeverse3d.prompts import render@@ -200,7 +199,7 @@ def _record_spec_hashes(ctx: RunContext, results: dict[str, AssetResult], assets# ----------------------------------------------------------------------------- threejs assetdef build_threejs_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> AssetResult:"""Single-shot → deterministic check → ONE repair → (only then) an agent session."""- rel, pascal = asset_file(asset), to_pascal(asset.name)+ rel, pascal = ctx.runtime.asset_file(asset), to_pascal(asset.name)# committed-child reuse (review-3 S2): a resume that re-enters the stage — budget# stop after the commit, or a failed sibling — must not re-pay a finished asset.# Deterministic node import-check only, no model call; the skeleton stub never@@ -376,11 +375,11 @@ def build_blender_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> Assnake = to_snake(asset.name)# committed-child reuse (review-3 S2), blender twin: a GLB only exists at this# path when a previous session finished the build+copy; a measurable one is done.- glb = ctx.ws.root / asset_file(asset)+ glb = ctx.ws.root / ctx.runtime.asset_file(asset)if glb.is_file() and glb.stat().st_size > 0 and _spec_hash_matches(ctx, asset) \and (size := _measure_size(ctx, glb)) is not None:ctx.events.emit("asset.generated", asset=asset.name, strategy="reused", ok=True, tris=0, errors=[])- return AssetResult(name=asset.name, kind=asset.kind, ok=True, path=asset_file(asset), size_m=size,+ return AssetResult(name=asset.name, kind=asset.kind, ok=True, path=ctx.runtime.asset_file(asset), size_m=size,strategy="reused", notes="committed GLB reused")w, h, d = asset.approx_size_msub_ws = Workspace(ctx.ws.root / "_assets" / snake).create()@@ -431,7 +430,7 @@ def build_blender_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> Aswhy = "; ".join(chk.errors[:2]) if chk and chk.errors else (notes or "no build")return AssetResult(name=asset.name, kind=asset.kind, ok=False, strategy=strategy, notes=f"build failed: {why}"[:300])sub_ws.commit("asset built")- rel = asset_file(asset)+ rel = ctx.runtime.asset_file(asset)dest = _copy_glb(ctx.ws, Path(chk.glb), rel)result = _stamp_glb(AssetResult(name=asset.name, kind=asset.kind, ok=True, path=rel, size_m=chk.size_m, strategy=strategy,notes=notes), ctx, dest)diff --git a/harness/docs/DECISIONS.md b/harness/docs/DECISIONS.mdindex 3d743b19..3be2c555 100644--- a/harness/docs/DECISIONS.md+++ b/harness/docs/DECISIONS.md@@ -1079,6 +1079,17 @@ Pointers: EVAL, PAPER_WRITING = `eval/docs/*.md`; COST, RUNBOOK, ARCHITECTURE, Imeasures an asset's lowest vertex, so a library tree's roots inside a non-exempt asset name can readas sunken there, as they already did for zone-placed trees.+* **D101 The scene track is language-dispatched through `SceneRuntime` (2026-09-24).** In preparation for+ `scene_blender` (`/home/yipeng/3dcodeverse_runs/scene_blender_2026-09-24/DESIGN.md` §11 phase 0):+ `languages/base.py` `SceneRuntime` (a `LanguageRuntime` plus `zone_file`, `asset_file`, `assemble`,+ `probe`, `render_scene`) is the only way the scene stages (`tracks/scene.py`, `tracks/scene_assets.py`),+ `Services.render_scene` / `assemble_scene` (which now take the runtime), the scene tools (`scene_probe`,+ `scene_views`, `check_placement`, registered for `SCENE_LANGUAGES`), `3dcode render` and the fixed+ evaluator reach a scene language; none of them imports `scene_threejs` any more. `SceneThreeJsRuntime`+ implements it by delegation, so behaviour is byte-identical (prompt manifest unchanged, not re-blessed).+ The design's `probe_args` member was left out: the probe's driver flags are the runtime's own business+ inside `probe`/`build`, and nothing outside a runtime would read them. `shader_probe` stays three.js-only.+## Rejected / deferred* A versioned `Spec`/`RunRecord`/`RunState` load-normaliser (rejected 2026-08-30: of the sevendiff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.mdindex 58d0abe1..a9094bf8 100644--- a/harness/docs/INTERFACES.md+++ b/harness/docs/INTERFACES.md@@ -250,6 +250,13 @@ rt.files_for(plan, target) -> list[str] # whole-artifact sessio# note). Gone: tracks/prompting.expected_files / file_for_target_factory / SCENE_FILES, graphics EXPECTED_FILES,# BaseTrack.round_files_hint, StaticObjectTrack.entry_files, scene.zone_file, scene_assets.asset_file,# BlenderRuntime.file_for_part (now part_file)+# Δ 2026-09-24 (D101) a scene-track runtime is a languages/base.SceneRuntime — the scene stages, Services, the scene+# tools, `3dcode render` and eval's fixed evaluator reach a scene language only through it (none imports scene_threejs):+rt.zone_file(name) -> str # src/zones/<snake>.<ext>+rt.asset_file(asset: AssetPlan) -> str # factory module, or public/assets/<snake>.glb for a hero+rt.assemble(ws, plan: ScenePlan) -> BaseModel # writes the entry; plan cameras, else derived; artifacts/assemble.json+rt.probe(ws, *, timeout_s=60.0) -> SceneProbeResult # scene_probe gate + census.json (scene_probe / check_placement tools)+rt.render_scene(ws, out_dir, *, cameras=None, orbit=True, times=(0.0, 1.5), width=1024, height=576, sheet=True) -> RenderSetfrom codeverse3d.prompts.catalog import language_prompt, language_textlanguage_prompt(language, name) -> str # "<dir>/<name>" under prompts/ (urdf_blender → urdf/): THE per-language promptlanguage_text(language, name) -> str # its text, "" for a file the language does not ship (Δ 2026-09-22: replaces@@ -360,6 +367,7 @@ from codeverse3d.spatial.measure import measure_glb, world_transform, node_name_# by walking the graph's edge matrices (trimesh's get() dropped a root pivot's rotation); a GLB with duplicate / unnamed nodes# lands a finding in Measurement.extra["findings"] — trimesh re-parents renamed nodes and the numbers are approximatefrom codeverse3d.spatial.scene_placement import placement_findings, placement_gate, placement_gate_safe, placement_census, placement_table_text+placement_census(ws, probe, *, force_probe=False, timeout_s=60.0) -> dict # Δ D101: probe = the language's SceneRuntime.probeplacement_findings(table, *, indoor=False) -> GateReport # gate "scene_placement"; data.kind ∈ floating | sunken |# unsupported | interpenetration | summary | probe_failed; target "Zone/Asset" (routes to src/zones/<zone>.js);# messages carry the scene_v1 floating_part cap words; reads artifacts/census.json["placement"] (host_placement.mjs)diff --git a/harness/tests/orchestrator_tracks/fakes.py b/harness/tests/orchestrator_tracks/fakes.pyindex b323c267..7bd69813 100644--- a/harness/tests/orchestrator_tracks/fakes.py+++ b/harness/tests/orchestrator_tracks/fakes.py@@ -32,6 +32,7 @@ from codeverse3d.contracts.plan import Plan, ScenePlanfrom codeverse3d.contracts.run import RunRecordfrom codeverse3d.conventions import to_snakefrom codeverse3d.languages import get_runtime+from codeverse3d.languages.base import SceneRuntimefrom codeverse3d.models.base import ModelErrorfrom codeverse3d.tracks.common import Servicesfrom codeverse3d.tracks.planner import plan_example@@ -56,6 +57,8 @@ class FakeRuntime:self.lock = threading.Lock()layout = get_runtime(language)self.expected_files, self.files_for = layout.expected_files, layout.files_for+ if isinstance(layout, SceneRuntime):+ self.zone_file, self.asset_file = layout.zone_file, layout.asset_filedef skeleton(self, ws: Workspace, plan: Plan) -> list[Path]:out = []@@ -384,7 +387,7 @@ class FakeServices(Services):vs.append(RenderView(name=v.name, path=str(p), mode="clay", width=32, height=32))return RenderSet(views=vs, renderer="fake")- def render_scene(self, ws: Workspace, out_dir: Path, *, cameras, times, width: int, height: int) -> RenderSet:+ def render_scene(self, runtime, ws: Workspace, out_dir: Path, *, cameras, times, width: int, height: int) -> RenderSet:vs = []for c in cameras or []:for t in times:@@ -419,7 +422,7 @@ class FakeServices(Services):def tool_cards(self, track: str, language: str) -> str:return "- `build` (slow): lint+build+measure\n- `measure` (fast): bbox per part"- def assemble_scene(self, ws: Workspace, plan: Plan) -> Any:+ def assemble_scene(self, runtime, ws: Workspace, plan: Plan) -> Any:if not self.assemble:raise ServiceUnavailable("no assembler in tests")(ws.src / "scene.js").write_text("// assembled by fake\nexport function createScene(){}\n")diff --git a/harness/tests/orchestrator_tracks/test_cost_latency.py b/harness/tests/orchestrator_tracks/test_cost_latency.pyindex d4d40323..ebc54883 100644--- a/harness/tests/orchestrator_tracks/test_cost_latency.py+++ b/harness/tests/orchestrator_tracks/test_cost_latency.py@@ -261,9 +261,9 @@ def test_stages_that_spend_the_clock_without_raising_still_get_a_salvaged_round(from tests.orchestrator_tracks.conftest import FAKE_CLOCKclass SlowAssemble(FakeServices):- def assemble_scene(self, ws, plan):+ def assemble_scene(self, runtime, ws, plan):FAKE_CLOCK["minutes"] += 30.0- return super().assemble_scene(ws, plan)+ return super().assemble_scene(runtime, ws, plan)plan = small_scene()spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=1, max_minutes=10.0)diff --git a/harness/tests/prompts/manifest.py b/harness/tests/prompts/manifest.pyindex ca005554..6928d581 100644--- a/harness/tests/prompts/manifest.py+++ b/harness/tests/prompts/manifest.py@@ -67,7 +67,7 @@ from codeverse3d.languages import get_runtimefrom codeverse3d.languages._gl_common import finish_build, judge_timesfrom codeverse3d.languages.glsl_shader import GlslShaderRuntimefrom codeverse3d.languages.opengl_python import OpenGLPythonRuntime-from codeverse3d.languages.scene_threejs import zone_file+from codeverse3d.languages.scene_threejs import asset_file, zone_filefrom codeverse3d.models.base import ModelErrorfrom codeverse3d.orchestrator import BudgetGuardfrom codeverse3d.spatial.gl_render import GlFrame, GlResult, gif_times@@ -76,7 +76,7 @@ from codeverse3d.texturing.plan import PackEntry, ScenePackfrom codeverse3d.tracks import get_track, scene_assetsfrom codeverse3d.tracks.common import Servicesfrom codeverse3d.tracks.planner import plan_example-from codeverse3d.tracks.scene_assets import AssetCheck, asset_file+from codeverse3d.tracks.scene_assets import AssetCheckfrom codeverse3d.tracks.zone_layout import validate_layoutfrom codeverse3d.workspace import Workspace, WorkspaceGitErrorfrom tests.orchestrator_tracks.fakes import (diff --git a/harness/tests/scene_runtime/test_runtime.py b/harness/tests/scene_runtime/test_runtime.pyindex 4127925a..f545c34b 100644--- a/harness/tests/scene_runtime/test_runtime.py+++ b/harness/tests/scene_runtime/test_runtime.py@@ -8,9 +8,9 @@ from types import SimpleNamespaceimport pytestfrom codeverse3d.contracts.artifacts import Severity-from codeverse3d.contracts.common import Language+from codeverse3d.contracts.common import TRACK_LANGUAGES, Language, Trackfrom codeverse3d.languages import get_runtime-from codeverse3d.languages.base import LanguageRuntime+from codeverse3d.languages.base import LanguageRuntime, SceneRuntimefrom codeverse3d.languages.scene_threejs import SceneThreeJsRuntimefrom codeverse3d.prompts.catalog import language_textfrom tests.scene_runtime.conftest import needs_browser@@ -20,6 +20,8 @@ def test_runtime_registered_conforms_and_writes_skeleton(ws):rt = get_runtime(Language.SCENE_THREEJS)assert isinstance(rt, SceneThreeJsRuntime)assert isinstance(rt, LanguageRuntime)+ # the scene track reaches every scene language only through SceneRuntime (D101)+ assert all(isinstance(get_runtime(lang), SceneRuntime) for lang in TRACK_LANGUAGES[Track.SCENE])assert rt.language == Language.SCENE_THREEJSassert "src/scene.js" in rt.entry_globs and "src/zones/*.js" in rt.entry_globsdoc = language_text(rt.language, "contract.md")diff --git a/harness/tests/spatial_tools/test_tools.py b/harness/tests/spatial_tools/test_tools.pyindex f5ba354d..8b229e07 100644--- a/harness/tests/spatial_tools/test_tools.py+++ b/harness/tests/spatial_tools/test_tools.py@@ -4,6 +4,7 @@ from __future__ import annotationsimport jsonfrom pathlib import Path+from types import SimpleNamespaceimport pytestfrom PIL import Image, ImageDraw@@ -74,7 +75,7 @@ class _FakeRuntime:return res-def _patch_runtime(monkeypatch: pytest.MonkeyPatch, rt: _FakeRuntime) -> None:+def _patch_runtime(monkeypatch: pytest.MonkeyPatch, rt: object) -> None:import codeverse3d.languages as langsmonkeypatch.setattr(langs, "get_runtime", lambda language: rt)@@ -238,7 +239,6 @@ def test_scene_tools_with_fake_siblings(stool_ctx: ToolContext, monkeypatch: pyt# shader_probe reports the BUILD's probe + preflight (one boot), never a driver of its ownmonkeypatch.setattr(ts, "run_probe", lambda ws, **kw: (GateReport.of("scene_probe"), shaders, {}))- monkeypatch.setattr(ts, "probe_scene", fake_probe_scene)obs = get_tool("shader_probe").call(stool_ctx, {})assert not obs.ok and not obs.failed and "vUv" in obs.text and "declare varying" in obs.textassert obs.text.startswith("shader probe: FAIL") # a shader that will not compile is a verdict@@ -255,14 +255,17 @@ def test_scene_tools_with_fake_siblings(stool_ctx: ToolContext, monkeypatch: pytmonkeypatch.setattr(ts, "run_probe", lambda ws, **kw: (died, skipped, {}))obs = get_tool("shader_probe").call(stool_ctx, {})assert obs.failed and "could not run" in obs.text- obs = get_tool("scene_probe").call(stool_ctx, {})+ # scene_probe probes through the workspace language's SceneRuntime (D101)+ scene_ctx = ToolContext(workspace=stool_ctx.workspace, language="scene_threejs", track="scene")+ _patch_runtime(monkeypatch, SimpleNamespace(probe=fake_probe_scene))+ obs = get_tool("scene_probe").call(scene_ctx, {})# ok = the gate verdict; failed = the probe TOOL could not run. The gate fails on# agent-fixable findings here, so the observation is a FAIL, not a tool errorassert not obs.ok and not obs.failedassert obs.text.startswith("scene probe: FAIL")assert "meshes=12" in obs.text and "boom" in obs.text and obs.numbers["census"]["meshes"] == 12- monkeypatch.setattr(ts, "probe_scene", lambda ws, **kw: SceneProbeResult(gate=failed, errors=["driver died"], ok=False))- obs = get_tool("scene_probe").call(stool_ctx, {})+ _patch_runtime(monkeypatch, SimpleNamespace(probe=lambda ws, **kw: SceneProbeResult(gate=failed, errors=["driver died"], ok=False)))+ obs = get_tool("scene_probe").call(scene_ctx, {})assert not obs.ok and obs.failed and "driver died" in obs.textobs = get_tool("joint_sweep").call(stool_ctx, {})assert not obs.ok and obs.failed and "run `build`" in obs.text # no robot.urdf in a static workspace