Skip to content

Official Codebase of 3DCodeVerse

Python

languages: the runtime owns the file layout — the tracks ask it which file owns what instead of restating it

gaoypeng29d8c6a48189
diff --git a/harness/codeverse3d/languages/base.py b/harness/codeverse3d/languages/base.py
index 5e651605..4cce3411 100644
--- a/harness/codeverse3d/languages/base.py
+++ b/harness/codeverse3d/languages/base.py
@@ -1,21 +1,24 @@
"""LanguageRuntime protocol + registry.
-A runtime knows how to (1) lay down starter files for a plan, (2) statically
-lint agent code for known pitfalls, (3) execute it in a sandboxed subprocess
-and export the canonical artifact(s). Its authoring contract is prompt material
-(``prompts/<lang>/contract.md``, found by ``prompts.catalog.language_prompt``).
+A runtime knows how to (1) lay down starter files for a plan — and so which file
+owns what (``expected_files`` / ``files_for``: the tracks ask, never restate), (2)
+statically lint agent code for known pitfalls, (3) execute it in a sandboxed
+subprocess and export the canonical artifact(s). Its authoring contract is prompt
+material (``prompts/<lang>/contract.md``, found by ``prompts.catalog.language_prompt``).
Runtimes never import agent code into the harness process.
"""
from __future__ import annotations
+from collections.abc import Callable
from importlib import import_module
from pathlib import Path
from typing import Protocol, runtime_checkable
from codeverse3d.contracts.artifacts import BuildResult, GateReport
-from codeverse3d.contracts.common import Language
+from codeverse3d.contracts.common import ENTRY_FILE, Language
from codeverse3d.contracts.plan import Plan
+from codeverse3d.conventions import to_snake
from codeverse3d.workspace import Workspace
@@ -37,6 +40,39 @@ class LanguageRuntime(Protocol):
"""Execute the code in a subprocess; export ``artifacts/object.glb`` (+extras)."""
...
+ def expected_files(self, plan: Plan | None) -> list[str]:
+ """The files a whole-artifact session writes for ``plan``, entry first."""
+ ...
+
+ def files_for(self, plan: Plan | None, target: str) -> list[str]:
+ """The files that own a refine target (a part, zone, asset, camera, env word); ``[]`` = no
+ owner, so the task stays whole-artifact."""
+ ...
+
+
+class RuntimeLayout:
+ """``expected_files`` / ``files_for`` for a runtime whose entry file (+ ``extra_files``) owns
+ the whole artifact — or, when it sets ``part_file``, one file per plan part too. The scene
+ runtime lays out zones / assets / env and overrides both."""
+
+ language: Language
+ #: files a whole-artifact session owns besides the entry (urdf: robot.urdf; glsl_shader: common.glsl)
+ extra_files: tuple[str, ...] = ()
+ #: plan part name → the file that builds it, in a language with one file per part (blender, three.js)
+ part_file: Callable[[str], str] | None = None
+
+ def expected_files(self, plan: Plan | None) -> list[str]:
+ parts = [self.part_file(p.name) for p in getattr(plan, "parts", None) or ()] if self.part_file else []
+ return [ENTRY_FILE[self.language], *self.extra_files, *parts]
+
+ def files_for(self, plan: Plan | None, target: str) -> list[str]:
+ if self.part_file is None:
+ return []
+ key = to_snake(target)
+ if key in {to_snake(p.name) for p in getattr(plan, "parts", None) or ()}:
+ return [self.part_file(target)]
+ return [ENTRY_FILE[self.language]] if key in ("overall", "assembly", "object", "") else []
+
#: Language → (module, class). Adding a language is a row, and the import stays lazy
#: (a runtime pulls in bpy / moderngl / node bindings the other six do not need).
diff --git a/harness/codeverse3d/languages/blender/__init__.py b/harness/codeverse3d/languages/blender/__init__.py
index b886daa0..8e5f964b 100644
--- a/harness/codeverse3d/languages/blender/__init__.py
+++ b/harness/codeverse3d/languages/blender/__init__.py
@@ -21,6 +21,7 @@ from codeverse3d.languages._ast_lint import (
safe_parse,
)
from codeverse3d.languages._common import MISSING_ENTRY, compose_build_result, strip_blender_noise
+from codeverse3d.languages.base import RuntimeLayout
from codeverse3d.proc import run_subprocess, scrub_secrets
from codeverse3d.workspace import Workspace
@@ -693,11 +694,12 @@ def blender_env() -> dict[str, str]:
return env
-class BlenderRuntime:
+class BlenderRuntime(RuntimeLayout):
"""LanguageRuntime for ``Language.BLENDER``."""
language = Language.BLENDER
entry_globs: tuple[str, ...] = (ENTRY_REL, "src/parts/*.py")
+ part_file = staticmethod(part_file_rel)
def __init__(self, *, blender: str | None = None, settings: Settings | None = None):
self._settings = settings or get_settings()
@@ -713,12 +715,6 @@ class BlenderRuntime:
def entry_file(self, ws: Workspace) -> Path:
return ws.root / ENTRY_REL
- @staticmethod
- def file_for_part(part_name: str) -> str:
- """Workspace-relative file that owns a plan part: ``src/parts/<snake>.py``
- (the tracks call this via ``getattr`` to fan out per-part refinement)."""
- return part_file_rel(part_name)
-
def build_command(
self, ws: Workspace, *, stl: bool = True, blend: bool = False, seed: int = 0,
tri_limit: int = MAX_TRIS_OBJECT,
diff --git a/harness/codeverse3d/languages/cadquery/__init__.py b/harness/codeverse3d/languages/cadquery/__init__.py
index 08b7ba05..c07e4268 100644
--- a/harness/codeverse3d/languages/cadquery/__init__.py
+++ b/harness/codeverse3d/languages/cadquery/__init__.py
@@ -22,6 +22,7 @@ from codeverse3d.languages._ast_lint import (
safe_parse,
)
from codeverse3d.languages._common import MISSING_ENTRY, compose_build_result
+from codeverse3d.languages.base import RuntimeLayout
from codeverse3d.languages.blender import _fmt, finish_for, instance_centers
from codeverse3d.proc import run_subprocess, scrub_secrets
from codeverse3d.workspace import Workspace
@@ -324,7 +325,7 @@ def cadquery_env() -> dict[str, str]:
return env
-class CadQueryRuntime:
+class CadQueryRuntime(RuntimeLayout):
"""LanguageRuntime for ``Language.CADQUERY``."""
language = Language.CADQUERY
diff --git a/harness/codeverse3d/languages/glsl_shader/__init__.py b/harness/codeverse3d/languages/glsl_shader/__init__.py
index f2ace1f5..5b1c04f9 100644
--- a/harness/codeverse3d/languages/glsl_shader/__init__.py
+++ b/harness/codeverse3d/languages/glsl_shader/__init__.py
@@ -23,6 +23,7 @@ from codeverse3d.languages._gl_common import ( # noqa: F401 — re-exported
parse_glsl_log,
resolution_for,
)
+from codeverse3d.languages.base import RuntimeLayout
from codeverse3d.spatial.gl_render import GlHost, GlResult, gif_times
from codeverse3d.workspace import Workspace
@@ -378,9 +379,10 @@ def write_skeleton(ws: Workspace, plan: Plan | None) -> list[Path]:
# ===================================================================== runtime
-class GlslShaderRuntime:
+class GlslShaderRuntime(RuntimeLayout):
language = Language.GLSL_SHADER
entry_globs: tuple[str, ...] = (ENTRY_FILE[Language.GLSL_SHADER], COMMON, BUFFER_A)
+ extra_files = (COMMON,)
def __init__(self, *, host: GlHost | None = None):
self._host = host
diff --git a/harness/codeverse3d/languages/opengl_python/__init__.py b/harness/codeverse3d/languages/opengl_python/__init__.py
index 1cdb0c0f..a8c860cb 100644
--- a/harness/codeverse3d/languages/opengl_python/__init__.py
+++ b/harness/codeverse3d/languages/opengl_python/__init__.py
@@ -26,6 +26,7 @@ from codeverse3d.languages._gl_common import (
resolution_for,
traceback_location,
)
+from codeverse3d.languages.base import RuntimeLayout
from codeverse3d.spatial.gl_render import GlHost, GlResult, gif_times
from codeverse3d.workspace import Workspace
@@ -335,7 +336,7 @@ def write_skeleton(ws: Workspace, plan: Plan | None) -> list[Path]:
# ===================================================================== runtime
-class OpenGLPythonRuntime:
+class OpenGLPythonRuntime(RuntimeLayout):
language = Language.OPENGL_PYTHON
entry_globs: tuple[str, ...] = (ENTRY_FILE[Language.OPENGL_PYTHON], "src/*.glsl")
diff --git a/harness/codeverse3d/languages/scene_threejs/__init__.py b/harness/codeverse3d/languages/scene_threejs/__init__.py
index e6fba5b2..42b6728e 100644
--- a/harness/codeverse3d/languages/scene_threejs/__init__.py
+++ b/harness/codeverse3d/languages/scene_threejs/__init__.py
@@ -234,6 +234,50 @@ def _env_for_plan(plan: ScenePlan) -> str:
return header + text
+# ===================================================================== layout
+#: what a whole-scene session edits: the entry and the environment (every zone and asset module
+#: has its own session and its own file below)
+SCENE_FILES: tuple[str, ...] = ("src/scene.js", "src/env.js")
+#: refine targets that are the environment's, whatever the plan calls its zones
+ENV_WORDS = frozenset({"env", "environment", "lighting", "sky", "fog", "ground", "water", "light"})
+
+
+def zone_file(name: str) -> str:
+ """``src/zones/<snake>.js`` — the module that builds zone ``name``."""
+ return f"src/zones/{to_snake(name)}.js"
+
+
+def asset_file(asset: AssetPlan) -> str:
+ """A three.js asset's factory module; a Blender hero's compiled GLB (built in its own sub-workspace)."""
+ snake = to_snake(asset.name)
+ return f"src/assets/{snake}.js" if asset.kind == "threejs" else f"public/assets/{snake}.glb"
+
+
+def scene_files_for(plan: Plan | None, target: str, *, alias: dict[str, str] | None = None) -> list[str]:
+ """The files that own a scene refine target. A three.js asset is fixed in its factory — a merged
+ asset's (``alias``: the dedupe note) in its survivor's, its own file being only the variant shim; a
+ hero ships as a GLB, so it is fixed where it is placed: the zones that list it. Cameras belong to
+ ``scene.js``, env words to ``env.js``; "Zone/Asset" (the placement gate) to the zone's file."""
+ zone_plans = list(getattr(plan, "zones", None) or [])
+ zones = {to_snake(z.name) for z in zone_plans}
+ assets = {to_snake(a.name): a for a in (getattr(plan, "assets", None) or [])}
+ survivor = {to_snake(k): v for k, v in (alias or {}).items()}
+ key = to_snake(target)
+ if key in zones:
+ return [zone_file(key)]
+ if key in assets:
+ if assets[key].kind == "threejs":
+ return [asset_file(assets[key].model_copy(update={"name": survivor.get(key, key)}))]
+ return [zone_file(z.name) for z in zone_plans if key in {to_snake(c) for c in z.contents}]
+ if key in {to_snake(c.name) for c in (getattr(plan, "cameras", None) or [])} or key in ("camera", "cameras", "composition"):
+ return ["src/scene.js"]
+ if key in ENV_WORDS:
+ return ["src/env.js"]
+ if "/" in target and to_snake(target.split("/", 1)[0]) in zones:
+ return [zone_file(target.split("/", 1)[0])]
+ return []
+
+
def _asset_stub(a: AssetPlan) -> str:
snake, pascal = to_snake(a.name), to_pascal(a.name)
w, h, d = (max(0.05, float(v)) for v in a.approx_size_m)
@@ -324,9 +368,9 @@ def write_skeleton(ws: Workspace, plan: Plan | None = None) -> list[Path]:
assets = {to_snake(a.name): a for a in plan.assets}
for a in plan.assets:
if a.kind == "threejs":
- _write(ws.src / "assets" / f"{to_snake(a.name)}.js", _asset_stub(a), written)
+ _write(ws.root / asset_file(a), _asset_stub(a), written)
for z in plan.zones:
- _write(ws.src / "zones" / f"{to_snake(z.name)}.js", _zone_stub(z, assets), written)
+ _write(ws.root / zone_file(z.name), _zone_stub(z, assets), written)
_write(ws.src / "scene.js", _scene_for_plan(plan), written)
(ws.public / "assets").mkdir(parents=True, exist_ok=True)
return written
@@ -681,6 +725,12 @@ class SceneThreeJsRuntime:
language = Language.SCENE_THREEJS
entry_globs: tuple[str, ...] = (ENTRY_FILE[Language.SCENE_THREEJS], "src/zones/*.js", "src/assets/*.js", "src/env.js", "src/shaders/*.js")
+ def expected_files(self, plan: Plan | None) -> list[str]:
+ return list(SCENE_FILES)
+
+ 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)
+
def skeleton(self, ws: Workspace, plan: Plan | None) -> list[Path]:
return write_skeleton(ws, plan)
diff --git a/harness/codeverse3d/languages/threejs/__init__.py b/harness/codeverse3d/languages/threejs/__init__.py
index 2233e166..0c6192e7 100644
--- a/harness/codeverse3d/languages/threejs/__init__.py
+++ b/harness/codeverse3d/languages/threejs/__init__.py
@@ -23,6 +23,7 @@ from codeverse3d.languages._js_lint import (
from codeverse3d.languages._js_lint import (
node_check_syntax as check_syntax, # module-level name: tests monkeypatch it
)
+from codeverse3d.languages.base import RuntimeLayout
from codeverse3d.proc import read_json_or_none
from codeverse3d.spatial.node import NodeError, NodeResult, run_node, runtime_js_dir
from codeverse3d.workspace import Workspace
@@ -267,9 +268,13 @@ def lint_workspace(ws: Workspace) -> GateReport:
# ===================================================================== skeleton
+def part_file_rel(part_name: str) -> str:
+ """``'Seat Cushion'`` → ``'src/parts/seat_cushion.js'`` (workspace-relative)."""
+ return f"src/parts/{to_snake(part_name)}.js"
+
+
def part_file(ws: Workspace, part_name: str) -> Path:
- """``src/parts/<snake>.js`` for a plan part name."""
- return ws.src / "parts" / f"{to_snake(part_name)}.js"
+ return ws.root / part_file_rel(part_name)
def _fmt(v: float) -> str:
@@ -337,11 +342,12 @@ BUILD_JSON = "build.json"
NODE_MEM_LIMIT_GB = 8.0 # RLIMIT_AS for the export process (geometry-bomb protection)
-class ThreeJsRuntime:
+class ThreeJsRuntime(RuntimeLayout):
"""LanguageRuntime for ``Language.THREEJS`` (raw ESM three.js, exported via node)."""
language = Language.THREEJS
entry_globs: tuple[str, ...] = (ENTRY_FILE[Language.THREEJS], "src/parts/*.js")
+ part_file = staticmethod(part_file_rel)
# ------------------------------------------------------------------ skeleton / lint
def skeleton(self, ws: Workspace, plan: Plan) -> list[Path]:
@@ -435,8 +441,8 @@ class ThreeJsRuntime:
"""
if ws is None or not isinstance(part, str) or not part.strip():
return ""
- rel = Path("src") / "parts" / f"{to_snake(part)}.js"
- return rel.as_posix() if (ws.root / rel).is_file() else ""
+ rel = part_file_rel(part)
+ return rel if (ws.root / rel).is_file() else ""
@staticmethod
def _write_build_json(ws: Workspace, result: BuildResult) -> None:
diff --git a/harness/codeverse3d/languages/urdf/__init__.py b/harness/codeverse3d/languages/urdf/__init__.py
index 79aabd85..3891497a 100644
--- a/harness/codeverse3d/languages/urdf/__init__.py
+++ b/harness/codeverse3d/languages/urdf/__init__.py
@@ -31,6 +31,7 @@ from codeverse3d.languages._ast_lint import (
safe_parse,
)
from codeverse3d.languages._common import ProcResult, compose_build_result, strip_blender_noise
+from codeverse3d.languages.base import RuntimeLayout
from codeverse3d.proc import run_subprocess
from codeverse3d.spatial.joints import (
UrdfError,
@@ -752,9 +753,10 @@ FK_TOL_M = 0.001
STAGED_OUTPUTS = ("build.json", "census.json", "meshes", "robot.urdf", "articulation.json", "object.glb")
-class UrdfBlenderRuntime:
+class UrdfBlenderRuntime(RuntimeLayout):
language = Language.URDF_BLENDER
entry_globs = (ENTRY_FILE[Language.URDF_BLENDER], "src/robot.urdf")
+ extra_files = ("src/robot.urdf",)
# ------------------------------------------------------------ protocol
def skeleton(self, ws: Workspace, plan: Plan) -> list[Path]:
diff --git a/harness/codeverse3d/tracks/graphics.py b/harness/codeverse3d/tracks/graphics.py
index ad28be46..fa046b92 100644
--- a/harness/codeverse3d/tracks/graphics.py
+++ b/harness/codeverse3d/tracks/graphics.py
@@ -276,17 +276,6 @@ def seed_recipes(ctx: RunContext) -> list[str]:
# ===================================================================== prompt context + frames
-EXPECTED_FILES: dict[Language, list[str]] = {
- Language.GLSL_SHADER: ["src/shader.frag", "src/common.glsl"],
- Language.OPENGL_PYTHON: ["src/program.py"],
-}
-
-
-# ----------------------------------------------------------------------------- prompt context
-def graphics_expected_files(ctx: RunContext) -> list[str]:
- return list(EXPECTED_FILES.get(ctx.language, ["src/shader.frag"]))
-
-
def passes_table(plan: GraphicsPlan | None) -> str:
if plan is None or not plan.passes:
return "(no passes)"
@@ -307,7 +296,7 @@ def graphics_prompt_context(ctx: RunContext, **extra: Any) -> dict[str, Any]:
"style": plan.style if plan else "", "resolution": f"{res[0]}x{res[1]}", "duration": f"{plan.duration_s:g}" if plan else "8",
"passes_table": passes_table(plan), "motion": plan.motion if plan else "", "key_visuals": list(plan.key_visuals) if plan else [],
"uniforms": ", ".join(plan.uniforms) if plan and plan.uniforms else "u_time, u_resolution",
- "expected_files": graphics_expected_files(ctx), "judge_times": "0, 1, 2.5, 4, 6 s", **extra})
+ "expected_files": ctx.runtime.expected_files(ctx.plan), "judge_times": "0, 1, 2.5, 4, 6 s", **extra})
# ----------------------------------------------------------------------------- renders / gates
@@ -397,7 +386,7 @@ class GraphicsTrack(BaseTrack):
# ------------------------------------------------------------------ baseline
def baseline_tasks(self, ctx: RunContext) -> list[GenerationTask]:
- files = graphics_expected_files(ctx)
+ files = ctx.runtime.expected_files(ctx.plan)
prompt = render(self.generate_template, **graphics_prompt_context(
ctx, skeleton_files=skeleton_files(ctx) if ctx.single_shot else {}, previous_error=""))
ctx.record_prompt("generate", prompt)
@@ -405,15 +394,12 @@ class GraphicsTrack(BaseTrack):
kind="baseline", temperature=0.6, thinking="medium", owns_entry=True,
images=reference_images(ctx))]
- def round_files_hint(self, ctx: RunContext) -> list[str]:
- return graphics_expected_files(ctx)
-
def generate_context(self, ctx: RunContext, **extra: Any) -> dict[str, Any]:
return graphics_prompt_context(ctx, **extra)
# ------------------------------------------------------------------ refine (scaffold hook; never fans out)
def _refine_task(self, ctx: RunContext, group: TaskGroup, last: RoundRecord, index: int, *, parallel: bool) -> GenerationTask:
- files = graphics_expected_files(ctx)
+ files = ctx.runtime.expected_files(ctx.plan)
prompt = render(self.refine_template, **graphics_prompt_context(
ctx, round_index=index, tasks=[t.line() for t in group.tasks], targets=group.targets, files=files,
judge_summary=judge_digest(last), frame_notes=frame_stats_text(ctx.ws),
diff --git a/harness/codeverse3d/tracks/lifecycle.py b/harness/codeverse3d/tracks/lifecycle.py
index 5f62c491..3f0824dc 100644
--- a/harness/codeverse3d/tracks/lifecycle.py
+++ b/harness/codeverse3d/tracks/lifecycle.py
@@ -13,7 +13,7 @@ from __future__ import annotations
import logging
import platform
import traceback
-from collections.abc import Sequence
+from collections.abc import Callable, Sequence
from dataclasses import replace
from datetime import UTC, datetime
from pathlib import Path
@@ -48,8 +48,6 @@ from codeverse3d.tracks.generation import GenerationTask, single_shot_model_id
from codeverse3d.tracks.planner import plan as run_planner
from codeverse3d.tracks.prompting import (
base_prompt_context,
- expected_files,
- file_for_target_factory,
language_system_prompt,
refine_inline_files,
)
@@ -185,9 +183,6 @@ class BaseTrack:
def system_prompt(self, ctx: RunContext) -> str:
return language_system_prompt(ctx.language, tools=not ctx.single_shot)
- def round_files_hint(self, ctx: RunContext) -> list[str]:
- return []
-
def round_extra_notes(self, ctx: RunContext) -> list[str]:
"""Notes folded into every round record (e.g. 'the baseline was degraded')."""
return list(ctx.extra.get("degraded") or [])
@@ -202,9 +197,9 @@ class BaseTrack:
return (ctx.ws.root / "rounds" / "candidates.json").is_file()
# ---- refine hooks (the scaffold below is shared; tracks fill in the task)
- def refine_file_for_target(self, ctx: RunContext) -> Any:
- """``target → [files]`` mapper for refine tasks (None = whole-object language)."""
- return file_for_target_factory(ctx)
+ def refine_file_for_target(self, ctx: RunContext) -> Callable[[str], list[str]]:
+ """``target → [files]`` for refine tasks: the runtime's layout (``[]`` = no owner)."""
+ return lambda target: ctx.runtime.files_for(ctx.plan, target)
def extra_refine_tasks(self, ctx: RunContext, last: RoundRecord) -> Sequence[Any]:
"""Harness-derived tasks prepended to the judge's (e.g. reference IoU)."""
@@ -212,7 +207,7 @@ class BaseTrack:
def generate_context(self, ctx: RunContext, **extra: Any) -> dict[str, Any]:
"""Template context for ``generate_template`` (baseline / rebuild prompts)."""
- extra.setdefault("expected_files", expected_files(ctx))
+ extra.setdefault("expected_files", ctx.runtime.expected_files(ctx.plan))
return base_prompt_context(ctx, **extra)
def _refine_task(self, ctx: RunContext, group: TaskGroup, last: RoundRecord, index: int, *, parallel: bool) -> GenerationTask:
@@ -242,7 +237,7 @@ class BaseTrack:
def _rebuild_task(self, ctx: RunContext, last: RoundRecord, index: int) -> GenerationTask:
"""Regenerate after a failed build: the generate prompt + the error report."""
- files = self.round_files_hint(ctx)
+ files = ctx.runtime.expected_files(ctx.plan)
lint = next((g for g in last.gates if g.gate.startswith("lint")), GateReport(gate="lint", passed=True))
report = format_error_report(last.build, lint, ctx.cookbook_text) if last.build else "build did not run"
prompt = render(self.generate_template, **self.generate_context(
@@ -545,10 +540,10 @@ class BaseTrack:
ctx.state.save(ctx.ws)
try:
if index == 0 and tasks and ctx.policy.n_candidates > 1:
- rec = run_best_of_n(self, ctx, tasks, pipeline, files_hint=self.round_files_hint(ctx))
+ rec = run_best_of_n(self, ctx, tasks, pipeline, files_hint=ctx.runtime.expected_files(ctx.plan))
else:
rec = run_round(ctx, index=index, kind=kind, tasks=tasks, pipeline=pipeline, instructions=instructions,
- previous=previous, files_hint=self.round_files_hint(ctx),
+ previous=previous, files_hint=ctx.runtime.expected_files(ctx.plan),
extra_notes=self.round_extra_notes(ctx))
except RoundFailed as e:
if looks_quota(str(e)):
@@ -602,7 +597,7 @@ class BaseTrack:
ctx.events.emit("budget.salvage_skipped", reason="nothing buildable to salvage")
return
rec = run_round(ctx, index=0, kind="baseline", tasks=[], pipeline=self.make_pipeline(), instructions=[],
- previous=None, files_hint=self.round_files_hint(ctx),
+ previous=None, files_hint=ctx.runtime.expected_files(ctx.plan),
extra_notes=["salvaged: the budget stopped the run before round 0", *self.round_extra_notes(ctx)])
except Exception as e: # noqa: BLE001 — the run is already stopping; never mask the budget stop
log.warning("salvage round failed: %s", e)
diff --git a/harness/codeverse3d/tracks/prompting.py b/harness/codeverse3d/tracks/prompting.py
index 91c13f4c..a6334c86 100644
--- a/harness/codeverse3d/tracks/prompting.py
+++ b/harness/codeverse3d/tracks/prompting.py
@@ -2,8 +2,8 @@
Everything a template may reference is produced here from the spec, the plan
and the run context — exact numbers (bbox tables in meters), acceptance lines,
-the language frame doc, reference-image notes — plus ``file_for_target_factory``
-which maps a refine target (part / zone / asset) to the files that own it.
+the language frame doc, reference-image notes. Which file owns what is the
+runtime's answer (``LanguageRuntime.expected_files`` / ``files_for``).
"""
from __future__ import annotations
@@ -32,9 +32,6 @@ log = logging.getLogger(__name__)
MAX_SKELETON_CHARS = 14_000
-#: the files a scene refine task falls back to when the group has no file ownership
-SCENE_FILES: tuple[str, ...] = ("src/scene.js", "src/env.js")
-
def parts_table(plan: Plan) -> str:
"""Markdown table of parts with exact bboxes (meters, 3 decimals)."""
@@ -302,7 +299,7 @@ def base_prompt_context(ctx: RunContext, **extra: Any) -> dict[str, Any]:
"part_details": part_details(plan) if plan else "",
"joints_table": joints_table(plan) if plan else "",
"acceptance": acceptance_lines(plan),
- "entry_files": ", ".join(getattr(ctx.runtime, "entry_globs", ()) or ()),
+ "entry_files": ", ".join(ctx.runtime.entry_globs),
"n_parts": len(getattr(plan, "parts", []) or []) if plan else 0,
"detail_budget": detail_budget_text(ctx),
"root_link": getattr(plan, "root_link", "") if plan else "",
@@ -440,28 +437,6 @@ def reference_note(ctx: RunContext) -> str:
# ----------------------------------------------------------------------------- files + round digests
-def expected_files(ctx: RunContext) -> list[str]:
- """Files the generator is expected to produce for this language + plan."""
- lang = ctx.language
- parts = getattr(ctx.plan, "parts", None) or []
- if lang is Language.THREEJS:
- return ["src/object.js"] + [f"src/parts/{to_snake(p.name)}.js" for p in parts]
- if lang is Language.URDF_BLENDER:
- return ["src/model.py", "src/robot.urdf"]
- files = ["src/model.py"]
- custom = getattr(ctx.runtime, "file_for_part", None) # blender: src/parts/<snake>.py per part
- if callable(custom):
- for p in parts:
- try:
- rel = custom(p.name)
- except Exception as e: # noqa: BLE001
- log.warning("runtime.file_for_part failed for %s: %s", p.name, e)
- continue
- if rel and str(rel) not in files:
- files.append(str(rel))
- return files
-
-
def skeleton_files(ctx: RunContext, max_chars: int = MAX_SKELETON_CHARS) -> dict[str, str]:
"""Current src/ files (the skeleton), trimmed, for single-shot prompts."""
return current_files(
@@ -586,70 +561,3 @@ AGENT_OUTPUT_RULES = """HOW TO FINISH (agent mode): edit files under src/ only (
Before you finish you MUST run the `build` tool and fix every error it reports; then run `measure`
(objects) or `scene_probe` (scenes) once and compare the numbers with the plan. Do not write
reports, READMEs or notes — only the code files. Stop when the build is clean."""
-
-
-def file_for_target_factory(ctx: RunContext):
- """Return ``target → [files]`` for the current language, or ``None`` when the
- language is whole-object (one file). Prefers ``runtime.file_for_part``."""
- rt = ctx.runtime
- plan = ctx.plan
- custom = getattr(rt, "file_for_part", None)
- part_names = {to_snake(p.name): p.name for p in (getattr(plan, "parts", None) or [])}
- lang = ctx.language
-
- if lang is Language.THREEJS or callable(custom):
- entry = "src/object.js" if lang is Language.THREEJS else "src/model.py"
-
- def _per_part(target: str) -> list[str]:
- key = to_snake(target)
- if key in part_names:
- if callable(custom):
- try:
- out = custom(part_names[key])
- if out:
- return (
- [str(out)]
- if isinstance(out, (str, Path))
- else [str(p) for p in out]
- )
- except Exception as e: # noqa: BLE001
- log.warning("runtime.file_for_part failed for %s: %s", target, e)
- return [f"src/parts/{key}.js"] if lang is Language.THREEJS else [entry]
- if key in ("overall", "assembly", "object", ""):
- return [entry]
- return []
-
- return _per_part
-
- if lang is Language.SCENE_THREEJS:
- zone_plans = list(getattr(plan, "zones", None) or [])
- zones = {to_snake(z.name) for z in zone_plans}
- assets = {to_snake(a.name): a.kind for a in (getattr(plan, "assets", None) or [])}
- # a merged asset's own file is only the variant shim: the geometry is its survivor's
- alias = {to_snake(k): to_snake(v) for k, v in (ctx.extra.get("asset_alias") or {}).items()}
- cameras = {to_snake(c.name) for c in (getattr(plan, "cameras", None) or [])}
-
- def _scene(target: str) -> list[str]:
- key = to_snake(target)
- if key in zones:
- return [f"src/zones/{key}.js"]
- if key in assets:
- if assets[key] == "threejs":
- return [f"src/assets/{alias.get(key, key)}.js"]
- # a hero is public/assets/<snake>.glb, built in its own sub-workspace: the scene
- # fixes it where it is placed — the zones that list it — else as a whole
- return [f"src/zones/{to_snake(z.name)}.js" for z in zone_plans if key in {to_snake(c) for c in z.contents}]
- if key in cameras or key in ("camera", "cameras", "composition"):
- return ["src/scene.js"]
- if key in ("env", "environment", "lighting", "sky", "fog", "ground", "water", "light"):
- return ["src/env.js"]
- # "Zone/Asset" — the scene_placement gate names the asset but the fix lives in the
- # zone's file; keeping the asset in the target keeps one refine task per asset
- if "/" in target:
- zone_key = to_snake(target.split("/", 1)[0])
- if zone_key in zones:
- return [f"src/zones/{zone_key}.js"]
- return []
-
- return _scene
- return None
diff --git a/harness/codeverse3d/tracks/repair.py b/harness/codeverse3d/tracks/repair.py
index a77625f5..a478616c 100644
--- a/harness/codeverse3d/tracks/repair.py
+++ b/harness/codeverse3d/tracks/repair.py
@@ -122,7 +122,7 @@ def files_for_repair(ctx: RunContext, build: BuildResult, lint: GateReport, file
cands.append(_rel(ctx, f.target))
cands.extend(files_hint)
if not cands:
- for glob in getattr(ctx.runtime, "entry_globs", ()) or ():
+ for glob in ctx.runtime.entry_globs:
cands.extend(str(p.relative_to(ctx.ws.root)) for p in sorted(ctx.ws.root.glob(glob)))
return current_files(ctx, list(dict.fromkeys(cands)), MAX_REPAIR_CONTEXT_CHARS)
diff --git a/harness/codeverse3d/tracks/scene.py b/harness/codeverse3d/tracks/scene.py
index 05c95826..de4fcc36 100644
--- a/harness/codeverse3d/tracks/scene.py
+++ b/harness/codeverse3d/tracks/scene.py
@@ -22,7 +22,7 @@ from __future__ import annotations
import logging
import time
-from collections.abc import Sequence
+from collections.abc import Callable, Sequence
from typing import Any
from codeverse3d.config import scene_textures_enabled
@@ -39,6 +39,7 @@ from codeverse3d.contracts.plan import Plan, ScenePlan, ZonePlan
from codeverse3d.contracts.run import RoundRecord
from codeverse3d.conventions import to_snake
from codeverse3d.judges.base import judged_subset
+from codeverse3d.languages.scene_threejs import zone_file
from codeverse3d.orchestrator import StageRunner, TaskGroup, compact_instructions
from codeverse3d.proc import fan_out
from codeverse3d.prompts import render
@@ -50,7 +51,6 @@ from codeverse3d.tracks.common import RunContext, generate_for, single_shot_ctx
from codeverse3d.tracks.generation import GenerationTask
from codeverse3d.tracks.lifecycle import BaseTrack
from codeverse3d.tracks.prompting import (
- SCENE_FILES,
base_prompt_context,
bbox_line,
cookbook_sections,
@@ -357,7 +357,7 @@ class SceneTrack(BaseTrack):
else:
written = {c.path for c in r.files_changed}
for zone in zones:
- rel = zone_file(zone)
+ rel = 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
@@ -376,7 +376,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) for z in batch]
+ files = [zone_file(z.name) for z in batch]
recipes = cookbook_sections(ctx, ZONE_RECIPES)
briefs = []
for i, zone in enumerate(batch):
@@ -384,7 +384,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), neighbours=neighbours,
+ zone_file=zone_file(zone.name), neighbours=neighbours,
layout=layout_block(ctx.extra.get("layouts", {}).get(zone.name)))))
ctx.record_prompt("scene_zone", briefs[0])
if len(batch) == 1:
@@ -421,7 +421,7 @@ class SceneTrack(BaseTrack):
write (the skeleton guarantees a stub per zone) so the run still delivers a
built, 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)).is_file()]
+ zones = [z for z in plan.zones if (ctx.ws.root / zone_file(z.name)).is_file()]
if not zones:
return False
ctx.extra.setdefault("asset_api", asset_api_summary(plan, ctx.extra.get("assets") or {}, ctx.extra.get("asset_alias")))
@@ -437,12 +437,13 @@ class SceneTrack(BaseTrack):
def baseline_tasks(self, ctx: RunContext) -> list[GenerationTask]:
return [] # generation happened in the stages; round 0 = build → render → judge
- def round_files_hint(self, ctx: RunContext) -> list[str]:
- return list(SCENE_FILES)
-
# ------------------------------------------------------------------ refine (scaffold hooks)
+ def refine_file_for_target(self, ctx: RunContext) -> Callable[[str], list[str]]:
+ """The runtime's layout, with the dedupe note: a merged asset is fixed in its survivor's factory."""
+ return lambda target: ctx.runtime.files_for(ctx.plan, target, alias=ctx.extra.get("asset_alias"))
+
def _refine_task(self, ctx: RunContext, group: TaskGroup, last: RoundRecord, index: int, *, parallel: bool) -> GenerationTask:
- files = group.files or list(SCENE_FILES)
+ files = group.files or ctx.runtime.expected_files(ctx.plan)
lines = compact_instructions(group.tasks, max_lines=ctx.policy.max_instructions_per_task)
prompt = render("tracks/scene_refine.j2", **self._ctx(ctx, recipes=refine_recipes(ctx, files), round_index=index, tasks=lines,
targets=group.targets, files=files, edit_only_these=parallel,
@@ -466,7 +467,7 @@ class SceneTrack(BaseTrack):
rel = last.build.error_file.removeprefix(str(ctx.ws.root)).lstrip("/")
if (ctx.ws.root / rel).is_file():
files = [rel]
- files = files or self.round_files_hint(ctx)
+ files = files or ctx.runtime.expected_files(ctx.plan)
prompt = render("tracks/scene_refine.j2", **self._ctx(ctx, recipes="", round_index=index, tasks=lines, targets=["build"],
files=files, edit_only_these=False,
judge_summary="(no judgment: the scene did not build — fix the errors above first)",
@@ -502,10 +503,6 @@ def refine_recipes(ctx: RunContext, files: Sequence[str]) -> str:
return cookbook_sections(ctx, names)
-def zone_file(zone: ZonePlan) -> str:
- return f"src/zones/{to_snake(zone.name)}.js"
-
-
def _touched(path: Any, since: float) -> bool:
"""Was ``path`` (re)written after ``since``? (mtime beats existence: every zone
path already holds a skeleton stub.)"""
diff --git a/harness/codeverse3d/tracks/scene_assets.py b/harness/codeverse3d/tracks/scene_assets.py
index 9c04a0b0..24f82e40 100644
--- a/harness/codeverse3d/tracks/scene_assets.py
+++ b/harness/codeverse3d/tracks/scene_assets.py
@@ -36,6 +36,7 @@ from codeverse3d.contracts.plan import AssetPlan, BBox, PartPlan, ScenePlan, Sta
from codeverse3d.contracts.spec import Constraints, Spec
from codeverse3d.conventions import OBJECT_VIEWS_QUICK, to_pascal, to_snake
from codeverse3d.judges.rubrics import is_degraded
+from codeverse3d.languages.scene_threejs import asset_file
from codeverse3d.orchestrator import BudgetExceeded
from codeverse3d.proc import fan_out, read_json_or_none, write_json_atomic, write_text_atomic
from codeverse3d.prompts import render
@@ -51,7 +52,6 @@ from codeverse3d.tracks.prompting import (
base_prompt_context,
constraints_text,
current_files,
- expected_files,
language_system_prompt,
reference_images,
skeleton_files,
@@ -115,11 +115,6 @@ def is_model_outage(e: BaseException) -> bool:
return False
-def asset_file(asset: AssetPlan) -> str:
- snake = to_snake(asset.name)
- return f"src/assets/{snake}.js" if asset.kind == "threejs" else f"public/assets/{snake}.glb"
-
-
def asset_api_summary(plan: ScenePlan, results: dict[str, AssetResult], alias: dict[str, str] | None = None) -> str:
"""What zone/composer tasks need to know about each asset (names + sizes + how to get it).
@@ -429,7 +424,7 @@ def build_blender_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> As
if not ctx.single_shot:
ctx.services.materialize(sub_ws, agent_kind=ctx.agent_kind, contract_md=sub.contract_text, cookbook_rel=sub.cookbook_rel,
spatial_tools=True)
- files = expected_files(sub)
+ files = sub.runtime.expected_files(sub.plan)
timeout_s = asset_timeout_s(ctx, 180)
label = f"asset_{snake}"
diff --git a/harness/codeverse3d/tracks/static_object.py b/harness/codeverse3d/tracks/static_object.py
index b30a47e0..097c1dc9 100644
--- a/harness/codeverse3d/tracks/static_object.py
+++ b/harness/codeverse3d/tracks/static_object.py
@@ -43,8 +43,6 @@ from codeverse3d.tracks.lifecycle import BaseTrack
from codeverse3d.tracks.prompting import (
base_prompt_context,
budget_for,
- expected_files,
- file_for_target_factory,
judge_digest,
judged_sheet,
language_system_prompt,
@@ -162,7 +160,7 @@ class StaticObjectTrack(BaseTrack):
scoped = self.scoped_baseline_tasks(ctx)
if scoped:
return scoped
- files = expected_files(ctx)
+ files = ctx.runtime.expected_files(ctx.plan)
prompt = render(
self.generate_template,
**base_prompt_context(
@@ -201,17 +199,12 @@ class StaticObjectTrack(BaseTrack):
return cached
got = scope_groups(
ctx.plan,
- files_for=file_for_target_factory(ctx),
+ files_for=self.refine_file_for_target(ctx),
max_groups=max(2, int(getattr(ctx.settings.limits, "max_parallel_agents", 6) or 6)),
)
ctx.extra["scopes"] = got
return got
- def entry_files(self, ctx: RunContext) -> list[str]:
- """The assembly session's files: the entry, and nothing else."""
- files = expected_files(ctx)
- return files[:1] or ["src/model.py"]
-
def scoped_baseline_tasks(self, ctx: RunContext) -> list[GenerationTask]:
"""Fan the baseline out: one session per few parts (phase 0), then ONE assembly
session that owns the entry file and the placement gates (phase 1).
@@ -250,7 +243,7 @@ class StaticObjectTrack(BaseTrack):
edit_only=True,
)
)
- entry = self.entry_files(ctx)
+ entry = ctx.runtime.expected_files(ctx.plan)[:1] # the assembly session's files: the entry, nothing else
assemble = render(
self.assemble_template, **base_prompt_context(ctx, files=entry, expected_files=entry)
)
@@ -283,9 +276,6 @@ class StaticObjectTrack(BaseTrack):
return language_system_prompt(ctx.language, role="scope",
n_parts=len(scope.parts), names=", ".join(scope.names))
- def round_files_hint(self, ctx: RunContext) -> list[str]:
- return expected_files(ctx)
-
# ------------------------------------------------------------------ refine (scaffold hooks)
def extra_refine_tasks(self, ctx: RunContext, last: RoundRecord) -> Sequence[RefineTask]:
# NB: the `detail_budget` WARN is deliberately NOT turned into a refine task. Measured:
@@ -299,7 +289,7 @@ class StaticObjectTrack(BaseTrack):
# scope is real whenever the judge's targets resolved to files — parallel or not.
# A group whose targets did not resolve (target "overall") keeps the whole tree.
scoped = parallel or bool(group.files)
- files = group.files if scoped else expected_files(ctx)
+ files = group.files if scoped else ctx.runtime.expected_files(ctx.plan)
lines = compact_instructions(group.tasks, max_lines=ctx.policy.max_instructions_per_task)
prompt = render(
self.refine_template,
diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.md
index e0cb2f48..59973b28 100644
--- a/harness/docs/ARCHITECTURE.md
+++ b/harness/docs/ARCHITECTURE.md
@@ -111,7 +111,8 @@ codeverse3d/
(gemini-cli / claude-code / codex / antigravity), cli_common.py (sessions,
the watchdog clocks, the transcript, retry trajectory naming,
files_changed attribution), materialize.py
- languages/ LanguageRuntime (base.py); one merged module per language since 2026-08-28 —
+ languages/ LanguageRuntime + RuntimeLayout (base.py: every runtime states its file layout —
+ expected_files / files_for — and the tracks ask it); one merged module per language since 2026-08-28 —
blender/ cadquery/ threejs/ urdf/ scene_threejs/ glsl_shader/ opengl_python/ are each
a single __init__.py (lint → skeleton → runtime, in dependency order) beside their
data (starter/, opengl_python/wrappers/run_gl.py; the contract text is
diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.md
index 3b54d407..56993b58 100644
--- a/harness/docs/INTERFACES.md
+++ b/harness/docs/INTERFACES.md
@@ -209,6 +209,14 @@ rt.language; rt.entry_globs
rt.lint(ws) -> GateReport # gate = "lint:<language>"
rt.build(ws, *, timeout_s=None, **per_runtime) -> BuildResult # Δ BuildResult.error_file is WORKSPACE-relative for
rt.skeleton(ws, plan) -> list[Path] # every runtime ("src/model.py", "src/parts/leg.py", "src/helpers.py")
+rt.expected_files(plan) -> list[str] # Δ 2026-09-22 THE file layout, asked by every track: the files a
+rt.files_for(plan, target) -> list[str] # whole-artifact session writes (entry first) / the files that own a refine
+ # target ([] = no owner → one whole-artifact task). languages/base.RuntimeLayout answers for the object + graphics
+ # runtimes (entry + extra_files, + part_file per part for blender / three.js); the scene runtime answers with
+ # languages/scene_threejs.{SCENE_FILES, zone_file, asset_file, scene_files_for} (files_for(..., alias=) — the dedupe
+ # 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)
from codeverse3d.prompts.catalog import language_prompt, language_text
language_prompt(language, name) -> str # "<dir>/<name>" under prompts/ (urdf_blender → urdf/): THE per-language prompt
language_text(language, name) -> str # its text, "" for a file the language does not ship (Δ 2026-09-22: replaces
@@ -219,7 +227,7 @@ BuildResult.error_type spellings (languages/_common.py): MISSING_ENTRY = "Missin
```
| runtime | entry_globs | notes / artifacts |
|---|---|---|
-| `BlenderRuntime` | `src/model.py`, `src/parts/*.py` | **Δ multi-file**: `file_for_part(name) -> "src/parts/<snake>.py"` (`def build_<snake>()`); lint = `layout.lint_workspace` over every src/*.py; skeleton writes model.py + per-part files; object.glb/stl, build.json, census.json |
+| `BlenderRuntime` | `src/model.py`, `src/parts/*.py` | **Δ multi-file**: `part_file(name) -> "src/parts/<snake>.py"` (`def build_<snake>()`); lint = `layout.lint_workspace` over every src/*.py; skeleton writes model.py + per-part files; object.glb/stl, build.json, census.json |
| `CadQueryRuntime` | `src/model.py` | trailing selector on the stack → parent solid exported + warning (ExportError when no solid exists); helper-module errors map to `src/<file>.py:line`; object.glb/stl/step |
| `ThreeJsRuntime` | `src/object.js`, `src/parts/*.js` | **Δ export as authored** (census `placement_offset`); InstancedMesh baked to `<Name>_<i>` meshes (`instanced_meshes_baked`); exported `selfcheck(THREE, root)` is called (throw → SelfCheckError); NaN geometry errors name mesh/part → routed to `src/parts/<snake>.js` |
| `UrdfBlenderRuntime` | `src/model.py`, `src/robot.urdf` | object.glb (Y-up, node=link, joint extras), meshes/<link>.glb (raw Z-up link frames); link name `world` is reserved (lint ERROR + UrdfError); robot GLB root gets `__root` suffix on name clash |
@@ -450,8 +458,8 @@ scope_groups(plan, *, files_for, max_groups=6, parts_per_scope=3, min_parts=8) -
# [] = one session owns the object (small plan, no per-part file ownership, or $C3D_SCOPED_PARTS=off);
# otherwise attachment-subtree groups whose files are disjoint, so the sessions run in parallel
interfaces_text(plan, scope) -> str # the planned boxes of the neighbours this scope must weld to
-from codeverse3d.tracks.prompting import base_prompt_context, reference_images, file_for_target_factory, \
- scope_context, budget_for, detail_budget_text # Δ split out of
+from codeverse3d.tracks.prompting import base_prompt_context, reference_images, scope_context, budget_for, \
+ detail_budget_text # Δ split out of
from codeverse3d.tracks.prompting import select_cookbook_chapters, is_always_chapter
# select_cookbook_chapters(ctx, brief, *, budget=9000, always=COOKBOOK_ALWAYS) -> list[Section]: the header +
# always-on chapters + the brief's chapters (whole, cookbook order, inside budget)
diff --git a/harness/docs/RUNBOOK.md b/harness/docs/RUNBOOK.md
index ba5fdca0..660a2976 100644
--- a/harness/docs/RUNBOOK.md
+++ b/harness/docs/RUNBOOK.md
@@ -360,14 +360,16 @@ model, produced the zero — check `cell.json`'s `error`).
* **New language**: enum in `contracts/common.py::Language` (+ `TRACK_LANGUAGES`,
`ENTRY_FILE`, `LANGUAGE_LABEL`), frame in `conventions.LANGUAGE_FRAME`;
- `languages/<lang>/__init__.py` (one merged module per language; the contract text is
- `prompts/<lang>/contract.md`) implementing `LanguageRuntime`, and a python-executed build
- wrapper beside the others in `languages/wrappers/` (import `_wrapper_common`; read its report
- with `_common.compose_build_result`, which publishes the final `build.json`); branch in `languages/base.py::get_runtime`;
- `prompts/<lang>/contract.md` + `cookbook.md` (every snippet must run —
- `tests/prompts` executes them); part→file mapping via `runtime.file_for_part`
- (blender has it; `tracks/prompting.file_for_target_factory` picks it up and maps
- every whole-object target to `[entry]` — no runtime `file_for_target` hook).
+ `languages/<lang>/__init__.py` (one merged module per language) implementing
+ `LanguageRuntime` — its file layout included: subclass `languages/base.RuntimeLayout`
+ (entry + `extra_files`, and `part_file` for a one-file-per-part language) or answer
+ `expected_files(plan)` / `files_for(plan, target)` yourself, as the scene runtime does; the
+ tracks never restate it. A python-executed build wrapper goes beside the others in
+ `languages/wrappers/` (import `_wrapper_common`; read its report with
+ `_common.compose_build_result`, which publishes the final `build.json`); branch in
+ `languages/base.py::get_runtime`; `prompts/<lang>/{system,contract,cookbook}.md` (found by
+ `prompts/catalog.language_prompt`; every cookbook snippet must run — `tests/prompts`
+ executes them).
* **New spatial tool**: pydantic args + `@tool("name", Args, "…", tracks=(…),
languages=(…), cost_hint=…)` in `spatial/tools.py`; available to tracks, MCP and prompt cards at once.
Update `tests/spatial_tools` EXPECTED_TOOLS.
@@ -379,13 +381,14 @@ model, produced the zero — check `cell.json`'s `error`).
* **New backend**: ChatModel → `models/<provider>.py` + registry + prices;
CodingAgent → `agents/backends.py` using `cli_common` + registry + `materialize.py`.
* **New track**: subclass `tracks/lifecycle.py::BaseTrack` (hooks: `make_pipeline`,
- `prepare`, `baseline_tasks`, `refine_tasks`, `round_files_hint`; `system_prompt`
+ `prepare`, `baseline_tasks`, `refine_tasks`; `system_prompt`
defaults to `language_system_prompt(ctx.language, tools=not ctx.single_shot)` and
- `refine_file_for_target` to `file_for_target_factory(ctx)` — override only for
+ `refine_file_for_target` to the runtime's `files_for` — override only for
role-specific prompts), a `RoundPipeline`,
- plan model in `contracts/plan.py`, `.j2` prompts, branch in `tracks/__init__.py`
- (`get_track` forwards `**options` to constructors). `tracks/graphics.py` is the
- template for a track with its own planner and no GLB.
+ plan model in `contracts/plan.py`, `.j2` prompts, the planner's per-track rows in
+ `tracks/planner.py` (template, example, temperature, acceptance), branch in
+ `tracks/__init__.py` (`get_track` forwards `**options` to constructors).
+ `tracks/graphics.py` is the template for a track with no GLB.
* **New bench battery**: `eval/bench/prompts/<name>.yaml` with `name, track, language,
prompts[{id, tier, category, prompt, must_have, dimensions_m}]`.
diff --git a/harness/tests/blender_cadquery/test_blender_multifile.py b/harness/tests/blender_cadquery/test_blender_multifile.py
index 7bb32357..84db89ed 100644
--- a/harness/tests/blender_cadquery/test_blender_multifile.py
+++ b/harness/tests/blender_cadquery/test_blender_multifile.py
@@ -99,7 +99,7 @@ def test_live_four_part_multifile_skeleton_builds(tmp_ws, four_part_plan, blende
paths = rt.skeleton(tmp_ws, four_part_plan)
assert [p.relative_to(tmp_ws.root).as_posix() for p in paths] == [
"src/model.py", "src/parts/seat.py", "src/parts/leg.py", "src/parts/foot_ring.py", "src/parts/seat_plate.py"]
- assert rt.file_for_part("FootRing") == "src/parts/foot_ring.py"
+ assert rt.expected_files(four_part_plan) == [p.relative_to(tmp_ws.root).as_posix() for p in paths] # the layout IS the skeleton
lint = rt.lint(tmp_ws)
assert lint.passed, [(f.target, f.message) for f in lint.errors]
r = rt.build(tmp_ws, timeout_s=120)
diff --git a/harness/tests/blender_cadquery/test_blender_runtime.py b/harness/tests/blender_cadquery/test_blender_runtime.py
index 8a213650..8f04159f 100644
--- a/harness/tests/blender_cadquery/test_blender_runtime.py
+++ b/harness/tests/blender_cadquery/test_blender_runtime.py
@@ -44,7 +44,7 @@ def test_protocol_and_registry() -> None:
rt = get_runtime("blender")
assert isinstance(rt, BlenderRuntime) and isinstance(rt, LanguageRuntime)
assert rt.entry_globs == ("src/model.py", "src/parts/*.py") and rt.language.value == "blender"
- assert rt.file_for_part("Seat Cushion") == "src/parts/seat_cushion.py" # tracks call this via getattr
+ assert rt.part_file("Seat Cushion") == "src/parts/seat_cushion.py" # the layout the tracks ask for
contract = language_text(rt.language, "contract.md")
assert "bpy" in contract and "Z is up" in contract
diff --git a/harness/tests/graphics/test_track.py b/harness/tests/graphics/test_track.py
index a0a46636..dcf90fa9 100644
--- a/harness/tests/graphics/test_track.py
+++ b/harness/tests/graphics/test_track.py
@@ -11,14 +11,15 @@ import pytest
from PIL import Image
from codeverse3d.config import Settings
-from codeverse3d.contracts.artifacts import BuildResult, GateReport
+from codeverse3d.contracts.artifacts import BuildResult
from codeverse3d.contracts.common import Backends, Budget, Language, Track
from codeverse3d.contracts.plan import GraphicsPlan
from codeverse3d.contracts.run import RunStatus
from codeverse3d.contracts.spec import Constraints, Spec
from codeverse3d.judges.rubrics import load_rubric
from codeverse3d.languages._gl_common import finish_build, judge_times
-from codeverse3d.languages.glsl_shader import lint_workspace, write_skeleton
+from codeverse3d.languages.glsl_shader import GlslShaderRuntime
+from codeverse3d.languages.opengl_python import OpenGLPythonRuntime
from codeverse3d.proc import EventLog
from codeverse3d.prompts import render
from codeverse3d.spatial.gl_render import GlFrame, GlResult, gif_times
@@ -47,21 +48,16 @@ def _frame(path: Path, t: float, static: bool) -> None:
Image.fromarray((rgb * 255).astype(np.uint8), "RGB").save(path)
-class FakeGlRuntime:
- """glsl_shader runtime without GL: writes synthetic frames through the real ``finish_build``."""
+class FakeGlRuntime(GlslShaderRuntime):
+ """glsl_shader runtime without GL: writes synthetic frames through the real ``finish_build``
+ (the real runtime's layout, skeleton and lint)."""
- language = Language.GLSL_SHADER
entry_globs = ("src/shader.frag", "src/common.glsl")
def __init__(self) -> None:
+ super().__init__()
self.builds = 0
- def skeleton(self, ws: Workspace, plan: Any) -> list[Path]:
- return write_skeleton(ws, plan)
-
- def lint(self, ws: Workspace) -> GateReport:
- return lint_workspace(ws)
-
def build(self, ws: Workspace, *, timeout_s: int | None = None, **kw: Any) -> BuildResult:
self.builds += 1
src = (ws.src / "shader.frag").read_text()
@@ -245,7 +241,7 @@ def test_templates_render_and_rubric_loads(tmp_path, settings):
assert {c.id for c in rubric.caps} >= {"nan_pixels", "static_frames", "black_or_blown", "build_error"}
spec = make_spec(language=Language.OPENGL_PYTHON, generator="single-shot:fake:fake-model")
ws = Workspace(tmp_path / "runs" / "tpl").create()
- track = GraphicsTrack(services=_services(), settings=settings, runtime=FakeGlRuntime())
+ track = GraphicsTrack(services=_services(), settings=settings, runtime=OpenGLPythonRuntime()) # nothing is built
from codeverse3d.orchestrator import RunState
ctx = track.build_context(spec, ws, EventLog(ws.events_path), RunState.load_or_new(ws, resume=False))
diff --git a/harness/tests/orchestrator_tracks/fakes.py b/harness/tests/orchestrator_tracks/fakes.py
index b29097d9..dcaec5f9 100644
--- a/harness/tests/orchestrator_tracks/fakes.py
+++ b/harness/tests/orchestrator_tracks/fakes.py
@@ -31,6 +31,7 @@ from codeverse3d.contracts.common import Language, Usage
from codeverse3d.contracts.plan import Plan
from codeverse3d.contracts.run import RunRecord
from codeverse3d.conventions import to_snake
+from codeverse3d.languages import get_runtime
from codeverse3d.tracks.common import Services
from codeverse3d.workspace import Workspace
@@ -43,7 +44,8 @@ class ServiceUnavailable(RuntimeError):
# ----------------------------------------------------------------------------- runtime
class FakeRuntime:
- """Writes a tiny GLB (one box per part) on build; fails when a src file contains FAIL_MARK."""
+ """Writes a tiny GLB (one box per part) on build; fails when a src file contains FAIL_MARK.
+ Its file layout (``expected_files`` / ``files_for``) is the real runtime's for the language."""
def __init__(self, language: Language = Language.THREEJS, *, lint_error_mark: str = "LINT_ERROR"):
self.language = language
@@ -51,6 +53,8 @@ class FakeRuntime:
self.lint_error_mark = lint_error_mark
self.builds = 0
self.lock = threading.Lock()
+ layout = get_runtime(language)
+ self.expected_files, self.files_for = layout.expected_files, layout.files_for
def skeleton(self, ws: Workspace, plan: Plan) -> list[Path]:
out = []
diff --git a/harness/tests/orchestrator_tracks/test_asset_alias_note.py b/harness/tests/orchestrator_tracks/test_asset_alias_note.py
index 84f8c292..ade10b8c 100644
--- a/harness/tests/orchestrator_tracks/test_asset_alias_note.py
+++ b/harness/tests/orchestrator_tracks/test_asset_alias_note.py
@@ -28,16 +28,16 @@ def test_a_refine_target_routes_to_the_file_that_really_holds_the_asset():
from codeverse3d.contracts.common import Language, Track
from codeverse3d.contracts.plan import ScenePlan
+ from codeverse3d.languages import get_runtime
from codeverse3d.tracks.planner import plan_example
- from codeverse3d.tracks.prompting import file_for_target_factory
+ from codeverse3d.tracks.scene import SceneTrack
plan = ScenePlan.model_validate(plan_example(Track.SCENE)) # Quay places Bollard and Crate (the hero)
plan.assets.append(next(a for a in plan.assets if a.name == "Bollard").model_copy(update={"name": "Mooring"}))
- ctx = SimpleNamespace(plan=plan, language=Language.SCENE_THREEJS, runtime=SimpleNamespace(),
- extra={"asset_alias": {"Mooring": "Bollard"}})
- files_for = file_for_target_factory(ctx)
+ ctx = SimpleNamespace(plan=plan, runtime=get_runtime(Language.SCENE_THREEJS), extra={"asset_alias": {"Mooring": "Bollard"}})
+ files_for = SceneTrack().refine_file_for_target(ctx)
assert files_for("Bollard") == ["src/assets/bollard.js"]
assert files_for("Mooring") == ["src/assets/bollard.js"], "the survivor's factory, not the shim"
assert files_for("Crate") == ["src/zones/quay.js"], "a hero is fixed where it is placed"
plan.zones = [z for z in plan.zones if z.name != "Quay"]
- assert file_for_target_factory(ctx)("Crate") == [], "placed nowhere: a whole-scene task"
+ assert files_for("Crate") == [], "placed nowhere: a whole-scene task"
diff --git a/harness/tests/orchestrator_tracks/test_candidates_reference_motion.py b/harness/tests/orchestrator_tracks/test_candidates_reference_motion.py
index 287e8886..ee7ded9e 100644
--- a/harness/tests/orchestrator_tracks/test_candidates_reference_motion.py
+++ b/harness/tests/orchestrator_tracks/test_candidates_reference_motion.py
@@ -239,25 +239,16 @@ def test_articulated_motion_direction_gate_feeds_refine_and_judge(tmp_path, sett
assert any(v.name == "pose_DrawerSlide_upper" for v in rec.rounds[0].renders.views)
-# ----------------------------------------------------------------------------- per-part files via runtime.file_for_part
-def test_expected_files_and_targets_follow_runtime_file_for_part(tmp_path, chair_plan, settings):
- from codeverse3d.conventions import to_snake
- from codeverse3d.tracks.prompting import file_for_target_factory
- from codeverse3d.tracks.static_object import expected_files
-
- class PartsRuntime(FakeRuntime):
- @staticmethod
- def file_for_part(name: str) -> str:
- return f"src/parts/{to_snake(name)}.py"
-
- spec = make_spec(language=Language.BLENDER, max_rounds=0)
- track = StaticObjectTrack(services=FakeServices(), settings=settings, runtime=PartsRuntime(Language.BLENDER))
+# ----------------------------------------------------------------------------- per-part files come from the runtime
+def test_expected_files_and_targets_follow_the_runtime_layout(tmp_path, chair_plan, settings):
from codeverse3d.orchestrator import RunState
+ spec = make_spec(language=Language.BLENDER, max_rounds=0)
+ track = StaticObjectTrack(services=FakeServices(), settings=settings, runtime=FakeRuntime(Language.BLENDER))
ctx = track.build_context(spec, Workspace(tmp_path / "ws").create(), EventLog(tmp_path / "e.jsonl"), RunState())
ctx.plan = chair_plan
- assert expected_files(ctx)[:3] == ["src/model.py", "src/parts/seat.py", "src/parts/front_leg.py"]
- fft = file_for_target_factory(ctx)
+ assert ctx.runtime.expected_files(ctx.plan)[:3] == ["src/model.py", "src/parts/seat.py", "src/parts/front_leg.py"]
+ fft = track.refine_file_for_target(ctx)
assert fft("Seat") == ["src/parts/seat.py"] and fft("overall") == ["src/model.py"] and fft("BackLeg_1") == []
diff --git a/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py b/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py
index c451ff7e..57c6ea1a 100644
--- a/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py
+++ b/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py
@@ -38,6 +38,7 @@ def test_every_track_sends_the_whole_cookbook(monkeypatch) -> None:
stage knows which chapters it needs (scene's env/zone recipes, graphics' recipe
seeding); it is not right as a way to shrink the reference itself.
"""
+ from codeverse3d.languages import get_runtime
from codeverse3d.tracks import graphics as graphics_steps
from codeverse3d.tracks.prompting import base_prompt_context
@@ -47,7 +48,7 @@ def test_every_track_sends_the_whole_cookbook(monkeypatch) -> None:
track=Track.GRAPHICS, language=Language.GLSL_SHADER,
contract_text="CONTRACT", cookbook_rel="glsl_shader/cookbook.md",
cookbook_text=big, tool_cards="", single_shot=True, extra={},
- runtime=SimpleNamespace(entry_globs=()))
+ runtime=get_runtime(Language.GLSL_SHADER))
monkeypatch.setattr("codeverse3d.tracks.prompting.constraints_text", lambda spec: "")
monkeypatch.setattr("codeverse3d.tracks.prompting.reference_note", lambda ctx: "")
monkeypatch.setattr("codeverse3d.tracks.prompting.acceptance_lines", lambda plan: "")
diff --git a/harness/tests/orchestrator_tracks/test_fixed_rounds.py b/harness/tests/orchestrator_tracks/test_fixed_rounds.py
index 48119e74..3cb1ac8c 100644
--- a/harness/tests/orchestrator_tracks/test_fixed_rounds.py
+++ b/harness/tests/orchestrator_tracks/test_fixed_rounds.py
@@ -24,7 +24,7 @@ def _track(chair_plan, settings, scores, *, agent=None) -> StaticObjectTrack:
agent = agent or FakeAgent(lambda job, ws: {"src/model.py": f"import bpy # {job.label} r{job.round}\n"})
return StaticObjectTrack(services=FakeServices(), judge=FakeJudge(scores=scores), agent=agent,
planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings,
- runtime=FakeRuntime(Language.BLENDER))
+ runtime=FakeRuntime(Language.CADQUERY))
@pytest.mark.parametrize("scores", [
@@ -36,7 +36,7 @@ def _track(chair_plan, settings, scores, *, agent=None) -> StaticObjectTrack:
def test_a_run_is_the_baseline_plus_max_rounds_whatever_the_judge_says(tmp_path, chair_plan, settings, scores,
max_rounds):
ws = Workspace(tmp_path / "runs" / "fixed")
- rec = _track(chair_plan, settings, scores).run(make_spec(language=Language.BLENDER, max_rounds=max_rounds), ws)
+ rec = _track(chair_plan, settings, scores).run(make_spec(language=Language.CADQUERY, max_rounds=max_rounds), ws)
assert len(rec.rounds) == max_rounds + 1
assert [r.kind for r in rec.rounds] == ["baseline"] + ["refine"] * max_rounds
assert rec.status is RunStatus.MAX_ROUNDS and rec.extra["stop_reason"] == "max_rounds"
@@ -50,7 +50,7 @@ def test_only_the_clock_stops_a_run_early(tmp_path, chair_plan, settings):
ws = Workspace(tmp_path / "runs" / "clock")
with fake_clock():
rec = _track(chair_plan, settings, (0.5, 0.6, 0.7, 0.8), agent=agent).run(
- make_spec(language=Language.BLENDER, max_rounds=4, max_minutes=10.0), ws)
+ make_spec(language=Language.CADQUERY, max_rounds=4, max_minutes=10.0), ws)
assert rec.status is RunStatus.BUDGET and 1 <= len(rec.rounds) < 5
@@ -66,7 +66,7 @@ def test_every_refine_starts_from_the_previous_rounds_commit(tmp_path, chair_pla
ws = Workspace(tmp_path / "runs" / "prev")
rec = _track(chair_plan, settings, (0.70, 0.30, 0.50), agent=FakeAgent(writer)).run(
- make_spec(language=Language.BLENDER, max_rounds=2), ws)
+ make_spec(language=Language.CADQUERY, max_rounds=2), ws)
assert seen[1] == "import bpy # written in r0\n"
assert seen[2] == "import bpy # written in r1\n", "r02 must refine r01, not the higher-scored r00"
assert rec.rounds[2].instructions, "the tasks come from r01's verdict and gates"
@@ -103,8 +103,8 @@ def test_every_round_keeps_its_build_and_any_round_can_be_packaged(tmp_path, cha
track = StaticObjectTrack(services=FakeServices(), judge=FakeJudge(scores=(0.5, 0.8, 0.6)),
agent=FakeAgent(lambda job, ws: {"src/model.py": f"import bpy # written in r{job.round}\n"}),
planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings,
- runtime=_RoundStampRuntime(Language.BLENDER))
- rec = track.run(make_spec(language=Language.BLENDER, max_rounds=2), ws)
+ runtime=_RoundStampRuntime(Language.CADQUERY))
+ rec = track.run(make_spec(language=Language.CADQUERY, max_rounds=2), ws)
kept = [ws.round_artifacts(i) / "object.glb" for i in range(3)]
assert all(p.is_file() for p in kept) and (ws.round_artifacts(1) / "object.stl").is_file()
assert len({p.read_bytes() for p in kept}) == 3, "each round keeps its OWN build"
diff --git a/harness/tests/orchestrator_tracks/test_generation_depth.py b/harness/tests/orchestrator_tracks/test_generation_depth.py
index 9cc51403..a523226f 100644
--- a/harness/tests/orchestrator_tracks/test_generation_depth.py
+++ b/harness/tests/orchestrator_tracks/test_generation_depth.py
@@ -173,6 +173,6 @@ def test_the_depth_templates_render_with_strict_undefined(tmp_path, settings):
part = render("tracks/generate_static_part.j2", **scope_context(ctx, scope, files=list(scope.files),
expected_files=list(scope.files)))
assert "Interfaces" in part and "DO NOT create or edit it" in part and scope.names[0] in part
- entry = track.entry_files(ctx)
+ entry = ctx.runtime.expected_files(ctx.plan)[:1]
asm = render("tracks/assemble_static.j2", **base_prompt_context(ctx, files=entry, expected_files=entry))
assert "you own placement, not geometry" in asm and "check_connectivity" in asm
diff --git a/harness/tests/orchestrator_tracks/test_graphics_recipes.py b/harness/tests/orchestrator_tracks/test_graphics_recipes.py
index 5aa5c380..e11ef80a 100644
--- a/harness/tests/orchestrator_tracks/test_graphics_recipes.py
+++ b/harness/tests/orchestrator_tracks/test_graphics_recipes.py
@@ -11,6 +11,7 @@ import pytest
from codeverse3d.config import Settings, seed_recipes_enabled
from codeverse3d.contracts.common import HARNESS_OWNED_SRC, Language, Track
from codeverse3d.contracts.plan import GraphicsPlan
+from codeverse3d.languages import get_runtime
from codeverse3d.languages.glsl_shader import (
COMMON_GLSL,
GlslShaderRuntime,
@@ -68,7 +69,7 @@ def _ctx(ws: Workspace, brief: str = AURORA, *, plan: GraphicsPlan | None = None
spec=SimpleNamespace(prompt=brief, constraints=SimpleNamespace(dimensions_m={}, max_triangles=None, style="",
must_have=[], must_not=[]), references=[]),
language=language, track=Track.GRAPHICS, ws=ws, extra={}, events=EventLog(ws.events_path),
- contract_text="", tool_cards="", single_shot=False, runtime=SimpleNamespace(entry_globs=()))
+ contract_text="", tool_cards="", single_shot=False, runtime=get_runtime(language))
def _defs(text: str) -> list[str]:
diff --git a/harness/tests/orchestrator_tracks/test_integrations2.py b/harness/tests/orchestrator_tracks/test_integrations2.py
index 1d4120d4..dd18b55c 100644
--- a/harness/tests/orchestrator_tracks/test_integrations2.py
+++ b/harness/tests/orchestrator_tracks/test_integrations2.py
@@ -6,14 +6,11 @@ from __future__ import annotations
from codeverse3d.contracts.common import Language, Track
from codeverse3d.contracts.plan import ScenePlan
-from codeverse3d.orchestrator import RunState
-from codeverse3d.proc import EventLog
from codeverse3d.tracks import get_track
from codeverse3d.tracks.graphics import GraphicsTrack
from codeverse3d.tracks.planner import plan_example
-from codeverse3d.tracks.prompting import file_for_target_factory
from codeverse3d.tracks.scene import SceneTrack
-from codeverse3d.tracks.static_object import StaticObjectTrack, expected_files
+from codeverse3d.tracks.static_object import StaticObjectTrack
from codeverse3d.workspace import Workspace
from tests.orchestrator_tracks.conftest import make_spec
from tests.orchestrator_tracks.fakes import (
@@ -75,40 +72,34 @@ def test_connectivity_gate_receives_spec_language(tmp_path, chair_plan, settings
assert services.connectivity_languages == ["threejs"]
-# --------------------------------------------------------------------- (e) blender multi-file expected files / targets
-class BlenderishRuntime(FakeRuntime):
- def __init__(self):
- super().__init__(Language.BLENDER)
-
- @staticmethod
- def file_for_part(part_name: str) -> str:
- from codeverse3d.conventions import to_snake
-
- return f"src/parts/{to_snake(part_name)}.py"
-
- @staticmethod
- def file_for_target(target: str) -> list[str]:
- from codeverse3d.conventions import to_snake
-
- if target.strip().lower() in ("", "overall", "assembly", "object", "model"):
- return ["src/model.py"]
- return [f"src/parts/{to_snake(target)}.py"]
-
-
-def test_blender_expected_files_and_whole_object_targets(tmp_path, chair_plan, settings):
- spec = make_spec(language=Language.BLENDER)
- ws = Workspace(tmp_path / "runs" / "b")
- ws.create()
- track = StaticObjectTrack(services=FakeServices(), settings=settings, runtime=BlenderishRuntime())
- ctx = track.build_context(spec, ws, EventLog(ws.events_path), RunState())
- ctx.plan = chair_plan
- files = expected_files(ctx)
- assert files[0] == "src/model.py" and "src/parts/seat.py" in files and "src/parts/front_leg.py" in files
- fft = file_for_target_factory(ctx)
- assert fft is not None
- assert fft("overall") == ["src/model.py"] # via runtime.file_for_target, never src/object.js
- assert fft("assembly") == ["src/model.py"] and fft("object") == ["src/model.py"]
- assert fft("Seat") == ["src/parts/seat.py"]
+# --------------------------------------------------------------------- (e) every runtime states its file layout
+def test_each_runtime_states_which_file_owns_what(chair_plan):
+ """The runtime owns the file layout its skeleton writes; the tracks ask it (``expected_files`` /
+ ``files_for``) instead of restating it — they did in four places, and the scene copy sent a
+ refine aimed at a GLB hero into ``src/assets/<hero>.js``, a module nothing imports."""
+ from codeverse3d.contracts.plan import ScenePlan
+ from codeverse3d.languages import get_runtime
+
+ per_part = {Language.BLENDER: ("src/model.py", ".py"), Language.THREEJS: ("src/object.js", ".js")}
+ for lang, (entry, ext) in per_part.items():
+ rt = get_runtime(lang)
+ assert rt.expected_files(chair_plan) == [entry, *(f"src/parts/{p}{ext}" for p in ("seat", "front_leg", "back_leg",
+ "backrest", "armrest"))]
+ assert rt.files_for(chair_plan, "Seat") == [f"src/parts/seat{ext}"] and rt.files_for(chair_plan, "overall") == [entry]
+ assert rt.files_for(chair_plan, "assembly") == rt.files_for(chair_plan, "object") == [entry]
+ assert rt.files_for(chair_plan, "BackLeg_1") == [] # an instance name is not a planned part
+ whole = {Language.CADQUERY: ["src/model.py"], Language.URDF_BLENDER: ["src/model.py", "src/robot.urdf"],
+ Language.GLSL_SHADER: ["src/shader.frag", "src/common.glsl"], Language.OPENGL_PYTHON: ["src/program.py"]}
+ for lang, files in whole.items():
+ rt = get_runtime(lang)
+ assert rt.expected_files(chair_plan) == files and rt.files_for(chair_plan, "Seat") == [] == rt.files_for(chair_plan, "overall")
+ scene = get_runtime(Language.SCENE_THREEJS)
+ plan = ScenePlan.model_validate(plan_example(Track.SCENE)) # Quay places Bollard (three.js) and Crate (the hero)
+ assert scene.expected_files(plan) == ["src/scene.js", "src/env.js"]
+ assert scene.files_for(plan, "Quay") == ["src/zones/quay.js"] and scene.files_for(plan, "Bollard") == ["src/assets/bollard.js"]
+ assert scene.files_for(plan, "Crate") == ["src/zones/quay.js"] # a hero is fixed where it is placed
+ assert scene.files_for(plan, "Overview") == ["src/scene.js"] and scene.files_for(plan, "fog") == ["src/env.js"]
+ assert scene.files_for(plan, "Quay/Bollard") == ["src/zones/quay.js"] and scene.files_for(plan, "overall") == []
# --------------------------------------------------------------------- (f) no texture pass in the run
diff --git a/harness/tests/orchestrator_tracks/test_one_world_session.py b/harness/tests/orchestrator_tracks/test_one_world_session.py
index 30584684..cc2b39fa 100644
--- a/harness/tests/orchestrator_tracks/test_one_world_session.py
+++ b/harness/tests/orchestrator_tracks/test_one_world_session.py
@@ -9,10 +9,11 @@ from __future__ import annotations
from codeverse3d.contracts.common import Language, Track
from codeverse3d.contracts.plan import ScenePlan
+from codeverse3d.languages.scene_threejs import zone_file
from codeverse3d.orchestrator import RunState
from codeverse3d.proc import EventLog
from codeverse3d.tracks.planner import plan_example
-from codeverse3d.tracks.scene import ZONE_TIMEOUT_S, SceneTrack, zone_file
+from codeverse3d.tracks.scene import ZONE_TIMEOUT_S, SceneTrack
from codeverse3d.workspace import Workspace
from tests.orchestrator_tracks.conftest import make_spec
from tests.orchestrator_tracks.fakes import FakeRuntime, FakeServices
@@ -26,7 +27,7 @@ def test_a_whole_world_batch_owns_every_zone_file_and_gets_a_window_per_zone(tmp
ctx = track.build_context(make_spec(Track.SCENE, Language.SCENE_THREEJS, max_minutes=600.0), ws, EventLog(ws.events_path), RunState())
ctx.plan = plan
whole = track._zone_task(ctx, list(plan.zones))
- assert whole.files_hint == [zone_file(z) for z in plan.zones] and whole.edit_only
+ assert whole.files_hint == [zone_file(z.name) for z in plan.zones] and whole.edit_only
assert whole.timeout_s == ZONE_TIMEOUT_S * len(plan.zones)
assert "you are its one author" in whole.prompt and "nothing floats" in whole.prompt
assert f"window is {len(plan.zones)} zones' worth ({ZONE_TIMEOUT_S * len(plan.zones) // 60} min)" in whole.prompt
diff --git a/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py b/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py
index df909739..a19bc8be 100644
--- a/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py
+++ b/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py
@@ -85,7 +85,9 @@ def test_hero_prompt_carries_the_scene_and_blenders_own_tools(tmp_ws, settings):
assert "CARDS(static_object/blender)" in job.prompt and "CARDS(scene/" not in job.prompt
# the plan's detail budget, not a flat number; the layout it must fill
assert "40k" not in job.prompt and "DETAIL BUDGET" in job.prompt
- assert job.files_hint == ["src/model.py"] and job.timeout_s <= SA.asset_timeout_s(ctx, 180)
+ # the blender layout: the entry + one file per planned part (the one-part sheet here)
+ assert job.files_hint == ["src/model.py", f"src/parts/{SA.to_snake(hero.name)}.py"]
+ assert job.timeout_s <= SA.asset_timeout_s(ctx, 180)
# the sub-run's plan.json is the plan the prompt was built from
sub = tmp_ws.root / "_assets" / SA.to_snake(hero.name)
assert json.loads((sub / "plan.json").read_text())["object_name"] == hero.name
diff --git a/harness/tests/orchestrator_tracks/test_tracks.py b/harness/tests/orchestrator_tracks/test_tracks.py
index e737910d..d5a37350 100644
--- a/harness/tests/orchestrator_tracks/test_tracks.py
+++ b/harness/tests/orchestrator_tracks/test_tracks.py
@@ -146,13 +146,14 @@ def test_static_track_failure_writes_failed_record_and_raises(tmp_path, chair_pl
assert RunState.load(ws).status is RunStatus.FAILED
-def test_static_track_blender_whole_object_refine(tmp_path, chair_plan, settings):
- """blender = whole-object language: refine is ONE task; prompt carries measured-vs-plan numbers in Z-up."""
- spec = make_spec(language=Language.BLENDER, max_rounds=1)
+def test_static_track_whole_object_refine(tmp_path, chair_plan, settings):
+ """cadquery = whole-object language (its runtime names no per-part file): refine is ONE task;
+ the prompt carries measured-vs-plan numbers in Z-up."""
+ spec = make_spec(language=Language.CADQUERY, max_rounds=1)
ws = Workspace(tmp_path / "runs" / "chair5")
agent = FakeAgent(lambda job, ws: {"src/model.py": f"import bpy # {job.label}\n"})
track = StaticObjectTrack(services=FakeServices(contract_errors=2), judge=FakeJudge(scores=(0.5, 0.6)), agent=agent,
- planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings, runtime=FakeRuntime(Language.BLENDER))
+ planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings, runtime=FakeRuntime(Language.CADQUERY))
rec = track.run(spec, ws)
assert [j.label for j in agent.jobs] == ["baseline", "refine"]
p = agent.jobs[1].prompt
diff --git a/harness/tests/orchestrator_tracks/test_write_scope.py b/harness/tests/orchestrator_tracks/test_write_scope.py
index b823d594..df9b2588 100644
--- a/harness/tests/orchestrator_tracks/test_write_scope.py
+++ b/harness/tests/orchestrator_tracks/test_write_scope.py
@@ -15,6 +15,7 @@ from codeverse3d.contracts.chat import ChatResponse
from codeverse3d.contracts.common import Language, Track, Usage
from codeverse3d.contracts.plan import BBox, PartPlan, ScenePlan, StaticPlan
from codeverse3d.contracts.run import RoundRecord
+from codeverse3d.languages.scene_threejs import zone_file
from codeverse3d.orchestrator import RefineTask, RunState, TaskGroup
from codeverse3d.proc import EventLog
from codeverse3d.tracks.generation import (
@@ -26,7 +27,7 @@ from codeverse3d.tracks.generation import (
write_files,
)
from codeverse3d.tracks.planner import plan_example
-from codeverse3d.tracks.scene import SceneTrack, zone_file
+from codeverse3d.tracks.scene import SceneTrack
from codeverse3d.tracks.static_object import StaticObjectTrack
from codeverse3d.workspace import Workspace
@@ -206,13 +207,13 @@ def test_scene_constructors_enforce_their_file_sets(tmp_path, settings, monkeypa
ctx.plan = plan
zone = plan.zones[0]
zt = track._zone_task(ctx, [zone])
- assert zt.edit_only and not zt.owns_entry and zt.files_hint == [zone_file(zone)]
+ assert zt.edit_only and not zt.owns_entry and zt.files_hint == [zone_file(zone.name)]
if len(plan.zones) >= 2:
bt = track._zone_task(ctx, list(plan.zones[:2]))
- assert bt.edit_only and bt.files_hint == [zone_file(z) for z in plan.zones[:2]]
+ assert bt.edit_only and bt.files_hint == [zone_file(z.name) for z in plan.zones[:2]]
last = RoundRecord(index=0, kind="baseline", build=BuildResult(ok=True, language="scene_threejs"))
group = TaskGroup(tasks=[RefineTask(target=zone.name, kind="geometry", instruction="denser",
- priority=2, files=[zone_file(zone)])], files=[zone_file(zone)])
+ priority=2, files=[zone_file(zone.name)])], files=[zone_file(zone.name)])
assert track._refine_task(ctx, group, last, 1, parallel=True).edit_only is True
assert track._refine_task(ctx, group, last, 1, parallel=False).edit_only is False
diff --git a/harness/tests/scene_gates/test_placement.py b/harness/tests/scene_gates/test_placement.py
index e9b2afd6..48a03da1 100644
--- a/harness/tests/scene_gates/test_placement.py
+++ b/harness/tests/scene_gates/test_placement.py
@@ -13,6 +13,7 @@ from codeverse3d.contracts.artifacts import BuildResult, Severity
from codeverse3d.contracts.common import Language
from codeverse3d.contracts.plan import AssetPlan, BBox, CameraPlan, ScenePlan, ZonePlan
from codeverse3d.judges.rubrics import apply_caps, load_rubric
+from codeverse3d.languages import get_runtime
from codeverse3d.orchestrator import build_refine_instructions
from codeverse3d.spatial.scene_placement import (
GATE,
@@ -21,7 +22,6 @@ from codeverse3d.spatial.scene_placement import (
placement_gate_safe,
placement_table_text,
)
-from codeverse3d.tracks.prompting import file_for_target_factory
from codeverse3d.tracks.scene import ScenePipeline
@@ -141,8 +141,8 @@ def _plan():
def test_error_findings_become_zone_routed_refine_tasks_one_per_asset():
plan = _plan()
r = placement_findings(_table(_row("Lantern", gap=0.3), _row("Bench", gap=0.4), _row("Vase", zone="House", gap=0.5)))
- ctx = SimpleNamespace(runtime=SimpleNamespace(), plan=plan, language=Language.SCENE_THREEJS, extra={})
- tasks = build_refine_instructions(None, [r], [], plan, file_for_target=file_for_target_factory(ctx))
+ rt = get_runtime(Language.SCENE_THREEJS)
+ tasks = build_refine_instructions(None, [r], [], plan, file_for_target=lambda target: rt.files_for(plan, target))
assert sorted((t.target, tuple(t.files)) for t in tasks) == [("House/Vase", ("src/zones/house.js",)), ("Yard/Bench", ("src/zones/yard.js",)),
("Yard/Lantern", ("src/zones/yard.js",))]
assert all(t.kind == f"gate:{GATE}" and "lower " in t.instruction for t in tasks)