Official Codebase of 3DCodeVerse
Python
tests: spatial_tools, scene_gates, graphics, second pass — twins fold, one dispatch test goes (−50 lines)
gaoypengf352c6980999
diff --git a/harness/tests/graphics/test_track.py b/harness/tests/graphics/test_track.pyindex 75ebd00d..26df0ca8 100644--- a/harness/tests/graphics/test_track.py+++ b/harness/tests/graphics/test_track.py@@ -75,15 +75,12 @@ def plan_example() -> dict[str, Any]:def _plan(spec, ws, model, budget=None):- """The planner as the live path calls it: everything graphics-specific (template, worked- example, T = 0.5, acceptance) is dispatched on ``spec.track`` inside it."""+ """The planner as the live path calls it (graphics dispatch happens on ``spec.track``)."""return planner.plan(spec, "fake:planner", GraphicsPlan, ws, model=model, budget=budget)def test_a_replayed_round_reads_the_payload_the_in_run_judge_read(tmp_path, settings):- """``3dcode judge`` / calibration (``cli/_judge.build_judge_input``) replayed a graphics round with- a digest of the plan's title and summary alone — no style, passes, key visuals or motion — while- the in-run judge read all of them. Both build the payload with ``judges.base.round_input`` now."""+ """``3dcode judge`` / calibration rebuild the payload the in-run judge read (``judges.base.round_input``)."""from codeverse3d.cli._judge import build_judge_inputfrom codeverse3d.record.record import load_recorddiff --git a/harness/tests/scene_gates/test_frame_metrics.py b/harness/tests/scene_gates/test_frame_metrics.pyindex 5932c3af..874aa59c 100644--- a/harness/tests/scene_gates/test_frame_metrics.py+++ b/harness/tests/scene_gates/test_frame_metrics.py@@ -2,14 +2,10 @@from __future__ import annotations-import json-from pathlib import Path--from codeverse3d.contracts.artifacts import RenderSet, RenderView, Severity+from codeverse3d.contracts.artifacts import Severityfrom codeverse3d.judges.rubrics import apply_caps, load_rubricfrom codeverse3d.spatial.frame_metrics import (frame_findings,- frame_gate_from_renders,frame_summary_text,)@@ -124,19 +120,6 @@ def test_content_small_roles():assert rep.findings[0].data["role"] == "establishing" and not rep.passed-def test_frame_gate_from_paths_and_renderset(tmp_path: Path):- out = tmp_path / "r00"- out.mkdir()- (out / "metrics.json").write_text(json.dumps(_metrics(_chk("Establishing", mean_lum=0.05))))- (out / "Establishing_t0.png").write_bytes(b"")- assert not frame_gate_from_renders(out).passed- assert not frame_gate_from_renders(out / "metrics.json").passed- rs = RenderSet(views=[RenderView(name="Establishing", path=str(out / "Establishing_t0.png"))])- assert not frame_gate_from_renders(rs).passed- assert frame_gate_from_renders(tmp_path / "nowhere").passed # no metrics → empty passing report- assert frame_gate_from_renders(RenderSet()).passed--def test_scene_rubric_caps_fire_on_frame_kinds():rubric = load_rubric("scene_v1")rep = frame_findings(_metrics(_chk("Establishing", mean_lum=0.07, dark_frac=0.41, content_frac=0.1)))diff --git a/harness/tests/scene_gates/test_orbit_framing.py b/harness/tests/scene_gates/test_orbit_framing.pyindex ab6c8292..a4f19146 100644--- a/harness/tests/scene_gates/test_orbit_framing.py+++ b/harness/tests/scene_gates/test_orbit_framing.py@@ -38,20 +38,14 @@ GARDEN = {BOUNDS = {"min": [-13, -1.5, -13], "max": [13, 6.5, 13]}-def test_framing_box_is_content_union_not_ground_or_sky():- box = _call("framingBox", GARDEN, BOUNDS)+def test_framing_box_is_the_content_union_without_sprawling_scatter():+ census = json.loads(json.dumps(GARDEN))+ census["groups"].append({"name": "GrassScatter", "kind": "content", "bbox": _box([-60, 0, -60], [60, 0.3, 60])})+ box = _call("framingBox", census, BOUNDS) # not the ground or sky, and the scatter is ignoredassert box["min"] == pytest.approx([-12.3, -0.3, -9.1]) and box["max"] == pytest.approx([10.4, 5.8, 11.7])- # without bounds: same union; no groups → the census content_bbox; no census → None- assert _call("framingBox", GARDEN)["size"] == pytest.approx(box["size"])+ # no groups → the census content_bbox; no census → Noneassert _call("framingBox", {"content_bbox": GARDEN["content_bbox"], "groups": []})["size"] == pytest.approx(GARDEN["content_bbox"]["size"])assert _call("framingBox", None) is None---def test_framing_box_drops_scatter_that_sprawls_past_bounds_and_clamps():- census = json.loads(json.dumps(GARDEN))- census["groups"].append({"name": "GrassScatter", "kind": "content", "bbox": _box([-60, 0, -60], [60, 0.3, 60])})- box = _call("framingBox", census, BOUNDS)- assert box["max"][0] == pytest.approx(10.4) and box["min"][2] == pytest.approx(-9.1) # scatter ignored# no bounds → nothing to judge sprawl against, but the union is still content onlybox2 = _call("framingBox", census)assert box2["size"][0] == pytest.approx(120)diff --git a/harness/tests/scene_gates/test_zone_contents_nesting.py b/harness/tests/scene_gates/test_zone_contents_nesting.pyindex b8b8fbcd..7c2c5c9d 100644--- a/harness/tests/scene_gates/test_zone_contents_nesting.py+++ b/harness/tests/scene_gates/test_zone_contents_nesting.py@@ -28,13 +28,9 @@ def _missing(findings) -> list[str]:return [m for f in findings if f.data.get("kind") == "missing_content" for m in f.data.get("missing", [])]-def test_content_one_group_down_is_found():+def test_content_is_looked_up_anywhere_under_its_row():out = contract_findings(_census(WRAPPED), _plan(["Windmill", "FloatingRock", "SkyPine"]))assert _missing(out) == [], "the zone built and named all three; only the shape differed"---def test_a_subtree_that_carries_the_name_nowhere_still_reads_as_missing():- """The rule is "somewhere under this row", not "anywhere in the scene"."""row = {"name": "Trees", "zone": "WindmillIsland", "inner": ["PineSway_0", "PineSway_1"]}out = contract_findings(_census(row), _plan(["SnowyPineTree"]))assert _missing(out) == ["SnowyPineTree"]diff --git a/harness/tests/spatial_tools/test_contract.py b/harness/tests/spatial_tools/test_contract.pyindex 17b14902..ee4f133b 100644--- a/harness/tests/spatial_tools/test_contract.py+++ b/harness/tests/spatial_tools/test_contract.py@@ -185,10 +185,7 @@ def test_a_box_rotated_90_about_x_is_lying_down() -> None:assert o[0].data["planned_up_m"] == pytest.approx(1.2) and o[0].data["measured_up_m"] == pytest.approx(0.2)assert "lying down relative to the planned box: planned 120.0 cm tall (z), measured 20.0 cm tall" in o[0].messageassert "rotate the whole object 90° about x so its height runs along z (blender frame: Z-up, -Y front)" in o[0].fix_hint---def test_the_same_in_the_threejs_frame() -> None:- # Y-up plan (0.4, 1.2, 0.2); built with the height along z: GLB (0.4, 0.2, 1.2)+ # the same in the threejs frame: Y-up plan (0.4, 1.2, 0.2) built with the height along zr = check_contract(_measurement_glb((0.4, 0.2, 1.2)), _one_part_plan((0.4, 1.2, 0.2), up=1), language="threejs")o = _orientation(r.findings)assert len(o) == 1 and o[0].severity == Severity.ERROR and o[0].data["best_axis"] == "z"diff --git a/harness/tests/spatial_tools/test_measure.py b/harness/tests/spatial_tools/test_measure.pyindex 73cad6b1..7f8dc529 100644--- a/harness/tests/spatial_tools/test_measure.py+++ b/harness/tests/spatial_tools/test_measure.py@@ -54,7 +54,7 @@ def test_cyclic_scene_graph_does_not_hang(tmp_path: Path) -> None:assert [k for k, v in part_meshes(scene).items() if v is not None]-def test_cached_parts_identity_and_invalidation(stool_glb: Path) -> None:+def test_caches_share_meshes_invalidate_on_stat_and_never_leak_edits(stool_glb: Path) -> None:from codeverse3d.spatial.measure import cached_partsp1 = cached_parts(stool_glb)@@ -66,9 +66,6 @@ def test_cached_parts_identity_and_invalidation(stool_glb: Path) -> None:os.utime(stool_glb, ns=(1, 1))p3 = cached_parts(stool_glb)assert set(p3) == set(p1) and all(p3[k] is not p1[k] for k in p3)---def test_measure_glb_memoized_and_isolated(stool_glb: Path) -> None:m1 = measure_glb(stool_glb)m2 = measure_glb(stool_glb)assert m1 is not m2 and m1 == m2diff --git a/harness/tests/spatial_tools/test_tools.py b/harness/tests/spatial_tools/test_tools.pyindex 00e1e0ea..f620b233 100644--- a/harness/tests/spatial_tools/test_tools.py+++ b/harness/tests/spatial_tools/test_tools.py@@ -361,13 +361,6 @@ def test_build_tool_graphics_reports_frames(tmp_ws: Workspace, monkeypatch: pyteassert "no GLB path" not in obs.textassert "frames=2" in obs.text and "sheet:" in obs.textassert obs.numbers["n_frames"] == 2 and obs.numbers["gate_errors"] == 0- # a failing gl_frames gate flips ok- bad = GateReport(gate="gl_frames", passed=False,- findings=[GateFinding(gate="gl_frames", severity=Severity.ERROR, message="static image",- data={"kind": "static"})])- monkeypatch.setattr(gl_build, "read_metrics", lambda ws: (stats, bad))- obs = get_tool("build").call(ctx, {})- assert not obs.ok and "static image" in obs.textclass _GlRuntime(_NoGlbRuntime):diff --git a/harness/tests/spatial_tools/test_tools_cli.py b/harness/tests/spatial_tools/test_tools_cli.pyindex b0418dab..b998b147 100644--- a/harness/tests/spatial_tools/test_tools_cli.py+++ b/harness/tests/spatial_tools/test_tools_cli.py@@ -17,9 +17,7 @@ def _panel_title(obs: Observation) -> str:def test_print_observation_shows_three_states() -> None:- """ok / FAIL / error, the same split the MCP server reports as ``is_error``: a human- reading `3dcode tools check_connectivity` must be able to tell a gate that answered FAIL- from a tool that could not run, and the panel title is where they look."""+ """ok / FAIL / error in the panel title — the split the MCP server reports as ``is_error``."""assert "ok" in _panel_title(Observation(ok=True, text="fine"))assert "FAIL" in _panel_title(Observation(ok=False, text="connectivity: FAIL — 1 error(s)"))assert "error" in _panel_title(Observation(ok=False, failed=True, text="measure: no GLB"))@@ -31,12 +29,7 @@ def test_print_observation_shows_three_states() -> None:def test_cli_exit_code_follows_the_verdict_not_the_failure(stool_ctx: ToolContext) -> None:- """`3dcode tools` exits 1 on ``not ok`` — a FAIL verdict included. Deliberate, and it- DID change one command: `scene_probe` used ``ok`` for "the probe tool ran", so a failing- scene gate now exits 1 where it exited 0 (docs/COST.md §30). Every other gate tool- already exited 1 on a FAIL; the exit code speaks to the human or script at the terminal,- while the MCP boundary — the one that costs money when a verdict is called an error —- reports ``failed`` alone."""+ """`3dcode tools` exits 1 on ``not ok`` — a FAIL verdict included (docs/COST.md §30)."""from codeverse3d.cli.main import apprunner = CliRunner()