Official Codebase of 3DCodeVerse
Python
tests: threejs_render, urdf_joints, blender_cadquery — 58 tests go that cover no line another test does not (−799 lines)
gaoypengb37aef663bff
diff --git a/harness/tests/blender_cadquery/test_artifact_stage.py b/harness/tests/blender_cadquery/test_artifact_stage.pyindex 64f9c939..03776966 100644--- a/harness/tests/blender_cadquery/test_artifact_stage.py+++ b/harness/tests/blender_cadquery/test_artifact_stage.py@@ -1,10 +1,4 @@-"""ArtifactStage: the stage-then-promote lifecycle every runtime's build outputs use.--The invariant under test: a canonical artifact exists ONLY when the build that owns-it finished with that artifact as its result — entering a stage invalidates the-canonical names before any early return can leak, and exit-without-promote leaves-them absent.-"""+"""ArtifactStage: a canonical artifact exists only when the build that owns it promoted it."""from __future__ import annotations@@ -36,31 +30,6 @@ def test_enter_invalidates_immediately_and_exit_discards(tmp_ws: Workspace) -> Nassert not staging_root.exists() or not any(staging_root.iterdir())-def test_promote_publishes_files_and_dirs(tmp_ws: Workspace) -> None:- _seed(tmp_ws)- with tmp_ws.stage_artifacts("build.json", "object.glb", "meshes") as stage:- stage.path("build.json").write_text('{"ok": true}')- stage.path("object.glb").write_bytes(b"new glb")- stage.path("meshes").mkdir()- (stage.path("meshes") / "leg.glb").write_bytes(b"new mesh")- published = stage.promote()- assert {p.name for p in published} == {"build.json", "object.glb", "meshes"}- assert (tmp_ws.artifacts / "object.glb").read_bytes() == b"new glb"- assert (tmp_ws.artifacts / "meshes" / "leg.glb").read_bytes() == b"new mesh"- assert not (tmp_ws.artifacts / ".staging").exists() # fully cleaned up---def test_selective_promote_leaves_the_rest_invalidated(tmp_ws: Workspace) -> None:- """The urdf failure paths publish build.json (the failed status) and nothing else."""- _seed(tmp_ws)- with tmp_ws.stage_artifacts("build.json", "object.glb") as stage:- stage.path("build.json").write_text('{"ok": false}')- stage.path("object.glb").write_bytes(b"fresh but unpublished")- stage.promote("build.json")- assert (tmp_ws.artifacts / "build.json").read_text() == '{"ok": false}'- assert not (tmp_ws.artifacts / "object.glb").exists()--def test_default_promote_skips_names_never_written(tmp_ws: Workspace) -> None:with tmp_ws.stage_artifacts("build.json", "object.stl") as stage:stage.path("build.json").write_text('{"ok": true}')diff --git a/harness/tests/blender_cadquery/test_blender_layout.py b/harness/tests/blender_cadquery/test_blender_layout.pyindex 2b4b5185..4fddadfa 100644--- a/harness/tests/blender_cadquery/test_blender_layout.py+++ b/harness/tests/blender_cadquery/test_blender_layout.py@@ -9,11 +9,7 @@ from pathlib import Pathfrom codeverse3d.languages.blender import (WRAPPER,- build_fn_name,lint_workspace,- part_file_rel,- part_files,- source_files,)SEAT = '''import bpy, bmesh@@ -46,37 +42,8 @@ def _write(ws, rel: str, text: str) -> Path:return p-def test_part_file_mapping_uses_the_name_normaliser() -> None:- assert part_file_rel("Seat Cushion") == "src/parts/seat_cushion.py"- assert part_file_rel("LeftFrontLeg") == "src/parts/left_front_leg.py"- assert build_fn_name("SeatCushion") == "build_seat_cushion"---def test_file_listing_excludes_helpers_and_orders_entry_first(tmp_ws) -> None:- _write(tmp_ws, "src/model.py", MODEL)- _write(tmp_ws, "src/parts/seat.py", SEAT)- _write(tmp_ws, "src/parts/leg.py", LEG)- _write(tmp_ws, "src/parts/_common.py", "def helper():\n return 1\n")- assert [p.name for p in part_files(tmp_ws)] == ["leg.py", "seat.py"]- rel = [p.relative_to(tmp_ws.root).as_posix() for p in source_files(tmp_ws)]- assert rel == ["src/model.py", "src/parts/_common.py", "src/parts/leg.py", "src/parts/seat.py"]---def test_lint_workspace_passes_clean_multi_file_layout(tmp_ws) -> None:- _write(tmp_ws, "src/model.py", MODEL)- _write(tmp_ws, "src/parts/seat.py", SEAT)- _write(tmp_ws, "src/parts/leg.py", LEG)- _write(tmp_ws, "src/parts/_common.py", "def helper():\n return 1\n") # no bpy import is fine for helpers- rep = lint_workspace(tmp_ws)- assert rep.passed, [(f.target, f.message) for f in rep.errors]- # the entry only imports + calls → no PascalCase-name warning for it- assert not [f for f in rep.findings if f.target == "src/model.py" and f.severity.value == "warn"]- assert {f.target for f in rep.findings} <= {"src/model.py", "src/parts/seat.py", "src/parts/leg.py", "src/parts/_common.py"}--def test_lint_workspace_reports_a_source_too_deep_to_parse_instead_of_crashing(tmp_ws) -> None:- """The layout rules re-parsed every file with a bare ``ast.parse`` — a literal nested past the- parser's stack raised ``MemoryError`` out of the lint and killed the round."""+ """A literal nested past the parser's stack is a finding, not a MemoryError that kills the round."""deep = "x = " + "-" * 20_000 + "1\n"_write(tmp_ws, "src/model.py", deep)_write(tmp_ws, "src/parts/seat.py", deep)diff --git a/harness/tests/blender_cadquery/test_blender_lint.py b/harness/tests/blender_cadquery/test_blender_lint.pyindex 0061a6fc..7766c36e 100644--- a/harness/tests/blender_cadquery/test_blender_lint.py+++ b/harness/tests/blender_cadquery/test_blender_lint.py@@ -36,11 +36,6 @@ def test_good_script_passes() -> None:assert any("Body" in m for m in _msgs(r, Severity.INFO))-def test_syntax_error() -> None:- r = lint_blender_source("import bpy\nx = (\n")- assert not r.passed and r.findings[0].data["line"] == 2 and "SyntaxError" in r.findings[0].message--def test_missing_bpy_import_and_forbidden_calls() -> None:src = "import os\nimport subprocess\nbpy.ops.render.render()\nbpy.ops.export_scene.gltf(filepath='x')\nbpy.ops.wm.save_mainfile()\nopen('f').read()\nos.system('ls')\n"r = lint_blender_source(src)@@ -76,22 +71,6 @@ def test_bmesh_lookup_rule_ignores_non_bmesh_bases() -> None:assert r.passed-def test_bmesh_lookup_rule_tracks_bmesh_bindings() -> None:- src = "import bpy, bmesh\nmesh_bm = bmesh.new()\nv = mesh_bm.verts[0]\n"- r = lint_blender_source(src)- f = [x for x in r.findings if "ensure_lookup_table" in x.message]- assert f and f[0].severity == Severity.ERROR and f[0].data["line"] == 3- src2 = "import bpy, bmesh\nedit_bm = bmesh.from_edit_mesh(bpy.context.object.data)\nx = edit_bm.faces[1]\n"- r2 = lint_blender_source(src2)- assert any("ensure_lookup_table" in f.message for f in r2.findings)---def test_vector_without_import() -> None:- r = lint_blender_source("import bpy\nv = Vector((1, 2, 3))\n")- f = [x for x in r.findings if "Vector" in x.message]- assert f and f[0].severity == Severity.ERROR and f[0].fix_hint == "from mathutils import Vector"--def test_removed_bsdf_inputs() -> None:r = lint_blender_source("import bpy\nm = bpy.data.materials.new('x')\nm.node_tree.nodes['Principled BSDF'].inputs['Specular'].default_value = 0.5\n")f = [x for x in r.findings if "Specular" in x.message]diff --git a/harness/tests/blender_cadquery/test_blender_live_gates.py b/harness/tests/blender_cadquery/test_blender_live_gates.pyindex 9cb4a953..aaa3845c 100644--- a/harness/tests/blender_cadquery/test_blender_live_gates.py+++ b/harness/tests/blender_cadquery/test_blender_live_gates.py@@ -1,9 +1,4 @@-"""Live Blender regressions for the review findings (skeleton instances, BSDF names, census).--All tests need the real binary (``-m blender``): they verify the harness's own skeleton-clears its own contract gate, that the lint's Principled BSDF table matches Blender 5.x,-and that the census counts exactly what the exporter exports.-"""+"""Live Blender: the lint's BSDF table matches Blender, and the census counts what the exporter exports."""from __future__ import annotations@@ -12,33 +7,11 @@ import subprocessimport pytest-from codeverse3d.contracts.artifacts import Severityfrom codeverse3d.languages.blender import REMOVED_BSDF_INPUTS, BlenderRuntime, blender_envpytestmark = pytest.mark.blender-def test_skeleton_with_instances_passes_contract_gate(tmp_ws, table_plan, blender_bin) -> None:- """Finding: instances under an Empty merged into one GLB part → 'plan part missing' ERROR."""- from codeverse3d.spatial.contract import check_contract- from codeverse3d.spatial.measure import measure_glb-- rt = BlenderRuntime(blender=blender_bin)- rt.skeleton(tmp_ws, table_plan) # multi-file: src/model.py + src/parts/*.py- assert (tmp_ws.src / "parts" / "leg.py").is_file()- r = rt.build(tmp_ws, timeout_s=120)- assert r.ok, (r.error_type, r.error_message)- m = measure_glb(r.glb_path)- names = {p.name for p in m.parts}- assert {"Leg_0", "Leg_1", "Leg_2", "Leg_3"} <= names # one measured part per instance- assert "Legs" not in names- rep = check_contract(m, table_plan, language="blender")- missing = [f for f in rep.findings if f.severity == Severity.ERROR and "missing" in f.message]- assert not missing, [(f.target, f.message) for f in missing]- assert rep.passed, [(f.severity, f.message) for f in rep.findings]--BSDF_PROBE = ("import bpy, json\n""m = bpy.data.materials.new('probe')\n"diff --git a/harness/tests/blender_cadquery/test_blender_runtime.py b/harness/tests/blender_cadquery/test_blender_runtime.pyindex 049fc650..cd34d62b 100644--- a/harness/tests/blender_cadquery/test_blender_runtime.py+++ b/harness/tests/blender_cadquery/test_blender_runtime.py@@ -1,52 +1,19 @@-"""BlenderRuntime: offline tests with a fake blender + integration tests on the real binary."""+"""BlenderRuntime: offline guards + integration tests on the real binary."""from __future__ import annotationsimport json-import statimport timefrom pathlib import Pathimport pytest-from codeverse3d.contracts.artifacts import BuildResult-from codeverse3d.languages import get_runtime-from codeverse3d.languages.base import LanguageRuntimefrom codeverse3d.languages.blender import (- WRAPPER,BlenderNotFoundError,BlenderRuntime,blender_env,lint_blender_source,)-from codeverse3d.prompts.catalog import language_text--FAKE_BLENDER = """#!/usr/bin/env python3-import json, os, sys-args = sys.argv[sys.argv.index("--") + 1:]-out = args[args.index("--out") + 1]-os.makedirs(out, exist_ok=True)-open(os.path.join(out, "object.glb"), "wb").write(b"glTF" + b"\\0" * 16)-json.dump({"ok": True, "error_type": "", "error_message": "", "duration_ms": 7, "warnings": []}, open(os.path.join(out, "build.json"), "w"))-json.dump({"tri_count": 12, "objects": []}, open(os.path.join(out, "census.json"), "w"))-print("fake blender ran", " ".join(args))-"""---def _fake_blender(tmp_path: Path) -> str:- p = tmp_path / "blender"- p.write_text(FAKE_BLENDER)- p.chmod(p.stat().st_mode | stat.S_IEXEC)- return str(p)---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.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 contractdef test_missing_binary_raises(tmp_ws) -> None:@@ -56,44 +23,16 @@ def test_missing_binary_raises(tmp_ws) -> None:rt.build(tmp_ws)-def test_missing_entry_invalidates_previous_outputs(tmp_ws, tmp_path) -> None:- """Deleting model.py between rounds must not leave round N-1's object.glb +- build.json (ok: true) looking current — the invalidation runs BEFORE the- missing-entry early return, and build.json on disk says what build() returned."""- for name in ("object.glb", "object.stl"):- (tmp_ws.artifacts / name).write_bytes(b"stale")- tmp_ws.write_json(tmp_ws.artifacts / "build.json", {"ok": True})- tmp_ws.write_json(tmp_ws.artifacts / "census.json", {"tri_count": 3})- r = BlenderRuntime(blender=_fake_blender(tmp_path)).build(tmp_ws)- assert not r.ok and r.error_type == "MissingEntryFile"- for name in ("object.glb", "object.stl", "census.json"):- assert not (tmp_ws.artifacts / name).exists(), name- disk = json.loads((tmp_ws.artifacts / "build.json").read_text())- assert disk["ok"] is False and disk["error_type"] == "MissingEntryFile"---def test_build_command_and_env(tmp_ws, tmp_path, monkeypatch) -> None:- rt = BlenderRuntime(blender=_fake_blender(tmp_path))- cmd = rt.build_command(tmp_ws, stl=True, seed=3, tri_limit=1000)- assert cmd[1:5] == ["-b", "--factory-startup", "--python", str(WRAPPER)] and "--" in cmd- assert cmd[cmd.index("--script") + 1] == str(tmp_ws.src / "model.py") and "--stl" in cmd and "--seed" in cmd+def test_blender_env_scrubs_secrets_and_host_python(monkeypatch) -> None:+ """model.py runs inside blender: no credentials, no host PYTHONPATH."""monkeypatch.setenv("PYTHONPATH", "/tmp/x")monkeypatch.setenv("GEMINI_API_KEYS", "k1,k2")monkeypatch.setenv("SOME_SERVICE_TOKEN", "t")env = blender_env()assert "PYTHONPATH" not in env and env["PYTHONNOUSERSITE"] == "1"- # model-authored model.py runs inside blender: credentials scrubbed, PATH/HOME keptassert "GEMINI_API_KEYS" not in env and "SOME_SERVICE_TOKEN" not in env and "PATH" in env-def test_build_with_fake_blender(tmp_ws, tmp_path) -> None:- rt = BlenderRuntime(blender=_fake_blender(tmp_path))- (tmp_ws.src / "model.py").write_text("import bpy\n")- r = rt.build(tmp_ws, timeout_s=30)- assert isinstance(r, BuildResult) and r.ok and r.glb_path == str(tmp_ws.artifacts / "object.glb")- assert r.census["tri_count"] == 12 and r.duration_ms == 7 and "fake blender ran" in r.stdout_tail--# --------------------------------------------------------------------------- real Blender@pytest.mark.blenderdef test_live_skeleton_builds_and_exports_canonical_glb(tmp_ws, table_plan, blender_bin) -> None:diff --git a/harness/tests/blender_cadquery/test_blender_skeleton.py b/harness/tests/blender_cadquery/test_blender_skeleton.pyindex 45aad899..d03107a6 100644--- a/harness/tests/blender_cadquery/test_blender_skeleton.py+++ b/harness/tests/blender_cadquery/test_blender_skeleton.py@@ -6,13 +6,9 @@ import astfrom codeverse3d.contracts.plan import BBoxfrom codeverse3d.languages.blender import (- finish_for,instance_centers,lint_blender_source,- lint_workspace,- model_file_source,part_file_source,- write_blender_skeleton,)@@ -32,28 +28,6 @@ def test_part_file_source_is_self_contained(table_plan) -> None:assert lint_blender_source(src, target="src/parts/leg.py").passed-def test_model_file_source_imports_and_calls_in_plan_order(table_plan) -> None:- src = model_file_source(table_plan)- ast.parse(src)- imports = [ln for ln in src.splitlines() if ln.startswith("from parts.")]- assert imports == ["from parts.table_top import build_table_top", "from parts.leg import build_leg",- "from parts.shelf import build_shelf"]- body = src[src.index("def main():"):]- assert body.index("build_table_top()") < body.index("build_leg()") < body.index("build_shelf()") < body.index("_selfcheck()")- assert "add_box(" not in src # no geometry in the entry- assert "[src/parts/leg.py]" in src # parts table points at the files---def test_write_skeleton_multi_file_and_workspace_lint(tmp_ws, table_plan) -> None:- paths = write_blender_skeleton(tmp_ws, table_plan)- rel = [p.relative_to(tmp_ws.root).as_posix() for p in paths]- assert rel == ["src/model.py", "src/parts/table_top.py", "src/parts/leg.py", "src/parts/shelf.py"]- assert all(p.is_file() for p in paths)- rep = lint_workspace(tmp_ws)- assert rep.passed, [(f.target, f.message) for f in rep.errors]- assert not [f for f in rep.findings if f.severity.value == "warn"], [f.message for f in rep.findings]--def test_instance_centers_symmetry() -> None:bb = BBox(center=(0.2, 0.3, 0.5), extents=(0.1, 0.1, 1.0))assert instance_centers(bb, 1, "none") == [(0.2, 0.3, 0.5)]@@ -62,9 +36,3 @@ def test_instance_centers_symmetry() -> None:assert len(four) == 4 and {(round(x, 3), round(y, 3)) for x, y, _ in four} == {(0.2, -0.3), (-0.2, -0.3), (-0.2, 0.3), (0.2, 0.3)}rad = instance_centers(BBox(center=(0.5, 0.0, 0.1), extents=(0.1, 0.1, 0.1)), 3, "radial")assert len(rad) == 3 and all(abs((x * x + y * y) ** 0.5 - 0.5) < 1e-9 for x, y, _ in rad)---def test_finish_for_keywords() -> None:- assert finish_for("brushed steel")[2] == 1.0- assert finish_for("oak wood")[0] == (0.55, 0.36, 0.20)- assert finish_for("something unknown")[0] == (0.6, 0.6, 0.6)diff --git a/harness/tests/blender_cadquery/test_cadquery_lint.py b/harness/tests/blender_cadquery/test_cadquery_lint.pyindex 82698daf..9dc66b2b 100644--- a/harness/tests/blender_cadquery/test_cadquery_lint.py+++ b/harness/tests/blender_cadquery/test_cadquery_lint.py@@ -5,25 +5,11 @@ from __future__ import annotationsfrom codeverse3d.contracts.artifacts import Severityfrom codeverse3d.languages.cadquery import lint_cadquery_source-GOOD = '''-import cadquery as cq-import math--top = cq.Workplane("XY").box(0.5, 0.5, 0.04).translate((0, 0, 0.58))-result = cq.Assembly(name="Table")-result.add(top, name="TableTop", color=cq.Color(0.5, 0.3, 0.2))-'''-def _msgs(r, sev=None):return [f.message for f in r.findings if sev is None or f.severity == sev]-def test_good_passes() -> None:- r = lint_cadquery_source(GOOD)- assert r.gate == "lint:cadquery" and r.passed, _msgs(r)--def test_missing_result_and_guarded_result() -> None:r = lint_cadquery_source("import cadquery as cq\nx = cq.Workplane().box(1, 1, 1)\n")assert not r.passed and any("module-level `result`" in m for m in _msgs(r, Severity.ERROR))@@ -72,11 +58,6 @@ def test_rotate_angle_expression_table() -> None:assert not r.passed and any("DEGREES" in m for m in _msgs(r, Severity.ERROR)), (expr, _msgs(r))-def test_bare_workplane_warns() -> None:- r = lint_cadquery_source("import cadquery as cq\nresult = cq.Workplane().box(1, 1, 1)\n")- assert r.passed and any("ONE unnamed part" in m for m in _msgs(r, Severity.WARN))--def test_syntax_error() -> None:r = lint_cadquery_source("import cadquery as cq\nresult = (\n")assert not r.passed and "SyntaxError" in r.findings[0].messagediff --git a/harness/tests/blender_cadquery/test_cadquery_runtime.py b/harness/tests/blender_cadquery/test_cadquery_runtime.pyindex e2d2c159..96f847f4 100644--- a/harness/tests/blender_cadquery/test_cadquery_runtime.py+++ b/harness/tests/blender_cadquery/test_cadquery_runtime.py@@ -2,50 +2,26 @@from __future__ import annotations-import astimport importlib.utilimport json-import statimport sysimport timefrom pathlib import Pathimport pytest-from codeverse3d.languages import get_runtime-from codeverse3d.languages.base import LanguageRuntimefrom codeverse3d.languages.cadquery import (WRAPPER,CadQueryRuntime,cadquery_env,- cadquery_skeleton_source,- lint_cadquery_source,)-from codeverse3d.prompts.catalog import language_textfrom tests.blender_cadquery.conftest import has_cadqueryneeds_cq = pytest.mark.skipif(not has_cadquery(), reason="cadquery not importable")-def test_protocol_and_contract() -> None:- rt = get_runtime("cadquery")- assert isinstance(rt, CadQueryRuntime) and isinstance(rt, LanguageRuntime)- assert "cq.Assembly" in language_text(rt.language, "contract.md") and rt.entry_globs == ("src/model.py",)- cmd = rt.build_command(__import__("codeverse3d.workspace", fromlist=["Workspace"]).Workspace("/tmp/x"), seed=1)- assert cmd[0] == sys.executable and cmd[1] == str(WRAPPER) and "--seed" in cmd---def test_skeleton_source_parses_and_lints(table_plan) -> None:- src = cadquery_skeleton_source(table_plan)- ast.parse(src)- assert "codeverse3d" not in src- assert 'name="TableTop"' in src and 'name=f"Leg_{_i}"' in src and "result = cq.Assembly(" in src- assert lint_cadquery_source(src).passed--def test_missing_entry_invalidates_previous_outputs(tmp_ws) -> None:- """Same invariant as BlenderRuntime: the invalidation runs BEFORE the- missing-entry early return and build.json agrees with the returned result."""+ """Stale outputs are invalidated before the missing-entry early return."""for name in ("object.glb", "object.step", "object.stl"):(tmp_ws.artifacts / name).write_bytes(b"stale")tmp_ws.write_json(tmp_ws.artifacts / "build.json", {"ok": True})@@ -58,15 +34,6 @@ def test_missing_entry_invalidates_previous_outputs(tmp_ws) -> None:assert disk["ok"] is False and disk["error_type"] == "MissingEntryFile"-def test_fake_python_wrapper_crash(tmp_ws, tmp_path) -> None:- fake = tmp_path / "py"- fake.write_text("#!/bin/sh\necho 'ImportError: no cadquery' >&2\nexit 1\n")- fake.chmod(fake.stat().st_mode | stat.S_IEXEC)- (tmp_ws.src / "model.py").write_text("import cadquery as cq\nresult = cq.Workplane().box(1, 1, 1)\n")- r = CadQueryRuntime(python=str(fake)).build(tmp_ws, timeout_s=20)- assert not r.ok and r.error_type == "WrapperCrash" and "no cadquery" in r.stderr_tail--@needs_cqdef test_skeleton_builds_named_coloured_glb(tmp_ws, table_plan) -> None:trimesh = pytest.importorskip("trimesh")@@ -92,7 +59,7 @@ def test_skeleton_builds_named_coloured_glb(tmp_ws, table_plan) -> None:@needs_cq-def test_assembly_with_subassembly_locations_and_errors(tmp_ws) -> None:+def test_assembly_with_subassembly_locations_and_bare_workplane(tmp_ws) -> None:trimesh = pytest.importorskip("trimesh")src = '''import cadquery as cqbase = cq.Workplane("XY").box(0.4, 0.4, 0.02).translate((0, 0, 0.01))@@ -119,14 +86,6 @@ result.add(pegs, name="Pegs", color=cq.Color(0, 1, 0))p1 = scene.geometry[scene.graph["Peg_1"][1]]assert list(p1.visual.material.baseColorFactor[:3]) == [0, 255, 0] # inherited from parent assembly- # error mapping: bad fillet → OCC error mapped to line with hint- (tmp_ws.src / "model.py").write_text("import cadquery as cq\n\nresult = cq.Workplane('XY').box(0.1, 0.1, 0.01).edges('|Z').fillet(0.2)\n")- r = rt.build(tmp_ws, timeout_s=120)- assert not r.ok and r.error_line == 3 and "fillet" in r.error_message.lower()- # missing result- (tmp_ws.src / "model.py").write_text("import cadquery as cq\nx = cq.Workplane('XY').box(1, 1, 1)\n")- r = rt.build(tmp_ws, timeout_s=120)- assert not r.ok and r.error_type == "MissingResult"# bare workplane → single node 'Object' + warning(tmp_ws.src / "model.py").write_text("import cadquery as cq\nresult = cq.Workplane('XY').box(1, 1, 1)\n")r = rt.build(tmp_ws, timeout_s=120)diff --git a/harness/tests/blender_cadquery/test_common.py b/harness/tests/blender_cadquery/test_common.pyindex 551cd0ed..9bd3b461 100644--- a/harness/tests/blender_cadquery/test_common.py+++ b/harness/tests/blender_cadquery/test_common.py@@ -9,16 +9,10 @@ from codeverse3d.contracts.artifacts import BuildResultfrom codeverse3d.languages._common import (ProcResult,compose_build_result,- strip_blender_noise,)from codeverse3d.proc import write_json_atomic-def test_strip_blender_noise() -> None:- raw = "Blender 5.0.1 (hash x)\nRead prefs: ...\n12:00:00 | INFO: Starting glTF 2.0 export\nTraceback (most recent call last):\n boom\nBlender quit"- assert strip_blender_noise(raw).splitlines() == ["Traceback (most recent call last):", " boom"]--def _proc(**kw) -> ProcResult:base = dict(returncode=0, stdout="", stderr="", timed_out=False, duration_ms=10)base.update(kw)@@ -56,20 +50,3 @@ def test_compose_ok_requires_glb(tmp_path: Path) -> None:assert r.extra_paths == {"stl": str(tmp_path / "o.stl")}assert r.census["tri_count"] == 12 and r.census["build_report"]["warnings"] == ["w"]assert BuildResult.model_validate_json(b.read_text()) == r---def test_compose_without_a_glb_goes_by_the_report(tmp_path: Path) -> None:- """The URDF wrapper exports meshes/, not object.glb: its report alone decides."""- b = tmp_path / "build.json"- write_json_atomic(b, {"ok": True, "duration_ms": 7})- r = compose_build_result(language="urdf_blender", proc=_proc(), build_json=b, census_json=tmp_path / "c.json",- glb_path=None, extra_paths={})- assert r.ok and r.glb_path is None and r.error_type == ""---def test_compose_script_error_fields(tmp_path: Path) -> None:- b = tmp_path / "build.json"- b.write_text(json.dumps({"ok": False, "error_type": "IndexError", "error_message": "boom", "error_file": "model.py", "error_line": 15}))- r = compose_build_result(language="blender", proc=_proc(), build_json=b, census_json=tmp_path / "none.json",- glb_path=tmp_path / "o.glb", extra_paths={})- assert not r.ok and r.error_type == "IndexError" and r.error_line == 15 and r.error_file == "model.py"diff --git a/harness/tests/blender_cadquery/test_material_slots.py b/harness/tests/blender_cadquery/test_material_slots.pyindex 7048fd33..38f251ce 100644--- a/harness/tests/blender_cadquery/test_material_slots.py+++ b/harness/tests/blender_cadquery/test_material_slots.py@@ -1,10 +1,4 @@-"""The census sees material slots the polygons never use.--The h2h microscope run authored 31 materials, assigned them through a helper that read-``res['faces']`` from ``bmesh.ops.create_cube`` (which returns only ``{'verts'}``), and-shipped an 11-slot arm in one off-white: every material was present, every polygon was on-slot 0, and nothing in the build said so — the judge capped the run for ``untextured_flat``.-"""+"""The census warns about material slots the polygons never use (a judge-capped flat-colour run)."""from __future__ import annotationsdiff --git a/harness/tests/threejs_render/test_build.py b/harness/tests/threejs_render/test_build.pyindex 9f28819a..9e509b2c 100644--- a/harness/tests/threejs_render/test_build.py+++ b/harness/tests/threejs_render/test_build.py@@ -45,42 +45,34 @@ def test_build_stool_glb_and_census(stool_ws: Workspace):assert np.allclose(hi, [0.17, 0.45, 0.17], atol=2e-3)-def test_build_runtime_error_maps_to_file_line(stool_ws: Workspace):- p = stool_ws.src / "parts" / "legs.js"- p.write_text(p.read_text().replace("const off = 0.13;", "const off = undefinedThing();"))[email protected]("path, find, repl, etype, line", [+ ("parts/legs.js", "const off = 0.13;", "const off = undefinedThing();", "ReferenceError", 6),+ ("parts/seat.js", None, "\nlet = 1;\n", "SyntaxError", 13),+])+def test_build_error_maps_to_file_line(stool_ws: Workspace, path, find, repl, etype, line):+ p = stool_ws.src / path+ p.write_text(p.read_text().replace(find, repl) if find else p.read_text() + repl)res = ThreeJsRuntime().build(stool_ws)- assert not res.ok- assert res.error_type == "ReferenceError"- assert "undefinedThing" in res.error_message- assert res.error_file == "src/parts/legs.js" and res.error_line == 6+ assert not res.ok and res.error_type == etype+ assert res.error_file == f"src/{path}" and res.error_line == lineassert not (stool_ws.artifacts / "object.glb").exists()assert (stool_ws.artifacts / "export_error.json").is_file()assert json.loads((stool_ws.artifacts / "build.json").read_text())["ok"] is False-def test_build_syntax_error_located(stool_ws: Workspace):- p = stool_ws.src / "parts" / "seat.js"- p.write_text(p.read_text() + "\nlet = 1;\n")[email protected]("source, message", [+ ("import * as THREE from 'three';\nexport function build(T) { const g = new THREE.Group(); g.name='Empty'; return g; }\n",+ "no meshes"),+ ("export const x = 1;\n", "export function build"),+])+def test_build_contract_errors(stool_ws: Workspace, source, message):+ (stool_ws.src / "object.js").write_text(source)res = ThreeJsRuntime().build(stool_ws)- assert not res.ok and res.error_type == "SyntaxError"- assert res.error_file == "src/parts/seat.js" and res.error_line == 13---def test_build_contract_error_no_meshes(stool_ws: Workspace):- (stool_ws.src / "object.js").write_text("import * as THREE from 'three';\nexport function build(T) { const g = new THREE.Group(); g.name='Empty'; return g; }\n")- res = ThreeJsRuntime().build(stool_ws)- assert not res.ok and res.error_type == "ContractError" and "no meshes" in res.error_message---def test_build_missing_build_export(stool_ws: Workspace):- (stool_ws.src / "object.js").write_text("export const x = 1;\n")- res = ThreeJsRuntime().build(stool_ws)- assert not res.ok and res.error_type == "ContractError" and "export function build" in res.error_message+ assert not res.ok and res.error_type == "ContractError" and message in res.error_messagedef test_build_keeps_source_placement_and_warns(stool_ws: Workspace):- """An off-ground / off-centre object is exported AS AUTHORED (no silent re-centring):- the census records the offset it would need and the warning says so."""+ """Law 7: an off-ground / off-centre object is exported as authored, with a warning."""p = stool_ws.src / "object.js"p.write_text(p.read_text().replace("return root;", "root.position.set(0.5, 0.2, 0); return root;"))res = ThreeJsRuntime().build(stool_ws)@@ -92,34 +84,8 @@ def test_build_keeps_source_placement_and_warns(stool_ws: Workspace):assert abs(lo[1] - 0.2) < 2e-3 and abs(lo[0] - 0.33) < 2e-3-def test_build_per_plan_placement_passes_contract_even_when_union_is_off_centre(stool_ws: Workspace):- """Plan parts whose union footprint is NOT centred (backrest-style skew): an object- built exactly per plan must not be reported as 'centre off' for every part."""- from codeverse3d.contracts.plan import StaticPlan- from codeverse3d.spatial.contract import check_contract- from codeverse3d.spatial.measure import measure_glb-- (stool_ws.src / "object.js").write_text(- "import * as THREE from 'three';\nexport function build(T) { const g = new THREE.Group(); g.name = 'Sign';\n"- " const base = new THREE.Mesh(new THREE.BoxGeometry(0.4, 0.35, 0.3), new THREE.MeshStandardMaterial({color: 0x888888}));\n"- " base.name = 'Base'; base.position.set(0, 0.175, 0); g.add(base);\n"- " const panel = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.1, 0.3), new THREE.MeshStandardMaterial({color: 0x884422}));\n"- " panel.name = 'Panel'; panel.position.set(0, 0.4, 0.2); g.add(panel); return g; }\n")- plan = StaticPlan(- object_name="Sign", summary="x", overall_bbox={"center": [0, 0.225, 0.1], "extents": [0.5, 0.45, 0.5]},- parts=[{"name": "Base", "role": "r", "description": "d", "bbox": {"center": [0, 0.175, 0], "extents": [0.4, 0.35, 0.3]}},- {"name": "Panel", "role": "r", "description": "d", "bbox": {"center": [0, 0.4, 0.2], "extents": [0.5, 0.1, 0.3]}}])- res = ThreeJsRuntime().build(stool_ws)- assert res.ok and res.census["placement_offset"] == [0, 0, -0.1]- rep = check_contract(measure_glb(res.glb_path), plan, language="threejs")- assert rep.passed, [f.message for f in rep.findings]- assert not [f for f in rep.findings if f.target in ("Base", "Panel")]- assert [f.message for f in rep.findings if "footprint" in f.message] # the offset is still reported, once, as WARN--def test_build_bakes_instanced_meshes_for_trimesh(stool_ws: Workspace):- """InstancedMesh must not export as EXT_mesh_gpu_instancing (trimesh ignores it):- measure/connectivity must see every instance as its own named mesh."""+ """InstancedMesh is baked (trimesh ignores EXT_mesh_gpu_instancing)."""from codeverse3d.spatial.connectivity import check_connectivity(stool_ws.src / "object.js").write_text(@@ -150,7 +116,6 @@ def test_build_bakes_instanced_meshes_for_trimesh(stool_ws: Workspace):def test_build_nan_geometry_names_mesh_part_and_file(stool_ws: Workspace):- """A NaN geometry error must name the mesh + part and route to src/parts/<snake>.js."""(stool_ws.src / "parts" / "legs.js").write_text("import * as THREE from 'three';\nexport function buildLegs(T) { const g = new THREE.Group(); g.name = 'Legs';\n"" const m = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 0/0, 12), new THREE.MeshStandardMaterial());\n"@@ -165,8 +130,6 @@ def test_build_nan_geometry_names_mesh_part_and_file(stool_ws: Workspace):def test_build_runs_exported_selfcheck(stool_ws: Workspace):- """`export function selfcheck(THREE, root)` is called by the harness: a throw fails- the build with the agent's message and the src frame; a passing one is recorded."""p = stool_ws.src / "object.js"src = p.read_text()p.write_text(src + "export function selfcheck(THREE_, root) {\n const box = new THREE.Box3().setFromObject(root);\n"diff --git a/harness/tests/threejs_render/test_camera_fit.py b/harness/tests/threejs_render/test_camera_fit.pyindex 9b2345f1..333e6a0e 100644--- a/harness/tests/threejs_render/test_camera_fit.py+++ b/harness/tests/threejs_render/test_camera_fit.py@@ -1,11 +1,4 @@-"""The object rig's camera fit — one distance-fit implementation, shared with the orbit rig.--``lib/browser/camera_fit.js`` used to iterate a projection loop of its own while-``lib/orbit.mjs`` solved the same problem analytically. Now both call-``orbit.fitDistance``; these tests pin the behaviour that merge must keep:-the projected bbox fills exactly ``fill`` of the half-frame for every canonical-view, at any aspect ratio, and the direction convention is the shared one.-"""+"""The object rig's camera fit fills exactly `fill` of the frame for every canonical view."""from __future__ import annotations@@ -68,15 +61,3 @@ def test_every_canonical_view_frames_the_box_exactly(tmp_path):assert r["distance"] > 0 and not r["inside"], where # never lands inside the objectassert 0 < r["near"] < r["far"], whereassert r["look_at"] == pytest.approx(r["centre"], abs=1e-9), where---def test_fit_scales_with_the_box_not_the_view(tmp_path):- rows = _fit_report(tmp_path)["rows"]- by = {(r["box"], r["name"], round(r["aspect"], 2)): r["distance"] for r in rows}- # the wide bench needs more distance than the small stool from the same view- for name in ("front", "front_right_high", "bottom"):- assert by[(1, name, 1.0)] > by[(0, name, 1.0)]- # a wider frame never needs to back off further than a square one (vertical fov fixed)- for (b, name, aspect), d in by.items():- if aspect == 1.0:- assert by[(b, name, 1.78)] <= d + 1e-9, (b, name)diff --git a/harness/tests/threejs_render/test_cli_flush.py b/harness/tests/threejs_render/test_cli_flush.pyindex 24362c16..3d94e165 100644--- a/harness/tests/threejs_render/test_cli_flush.py+++ b/harness/tests/threejs_render/test_cli_flush.py@@ -1,17 +1,4 @@-"""A driver's summary survives a pipe, however big it is.--`finish()` used to `process.stdout.write(...)` and then `process.exit()`. Node's stdout-to a PIPE is asynchronous, and `process.exit` does not flush it, so a summary larger than-the pipe buffer was cut mid-JSON and the caller saw no parsable last line.--Measured 2026-09-06 on the starter scene, `probe_scene.mjs --compile`: written to a file-the summary is 10 462 bytes and parses; through a pipe it was **exactly 8192** and did not.-That is the real mechanism behind every "driver output lost" and "[?] scene did not boot"-in `eval/bench/out/scene_baseline` / `scene_textures` — it depends on how big the census is, not-on how busy the machine is, which is why it read as weather for two batteries. In-`scene_textures/japanese_garden` it cost the round all three repair attempts and the-texture use the arm existed to measure.-"""+"""A driver's summary survives a pipe larger than the 8 KiB buffer (finish() used to exit before flushing)."""from __future__ import annotationsdiff --git a/harness/tests/threejs_render/test_error_routing.py b/harness/tests/threejs_render/test_error_routing.pydeleted file mode 100644index 1940e42f..00000000--- a/harness/tests/threejs_render/test_error_routing.py+++ /dev/null@@ -1,30 +0,0 @@-"""ThreeJsRuntime error-record → BuildResult routing (pure python: no node needed)."""--from __future__ import annotations--from pathlib import Path--from codeverse3d.languages.threejs import ThreeJsRuntime-from codeverse3d.spatial.node import NodeResult-from codeverse3d.workspace import Workspace---def _res(error: dict) -> NodeResult:- return NodeResult(rc=1, stdout="", stderr="", last_json={"ok": False, "error": error}, duration_ms=1)---def test_contract_error_part_routes_to_part_file(tmp_path: Path):- ws = Workspace(tmp_path)- (ws.src / "parts").mkdir(parents=True)- (ws.src / "parts" / "seat_cushion.js").write_text("export function buildSeatCushion(T) {}\n")- rt = ThreeJsRuntime()- err = {"type": "ContractError", "message": "Mesh 'Top' (in part 'SeatCushion') has NaN/Infinity vertex positions",- "file": "", "line": None, "frames": [{"file": "/abs/runtime_js/export_glb.mjs", "line": 9}], "part": "SeatCushion"}- out = rt._from_error_record(_res(err), ws)- assert out.error_type == "ContractError" and out.error_file == "src/parts/seat_cushion.js" and out.error_line is None- assert out.census["part"] == "SeatCushion"- # unknown part (no such file) → no guess; a src frame always wins over the part mapping- assert rt._from_error_record(_res({**err, "part": "Nope"}), ws).error_file == ""- assert rt._from_error_record(_res({**err, "file": "src/object.js", "line": 3}), ws).error_file == "src/object.js"- # no frames at all (e.g. module-level failure) keeps the entry-file fallback- assert rt._from_error_record(_res({**err, "part": "", "frames": []}), ws).error_file == "src/object.js"diff --git a/harness/tests/threejs_render/test_lint.py b/harness/tests/threejs_render/test_lint.pyindex 094b02f2..68f94fec 100644--- a/harness/tests/threejs_render/test_lint.py+++ b/harness/tests/threejs_render/test_lint.py@@ -95,11 +95,6 @@ def test_syntax_error_reported_with_line(stool_ws: Workspace):assert any("seat.js:13" in m and "SyntaxError" in m for m in _msgs(rep, Severity.ERROR))-def test_real_syntax_check_on_clean_stool(stool_ws: Workspace):- assert lint_workspace(stool_ws).passed--@pytest.mark.nodedef test_one_node_checks_every_file_and_a_parsed_file_is_not_sent_again(tmp_path: Path, monkeypatch):import codeverse3d.languages._js_lint as js_lintdiff --git a/harness/tests/threejs_render/test_node.py b/harness/tests/threejs_render/test_node.pyindex 8ce97ffb..b6570838 100644--- a/harness/tests/threejs_render/test_node.py+++ b/harness/tests/threejs_render/test_node.py@@ -6,7 +6,7 @@ from pathlib import Pathimport pytest-from codeverse3d.spatial.node import NodeError, parse_last_json, run_node, runtime_js_dir+from codeverse3d.spatial.node import NodeError, parse_last_json, run_nodedef test_parse_last_json_picks_last_object():@@ -21,17 +21,6 @@ def test_missing_script_raises(tmp_path: Path):run_node(tmp_path / "nope.mjs", [], timeout_s=5)-def test_run_node_echo(tmp_path: Path):- script = tmp_path / "echo.mjs"- script.write_text("console.log('hello'); console.log(JSON.stringify({ok: true, argv: process.argv.slice(2), np: process.env.NODE_PATH}));")- res = run_node(script, ["--x", "1"], timeout_s=20)- assert res.rc == 0- assert res.last_json["argv"] == ["--x", "1"]- assert res.last_json["np"].endswith("runtime_js/node_modules")- assert res.duration_ms >= 0--@pytest.mark.nodedef test_run_node_timeout_kills(tmp_path: Path):script = tmp_path / "hang.mjs"@@ -41,28 +30,6 @@ def test_run_node_timeout_kills(tmp_path: Path):assert ei.value.result is not None and ei.value.result.timed_out-def test_run_node_nonzero_exit(tmp_path: Path):- script = tmp_path / "fail.mjs"- script.write_text("console.log(JSON.stringify({ok:false, error:{message:'bad thing'}})); process.exit(3);")- with pytest.raises(NodeError) as ei:- run_node(script, [], timeout_s=20)- assert "bad thing" in str(ei.value)- assert ei.value.result.rc == 3- res = run_node(script, [], timeout_s=20, check=False)- assert res.rc == 3 and res.last_json["ok"] is False---def test_three_hook_resolves_bare_three(tmp_path: Path):- script = tmp_path / "t.mjs"- script.write_text("import * as THREE from 'three'; import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';"- "console.log(JSON.stringify({rev: THREE.REVISION, rb: typeof RoundedBoxGeometry}));")- res = run_node(script, [], timeout_s=30, three_hook=True)- assert res.last_json["rev"] == "182" and res.last_json["rb"] == "function"- assert (runtime_js_dir() / "lib" / "resolve_three.mjs").is_file()--@pytest.mark.nodedef test_run_node_env_is_scrubbed_of_secrets(tmp_path: Path, monkeypatch):"""Generated js (scene.js, agent modules) runs under run_node: no credentials."""diff --git a/harness/tests/threejs_render/test_render.py b/harness/tests/threejs_render/test_render.pyindex d721867f..3f5f94d1 100644--- a/harness/tests/threejs_render/test_render.py+++ b/harness/tests/threejs_render/test_render.py@@ -9,7 +9,6 @@ import pytestfrom PIL import Imagefrom codeverse3d.conventions import OBJECT_VIEWS_QUICK, ViewPreset-from codeverse3d.spatial import render as render_modfrom codeverse3d.spatial.render import RenderError, render_glb@@ -26,16 +25,6 @@ def test_render_glb_offline_validation(tmp_path: Path):render_glb(fake, tmp_path / "out", views=[])-def test_cache_key_depends_on_params(tmp_path: Path):- glb = tmp_path / "a.glb"- glb.write_bytes(b"abc")- k1 = render_mod._cache_key(glb, {"mode": "shaded", "w": 1})- k2 = render_mod._cache_key(glb, {"mode": "clay", "w": 1})- glb.write_bytes(b"abd")- k3 = render_mod._cache_key(glb, {"mode": "shaded", "w": 1})- assert len({k1, k2, k3}) == 3--@pytest.mark.nodedef test_render_views_modes_isolate_and_cache(stool_glb: Path, tmp_path: Path):out = tmp_path / "shaded"@@ -60,9 +49,7 @@ def test_render_views_modes_isolate_and_cache(stool_glb: Path, tmp_path: Path):sil = render_glb(stool_glb, tmp_path / "sil", views=[ViewPreset("front", 0, 8)], mode="silhouette", width=128, height=128, sheet=False)with Image.open(sil.views[0].path) as im:px = list(im.convert("L").getdata())- # The contract of silhouette mode is SEPARABILITY (compare_silhouette- # thresholds it), not literally two pixel values: antialiased edges are- # legitimate — a tighter camera fit simply produces more of them.+ # silhouette mode must be separable (compare_silhouette thresholds it)dark = sum(1 for v in px if v < 32)light = sum(1 for v in px if v > 223)mid = len(px) - dark - lightdiff --git a/harness/tests/threejs_render/test_render_retry.py b/harness/tests/threejs_render/test_render_retry.pyindex d2fce115..21b3202e 100644--- a/harness/tests/threejs_render/test_render_retry.py+++ b/harness/tests/threejs_render/test_render_retry.py@@ -55,10 +55,7 @@ def test_real_failure_is_not_retried(tmp_path, monkeypatch):assert calls == [100]-# The string below is verbatim from eval/bench/out/scene_baseline (2026-09-05): with the box-# at load 93 and swap full, Chrome reaped the render tab and every driver reported it-# this way. "detached frame" was not in TRANSIENT_MARKERS, so the object path did not-# retry it either — it only ever matched the "Target closed" spelling.+# verbatim from a real run where Chrome reaped the render tabDETACHED = "render_glb failed: Attempted to use detached Frame '10276B428E350BFA074A02AF37D52E6C'."diff --git a/harness/tests/threejs_render/test_runtime_js.py b/harness/tests/threejs_render/test_runtime_js.pyindex 0bdcb6c8..d5cf0930 100644--- a/harness/tests/threejs_render/test_runtime_js.py+++ b/harness/tests/threejs_render/test_runtime_js.py@@ -45,19 +45,6 @@ def test_render_glb_driver_reports_invalid_requests_as_last_json(tmp_path: Path)assert "non-empty JSON list" in ei.value.result.last_json["error"]-def test_one_webgl_renderer_factory():- """Object rig and scene host share `lib/browser/renderer.js`: one place sets- the colour pipeline (sRGB + ACES + PCF shadows, pixel ratio 1), so an object- render and a scene render cannot drift apart."""- rt = runtime_js_dir()- sources = sorted(rt.glob("*.mjs")) + sorted(rt.glob("*.cjs")) + sorted((rt / "lib").rglob("*.mjs")) \- + sorted((rt / "lib").rglob("*.js"))- owners = [p for p in sources if "new THREE.WebGLRenderer(" in p.read_text()]- assert [p.name for p in owners] == ["renderer.js"], owners- assert "from './renderer.js'" in (rt / "lib/browser/studio.js").read_text()- assert "from './browser/renderer.js'" in (rt / "lib/scene_host.mjs").read_text()--def test_serve_and_importmap(tmp_path: Path):script = tmp_path / "s.cjs"root = tmp_path / "root"@@ -119,11 +106,7 @@ const {{ launchBrowser, rendererInfo }} = require({json.dumps(str(runtime_js_dirdef test_two_runtime_trees_never_share_one_browser_endpoint(tmp_path: Path):- """A git worktree and the main checkout run their own runtime_js but share- ~/.cache/codeverse3d unless the operator remembers C3D_CACHE_DIR. Measured- 2026-09-05: two daemons, one endpoint file, `Session closed` across the scene- suite. The endpoint name carries the runtime_js that spawned it, so the two- trees keep separate browsers inside the SAME cache dir — no env var required."""+ """The browser endpoint name carries the runtime_js tree, so two trees share one cache dir safely."""cache = tmp_path / "cache"paths = []for tree in ("worktree", "checkout"):@@ -168,9 +151,7 @@ def _reap_daemons(cache_dir: Path) -> None:def test_gpu_launch_browser_reuse(tmp_path: Path):- """F21 phase 2: second launchBrowser connects to the daemon's shared browser- (~ms, shared=true); release() disconnects and the browser survives; with- C3D_BROWSER_REUSE=off every launch is owned."""+ """A second launch reconnects to the shared browser; C3D_BROWSER_REUSE=off owns every launch."""script = tmp_path / "r.cjs"script.write_text(f"""const {{ launchBrowser }} = require({json.dumps(str(runtime_js_dir() / 'gpu_launch.cjs'))});@@ -201,9 +182,7 @@ const {{ launchBrowser }} = require({json.dumps(str(runtime_js_dir() / 'gpu_laundef test_serve_refuses_symlinks_that_escape_the_root(tmp_path: Path):- """resolveInside is lexical + realpath: a symlink inside the workspace pointing- outside must 404 (workspace content is model-authored); in-root symlinks and- plain files keep serving."""+ """Workspace content is model-authored: a symlink out of the root 404s."""root = tmp_path / "root"root.mkdir()(root / "ok.txt").write_text("fine")@@ -228,9 +207,7 @@ const {{ serveDirs }} = require({json.dumps(str(runtime_js_dir() / 'serve.cjs'))def test_scene_server_only_mounts_src_public_assets(tmp_path: Path):- """serveWorkspace used to pass ``root: wsRoot``, so generated scene code could GET- /spec.json, /run_state.json, /events.jsonl, /.git/config and /artifacts/** — a scene- could read the previous round's judge output (audit 2026-08-27)."""+ """Scene code must not read the run's spec, state, git or judge output."""ws = Workspace(tmp_path / "run").create()(ws.src / "scene.js").write_text("export function createScene() {}\n")(ws.public / "assets").mkdir(parents=True, exist_ok=True)diff --git a/harness/tests/threejs_render/test_sheet.py b/harness/tests/threejs_render/test_sheet.pyindex 82958902..f7371420 100644--- a/harness/tests/threejs_render/test_sheet.py+++ b/harness/tests/threejs_render/test_sheet.py@@ -32,19 +32,6 @@ def test_sheet_missing_image_is_grey_tile(tmp_path: Path):assert im.getpixel((PAD + 64 + PAD + 40, PAD + 40)) == (200, 200, 200)-def test_sheet_deterministic(tmp_path: Path):- imgs = [("a", _png(tmp_path / "a.png", (1, 2, 3))), ("b", _png(tmp_path / "b.png", (3, 2, 1)))]- a = contact_sheet(imgs, tmp_path / "s1.png", cols=2, tile=64).read_bytes()- b = contact_sheet(imgs, tmp_path / "s2.png", cols=2, tile=64).read_bytes()- assert a == b---def test_sheet_no_label(tmp_path: Path):- out = contact_sheet([("a", _png(tmp_path / "a.png", (1, 2, 3)))], tmp_path / "s.png", cols=4, tile=50, label=False)- with Image.open(out) as im:- assert im.size == (50 + 2 * PAD, 50 + 2 * PAD)--def test_sheet_empty_raises(tmp_path: Path):with pytest.raises(ValueError):contact_sheet([], tmp_path / "s.png")diff --git a/harness/tests/threejs_render/test_skeleton.py b/harness/tests/threejs_render/test_skeleton.pyindex 151a97aa..2e635a9b 100644--- a/harness/tests/threejs_render/test_skeleton.py+++ b/harness/tests/threejs_render/test_skeleton.py@@ -7,8 +7,7 @@ from pathlib import Pathimport pytestfrom codeverse3d.contracts.plan import BBox, PartPlan, StaticPlan-from codeverse3d.languages.threejs import ThreeJsRuntime, write_skeleton-from codeverse3d.prompts.catalog import language_text+from codeverse3d.languages.threejs import write_skeletonfrom codeverse3d.workspace import Workspace@@ -37,25 +36,13 @@ def test_skeleton_files_and_contents(tmp_path: Path):assert "RoundedBoxGeometry" in seat and "ExtrudeGeometry" in seatassert "Material: leather" in seatassert '"type": "module"' in (ws.src / "package.json").read_text()---def test_skeleton_never_overwrites(tmp_path: Path):- ws = Workspace(tmp_path / "ws")- write_skeleton(ws, _plan())+ # never overwrites(ws.src / "parts" / "seat_cushion.js").write_text("// mine\n")again = write_skeleton(ws, _plan())assert again == []assert (ws.src / "parts" / "seat_cushion.js").read_text() == "// mine\n"-def test_runtime_protocol_surface():- rt = ThreeJsRuntime()- assert rt.language.value == "threejs"- assert rt.entry_globs == ("src/object.js", "src/parts/*.js")- doc = language_text(rt.language, "contract.md") # the contract is prompt material (prompts/catalog)- assert "build" in doc and "three" in doc.lower()--def test_skeleton_rejects_non_static_plan(tmp_path: Path):with pytest.raises(TypeError):write_skeleton(Workspace(tmp_path), object()) # type: ignore[arg-type]diff --git a/harness/tests/threejs_render/test_stale_outputs.py b/harness/tests/threejs_render/test_stale_outputs.pyindex 149a788a..934df48f 100644--- a/harness/tests/threejs_render/test_stale_outputs.py+++ b/harness/tests/threejs_render/test_stale_outputs.py@@ -1,9 +1,4 @@-"""ThreeJsRuntime.build stale-output invalidation (offline — node never runs).--The node-missing raise used to happen AFTER the glb/census wipe but BEFORE any-build.json write, so a previous round's build.json (ok: true) survived a harness-failure and every bare-existence reader treated the old outputs as current.-"""+"""ThreeJsRuntime.build never leaves a previous round's outputs looking current (offline)."""from __future__ import annotationsdiff --git a/harness/tests/threejs_render/test_studio_rig.py b/harness/tests/threejs_render/test_studio_rig.pyindex a83d5928..71ee4d4d 100644--- a/harness/tests/threejs_render/test_studio_rig.py+++ b/harness/tests/threejs_render/test_studio_rig.py@@ -1,12 +1,4 @@-"""The object studio rig (rig v2): what it is made of, and that it stays deterministic.--Rig v2 replaced `RoomEnvironment` + three white directionals on a flat clear colour-with a procedural softbox environment, a swept backdrop, a camera-relative key and a-soft contact shadow. Two properties have to hold for the harness around it to keep-working: the pictures must be reproducible (the render cache keys on file content,-not on a timestamp), and every file that can change the look must be inside the cache-signature — otherwise an edited rig silently serves stale PNGs to the judge.-"""+"""The object studio rig: every look-changing file is in the cache signature, and renders are reproducible."""from __future__ import annotations@@ -30,8 +22,6 @@ PAGE_RIG = ("lib/browser/render_rig.js", "lib/browser/studio.js", "lib/browser/sdef test_rig_signature_covers_every_file_that_can_change_the_look():- """`_rig_signature` is what makes an edited rig invalidate the render cache. Any- module the browser rig imports must be in it; a new one silently breaks caching."""rt = runtime_js_dir().resolve()entry = "lib/browser/render_rig.js"reachable = {entry}@@ -62,22 +52,6 @@ def test_rig_signature_covers_every_file_that_can_change_the_look():assert len(sig) == 12 and sig != "d41d8cd98f00"-def test_rig_is_procedural_and_deterministic_by_construction():- """No randomness, no wall clock, no external asset: the environment, the backdrop- and the contact shadow are all generated from constants in studio_env.js."""- rt = runtime_js_dir()- for rel in ("lib/browser/studio.js", "lib/browser/studio_env.js", "lib/browser/render_rig.js"):- src = (rt / rel).read_text()- assert "Math.random" not in src, rel- for rel in ("lib/browser/studio.js", "lib/browser/studio_env.js"):- assert "Date.now" not in (rt / rel).read_text(), rel- studio = (rt / "lib/browser/studio.js").read_text()- assert "environments/RoomEnvironment" not in studio, "rig v2 builds its own environment"- assert "softboxEnvironment" in studio and "backdropTexture" in studio- assert "export const RIG_VERSION = 2" in studio- assert "aimStudio" in (rt / "lib/browser/render_rig.js").read_text()--@pytest.mark.nodedef test_studio_render_is_reproducible_and_stamps_the_rig_version(stool_glb: Path, tmp_path: Path):a = render_glb(stool_glb, tmp_path / "a", views=OBJECT_VIEWS_QUICK, width=256, height=256,@@ -105,13 +79,7 @@ def test_studio_render_is_reproducible_and_stamps_the_rig_version(stool_glb: Pat@pytest.mark.node # renders through the node studio rigdef test_orbit_views_share_one_camera_distance(stool_glb: Path, tmp_path: Path):- """Consistent framing: views in the orbit band (|elevation| <= 60) are pulled towards- one shared camera distance so the object keeps its apparent size across the montage —- but no view is pulled back by more than 10 % beyond its own exact fit, or a deep- object shrinks every frame to what its widest side needs and the judge loses detail- resolution. Under the 14-view rig (D47) the band spans three elevation rings whose- exact fits genuinely differ, so the 10 % cap leaves a bounded spread between rings;- within a ring the distance must still be one number."""+ """D47: one camera distance per elevation ring; the 10 % pullback cap bounds the spread."""from codeverse3d.conventions import OBJECT_VIEWSrender_glb(stool_glb, tmp_path / "o", views=OBJECT_VIEWS, width=192, height=192,diff --git a/harness/tests/urdf_joints/test_axis_repair.py b/harness/tests/urdf_joints/test_axis_repair.pyindex 6afcb16a..d6ddbd61 100644--- a/harness/tests/urdf_joints/test_axis_repair.py+++ b/harness/tests/urdf_joints/test_axis_repair.py@@ -52,8 +52,8 @@ def _axis_of(ws: Workspace, joint: str):def test_anti_parallel_negates_the_authored_axis(tmp_path):- ws = _ws(tmp_path)- assert repair_motion_axes(ws, _report(_finding("Hinge", cos=-0.98))) == ["Hinge"]+ ws = _ws(tmp_path) # the plan's casing maps to the URDF joint+ assert repair_motion_axes(ws, _report(_finding("hinge", cos=-0.98))) == ["hinge"]assert _axis_of(ws, "Hinge") == (0.0, 0.0, 1.0)assert "authored comment must survive" in (ws.src / "robot.urdf").read_text()@@ -64,28 +64,16 @@ def test_orthogonal_writes_suggested_axis_and_inserts_missing_element(tmp_path):assert _axis_of(ws, "Slide") == (0.0, 0.0, 1.0)-def test_plan_casing_maps_to_urdf_joint(tmp_path):- ws = _ws(tmp_path)- assert repair_motion_axes(ws, _report(_finding("hinge", cos=-1.0))) == ["hinge"]- assert _axis_of(ws, "Hinge") == (0.0, 0.0, 1.0)---def test_findings_without_measured_data_are_never_touched(tmp_path):- ws = _ws(tmp_path) # the FakeServices shape: ERROR finding, empty data- assert repair_motion_axes(ws, _report(_finding("Hinge"))) == []- assert _axis_of(ws, "Hinge") == (0.0, 0.0, -1.0)---def test_warn_and_unknown_joints_are_skipped(tmp_path):+def test_warn_unknown_and_unmeasured_findings_are_skipped(tmp_path):ws = _ws(tmp_path)- rep = _report(_finding("Hinge", cos=-1.0, sev=Severity.WARN), _finding("Ghost", cos=-1.0))+ rep = _report(_finding("Hinge", cos=-1.0, sev=Severity.WARN), _finding("Ghost", cos=-1.0), _finding("Hinge"))assert repair_motion_axes(ws, rep) == []assert _axis_of(ws, "Hinge") == (0.0, 0.0, -1.0)@pytest.mark.parametrize("raw", ["0", "off", "false"])def test_kill_switch_disables(tmp_path, switch, raw):- """``C3D_AXIS_REPAIR=off`` was silently ignored until 2026-09-22: only "0" was read."""+ """Every off spelling disables it (only "0" used to be read)."""switch("C3D_AXIS_REPAIR", raw)ws = _ws(tmp_path)assert repair_motion_axes(ws, _report(_finding("Hinge", cos=-1.0))) == []@@ -100,9 +88,7 @@ def test_artifacts_copy_is_kept_in_step(tmp_path):def test_a_paired_axis_tag_keeps_the_joints_limit():- """PR #3 review: '/>' never occurs inside '</axis>', so the old splice searched past- the paired tag, landed on the NEXT self-closing element and deleted the joint's- <limit/> — an invalid revolute joint shipped to src/ and artifacts/."""+ """The splice of a paired <axis></axis> used to eat the joint's <limit/>."""from codeverse3d.tracks.articulated_object import _set_axis_in_urdf_textfor axis_form in ('<axis xyz="1 0 0"></axis>', '<axis xyz="1 0 0"/>'):@@ -115,10 +101,7 @@ def test_a_paired_axis_tag_keeps_the_joints_limit():def test_suggested_axis_is_expressed_in_the_joint_frame(tmp_path):- """PR #3 review: the suggestion was a WORLD vector written into the JOINT-frame- <axis>; with a rotated joint origin the 'exact' repair installed a provably wrong- axis and the motion gate kept its ERROR every round. The suggestion must FIX the- motion when installed."""+ """A rotated joint origin: installing the suggestion must actually fix the motion."""import numpy as npfrom codeverse3d.spatial.joints_model import load_urdfdiff --git a/harness/tests/urdf_joints/test_consistency.py b/harness/tests/urdf_joints/test_consistency.pyindex 20b32503..4a6fad01 100644--- a/harness/tests/urdf_joints/test_consistency.py+++ b/harness/tests/urdf_joints/test_consistency.py@@ -11,11 +11,6 @@ CENSUS = {"body": {"bbox_min": [-0.3, -0.2, 0.0], "bbox_max": [0.3, 0.2, 0.8]},"door": {"bbox_min": [-0.29, -0.22, 0.01], "bbox_max": [0.29, -0.2, 0.79]}}-def test_consistent(tmp_path):- urdf, meshes = write_mesh_robot(tmp_path)- assert check_fk_consistency(load_urdf(urdf, meshes), CENSUS) == []--def test_sign_error_reports_exact_fix(tmp_path):urdf, meshes = write_mesh_robot(tmp_path, door_visual_xyz="-0.29 -0.2 0")f = check_fk_consistency(load_urdf(urdf, meshes), CENSUS)diff --git a/harness/tests/urdf_joints/test_export.py b/harness/tests/urdf_joints/test_export.pyindex 04bd9891..d1443d05 100644--- a/harness/tests/urdf_joints/test_export.py+++ b/harness/tests/urdf_joints/test_export.py@@ -93,34 +93,6 @@ def test_multi_material_link_keeps_materials(tmp_path):assert sorted(n for n in [e[1] for e in s.graph.to_edgelist()] if n.startswith("body")) == ["body", "body__0", "body__1"]-def test_joint_sweep_tool_offline(tmp_path, monkeypatch):- """The ``joint_sweep`` tool reports the round's gate (``sweep_gate``) over every joint;- its renders are narrowed to ``joints`` (+ rest) through ``render_poses``."""- import codeverse3d.spatial.tools as ts- from codeverse3d.spatial.registry import ToolContext, get_tool- from codeverse3d.workspace import Workspace-- ws = Workspace(tmp_path / "ws").create()- ctx = ToolContext(workspace=ws, language="urdf_blender", track="articulated_object")- obs = get_tool("joint_sweep").call(ctx, {})- assert not obs.ok and "run `build`" in obs.text- write_mesh_robot(ws.artifacts)- rendered: list[list[str] | None] = []-- def fake_render_poses(robot, out_dir, poses=None, **kw):- rendered.append(None if poses is None else [label for label, _ in poses])- Image.new("RGB", (8, 8), "gray").save(out_dir / ARTICULATION_SHEET_NAME)- return []-- monkeypatch.setattr(ts, "render_poses", fake_render_poses)- obs = get_tool("joint_sweep").call(ctx, {"joints": ["hinge"]})- assert obs.ok and obs.numbers["errors"] == 0- assert obs.text.startswith("joint_sweep: PASS")- assert rendered == [["rest", "hinge@upper"]] and obs.images[0].endswith(ARTICULATION_SHEET_NAME) # lower=0 dedupes into rest- obs = get_tool("joint_sweep").call(ctx, {})- assert rendered[-1] is None # empty joints = the full sheet (render_poses default)--def test_joint_sweep_penetration_is_a_verdict_not_an_mcp_error(tmp_path, monkeypatch):"""A sweep that finds a penetration RAN: ``failed`` stays False (63% of 1404 recordedjoint_sweep calls answered FAIL, and each one reported as an MCP error bought a retrydiff --git a/harness/tests/urdf_joints/test_joints_model.py b/harness/tests/urdf_joints/test_joints_model.pyindex f4482af5..2788d961 100644--- a/harness/tests/urdf_joints/test_joints_model.py+++ b/harness/tests/urdf_joints/test_joints_model.py@@ -10,24 +10,10 @@ import pytestfrom codeverse3d.spatial.joints_model import (UrdfError,fk,- invert_transform,- link_world_meshes,load_urdf,- make_transform,- matrix_to_rpy,- rpy_to_matrix,)from codeverse3d.spatial.joints_poses import limit_poses, pose_label, pose_samples-from tests.urdf_joints.conftest import write_mesh_robot, write_prims_robot---def test_rpy_roundtrip_and_inverse():- for rpy in [(0, 0, 0), (0.3, -0.2, 1.1), (-1.0, 0.5, -2.0)]:- R = rpy_to_matrix(rpy)- assert np.allclose(R @ R.T, np.eye(3))- assert np.allclose(rpy_to_matrix(matrix_to_rpy(R)), R, atol=1e-9)- T = make_transform((1, 2, 3), (0.3, 0.2, 0.1))- assert np.allclose(T @ invert_transform(T), np.eye(4))+from tests.urdf_joints.conftest import write_prims_robotdef test_load_prims_and_fk(tmp_path):@@ -42,19 +28,6 @@ def test_load_prims_and_fk(tmp_path):fk(r, {"nope": 1.0})-def test_mesh_robot_world_placement(tmp_path):- urdf, meshes = write_mesh_robot(tmp_path, handle=True)- r = load_urdf(urdf, meshes)- wm = link_world_meshes(r)- assert np.allclose(wm["door"].bounds, [[-0.29, -0.22, 0.01], [0.29, -0.2, 0.79]], atol=1e-6)- assert np.allclose(wm["handle"].bounds, [[0.19, -0.26, 0.35], [0.21, -0.22, 0.45]], atol=1e-6)- # merged vertices → real topology- assert r.links["body"].mesh.is_watertight- # the handle follows the door- wm2 = link_world_meshes(r, {"hinge": math.pi / 2})- assert wm2["handle"].centroid[1] < -0.5--def test_load_errors(tmp_path):p = tmp_path / "bad.urdf"p.write_text("<robot name='x'><link name='a'/><link name='b'/></robot>")diff --git a/harness/tests/urdf_joints/test_lint.py b/harness/tests/urdf_joints/test_lint.pyindex bdcaf2b9..a334c06a 100644--- a/harness/tests/urdf_joints/test_lint.py+++ b/harness/tests/urdf_joints/test_lint.py@@ -30,11 +30,6 @@ def _msgs(findings, sev=None):return [f.message for f in findings if sev is None or f.severity == sev]-def test_good_urdf_is_clean():- f, links = lint_urdf_text(GOOD)- assert f == [] and links == ["body", "door"]--def test_xml_and_structure_errors():f, _ = lint_urdf_text("<robot name='x'><link name='a'>")assert f[0].severity == Severity.ERROR and "well-formed" in f[0].message and f[0].data.get("line") == 1diff --git a/harness/tests/urdf_joints/test_mimic.py b/harness/tests/urdf_joints/test_mimic.pyindex c86ccf3e..cfec15bf 100644--- a/harness/tests/urdf_joints/test_mimic.py+++ b/harness/tests/urdf_joints/test_mimic.py@@ -1,9 +1,4 @@-"""Coupled mechanisms: a <mimic> joint follows the joint it names, everywhere.--compare_art_v3/v4: umbrella, scissor_mirror and folding_workbench are the lowest scorers-on the battery, and all three are one-input mechanisms with many moving links. Before-this the sweep drove every link independently and posed them in states the mechanism-cannot reach."""+"""Coupled mechanisms: a <mimic> joint follows the joint it names, everywhere."""from __future__ import annotations@@ -70,19 +65,7 @@ def test_a_driven_joint_follows_its_driver_through_the_chain(tmp_path):assert fk(r, {"runner_slide": 0.1})["runner"][2, 3] == pytest.approx(fk(r, {})["runner"][2, 3] + 0.1)-def test_pose_samples_drive_only_the_degrees_of_freedom(tmp_path):- r = _robot(tmp_path)- poses = pose_samples(r)- assert all(set(p) <= {"runner_slide"} for p in poses), poses- assert any(p.get("runner_slide") == pytest.approx(0.3) for p in poses)- # the ribs still move: the sweep sees the coupled pose, not a frozen one- opened = [p for p in poses if p.get("runner_slide")][0]- assert fk(r, opened)["rib_a"][:3, :3].tolist() != fk(r, {})["rib_a"][:3, :3].tolist()--def test_the_contact_sheet_and_joint_narrowing_show_only_input_joints(tmp_path):- """`limit_poses` feeds the articulation sheet and `joint_sweep(joints=...)`: a tile for- a driven joint would be the rest pose with a label saying it moved."""from codeverse3d.spatial.joints_model import fkfrom codeverse3d.spatial.joints_poses import limit_poses@@ -120,18 +103,6 @@ def test_a_broken_coupling_is_refused_at_load(tmp_path, bad, msg):_robot(tmp_path, text)-def test_the_skeleton_writes_the_plan_s_coupling(cabinet_plan):- from codeverse3d.contracts.plan import MimicPlan- from codeverse3d.languages.urdf import compute_urdf_frames-- plan = cabinet_plan.model_copy(deep=True)- plan.joints[0].mimic = MimicPlan(joint="handle_mount", multiplier=2.0, offset=0.1)- plan.joints[1].type = "revolute"- plan.joints[1].lower, plan.joints[1].upper, plan.joints[1].rest = 0.0, 1.0, 0.0- urdf = render_urdf(compute_urdf_frames(plan))- assert '<mimic joint="handle_mount" multiplier="2" offset="0.1"/>' in urdf--def test_the_lint_accepts_a_real_coupling_and_names_a_broken_one(tmp_path, monkeypatch):from codeverse3d.workspace import Workspace@@ -163,17 +134,9 @@ def _plan(**joint_overrides):return d-def test_a_declared_coupling_validates_and_survives_the_round_trip():- d = _plan(mimic={"joint": "DrawerSlide", "multiplier": 2.0, "offset": 0.1})- plan = ArticulatedPlan.model_validate(d)- assert plan.joints[1].mimic is not None and plan.joints[1].mimic.joint == "DrawerSlide"- assert plan.joints[1].mimic.multiplier == 2.0 and plan.joints[1].mimic.offset == 0.1--@pytest.mark.parametrize("mimic,msg", [({"joint": "NoSuchJoint"}, "is not a joint in this plan"),({"joint": "LidHinge"}, "mimics itself"),- ({"joint": "DrawerSlide", "multiplier": 0.0}, "multiplier 0"),])def test_a_broken_coupling_is_refused_by_the_plan(mimic, msg):with pytest.raises(Exception, match=msg):@@ -197,31 +160,9 @@ def test_a_mimic_cycle_is_refused():ArticulatedPlan.model_validate(d)-def test_a_mimic_of_an_instanced_driver_follows_the_first_instance():- """An instanced driver exists only as ``<name>_1..._n``; writing the plan's bare name- made the skeleton fail its own lint and `load_urdf` (a scissor/pantograph plan is the- likely place to hit it)."""- from codeverse3d.languages.urdf import compute_urdf_frames-- d = _plan()- d["parts"][1]["instances"] = 2 # the drawer, driven by DrawerSlide- d["joints"][1]["mimic"] = {"joint": "DrawerSlide", "multiplier": 0.5}- urdf = render_urdf(compute_urdf_frames(ArticulatedPlan.model_validate(d)))- assert '<mimic joint="drawer_slide_1" multiplier="0.5" offset="0"/>' in urdf- assert "drawer_slide_1" in urdf and "drawer_slide_2" in urdf- names = {ln.split('"')[1] for ln in urdf.splitlines() if "<joint name=" in ln}- refs = {ln.split('"')[1] for ln in urdf.splitlines() if "<mimic joint=" in ln}- assert refs <= names, f"dangling mimic reference: {refs - names}"--# ------------------------------------------------------------------ one rule set, three layersdef test_the_three_layers_reject_the_same_near_zero_multiplier(tmp_path):- """A multiplier of 1e-10 is a coupling that transmits nothing.-- The plan validator refused it (< 1e-9) while the loader and the lint accepted it- (< 1e-12), so a coupling the planner could not write was one the URDF path took.- All three read ``MIMIC_MIN_MULTIPLIER`` now.- """+ """Plan validator, loader and lint share one MIMIC_MIN_MULTIPLIER floor."""from codeverse3d.contracts.common import MIMIC_MIN_MULTIPLIERfrom codeverse3d.workspace import Workspace@@ -241,9 +182,7 @@ def test_the_three_layers_reject_the_same_near_zero_multiplier(tmp_path):def test_the_lint_sees_a_cycle_the_per_joint_pass_could_not(tmp_path):- """``rib_a`` follows ``rib_b`` follows ``rib_a``: no single <mimic> element is wrong,- only the graph is. The lint checked one joint at a time and passed this file; the- loader then refused it, so the failure landed after the build instead of before."""+ """No single <mimic> is wrong, only the graph: the lint must see it before the build."""from codeverse3d.workspace import Workspacews = Workspace(tmp_path / "ws").create()@@ -255,8 +194,6 @@ def test_the_lint_sees_a_cycle_the_per_joint_pass_could_not(tmp_path):def test_an_unknown_target_is_reported_once_not_once_per_follower():- """The chain walk exists to find cycles. Every joint it walks through is itself in- the set and reports its own broken target, so the walk must not report it again."""from codeverse3d.contracts.common import MimicSpec, mimic_issuesissues = mimic_issues([@@ -267,10 +204,7 @@ def test_an_unknown_target_is_reported_once_not_once_per_follower():def test_the_lint_warns_when_a_coupling_drives_past_the_follower_s_own_limits(tmp_path):- """``rib_a_hinge`` is limited to 1.2 and follows a 0–0.3 slide at multiplier 4 — the- coupling reaches exactly 1.2, so the file that ships is silent. At multiplier 5 it- reaches 1.5 and the limits and the multiplier disagree; the sweep then poses the joint- where its own <limit> says it cannot go."""+ """At multiplier 4 the coupling reaches exactly the 1.2 limit (silent); at 5 it overshoots."""from codeverse3d.workspace import Workspacews = Workspace(tmp_path / "ws").create()@@ -295,24 +229,23 @@ EXTRA_RUNNER = """ <link name="runner2"><visual><geometry><mesh filename="meshedef test_the_skeleton_says_when_only_the_first_instance_of_a_driver_is_followed():- """The skeleton binds a coupling to ``<driver>_1``, so with an INSTANCED driver the- other instances stay independent inputs and the sweep drives them separately. The- file that ships says so, beside the ``<mimic>`` — written where the instancing is- known, because a lint cannot tell an instance from a joint an agent named ``hinge_2``.- """+ """An instanced driver exists only as <name>_1.._n: the skeleton follows _1 and says so."""from codeverse3d.languages.urdf import compute_urdf_framesd = _plan()d["parts"][1]["instances"] = 2d["joints"][1]["mimic"] = {"joint": "DrawerSlide", "multiplier": 0.5}urdf = render_urdf(compute_urdf_frames(ArticulatedPlan.model_validate(d)))+ assert '<mimic joint="drawer_slide_1" multiplier="0.5" offset="0"/>' in urdf+ names = {ln.split('"')[1] for ln in urdf.splitlines() if "<joint name=" in ln}+ refs = {ln.split('"')[1] for ln in urdf.splitlines() if "<mimic joint=" in ln}+ assert refs <= names, f"dangling mimic reference: {refs - names}"line = next(ln for ln in urdf.splitlines() if "<mimic joint=" in ln)assert "follows drawer_slide_1 only; drawer_slide_2 stay independent inputs" in linedef test_the_lint_does_not_mistake_hand_named_joints_for_instances(tmp_path):- """``hinge_1`` / ``hinge_2`` named by an agent are two joints, not one instanced- driver: a follower of ``hinge_1`` must not be told to couple ``hinge_2`` too."""+ """hinge_1 / hinge_2 written by an agent are two joints, not one instanced driver."""from codeverse3d.workspace import Workspaceurdf = (RIB.replace('joint name="runner_slide"', 'joint name="runner_slide_1"')@@ -328,10 +261,7 @@ def test_the_lint_does_not_mistake_hand_named_joints_for_instances(tmp_path):def test_the_exported_pose_glb_moves_the_followers_like_fk_does(tmp_path):- """The articulation sheet and the sweep must pose ONE mechanism: ``urdf_to_glb`` posed- the followers at rest (it read the raw pose dict, not the resolved one) while- ``sweep_collisions`` posed them through ``fk`` — the judge scored a closed umbrella- over a sweep that reported its open ribs colliding (review, 2026-09-04)."""+ """urdf_to_glb poses followers through fk, like the sweep (it used to leave them at rest)."""import numpy as npimport trimesh@@ -359,9 +289,6 @@ def test_the_exported_pose_glb_moves_the_followers_like_fk_does(tmp_path):def test_a_self_mimic_says_it_names_itself(tmp_path):- """The loader reported a self-coupling as "chain is a cycle", which is true of the- graph and useless to whoever wrote ``<mimic joint="itself">``. The shared rules have a- ``self`` kind; the URDF renderer now has the sentence for it."""text = RIB.replace('<mimic joint="runner_slide" multiplier="4" offset="0"/>','<mimic joint="rib_a_hinge" multiplier="1" offset="0"/>')with pytest.raises(UrdfError, match="names itself"):@@ -369,19 +296,13 @@ def test_a_self_mimic_says_it_names_itself(tmp_path):def test_a_self_joint_says_which_links_collided():- """`parent == child` was the whole message, and pydantic truncates the offending value- right after the joint name — so a model that wrote one had nothing to act on and- rewrote the same joint through every re-ask (7 plan calls died that way on- 2026-09-03). Both sides are named now, and a collision that only exists after- normalisation says so."""- import pytest as _pytest-+ """parent == child names both sides (pydantic truncated the value; models re-asked blind)."""from codeverse3d.contracts.plan import JointPlancommon = {"type": "revolute", "axis": [0, 0, 1], "pivot": [0, 0, 0],"lower": 0.0, "upper": 1.0, "rest": 0.0}- with _pytest.raises(Exception, match="parent and child are both 'Sash'"):+ with pytest.raises(Exception, match="parent and child are both 'Sash'"):JointPlan.model_validate({"name": "SashHinge", "parent": "Sash", "child": "Sash", **common})- with _pytest.raises(Exception, match="same name once normalised"):+ with pytest.raises(Exception, match="same name once normalised"):JointPlan.model_validate({"name": "SashHinge", "parent": "SashFrame", "child": "sash_frame",**common})diff --git a/harness/tests/urdf_joints/test_runtime_offline.py b/harness/tests/urdf_joints/test_runtime_offline.pyindex 39fa1c13..9fa73fc8 100644--- a/harness/tests/urdf_joints/test_runtime_offline.py+++ b/harness/tests/urdf_joints/test_runtime_offline.py@@ -8,12 +8,8 @@ from types import SimpleNamespaceimport pytestimport codeverse3d.languages.urdf as rt_mod-from codeverse3d.contracts.common import Language-from codeverse3d.languages import get_runtimefrom codeverse3d.languages.urdf import UrdfBlenderRuntimefrom codeverse3d.proc import ProcResult-from codeverse3d.prompts.catalog import language_text-from codeverse3d.spatial.joints_sweep import sweep_gatefrom codeverse3d.workspace import Workspacefrom tests.urdf_joints.conftest import box_glb@@ -61,24 +57,6 @@ def _two_link(plan):return plan.model_copy(update={"parts": plan.parts[:2], "joints": plan.joints[:1]})-def test_registry_and_contract():- rt = get_runtime(Language.URDF_BLENDER)- assert isinstance(rt, UrdfBlenderRuntime) and rt.entry_globs == ("src/model.py", "src/robot.urdf")- doc = language_text(rt.language, "contract.md") # prompts/urdf/contract.md- assert "meshes/<link>.glb" in doc and "pivot" in doc---def test_build_ok(tmp_path, cabinet_plan, fake_blender):- ws = _ws(tmp_path, cabinet_plan)- res = UrdfBlenderRuntime().build(ws)- assert res.ok, res.error_message- assert res.glb_path and (ws.artifacts / "object.glb").is_file() and (ws.artifacts / "robot.urdf").is_file()- # the build checks the rest pose only; every pose is the round's joint_sweep gate- assert "articulation" not in res.census and not (ws.artifacts / "articulation.json").exists()- assert sweep_gate(ws)[0].passed- assert res.stdout_tail == "built" # proc.tail joins lines: same shape as blender/cadquery--def test_build_script_error_maps_line(tmp_path, cabinet_plan, fake_blender):fake_blender["error"] = {"error_type": "NameError", "error_message": "name 'bpyy' is not defined", "error_file": "src/model.py","error_line": 7, "stderr_tail": "Traceback..."}@@ -102,25 +80,6 @@ def test_build_rest_penetration_fails_and_publishes_nothing(tmp_path, cabinet_plassert json.loads((ws.artifacts / "build.json").read_text())["ok"] is False-def test_build_failure_invalidates_previous_success(tmp_path, cabinet_plan, fake_blender):- """Round N fails after round N-1 succeeded: every canonical output of the old- round is gone and build.json on disk agrees with the returned (failed) result."""- ws = _ws(tmp_path, cabinet_plan)- rt = UrdfBlenderRuntime()- assert rt.build(ws).ok- for name in ("object.glb", "robot.urdf", "census.json", "meshes"):- assert (ws.artifacts / name).exists(), name- fake_blender["error"] = {"error_type": "NameError", "error_message": "boom",- "error_file": "src/model.py", "error_line": 3}- res = rt.build(ws)- assert not res.ok and res.error_type == "NameError"- for name in ("object.glb", "robot.urdf"):- assert not (ws.artifacts / name).exists(), name- assert not (ws.artifacts / "meshes").exists()- disk = json.loads((ws.artifacts / "build.json").read_text())- assert disk["ok"] is False and disk["error_type"] == "NameError"--def test_post_wrapper_failure_never_leaves_ok_true_build_json(tmp_path, cabinet_plan, fake_blender):"""The wrapper reports ok:true, then FkInconsistent fails the build — thepublished build.json must say what the returned BuildResult says (the old codediff --git a/harness/tests/urdf_joints/test_skeleton.py b/harness/tests/urdf_joints/test_skeleton.pyindex c89de30e..8ffdb0b0 100644--- a/harness/tests/urdf_joints/test_skeleton.py+++ b/harness/tests/urdf_joints/test_skeleton.py@@ -14,7 +14,6 @@ from codeverse3d.languages.urdf import (lint_urdf_text,render_model_py,render_urdf,- write_skeleton,)from codeverse3d.spatial.joints_model import fk, load_urdffrom codeverse3d.workspace import Workspace@@ -52,14 +51,6 @@ def test_rest_shift():assert lint_urdf_text(urdf_text)[0] == []-def test_no_rest_note_when_rest_is_zero(cabinet_plan):- fr = compute_urdf_frames(cabinet_plan)- urdf_text = render_urdf(fr)- assert all(j.rest == 0.0 for j in fr.joints)- assert "shifted by -rest" not in urdf_text and "plan rest=" not in render_model_py(cabinet_plan, fr)- assert '<limit lower="0" upper="1.57" effort="10" velocity="1"/>' in urdf_text--def test_rendered_files_lint_clean_and_load(tmp_path, cabinet_plan):fr = compute_urdf_frames(cabinet_plan)urdf_text = render_urdf(fr)@@ -77,27 +68,6 @@ def test_rendered_files_lint_clean_and_load(tmp_path, cabinet_plan):assert np.allclose(T[name] @ r.links[name].visual_origin, np.eye(4), atol=1e-9), name-def test_instances_expand():- plan = ArticulatedPlan(- object_name="Cart", summary="s", overall_bbox=BBox(center=(0, 0, 0.3), extents=(1, 1, 0.6)), root_link="Frame",- parts=[PartPlan(name="Frame", role="r", description="d", bbox=BBox(center=(0, 0, 0.4), extents=(0.8, 0.5, 0.1))),- PartPlan(name="Wheel", role="r", description="d", bbox=BBox(center=(-0.3, 0, 0.1), extents=(0.2, 0.05, 0.2)), instances=2)],- joints=[JointPlan(name="axle", type="continuous", parent="Frame", child="Wheel", axis=(0, 1, 0), pivot=(-0.3, 0, 0.1))],- )- fr = compute_urdf_frames(plan)- assert list(fr.links) == ["frame", "wheel_1", "wheel_2"]- assert [j.name for j in fr.joints] == ["axle_1", "axle_2"]- assert fr.links["wheel_2"].frame_xyz[0] > fr.links["wheel_1"].frame_xyz[0]- assert lint_urdf_text(render_urdf(fr))[0] == []---def test_write_skeleton(tmp_path, drawer_plan):- ws = Workspace(tmp_path / "ws").create()- paths = write_skeleton(ws, drawer_plan)- assert [p.name for p in paths] == ["model.py", "robot.urdf"]- assert "prismatic" in paths[1].read_text() and 'box(\'drawer\'' in paths[0].read_text()--def test_skeleton_rejects_static_plan(tmp_path):from codeverse3d.contracts.plan import StaticPlanfrom codeverse3d.languages.urdf import UrdfBlenderRuntimediff --git a/harness/tests/urdf_joints/test_sweep.py b/harness/tests/urdf_joints/test_sweep.pyindex fb5a5ac1..517036ad 100644--- a/harness/tests/urdf_joints/test_sweep.py+++ b/harness/tests/urdf_joints/test_sweep.py@@ -21,15 +21,6 @@ from tests.urdf_joints.conftest import ()-def test_good_design_has_no_overlaps(tmp_path):- r = load_urdf(write_prims_robot(tmp_path / "cab.urdf", axis_z=-1))- rep = sweep_collisions(r, pose_samples(r))- assert rep.summary.max_penetration_m == 0.0- assert rep.summary.floating_links == []- assert rep.per_pose[0].n_contacts == 1 # door touches body at rest- assert sweep_findings(rep) == []--def test_bad_axis_swings_door_into_body(tmp_path):r = load_urdf(write_prims_robot(tmp_path / "cab.urdf", axis_z=+1))rep = sweep_collisions(r, pose_samples(r))@@ -91,23 +82,9 @@ def test_motion_direction(tmp_path):motion_direction_check(r, "nope", "front")-def test_trimesh_fallback_backend(tmp_path, monkeypatch):- import codeverse3d.spatial.joints_collide as jc- import codeverse3d.spatial.joints_sweep as js-- monkeypatch.setattr(jc, "_fcl", None)- r = load_urdf(write_prims_robot(tmp_path / "cab.urdf", axis_z=+1))- rep = js.sweep_collisions(r, pose_samples(r), volumes=False)- assert rep.summary.backend == "trimesh"- assert rep.summary.max_penetration_m > 0.1 and rep.summary.rest_max_penetration_m == 0.0- assert rep.summary.floating_links == []--@pytest.mark.parametrize("fcl", [True, False], ids=["fcl", "trimesh-fallback"])def test_agent_style_meshes_penetration_is_real_and_deterministic(tmp_path, monkeypatch, fcl):- """Non-watertight, inverted-winding links (the wrapper's usual output): a clean design- must report no overlap and a drawer driven 30 mm through the side panel must be caught —- identically on every call (no random ray re-casts) and on both backends."""+ """Non-watertight, inverted-winding links (the wrapper's usual output), both backends, deterministic."""import codeverse3d.spatial.joints_collide as jcif not fcl:@@ -131,8 +108,7 @@ def test_agent_style_meshes_penetration_is_real_and_deterministic(tmp_path, monkdef test_welded_child_overlap_is_structural_not_motion(tmp_path):- """A handle sunk 3 mm into its door (fixed joint) never moves relative to the door:- one WARN under the rest policy, not an ERROR repeated for every swung pose."""+ """A weld overlap is one WARN under the rest policy, not an ERROR per swung pose."""urdf, meshes = write_mesh_robot(tmp_path, handle=True)urdf.write_text(urdf.read_text().replace('<origin xyz="-0.2 0.24 -0.4" rpy="0 0 0"/>', '<origin xyz="-0.2 0.243 -0.4" rpy="0 0 0"/>'))r = load_urdf(urdf, meshes)@@ -150,10 +126,6 @@ def test_welded_child_overlap_is_structural_not_motion(tmp_path):# ------------------------------------------------- joints= narrows the RENDER, not the sweepdef test_joints_argument_narrows_the_render_to_those_joints(monkeypatch, tmp_path):- """The tool accepted joints=[...] from the start and nothing consumed it: every call- rendered every joint's limit poses (three views each). Measured 2026-08-25: articulated- rounds ran a median 1007 s vs 497 s for static objects, agents calling the sweep 3-8- times a round on 10-joint objects (~63 renders a call)."""from codeverse3d.spatial import tools as tsclass _J:@@ -200,9 +172,3 @@ def test_aggregate_caps_errors_and_summarises_the_rest():warns = [f for f in out if f.severity == Severity.WARN]assert len(errors) == MAX_PAIR_FINDINGS and errors[0].target == f"p{MAX_PAIR_FINDINGS + 2}|base"assert len(warns) == 1 and warns[0].data["kind"] == "penetration_summary" and "3 more" in warns[0].message---def test_aggregate_keeps_single_and_warn_findings():- fs = [_pen("a", "b", 0.001, {}, sev=Severity.WARN)]- assert aggregate_findings(fs) == fs- assert aggregate_findings([]) == []