Skip to content

Official Codebase of 3DCodeVerse

Python

tests: one small_scene plan (was three copies), one starter_ws fixture (was two), one skills _plan (was two)

gaoypengfc7849a8b062
diff --git a/harness/tests/conftest.py b/harness/tests/conftest.py
index 8214d8c2..94e5a8ed 100644
--- a/harness/tests/conftest.py
+++ b/harness/tests/conftest.py
@@ -55,6 +55,15 @@ def tmp_ws(tmp_path: Path) -> Workspace:
return Workspace(tmp_path / "run").create()
+def starter_ws(tmp_ws: Workspace) -> Workspace:
+ """A workspace holding the complete example scene."""
+ from codeverse3d.languages.scene_threejs import write_example
+
+ write_example(tmp_ws)
+ return tmp_ws
+
+
def assert_pid_gone(pid: int, *, group: bool = False, timeout_s: float = 10.0) -> None:
"""Block until ``pid`` (``group=True``: its whole process group) is dead and reaped.
diff --git a/harness/tests/orchestrator_tracks/fakes.py b/harness/tests/orchestrator_tracks/fakes.py
index c3f20a57..e247b3ba 100644
--- a/harness/tests/orchestrator_tracks/fakes.py
+++ b/harness/tests/orchestrator_tracks/fakes.py
@@ -27,13 +27,14 @@ from codeverse3d.contracts.artifacts import (
Severity,
)
from codeverse3d.contracts.chat import ChatRequest, ChatResponse
-from codeverse3d.contracts.common import Language, Usage
-from codeverse3d.contracts.plan import Plan
+from codeverse3d.contracts.common import Language, Track, Usage
+from codeverse3d.contracts.plan import Plan, ScenePlan
from codeverse3d.contracts.run import RunRecord
from codeverse3d.conventions import to_snake
from codeverse3d.languages import get_runtime
from codeverse3d.models.base import ModelError
from codeverse3d.tracks.common import Services
+from codeverse3d.tracks.planner import plan_example
from codeverse3d.workspace import Workspace
FAIL_MARK = "RAISE_BUILD_ERROR"
@@ -279,6 +280,16 @@ def bill_verdict(cost: float, round_index: int) -> Usage:
return usage
+def small_scene() -> ScenePlan:
+ """The example scene without its Blender hero (every asset a three.js module — the only kind
+ FakeRuntime builds)."""
+ plan = ScenePlan.model_validate(plan_example(Track.SCENE))
+ plan.assets = [a for a in plan.assets if a.kind == "threejs"]
+ for z in plan.zones:
+ z.contents = [c for c in z.contents if c in {a.name for a in plan.assets}]
+ return plan
+
+
# ----------------------------------------------------------------------------- services
def _png(path: Path, size: int = 32) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
diff --git a/harness/tests/orchestrator_tracks/test_cost_latency.py b/harness/tests/orchestrator_tracks/test_cost_latency.py
index f8c84130..d0a689f1 100644
--- a/harness/tests/orchestrator_tracks/test_cost_latency.py
+++ b/harness/tests/orchestrator_tracks/test_cost_latency.py
@@ -40,6 +40,7 @@ from tests.orchestrator_tracks.fakes import (
FakeRuntime,
FakeServices,
_planner,
+ small_scene,
)
RUNTIME_JS = get_settings().runtime_js_dir()
@@ -289,17 +290,8 @@ def test_a_plain_failed_session_does_not_fall_back(tmp_path, settings):
# ----------------------------------------------------------------------------- salvage
-def _threejs_scene_plan() -> ScenePlan:
- """The scene example narrowed to its three.js assets — the only kind these fakes build."""
- plan = ScenePlan.model_validate(plan_example(Track.SCENE))
- plan.assets = [a for a in plan.assets if a.kind == "threejs"]
- for z in plan.zones:
- z.contents = [c for c in z.contents if c in {a.name for a in plan.assets}]
- return plan
-
-
def test_a_budget_stop_before_round_zero_still_delivers_a_judged_round(tmp_path, settings):
- plan = _threejs_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=1)
ws = Workspace(tmp_path / "runs" / "greenhouse")
services = FakeServices(assemble=True)
@@ -333,7 +325,7 @@ def test_a_zones_session_the_clock_stopped_is_kept_for_the_resume(tmp_path, sett
"""Q1: the clock is checked AFTER the zones stage is recorded, so the finished (paid) session
is cached, and the resume under the salvaged r00 serves it — it used to re-run the zones
session over r00's src/ (reproduced in the 2026-09-22 review)."""
- plan = _threejs_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=1)
ws = Workspace(tmp_path / "runs" / "quay")
agent = FakeAgent(lambda job, ws_: {rel: "export function build(){}\n" for rel in (job.files_hint or ["src/scene.js"])},
@@ -351,7 +343,7 @@ def test_a_zones_session_the_clock_stopped_is_kept_for_the_resume(tmp_path, sett
def test_soft_budget_notes_land_in_the_round_record(tmp_path, settings):
- plan = _threejs_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0)
ws = Workspace(tmp_path / "runs" / "degraded")
services = FakeServices(assemble=True)
@@ -485,7 +477,7 @@ def test_an_imperfect_asset_stays_available_but_a_broken_one_does_not(tmp_path,
def test_a_scene_round_judged_at_the_ceiling_keeps_its_verdict(tmp_path, settings):
- plan = _threejs_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=2)
ws = Workspace(tmp_path / "runs" / "ceiling")
judge = FakeJudge(scores=(0.61,), cost=0.5, minutes=12.0)
diff --git a/harness/tests/orchestrator_tracks/test_tracks.py b/harness/tests/orchestrator_tracks/test_tracks.py
index e2ba42bb..388da8ee 100644
--- a/harness/tests/orchestrator_tracks/test_tracks.py
+++ b/harness/tests/orchestrator_tracks/test_tracks.py
@@ -28,6 +28,7 @@ from tests.orchestrator_tracks.fakes import (
FakeRuntime,
FakeServices,
_planner,
+ small_scene,
)
@@ -243,18 +244,10 @@ def test_scene_track_deterministic_assembler_and_resume(tmp_path, settings):
assert len(rec2.rounds) == 1 and rec2.rounds[0].commit == rec.rounds[0].commit
-def _small_scene_plan():
- plan = ScenePlan.model_validate(plan_example(Track.SCENE))
- plan.assets = [a for a in plan.assets if a.kind == "threejs"]
- for z in plan.zones:
- z.contents = [c for c in z.contents if c in {a.name for a in plan.assets}]
- return plan
-
-
def test_scene_children_are_stages_and_a_failed_env_never_repays_assets(tmp_path, settings):
"""Review-3 V3-claim3: assets/env/layouts each cache as their OWN stage, so a
failing sibling leaves the paid asset results cached and resume re-runs only it."""
- plan = _small_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0)
ws = Workspace(tmp_path / "runs" / "harbour3")
boom = {"on": True}
@@ -284,7 +277,7 @@ def test_scene_children_are_stages_and_a_failed_env_never_repays_assets(tmp_path
def _mood_replanned(tmp_path, settings, name, *, force):
"""A scene run with r00, whose plan then changes ONLY in `mood` (the spec does not change); resumed,
with ``--force`` when ``force``. Returns (resumed job labels, event names)."""
- plan = _small_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0)
ws = Workspace(tmp_path / "runs" / name)
agent = FakeAgent(_scene_writer)
@@ -341,7 +334,7 @@ def test_the_builds_own_gate_reports_join_the_round(tmp_path, settings, broken):
error is what routes the shader skill (R21) into the next round."""
from codeverse3d.skills.registry import SHADER_COMPILE_OR_BINDING, finding_kinds
- plan = _small_scene_plan()
+ plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0)
ws = Workspace(tmp_path / "runs" / "probed")
diff --git a/harness/tests/prompts/manifest.py b/harness/tests/prompts/manifest.py
index 4f88a256..89dd9547 100644
--- a/harness/tests/prompts/manifest.py
+++ b/harness/tests/prompts/manifest.py
@@ -86,6 +86,7 @@ from tests.orchestrator_tracks.fakes import (
FakeJudge,
FakeRuntime,
FakeServices,
+ small_scene,
)
MANIFEST = Path(__file__).with_name("manifest.json")
@@ -345,15 +346,6 @@ class Rig:
# ============================================================================ the scenarios
-def small_scene() -> ScenePlan:
- """The example scene without its Blender hero (every asset a three.js module)."""
- plan = ScenePlan.model_validate(plan_example(Track.SCENE))
- plan.assets = [a for a in plan.assets if a.kind == "threejs"]
- for z in plan.zones:
- z.contents = [c for c in z.contents if c in {a.name for a in plan.assets}]
- return plan
-
-
def machine() -> StaticPlan:
"""An 11-part object: past the scoped-baseline threshold, with a real attachment tree."""
parts = [PartPlan(name="Body", role="main mass", description="the shell", bbox=BBox(center=(0, 0.5, 0), extents=(0.6, 1.0, 0.4)))]
diff --git a/harness/tests/scene_gates/conftest.py b/harness/tests/scene_gates/conftest.py
deleted file mode 100644
index 91aec327..00000000
--- a/harness/tests/scene_gates/conftest.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""Fixtures for the scene gate tests (reuse the C2 scene runtime helpers)."""
-
-from __future__ import annotations
-
-from pathlib import Path
-
-import pytest
-
-from codeverse3d.languages.scene_threejs import write_example
-from codeverse3d.workspace import Workspace
-
-
-def starter_ws(tmp_path: Path) -> Workspace:
- """Workspace with the complete example scene."""
- w = Workspace(tmp_path / "run").create()
- write_example(w)
- return w
diff --git a/harness/tests/scene_runtime/conftest.py b/harness/tests/scene_runtime/conftest.py
index 92724358..a0cd0c23 100644
--- a/harness/tests/scene_runtime/conftest.py
+++ b/harness/tests/scene_runtime/conftest.py
@@ -10,7 +10,6 @@ from pathlib import Path
import pytest
from codeverse3d.config import get_settings
-from codeverse3d.languages.scene_threejs import write_example
from codeverse3d.spatial.node import run_node
from codeverse3d.workspace import Workspace
@@ -35,14 +34,6 @@ def ws(tmp_path: Path) -> Workspace:
return Workspace(tmp_path / "run").create()
-def starter_ws(tmp_path: Path) -> Workspace:
- """Workspace with the complete example scene."""
- w = Workspace(tmp_path / "run").create()
- write_example(w)
- return w
-
-
def run_node_json(script_body: str, *, timeout: int = 60) -> dict | list:
"""Run an ESM snippet whose ``./lib/`` is runtime_js/lib and parse its last stdout line as JSON."""
with tempfile.TemporaryDirectory(prefix="c3d-node-json-") as tmp:
diff --git a/harness/tests/skills/test_telemetry.py b/harness/tests/skills/test_telemetry.py
index d5af7902..5d06e0c1 100644
--- a/harness/tests/skills/test_telemetry.py
+++ b/harness/tests/skills/test_telemetry.py
@@ -21,6 +21,7 @@ from codeverse3d.skills.telemetry import (
probe_reads,
)
from tests.skills.conftest import write_bundle
+from tests.skills.test_materialize_prompting import _plan
@pytest.fixture
@@ -31,12 +32,6 @@ def ws(tmp_path: Path) -> Path:
return root
-def _plan(n=3):
- from types import SimpleNamespace as NS
-
- return NS(parts=[NS(name=f"P{i}", instances=1, symmetry="none", children=[]) for i in range(n)], summary="")
-
-
def _attach(ws, library, **kw):
return attach_skills(ws, track="static_object", language="blender", kind="baseline",
plan=_plan(), library=library,