Skip to content

Official Codebase of 3DCodeVerse

Python

tests: judges, skills, urdf, graphics — delete duplicates and asserts that measure nothing

gaoypengcb0b3bd1d793
diff --git a/harness/tests/graphics/test_stale_invalidation.py b/harness/tests/graphics/test_stale_invalidation.py
index 22e6f973..aa505809 100644
--- a/harness/tests/graphics/test_stale_invalidation.py
+++ b/harness/tests/graphics/test_stale_invalidation.py
@@ -10,6 +10,8 @@ from __future__ import annotations
import json
+import pytest
+
import codeverse3d.spatial.tools # noqa: F401 — registers the gl_* tools
from codeverse3d.languages.glsl_shader import GlslShaderRuntime
from codeverse3d.spatial.gl_render import GlResult
@@ -36,30 +38,23 @@ def _seed_stale(ws: Workspace) -> None:
(ws.artifacts / "gl_result.json").write_text("{}")
-def test_failed_build_invalidates_sheet_gif_metrics(tmp_ws: Workspace) -> None:
- (tmp_ws.src / "shader.frag").write_text(
- "void mainImage(out vec4 fragColor, in vec2 fragCoord) { fragColor = vec4(nope); }\n")
[email protected]("frag, error_type", [
+ ("void mainImage(out vec4 fragColor, in vec2 fragCoord) { fragColor = vec4(nope); }\n", "GlslCompileError"),
+ # the MissingEntryFile early return never reaches the host: the hoisted wipe must still clear
+ (None, "MissingEntryFile"),
+])
+def test_a_failed_build_invalidates_every_output_of_the_last_one(tmp_ws: Workspace, frag: str | None, error_type: str) -> None:
+ if frag is not None:
+ (tmp_ws.src / "shader.frag").write_text(frag)
_seed_stale(tmp_ws)
br = GlslShaderRuntime(host=_FailingHost()).build(tmp_ws, preview=False)
- assert not br.ok and br.error_type == "GlslCompileError"
+ assert not br.ok and br.error_type == error_type
for name in ("frames_sheet.png", "preview.gif", "metrics.json", "gl_result.json"):
assert not (tmp_ws.artifacts / name).exists(), name
assert not list((tmp_ws.artifacts / "frames").glob("*.png"))
assert json.loads((tmp_ws.artifacts / "build.json").read_text())["ok"] is False
-def test_missing_entry_clears_frames_and_result(tmp_ws: Workspace) -> None:
- """The MissingEntryFile early return never reaches the host — the hoisted wipe must
- still clear frames/ + gl_result.json (and the sheet/gif/metrics trio)."""
- _seed_stale(tmp_ws)
- br = GlslShaderRuntime(host=_FailingHost()).build(tmp_ws, preview=False)
- assert not br.ok and br.error_type == "MissingEntryFile"
- assert not list((tmp_ws.artifacts / "frames").glob("*.png"))
- for name in ("gl_result.json", "frames_sheet.png", "preview.gif", "metrics.json"):
- assert not (tmp_ws.artifacts / name).exists(), name
- assert json.loads((tmp_ws.artifacts / "build.json").read_text())["ok"] is False
-
-
def test_gl_tool_lint_fail_records_the_failed_build_status(tmp_ws: Workspace) -> None:
"""A lint refusal in the gl tools is the LATEST build status — the previous
round's build.json (ok: true) must not stay readable as current."""
diff --git a/harness/tests/judges/test_caps.py b/harness/tests/judges/test_caps.py
index da73c996..fd31c4fe 100644
--- a/harness/tests/judges/test_caps.py
+++ b/harness/tests/judges/test_caps.py
@@ -170,33 +170,3 @@ def test_graded_acceptance_cap_keeps_the_gradient_but_not_the_pass():
defects={d.id: False for d in R.defects})
j = aggregate_samples(R, [sample], gates=[], acceptance_items=ten)
assert j.overall == pytest.approx(0.96) and not j.passed and "must items unverified: M3" in j.summary
-
-
-def test_a_defect_vote_tie_is_absent_and_an_acceptance_tie_still_follows_the_representative():
- """Burden of proof on the defect (2026-08-30): the rubric marks an item present only when an
- image or a gate finding shows it, so a split vote has not shown it. Acceptance ties keep the
- owner's policy (representative sample). 419/420 corpus verdicts are n=1: nothing moved."""
- import json
-
- import pytest
-
- from codeverse3d.judges.rubrics import (
- AcceptanceVerdict,
- CriterionScore,
- JudgeOutput,
- aggregate_samples,
- )
-
- def sample(defect_on: bool, acc_ok: bool) -> JudgeOutput:
- return JudgeOutput(criteria={c.id: CriterionScore(score=0.9, evidence="") for c in R.criteria},
- acceptance={"M1": AcceptanceVerdict(verified=acc_ok)},
- defects={d.id: (d.id == "render_artifacts" and defect_on) for d in R.defects})
-
- item = [AcceptanceItem(id="M1", text="x", priority="must")]
- j = aggregate_samples(R, [sample(True, True), sample(False, True)], gates=[], acceptance_items=item)
- raw = json.loads(j.raw)
- assert raw["defect_votes"]["render_artifacts"] == [True, False] and raw["defects"]["render_artifacts"] is False
- assert raw["tie_broken"] == ["render_artifacts"] and j.overall == pytest.approx(0.9)
- j2 = aggregate_samples(R, [sample(False, True), sample(False, False)], gates=[], acceptance_items=item)
- assert j2.acceptance_results["M1"] is True and json.loads(j2.raw)["tie_broken"] == ["M1"]
- assert raw["scoring_version"] == 2 and raw["overridden"] == []
diff --git a/harness/tests/judges/test_defects.py b/harness/tests/judges/test_defects.py
index 6181ab81..e64928fb 100644
--- a/harness/tests/judges/test_defects.py
+++ b/harness/tests/judges/test_defects.py
@@ -36,6 +36,7 @@ def test_rubrics_declare_defects_with_costs():
assert all(d.penalty > 0 or d.cap is not None for d in r.defects)
assert R.defect("floating_part").penalty == 0.10 and R.defect("floating_part").cap == 0.60
assert R.defect("wrong_object").cap == 0.25 and R.defect("wrong_object").penalty == 0.0
+ assert R.defect("interpenetration").cap == 0.7
assert {"no_articulation_visible", "wrong_motion_type", "pivot_misplaced", "pose_clips_body"} <= {d.id for d in A.defects}
with pytest.raises(KeyError):
R.defect("nope")
@@ -118,6 +119,7 @@ def test_defect_vote_ties_are_absent(judge_input, cache_dir, caplog):
assert raw["defect_votes"]["render_artifacts"] == [True, False]
assert raw["defects"]["render_artifacts"] is False and j.overall == pytest.approx(0.9)
assert raw["tie_broken"] == ["render_artifacts"]
+ assert raw["scoring_version"] == 2 and raw["overridden"] == []
clean_first = FakeChatModel(by_label={":s0": [_reply(0.9)], ":s1": [_reply(0.9, ["render_artifacts"])]})
j2 = VlmJudge("static_object_v1", chat_model=clean_first, n_samples=2, cache_dir=cache_dir).judge(judge_input)
diff --git a/harness/tests/judges/test_detail_anchors.py b/harness/tests/judges/test_detail_anchors.py
index 23ec881f..c97de712 100644
--- a/harness/tests/judges/test_detail_anchors.py
+++ b/harness/tests/judges/test_detail_anchors.py
@@ -76,19 +76,6 @@ def test_primitive_stack_defect_fires_on_a_majority_not_on_perfection() -> None:
assert d.penalty == pytest.approx(0.08)
-def test_physical_plausibility_caps_are_untouched() -> None:
- """The complexity wave may sharpen detail; it may never soften the gates."""
- caps = {c.id: c for c in load_rubric("static_object_v1").caps}
- assert caps["build_error"].cap == 0.0
- assert caps["floating_part"].cap == 0.6
- assert caps["penetration_error"].cap == 0.7
- assert caps["contract_violation"].cap == 0.75
- assert caps["missing_must_acceptance"].cap == 0.6
- defects = {d.id: d for d in load_rubric("static_object_v1").defects}
- assert defects["floating_part"].cap == 0.6 and defects["interpenetration"].cap == 0.7
- assert defects["wrong_object"].cap == 0.25
-
-
@pytest.mark.parametrize("rubric", ["static_object_v1", "articulated_v1"])
def test_acceptance_cap_is_graded_with_the_floor_pinned(rubric: str) -> None:
"""The acceptance cap is GRADED since 2026-08-30 (DECISIONS D46 b): 0.6 + 0.4·verified/total.
diff --git a/harness/tests/judges/test_pairwise.py b/harness/tests/judges/test_pairwise.py
index 64642b85..cc2098e2 100644
--- a/harness/tests/judges/test_pairwise.py
+++ b/harness/tests/judges/test_pairwise.py
@@ -14,8 +14,10 @@ def test_agreement_across_swap(tmp_path, cache_dir):
# ordering 1: A=ra,B=rb → "A" wins; ordering 2 (swapped): A=rb,B=ra → "B" wins → both say ra
model = FakeChatModel(by_label={":fwd": [_reply("A", 0.9)], ":swap": [_reply("B", 0.7)]})
res = PairwiseJudge("fake:fake-1", chat_model=model, cache_dir=cache_dir).compare(make_spec(), ra, rb)
- assert res.winner == "a" and res.confidence == 0.8 and len(res.orderings) == 2
- assert res.usage.cost_usd > 0
+ assert res.winner == "a" and res.confidence == 0.8
+ # the two orderings run concurrently but land in (fwd, swap) order; usage sums across both
+ assert [(o["swapped"], o["confidence"]) for o in res.orderings] == [(False, 0.9), (True, 0.7)]
+ assert res.usage.cost_usd == pytest.approx(0.002) and res.usage.input_tokens == 2000
reqs = {r.label: r for r in model.requests} # orderings run in parallel: look up by label
labels = [p.label for p in image_parts(reqs["pairwise:fwd"])]
assert len(labels) == 2 # one 2×2 montage per side
@@ -57,19 +59,6 @@ def test_unswap_reasons():
assert _unswap_text("Candidate A beats candidate B", False) == "Candidate A beats candidate B"
-def test_parallel_orderings_accumulate_in_order(tmp_path, cache_dir):
- """The two orderings run concurrently but land in (fwd, swap) order."""
- ra, rb = make_renders(tmp_path / "a"), make_renders(tmp_path / "b")
- model = FakeChatModel(by_label={":fwd": [_reply("A", 0.9)], ":swap": [_reply("B", 0.7)]})
- res = PairwiseJudge("fake:fake-1", chat_model=model, cache_dir=cache_dir).compare(make_spec(), ra, rb)
- assert [o["swapped"] for o in res.orderings] == [False, True]
- assert [o["confidence"] for o in res.orderings] == [0.9, 0.7]
- # usage sums across both parallel orderings
- assert res.usage.cost_usd == pytest.approx(0.002) and res.usage.input_tokens == 2000
-
-
-
-
def test_a_scene_pair_is_ranked_as_a_scene_from_the_views_the_judge_saw(tmp_path, cache_dir):
"""Every candidate used to be ranked as an OBJECT from its whole render set: a scene's
own camera sank behind the overview rig, and a view the verdict judge never saw
diff --git a/harness/tests/judges/test_rubrics.py b/harness/tests/judges/test_rubrics.py
index 74783aec..84e5dafc 100644
--- a/harness/tests/judges/test_rubrics.py
+++ b/harness/tests/judges/test_rubrics.py
@@ -54,7 +54,6 @@ def test_unknown_and_invalid_rubric():
def test_content_hash_stable():
- assert load_rubric("scene_v1").content_hash() == load_rubric("scene_v1").content_hash()
assert load_rubric("scene_v1").content_hash() != load_rubric("asset_v1").content_hash()
diff --git a/harness/tests/judges/test_vlm_judge.py b/harness/tests/judges/test_vlm_judge.py
index 90dd83ed..bea83860 100644
--- a/harness/tests/judges/test_vlm_judge.py
+++ b/harness/tests/judges/test_vlm_judge.py
@@ -127,12 +127,6 @@ def test_retry_on_parse_failure_then_success(judge_input, cache_dir):
assert j.usage.cost_usd == pytest.approx(0.002) # failed attempt still charged
-def test_retry_on_model_error_then_success(judge_input, cache_dir):
- model = FakeChatModel([ModelError("503", retryable=True), good_reply(R, IDS, 0.8)])
- j = _judge(model, cache_dir=cache_dir).judge(judge_input)
- assert j.passed and len(model.requests) == 2
-
-
def test_degraded_after_exhausting_attempts(judge_input, cache_dir):
model = FakeChatModel(default=ModelError("boom", retryable=True))
j = _judge(model, cache_dir=cache_dir).judge(judge_input)
diff --git a/harness/tests/skills/test_materialize_prompting.py b/harness/tests/skills/test_materialize_prompting.py
index 826c9359..8eb6bc2a 100644
--- a/harness/tests/skills/test_materialize_prompting.py
+++ b/harness/tests/skills/test_materialize_prompting.py
@@ -87,7 +87,8 @@ def test_the_control_survives_a_reroute_and_never_counts_as_a_stale_bundle(ws, l
materialize_skills(ws, [library["c3d-bbox-contract"]])
for root in SKILL_ROOTS:
assert (ws / root / CONTROL_NAME / "SKILL.md").is_file()
- assert not (ws / root / "c3d-part-contact").exists()
+ assert (ws / root / "c3d-bbox-contract").is_dir() # still routed: kept
+ assert not (ws / root / "c3d-part-contact").exists() # no longer routed: removed
def test_nothing_in_a_materialised_tree_is_a_symlink_because_codex_refuses_them(ws, library):
@@ -102,14 +103,6 @@ def test_atime_equals_mtime_after_writing_so_the_read_probe_has_a_zero_point(ws,
assert abs(st.st_atime - st.st_mtime) < 0.001
-def test_a_skill_that_is_no_longer_routed_is_removed_from_the_workspace(ws, library):
- materialize_skills(ws, [library["c3d-part-contact"], library["c3d-blender-forms"]])
- materialize_skills(ws, [library["c3d-part-contact"]])
- for root in SKILL_ROOTS:
- assert (ws / root / "c3d-part-contact").is_dir()
- assert not (ws / root / "c3d-blender-forms").exists()
-
-
def test_an_empty_selection_still_sweeps_last_rounds_bundles(ws, library):
"""attach_skills' empty-selection early return used to skip the sweep entirely:
last round's bundles stayed live in both discovery roots, where the native CLIs
diff --git a/harness/tests/skills/test_registry.py b/harness/tests/skills/test_registry.py
index bba2918e..93808da0 100644
--- a/harness/tests/skills/test_registry.py
+++ b/harness/tests/skills/test_registry.py
@@ -5,7 +5,7 @@ from __future__ import annotations
import json
from pathlib import Path
-from codeverse3d.skills.registry import ROUTED_SKILLS, ROUTES, Route, finding_kind, finding_kinds
+from codeverse3d.skills.registry import ROUTES, Route, finding_kind, finding_kinds
DATA = Path(__file__).parent / "data" / "gate_findings.json"
GOLDEN = json.loads(DATA.read_text())["findings"]
@@ -89,7 +89,6 @@ def test_gate_fired_rows_always_outrank_standing_rows():
def test_every_row_carries_a_reason_and_a_known_skill():
for r in ROUTES:
assert r.why and len(r.why) > 20, r.rule
- assert r.skill in ROUTED_SKILLS
assert r.skill.startswith("c3d-")
diff --git a/harness/tests/skills/test_telemetry.py b/harness/tests/skills/test_telemetry.py
index 5d06e0c1..19b271e7 100644
--- a/harness/tests/skills/test_telemetry.py
+++ b/harness/tests/skills/test_telemetry.py
@@ -98,12 +98,11 @@ def test_usage_is_appended_as_one_json_line_per_session(ws, library):
def test_the_control_bundle_is_materialised_and_starts_unread(ws, library):
- from codeverse3d.skills.materialize import CONTROL_NAME, materialize_skills
+ from codeverse3d.skills.materialize import materialize_skills
materialize_skills(ws, [library["c3d-part-contact"]])
usage = probe_reads(ws, _materialized(library, "c3d-part-contact"))
assert usage.control_present and not usage.control_read
- assert CONTROL_NAME not in usage.listed
def test_a_control_that_was_opened_makes_the_rate_unmeasurable(ws, library):
@@ -117,8 +116,7 @@ def test_a_control_that_was_opened_makes_the_rate_unmeasurable(ws, library):
_touch(ws / AGENTS_SKILL_ROOT / CONTROL_NAME / "references" / "control.md")
usage = probe_reads(ws, _materialized(library, "c3d-part-contact"))
assert usage.deep == ["c3d-part-contact"] # the raw signal is still reported
- assert usage.control_read and usage.deep_read_rate is None
- assert usage.deep_read_rate is None # but the RATE refuses to lie
+ assert usage.control_read and usage.deep_read_rate is None # but the RATE refuses to lie
def test_git_diff_alone_trips_the_control(tmp_path, library): # noqa: PLR0915
diff --git a/harness/tests/spatial_tools/test_render_common.py b/harness/tests/spatial_tools/test_render_common.py
index 216e4470..2882f7e7 100644
--- a/harness/tests/spatial_tools/test_render_common.py
+++ b/harness/tests/spatial_tools/test_render_common.py
@@ -245,9 +245,3 @@ def test_gl_metrics_summary_is_the_one_frame_stats_formatter(tmp_ws: Workspace,
monkeypatch.setattr("codeverse3d.languages._gl_common.read_metrics", lambda ws: None)
assert gl_metrics_summary(tmp_ws) == (["(no frame metrics)"], {}, True)
-
-def test_render_scene_still_exports_runtime_js_dir() -> None:
- """Public symbol kept while the definition moved to spatial.node."""
- from codeverse3d.spatial import node, render_scene
-
- assert render_scene.runtime_js_dir() == node.runtime_js_dir()
diff --git a/harness/tests/urdf_joints/test_runtime_offline.py b/harness/tests/urdf_joints/test_runtime_offline.py
index ac7251b3..39fa1c13 100644
--- a/harness/tests/urdf_joints/test_runtime_offline.py
+++ b/harness/tests/urdf_joints/test_runtime_offline.py
@@ -79,14 +79,6 @@ def test_build_ok(tmp_path, cabinet_plan, fake_blender):
assert res.stdout_tail == "built" # proc.tail joins lines: same shape as blender/cadquery
-def test_build_lint_error_short_circuits(tmp_path, cabinet_plan, fake_blender):
- ws = _ws(tmp_path, cabinet_plan)
- (ws.src / "robot.urdf").write_text("<robot name='x'><link name='a'>")
- res = UrdfBlenderRuntime().build(ws)
- assert not res.ok and res.error_type == "LintError" and "well-formed" in res.error_message
- assert not (ws.artifacts / "meshes").exists()
-
-
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..."}
@@ -96,15 +88,6 @@ def test_build_script_error_maps_line(tmp_path, cabinet_plan, fake_blender):
assert "hint: did you mean" in res.error_message
-def test_build_fk_inconsistent(tmp_path, cabinet_plan, fake_blender):
- ws = _ws(tmp_path, cabinet_plan)
- u = ws.src / "robot.urdf"
- u.write_text(u.read_text().replace('xyz="0.29 0.2 0"', 'xyz="-0.29 -0.2 0"'))
- res = UrdfBlenderRuntime().build(ws)
- assert not res.ok and res.error_type == "FkInconsistent"
- assert 'xyz="0.29 0.2 0"' in res.error_message and res.census["fk_check"][0]["target"] == "door"
-
-
def test_build_rest_penetration_fails_and_publishes_nothing(tmp_path, cabinet_plan, fake_blender):
fake_blender["door"] = ((0, -0.19, 0.4), (0.58, 0.02, 0.78)) # authored 10 mm inside the body
ws = _ws(tmp_path, cabinet_plan)
@@ -147,6 +130,7 @@ def test_post_wrapper_failure_never_leaves_ok_true_build_json(tmp_path, cabinet_
u.write_text(u.read_text().replace('xyz="0.29 0.2 0"', 'xyz="-0.29 -0.2 0"'))
res = UrdfBlenderRuntime().build(ws)
assert not res.ok and res.error_type == "FkInconsistent"
+ assert 'xyz="0.29 0.2 0"' in res.error_message and res.census["fk_check"][0]["target"] == "door"
disk = json.loads((ws.artifacts / "build.json").read_text())
assert disk["ok"] is False and disk["error_type"] == "FkInconsistent"
assert not (ws.artifacts / "object.glb").exists() and not (ws.artifacts / "meshes").exists()
@@ -158,7 +142,7 @@ def test_lint_fail_invalidates_stale_artifacts(tmp_path, cabinet_plan, fake_blen
assert rt.build(ws).ok
(ws.src / "robot.urdf").write_text("<robot name='x'><link name='a'>")
res = rt.build(ws)
- assert not res.ok and res.error_type == "LintError"
+ assert not res.ok and res.error_type == "LintError" and "well-formed" in res.error_message
assert not (ws.artifacts / "object.glb").exists() and not (ws.artifacts / "meshes").exists()
assert json.loads((ws.artifacts / "build.json").read_text())["error_type"] == "LintError"