Official Codebase of 3DCodeVerse
Python
tracks: the pre-round stages are declared per track as StageNode tuples and walked by run_stages — the prepare hook goes (Phase B, Q3)
gaoypeng6998038e7cb7
diff --git a/harness/codeverse3d/tracks/graphics.py b/harness/codeverse3d/tracks/graphics.pyindex 1b4ef341..698bcc73 100644--- a/harness/codeverse3d/tracks/graphics.py+++ b/harness/codeverse3d/tracks/graphics.py@@ -43,7 +43,7 @@ from codeverse3d.prompts import renderfrom codeverse3d.prompts.sections import Section, split_sectionsfrom codeverse3d.tracks.common import RunContextfrom codeverse3d.tracks.generation import GenerationTask-from codeverse3d.tracks.lifecycle import BaseTrack, StageRunner+from codeverse3d.tracks.lifecycle import MATERIALIZE, SKELETON, BaseTrack, StageNodefrom codeverse3d.tracks.prompting import (base_prompt_context,is_always_chapter,@@ -356,6 +356,15 @@ def frame_stats_text(ws: Workspace, round_index: int | None = None) -> str:return "\n".join(lines)+def _commit_recipes(ctx: RunContext) -> None:+ """The brief's verified cookbook recipes into the harness-owned, read-only src/recipes.glsl+ (seed_recipes: measured, flash does not call a recipe it is only shown — and a recipe seeded+ into its own common.glsl was overwritten by the end of the run, so the file is one the agent+ cannot write: AgentJob.read_only). Idempotent (a resume adds only missing names): uncached."""+ if seed_recipes(ctx):+ ctx.ws.commit("recipes")++class GraphicsPipeline:"""No measurement; no gates of its own — the build's ``gl_frames`` report is the round'sgate (``BuildResult.gates``, appended by ``steps``); render = the frames."""@@ -383,20 +392,11 @@ class GraphicsTrack(BaseTrack):# refinement is always ONE whole-program taskallow_refine_fanout = Falsebaseline_temperature = 0.6+ stages = (SKELETON, StageNode("recipes", lambda t, c: _commit_recipes(c)), MATERIALIZE)def make_pipeline(self) -> GraphicsPipeline:return GraphicsPipeline()- # ------------------------------------------------------------------ prepare- def prepare(self, ctx: RunContext, runner: StageRunner) -> None:- """Skeleton, then the brief's verified cookbook recipes into the harness-owned, read-only- src/recipes.glsl (seed_recipes: measured, flash does not call a recipe it is only shown — and a- recipe seeded into its own common.glsl was overwritten by the end of the run, so the file is one- the agent cannot write: AgentJob.read_only)."""- super().prepare(ctx, runner)- if seed_recipes(ctx):- ctx.ws.commit("recipes")-def generate_context(self, ctx: RunContext, **extra: Any) -> dict[str, Any]:return graphics_prompt_context(ctx, **extra)diff --git a/harness/codeverse3d/tracks/lifecycle.py b/harness/codeverse3d/tracks/lifecycle.pyindex 5abada72..419b0e48 100644--- a/harness/codeverse3d/tracks/lifecycle.py+++ b/harness/codeverse3d/tracks/lifecycle.py@@ -1,8 +1,9 @@-"""BaseTrack: the resumable plan → prepare → rounds → finalise lifecycle.+"""BaseTrack: the resumable plan → pre-round stages → rounds → finalise lifecycle.-Concrete tracks (static / articulated / scene / graphics) override the hooks-(``plan_model``, ``make_pipeline``, ``prepare``, ``baseline_tasks`` and the refine-scaffold's ``_refine_task``); what differs per track at PLANNING time is+Concrete tracks (static / articulated / scene / graphics) declare their pre-round graph+(``stages``: :class:`StageNode` tuples, walked by :func:`run_stages`) and override the+hooks (``plan_model``, ``make_pipeline``, ``baseline_tasks`` and the refine scaffold's+``_refine_task``); what differs per track at PLANNING time is``tracks/planner.py``'s alone. All bookkeeping — workspace, events, budget, runstate, stage cache, the fixed round count, record — lives here once. Which round of afinished run to hand over is not the core's question: ``codeverse3d.addons.select``.@@ -14,7 +15,7 @@ import loggingimport platformimport tracebackfrom collections.abc import Callable, Sequence-from dataclasses import replace+from dataclasses import dataclass, replacefrom datetime import UTC, datetimefrom pathlib import Pathfrom typing import Any@@ -28,6 +29,7 @@ from codeverse3d.contracts.spec import Specfrom codeverse3d.cost.context import run_bindingfrom codeverse3d.cost.instrument import metered_agent, metered_chat_model, run_ledgerfrom codeverse3d.cost.ledger import ledger_usage, load_ledger+from codeverse3d.cost.tally import timedfrom codeverse3d.orchestrator import (BudgetExceeded,BudgetGuard,@@ -40,7 +42,7 @@ from codeverse3d.orchestrator import (hash_inputs,plan_refine_groups,)-from codeverse3d.proc import EventLog+from codeverse3d.proc import EventLog, fan_outfrom codeverse3d.prompts import load_text, renderfrom codeverse3d.prompts.catalog import language_prompt, language_textfrom codeverse3d.tracks.candidates import run_best_of_n@@ -109,13 +111,81 @@ class SpecChanged(RuntimeError):archive the old rounds under ``rounds/pre_force/`` and re-plan."""+# ============================================================================ the pre-round graph+@dataclass(frozen=True)+class StageNode:+ """One pre-round stage of a track's declared graph (``BaseTrack.stages``).++ ``key``: what the result depends on — the stage is cached under it (``stages/<name>.json``,+ ``StageRunner``), and served as recorded once rounds exist (``StageRunner.frozen``). ``None``:+ not cached, it runs every session (an idempotent step). ``when``: the ``Settings`` switch the+ stage runs under. ``seeds_src``: it writes the whole ``src/`` — never run once rounds exist,+ recorded or not. The result lands in ``ctx.extra[name]`` for the stages after it."""++ name: str+ run: Callable[[Any, RunContext], Any] # (track, ctx) -> result+ key: Callable[[RunContext], dict[str, Any]] | None = None+ when: Callable[[Settings], bool] | None = None+ seeds_src: bool = False+++#: a track's pre-round graph, in order; an inner tuple = siblings that run side by side+Stages = tuple[StageNode | tuple[StageNode, ...], ...]+++def run_stages(track: BaseTrack, ctx: RunContext, runner: StageRunner, stages: Stages) -> None:+ """Walk ``stages``. Siblings run side by side as ONE timed step of the run's minutes, each+ its own cached stage; a failing sibling is raised after every sibling finished and cached."""+ def one(node: StageNode, *, timed_step: bool = True) -> Any:+ if node.key is None:+ return node.run(track, ctx)+ key = node.key(ctx)+ if node.seeds_src and runner.frozen and not runner.is_done(node.name, key):+ # a drifted key or a lost state entry under existing rounds: re-running the writer+ # would overwrite agent-authored src/ — never do that+ ctx.events.emit("stage.skipped", stage=node.name, reason="rounds_exist")+ return None+ return runner.stage(node.name, lambda: node.run(track, ctx), inputs=key, timed_step=timed_step)++ for item in stages:+ live = [n for n in (item if isinstance(item, tuple) else (item,)) if n.when is None or n.when(get_settings())]+ if not live:+ continue+ if len(live) == 1:+ results = [one(live[0])]+ else:+ group = "+".join(n.name for n in live)+ with timed(group, ctx.state.steps):+ results = fan_out(live, lambda n: one(n, timed_step=False), max_workers=len(live), label=group,+ item_name=lambda n: n.name)+ if (exc := next((r for r in results if isinstance(r, Exception)), None)) is not None:+ raise exc+ ctx.extra.update(zip((n.name for n in live), results, strict=True))+++def _skeleton(track: BaseTrack, ctx: RunContext) -> list[str]:+ paths = ctx.runtime.skeleton(ctx.ws, ctx.plan)+ ctx.ws.commit("skeleton")+ return [str(Path(p).relative_to(ctx.ws.root)) if Path(p).is_absolute() else str(p) for p in paths]+++#: the buildable placeholder of every file the plan names+SKELETON = StageNode("skeleton", _skeleton, key=lambda c: {"plan": c.plan, "language": c.language.value}, seeds_src=True)+#: the vendor CLI's workspace files (AGENTS.md, MCP config, the cookbook copy): once per agent kind+MATERIALIZE = StageNode("materialize", lambda t, c: t.ensure_materialized(c))+#: a stage boundary: the run stops here when the hard budget is spent+CLOCK = StageNode("clock", lambda t, c: c.budget.check())++class BaseTrack:- """Shared lifecycle. Subclasses set ``track``, ``rubric``, ``plan_model``- and parameterise the refine scaffold via the hooks below (``_refine_task`` …)."""+ """Shared lifecycle. Subclasses set ``track``, ``rubric``, ``plan_model``, their pre-round+ ``stages`` and parameterise the refine scaffold via the hooks below (``_refine_task`` …)."""track: Trackrubric: strplan_model: type[Plan]+ #: the pre-round graph, between the plan and round 0 (docs/ARCHITECTURE.md §7 is drawn from it)+ stages: Stages = (SKELETON, MATERIALIZE)generate_template: str = ""refine_template: str = ""#: refine fan-out (graphics is always ONE whole-program task)@@ -153,10 +223,6 @@ class BaseTrack:def make_pipeline(self) -> RoundPipeline:raise NotImplementedError- def prepare(self, ctx: RunContext, runner: StageRunner) -> None:- """Stages between plan and baseline (skeleton; scene assets/env/zones/assemble)."""- self.stage_skeleton(ctx, runner)-def baseline_tasks(self, ctx: RunContext) -> list[GenerationTask]:"""Round 0: one whole-program session — ``generate_template`` over :meth:`generate_context`."""files = ctx.runtime.expected_files(ctx.plan)@@ -261,7 +327,7 @@ class BaseTrack:ctx.plan = runner.stage("plan", lambda: self._plan_stage(ctx), inputs=plan_stage_key(spec, self.track),model=self.plan_model)self.after_plan(ctx)- self.prepare(ctx, runner)+ run_stages(self, ctx, runner, self.stages)ctx.extra["prepared_commit"] = ws.head() # what a salvage compares the baseline's work withstop = self._round_loop(ctx, rounds)except BudgetExceeded as e:@@ -445,20 +511,6 @@ class BaseTrack:return plan# ------------------------------------------------------------------ stages- def stage_skeleton(self, ctx: RunContext, runner: StageRunner) -> list[str]:- def _do() -> list[str]:- paths = ctx.runtime.skeleton(ctx.ws, ctx.plan)- ctx.ws.commit("skeleton")- return [str(Path(p).relative_to(ctx.ws.root)) if Path(p).is_absolute() else str(p) for p in paths]-- inputs = {"plan": ctx.plan, "language": ctx.language.value}- if not runner.is_done("skeleton", inputs) and (journal := load_round_journal(ctx.ws)):- # stale skeleton hash on resume: rounds exist, so re-running the skeleton- # writer would overwrite agent-authored src/ — never do that.- ctx.events.emit("skeleton.skipped", reason="rounds_exist", rounds=len(journal))- return []- return runner.stage("skeleton", _do, inputs=inputs)-def ensure_materialized(self, ctx: RunContext) -> None:"""Materialise AGENTS.md/MCP config once per run for agent generators."""if ctx.single_shot:@@ -486,7 +538,6 @@ class BaseTrack:the vendor's quota, a refine round whose sessions changed nothing, or a last roundthat leaves nothing to ask for (no gate error, no failed must-item, no judge plan) orno verdict to ask from."""- self.ensure_materialized(ctx)pipeline = self.make_pipeline()rejudged: set[int] = set()transport_retried: set[int] = set()diff --git a/harness/codeverse3d/tracks/scene.py b/harness/codeverse3d/tracks/scene.pyindex 435865a5..c43c499a 100644--- a/harness/codeverse3d/tracks/scene.py+++ b/harness/codeverse3d/tracks/scene.py@@ -1,4 +1,4 @@-"""SceneTrack: plan → skeleton → (assets ∥ env) → zones → assemble → rounds.+"""SceneTrack: the plan, the pre-round stages (``SceneTrack.stages``: the whole baseline), rounds.Language: scene_threejs. Generation is staged (each stage cached by``StageRunner`` for resume); the round loop then builds (probe + shaders — the@@ -26,7 +26,6 @@ import timefrom collections.abc import Callable, Sequencefrom typing import Any-from codeverse3d.config import get_settingsfrom codeverse3d.contracts.artifacts import (BuildResult,GateFinding,@@ -39,11 +38,9 @@ from codeverse3d.contracts.common import TRACK_INFO, Trackfrom codeverse3d.contracts.plan import Plan, ScenePlan, ZonePlanfrom codeverse3d.contracts.run import RoundRecordfrom codeverse3d.conventions import to_snake-from codeverse3d.cost.tally import timedfrom codeverse3d.judges.base import judged_subsetfrom codeverse3d.languages.scene_threejs import zone_file-from codeverse3d.orchestrator import StageRunner, TaskGroup, compact_instructions-from codeverse3d.proc import fan_out+from codeverse3d.orchestrator import TaskGroup, compact_instructionsfrom codeverse3d.prompts import renderfrom codeverse3d.spatial.frame_motion import motion_text_forfrom codeverse3d.spatial.render_scene import perf_detail@@ -52,7 +49,7 @@ from codeverse3d.texturing.plan import texture_pack_promptfrom codeverse3d.tracks import skills_hookfrom codeverse3d.tracks.common import RunContext, generate_for, single_shot_ctxfrom codeverse3d.tracks.generation import GenerationResult, GenerationTask-from codeverse3d.tracks.lifecycle import BaseTrack+from codeverse3d.tracks.lifecycle import CLOCK, MATERIALIZE, SKELETON, BaseTrack, StageNodefrom codeverse3d.tracks.prompting import (base_prompt_context,bbox_line,@@ -161,88 +158,79 @@ class ScenePipeline:return "\n".join(lines)+def _plan_agent(ctx: RunContext) -> dict[str, Any]:+ # the WHOLE plan (+ agent), not enumerated fields (2026-08-31): a mood/title/bounds/camera-only+ # re-plan used to hit a stale cached stage+ return {"plan": ctx.plan, "agent": ctx.agent_id}+++def _pack(ctx: RunContext) -> dict[str, Any]:+ # the texture pack is part of a key only when it has files: a run without one keeps its keys+ return {"textures": ctx.extra["textures"]} if ctx.extra.get("textures") else {}++class SceneTrack(BaseTrack):track = Track.SCENErubric = TRACK_INFO[Track.SCENE].rubricplan_model = ScenePlan+ #: the pre-round graph writes the whole baseline; round 0 builds, renders and judges it+ stages = (+ SKELETON, MATERIALIZE,+ # first and alone: env and zones name its files (Settings.scene_textures: off by default, and why)+ StageNode("textures", lambda t, c: t._textures_stage(c), key=lambda c: {"plan": c.plan}, when=lambda s: s.scene_textures),+ # side by side (2026-08-30): the env brief reads no asset output — la_boulevard's 15 + 12 min ran+ # in max(15, 12), a whole refine round saved. Each is its OWN cached stage (2026-08-31): a failing+ # sibling never costs a succeeded one its paid result. Layouts: L2 zone layouts, an accelerator+ # (C3D_ZONE_LAYOUTS, default on), riding along at no wall clock (beb6605)+ (StageNode("assets", lambda t, c: run_asset_stage(c), key=_plan_agent),+ StageNode("env", lambda t, c: t._env_stage(c), key=lambda c: {**_plan_agent(c), **_pack(c)}),+ StageNode("layouts", lambda t, c: t._layouts_stage(c), key=_plan_agent, when=lambda s: s.zone_layouts)),+ StageNode("asset_api", lambda t, c: t._asset_api(c)),+ # ONE session writes every zone (D70)+ StageNode("zones", lambda t, c: t._zones_stage(c), key=lambda c: {+ "plan": c.plan, "asset_api": c.extra["asset_api"], "layouts": c.extra.get("layouts", {}), "agent": c.agent_id,+ **_pack(c)}),+ # after the zones are recorded: a run the clock stops here keeps them (salvage assembles+ # them; a resume serves them instead of paying the session again)+ CLOCK,+ # scene.js, deterministic: no session+ StageNode("assemble", lambda t, c: t._assemble_stage(c), key=lambda c: {"plan": c.plan}),+ )def make_pipeline(self) -> ScenePipeline:return ScenePipeline()- #: the baseline (assets → env → zones → assemble → round 0) may use this share of- #: the run budget; the rest belongs to the refine rounds.+ #: the baseline (the pre-round stages → round 0) may use this share of the run budget; the+ #: rest belongs to the refine rounds.soft_budget_fraction = 0.55# ------------------------------------------------------------------ stages- def prepare(self, ctx: RunContext, runner: StageRunner) -> None:- self.stage_skeleton(ctx, runner)- self.ensure_materialized(ctx)+ def _layouts_stage(self, ctx: RunContext) -> dict[str, Any]:+ """L2 zone layouts (optional accelerator): planner-model calls, never fatal."""+ try:+ model = self._planner_model+ if model is None:+ from codeverse3d.models import get_chat_model++ model = get_chat_model(ctx.spec.backends.planner)+ layouts = layout_zones(ctx.plan, model, budget=ctx.budget, events=ctx.events)+ return {k: v.model_dump(mode="json") for k, v in layouts.items()}+ except Exception as e: # noqa: BLE001 — layouts accelerate, they must never kill+ ctx.events.emit("layout.stage_failed", error=f"{type(e).__name__}: {e}"[:300])+ return {}++ def _asset_api(self, ctx: RunContext) -> str:+ """What the zones are told about the assets. The asset results come back revived (a cached+ stage is JSON), with the merge map the STAGE used: its cap depends on the soft budget at the+ time (a degraded run folded more), so it is read back for a resumed run and the zones to+ agree; the plan-only recomputation is the fallback for a workspace without the note."""plan: ScenePlan = ctx.plan # type: ignore[assignment]- # assets ∥ env (2026-08-30): the env brief is a pure function of the plan — the- # template references no asset output (0 uses of asset_api) and says "No assets/- # zones here" — yet the two stages ran back to back. Measured on la_boulevard:- # assets 15 min + env 12 min sequential = 27 min of a 75-min budget; the pair- # runs in max(15, 12) and the ~12 saved minutes are a whole refine round- # (each measured at ~+0.13). Workspace.commit serialises under its own lock,- # so the two stages' commits cannot race.- def _layouts() -> dict[str, Any]:- """L2 zone layouts (optional accelerator): planner-model calls, never fatal."""- try:- model = self._planner_model- if model is None:- from codeverse3d.models import get_chat_model-- model = get_chat_model(ctx.spec.backends.planner)- layouts = layout_zones(plan, model, budget=ctx.budget, events=ctx.events)- return {k: v.model_dump(mode="json") for k, v in layouts.items()}- except Exception as e: # noqa: BLE001 — layouts accelerate, they must never kill- ctx.events.emit("layout.stage_failed", error=f"{type(e).__name__}: {e}"[:300])- return {}-- # each child is its OWN cached stage (2026-08-31): a failing sibling never- # invalidates a succeeded one's paid, committed result on resume. The key is- # the WHOLE plan (+ agent) — correct-by-construction against future prompt- # fields; the old enumerated keys let a mood/title/bounds/camera-only re-plan- # hit a stale cached stage. Old "assets+env" composite entries are ignored.- key = {"plan": plan, "agent": ctx.agent_id}- # textures first and alone: env and zones can only name the files if they exist by- # the time those prompts are built (Settings.scene_textures says why this- # is off by default and what it costs). A pack is part of the env and zones keys- # only when it has files, so a run without one keeps the keys it always had.- if get_settings().scene_textures:- ctx.extra["textures"] = runner.stage("textures", lambda: self._textures_stage(ctx), inputs={"plan": plan}) or {}- textures = {"textures": ctx.extra["textures"]} if ctx.extra.get("textures") else {}- stage_fns: dict[str, Any] = {"assets": lambda: run_asset_stage(ctx), "env": lambda: self._env_stage(ctx)}- keys = {"env": {**key, **textures}}- if get_settings().zone_layouts: # C3D_ZONE_LAYOUTS (an A/B switch, default on): off = no stage, so none is cached- stage_fns["layouts"] = _layouts- group = "+".join(stage_fns)- with timed(group, ctx.state.steps): # side by side: ONE step of the run's minutes- results = fan_out(list(stage_fns.items()), lambda kv: runner.stage(kv[0], kv[1], inputs=keys.get(kv[0], key), timed_step=False),- max_workers=len(stage_fns), label=group, item_name=lambda kv: kv[0])- staged = dict(zip(stage_fns, results, strict=True))- first_exc = next((r for r in results if isinstance(r, Exception)), None)- if first_exc is not None:- raise first_exc # after every sibling has finished and cached its own result- ctx.extra["layouts"] = staged.get("layouts") or {}- assets = {k: AssetResult.model_validate(v) if isinstance(v, dict) else v- for k, v in (staged["assets"] or {}).items()}- # the merge map the STAGE used (its cap depends on the soft budget at the time: a- # degraded run folded more), read back so a resumed run and the zones agree; the- # plan-only recomputation is the fallback for a workspace without the note+ assets = {k: AssetResult.model_validate(v) if isinstance(v, dict) else v for k, v in (ctx.extra.get("assets") or {}).items()}alias = read_dedupe_note(ctx.ws)if alias is None:_, alias = select_assets(list(plan.assets), MAX_ASSETS)- ctx.extra["assets"] = assets- ctx.extra["asset_alias"] = alias- ctx.extra["asset_api"] = asset_api_summary(plan, assets, alias)- runner.stage("zones", lambda: self._zones_stage(ctx),- inputs={"plan": plan, "asset_api": ctx.extra["asset_api"], "layouts": ctx.extra["layouts"], "agent": ctx.agent_id,- **textures})- # stage boundary, AFTER the finished zones are recorded: a run the clock stops here keeps- # them (salvage assembles them; a resume serves them instead of paying the session again)- ctx.budget.check()- runner.stage("assemble", lambda: self._assemble_stage(ctx), inputs={"plan": plan})+ ctx.extra["assets"], ctx.extra["asset_alias"] = assets, alias+ return asset_api_summary(plan, assets, alias)# ---- degradation ------------------------------------------------------def _strategy(self, ctx: RunContext, stage: str) -> RunContext:@@ -273,7 +261,7 @@ class SceneTrack(BaseTrack):session that raises still leaves its telemetry and its commit before the exception goes on.The skills are this hook's job, not ``steps.run_round``'s: a scene builds its whole baseline- in ``prepare()``, in sessions that never pass through ``run_round`` (``scene.js`` is+ in its pre-round ``stages``, in sessions that never pass through ``run_round`` (``scene.js`` isassembled, not written), so the router's ``kinds=("env", "zone")`` rows were selected anddelivered to nobody — 0 opens out of 30 listings, measured 2026-08-25. ``index=0``: thesestages ARE round 0's generation. One attach per stage keeps it to one AGENTS.md write, anddiff --git a/harness/codeverse3d/tracks/scene_assets.py b/harness/codeverse3d/tracks/scene_assets.pyindex a19f08e5..2a198c40 100644--- a/harness/codeverse3d/tracks/scene_assets.py+++ b/harness/codeverse3d/tracks/scene_assets.py@@ -926,7 +926,7 @@ def variant_index(alias: dict[str, str], name: str) -> int:def write_dedupe_note(ws: Workspace, alias: dict[str, str]) -> None:- """Persist the merge map the stage USED: `prepare` reads it back, because the cap that+ """Persist the merge map the stage USED: the ``asset_api`` stage reads it back, because the cap thatmade it (`MAX_ASSETS` or `DEGRADED_MAX_ASSETS`) depends on the soft budget at the time."""write_json_atomic(ws.root / "stages" / "asset_aliases.json", {"alias": alias})diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex 0761f7bd..ba8ebf7f 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -459,13 +459,45 @@ its range is carried by the defect checklist). Hence **default judge =`gemini-3.1-pro-preview`** (`Settings.default_judge`); flash stays the cheapin-loop option with `n_samples ≥ 2` for decisions.-## 7. Round loop (all tracks)+## 7. Run pipeline (all tracks)++A run is three parts, and only the first is a graph.++**7.1 The pre-round stages — declared, one tuple per track.** `BaseTrack.stages` (the tracks'+`stages` class attribute) is a tuple of `StageNode`s, walked by `lifecycle.run_stages` over+`StageRunner`. The block below is drawn from those declarations (`tests/install/test_docs.py`+fails when it drifts, printing the block to paste):++```stage-graph+static_object plan → skeleton → materialize* → round 0+articulated_object plan → skeleton → materialize* → round 0+scene plan → skeleton → materialize* → textures? → (assets ∥ env ∥ layouts?) → asset_api* → zones → clock* → assemble → round 0+graphics plan → skeleton → recipes* → materialize* → round 0+```++`→` in order; `(a ∥ b)` siblings side by side, each its own cached stage, timed as ONE step of the+run's minutes, a failing sibling raised after every sibling has finished and cached; `?` runs under a+`Settings` switch (`textures`: `scene_textures`, off by default; `layouts`: `zone_layouts`, on); `*`+is not cached — it runs every session. Every other stage is cached under its key+(`stages/<name>.json`): what its result depends on, named in the declaration. **Once rounds exist**+a recorded stage is served whatever its key (`stage.frozen`), and the skeleton (`seeds_src`) never+runs at all; `3dcode resume --force` (which archives the rounds) is the one way to regenerate a+stage under them. The plan itself is `run()`'s, before the graph (`plan_stage_key`). What the+scene stages do: `assets` — both kinds climb one ladder (single-shot → check → one repair → agent;+blender_glb heroes get a sub-workspace with the static planner's parts + asset_v1 judge + one+re-judged fix pass, undone when worse; a degraded asset verdict leaves score None / judged False,+emits asset.judge_degraded and skips the fix pass); `env` — `src/env.js`; `layouts` — L2 zone+layouts (planner calls, never fatal); `asset_api` — what the zones are told about the assets;+`zones` — ONE session owns every zone file (D70); `clock` — the run stops here when the hard budget+is spent, after the zones are recorded; `assemble` — `scene.js`, deterministic.++**7.2 The round — `steps._run_round`, a fixed chain in code.** Not nodes: nothing in a round can+be cached (every step reads the git tree the step before it wrote), and articulated's axis repair+ties gates to render. **7.3 The round loop — `BaseTrack._round_loop`, a state machine in code**:+each round's tasks come from the previous round's verdict, with seven exits and two retry-once sets.+Best-of-N, refine planning and the asset ladder are sized at run time; they stay code too.```-plan (structured output, one re-ask) → skeleton (buildable placeholder) → materialise workspace-[scene only] assets (parallel; both kinds climb one ladder — single-shot → check → one repair → agent; blender_glb heroes get a sub-workspace with the static planner's parts + asset_v1 judge + one re-judged fix pass, undone when worse; a degraded asset verdict leaves- score None / judged False, emits asset.judge_degraded and skips the fix pass)- → env → zones (ONE session owns every zone file, D70) → assemble (deterministic scene.js)round 0 "baseline": generate → build_with_repair → measure → gates → render → post-render gates → judge(object tracks, ≥ 8 plan parts, a language with one file per part, an agent backend: the baseline FANS OUTper part — phase 0 = one scoped session per attachment subtree (its parts + the planned boxes of thediff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.mdindex d368ab28..17e6be98 100644--- a/harness/docs/INTERFACES.md+++ b/harness/docs/INTERFACES.md@@ -516,7 +516,8 @@ from codeverse3d.tracks.graphics import seed_recipes, graphics_brief, cookbook_f# [{name, signature, purpose}] for every seeded recipe on disk (the prompt block); emits recipes.seeded# {file, names, present, chapters, trimmed}. Never writes src/common.glsl — except the untouched skeleton,# which loses the helpers recipes.glsl now provides (trim_skeleton_common; recipes are pasted first).- # GraphicsTrack.prepare() runs it after the skeleton and commits "recipes" when it wrote something.+ # GraphicsTrack.stages runs it (the uncached "recipes" stage) after the skeleton and commits "recipes"+ # when it wrote something.from codeverse3d.tracks.common import RunContext, Services # common.py; RunContext.single_shot / .agent_kind# (Δ 2026-08-30) Services.connectivity(glb, language="", planned_edges=()) forwards the plan's attach_to pairs;# spatial.contract.planned_joins(plan, measurement) -> [(child, (parent copies…))] spells them in GLB part names viadiff --git a/harness/docs/RUNBOOK.md b/harness/docs/RUNBOOK.mdindex b5869465..e0ac476a 100644--- a/harness/docs/RUNBOOK.md+++ b/harness/docs/RUNBOOK.md@@ -404,8 +404,9 @@ weather: they leave the provider's errors out (docs/COST.md §31); the ceiling d`3dcode judge` maps track → rubric in `cli/_judge.py::rubric_for`.* **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`; `system_prompt`+* **New track**: subclass `tracks/lifecycle.py::BaseTrack` (its pre-round graph `stages`, a tuple of+ `StageNode`s — the default is skeleton → materialize, and a new track adds its line to+ `docs/ARCHITECTURE.md` §7.1; hooks: `make_pipeline`, `baseline_tasks`, `refine_tasks`; `system_prompt`defaults to `language_system_prompt(ctx.language, tools=not ctx.single_shot)` and`refine_file_for_target` to the runtime's `files_for` — override only forrole-specific prompts), a `RoundPipeline`,diff --git a/harness/tests/install/test_docs.py b/harness/tests/install/test_docs.pyindex f1dc452a..22e4a0e0 100644--- a/harness/tests/install/test_docs.py+++ b/harness/tests/install/test_docs.py@@ -317,6 +317,32 @@ def test_architecture_package_map_covers_every_module():"modules missing from the docs/ARCHITECTURE.md package map:\n " + "\n ".join(missing))+def stage_graph() -> str:+ """Every track's declared pre-round graph (``BaseTrack.stages``), one line per track."""+ from codeverse3d.contracts.common import Track+ from codeverse3d.tracks import get_track++ def node(n) -> str:+ return n.name + ("?" if n.when else "") + ("*" if n.key is None else "")++ lines = []+ for track in Track:+ steps = ["plan"]+ for item in get_track(track).stages:+ steps.append(f"({' ∥ '.join(node(n) for n in item)})" if isinstance(item, tuple) else node(item))+ lines.append(f"{track.value:<19} " + " → ".join([*steps, "round 0"]))+ return "\n".join(lines)+++def test_architecture_stage_graph_is_drawn_from_the_declarations():+ """ARCHITECTURE §7.1 shows the pre-round graph each track declares, and only that."""+ arch = (Path(__file__).resolve().parents[2] / "docs" / "ARCHITECTURE.md").read_text()+ drawn = [body for lang, body in fenced_blocks(arch) if lang == "stage-graph"]+ assert drawn == [stage_graph()], (+ "docs/ARCHITECTURE.md §7.1 no longer shows the declared stages; replace its stage-graph block with:\n"+ + stage_graph())++def test_setup_verifies_the_interpreter_it_installed_into(tmp_path) -> None:"""The closing doctor uses ``--python``, not an unrelated executable on PATH."""import sysdiff --git a/harness/tests/orchestrator_tracks/test_fix_batch2.py b/harness/tests/orchestrator_tracks/test_fix_batch2.pyindex 05c2f840..87a5c917 100644--- a/harness/tests/orchestrator_tracks/test_fix_batch2.py+++ b/harness/tests/orchestrator_tracks/test_fix_batch2.py@@ -262,7 +262,7 @@ def test_skeleton_never_reruns_over_existing_rounds(tmp_path, chair_plan, settinassert rt.skeletons == 1, "skeleton must not overwrite agent-authored src/ once rounds exist"assert (ws.src / "object.js").read_text() == src_beforekinds = [e["event"] for e in EventLog(ws.events_path).read()]- assert "skeleton.skipped" in kinds+ assert "stage.skipped" in kinds# --------------------------------------------------------------------- finding: scene track rebuild path