Skip to content

Official Codebase of 3DCodeVerse

Python

eval tests: second pass — 19 tests fold into the scenario beside them (202 → 183, −113 lines)

gaoypeng761aaac1e46c
diff --git a/eval/tests/test_ab_plan.py b/eval/tests/test_ab_plan.py
index 914e4d20..dc6705ff 100644
--- a/eval/tests/test_ab_plan.py
+++ b/eval/tests/test_ab_plan.py
@@ -90,13 +90,6 @@ def test_outage_cells_are_excluded_from_every_arm_rate():
assert "| p9 | | missing | infra_failed | — | unpaired: control missing; variant infra_failed |" in md
-def test_summary_marks_regressions_and_states_the_rule():
- rows = [_row("a", CONTROL, 0.8), _row("a", VARIANT, 0.7), _row("b", CONTROL, 0.5), _row("b", VARIANT, 0.6)]
- md = render_summary(pair_up(rows), rows, title="t", variant_env={}, generator="g", judge="j", rounds=1)
- assert "| a | | 0.800 | 0.700 | -0.100 | REGRESSION |" in md and "## Verdict: **inconclusive**" in md
- assert "keep iff mean delta >= +0.02" in md and "(none)" in md
-
-
# ----------------------------------------------------------------------------- noise floor
def test_a_verdict_carries_its_noise_beside_the_word():
"""An A/A run once said "keep" on +0.344 from one prompt: the verdict must say when it is noise."""
@@ -110,14 +103,20 @@ def test_a_verdict_carries_its_noise_beside_the_word():
assert v.sd_delta is None and not v.separated and "one pair cannot separate" in v.caution
-def test_an_aa_run_is_labelled_so_nobody_reads_it_as_a_decision():
- rows = [_row("a", CONTROL, 0.59), _row("a", VARIANT, 0.93)]
+def test_the_summary_marks_regressions_states_the_rule_and_labels_an_aa_run():
+ rows = [_row("a", CONTROL, 0.8), _row("a", VARIANT, 0.7), _row("b", CONTROL, 0.5), _row("b", VARIANT, 0.6)]
+ md = render_summary(pair_up(rows), rows, title="t", variant_env={}, generator="g", judge="j", rounds=1)
+ assert "| a | | 0.800 | 0.700 | -0.100 | REGRESSION |" in md and "## Verdict: **inconclusive**" in md
+ assert "keep iff mean delta >= +0.02" in md and "(none)" in md
+ # an A/A run is labelled so nobody reads it as a decision
md = render_summary(pair_up(rows), rows, title="t", variant_env={}, generator="g", judge="j", rounds=1, aa=True)
assert md.startswith("# A/A: t") and "A/A calibration — the arms are identical" in md
# ----------------------------------------------------------------------------- env isolation
-def test_variant_env_is_applied_to_the_variant_arm_only():
+def test_child_env_isolates_the_variant_switch_and_pins_the_in_flight_cap(monkeypatch):
+ """The control never inherits the switch under test; CQ-3: an explicit --max-in-flight beats the
+ shell's C3D_MAX_IN_FLIGHT (docs/COST.md §23), and --variant-env may not set the cap."""
opts = AbOptions(variant_env={"C3D_PLAN_BRIEF": "on"})
base = {"PATH": "/bin", "C3D_PLAN_BRIEF": "on"} # leaked from the launching shell
c, v = child_env(CONTROL, opts, base), child_env(VARIANT, opts, base)
@@ -127,9 +126,6 @@ def test_variant_env_is_applied_to_the_variant_arm_only():
assert c[MAX_IN_FLIGHT_ENV] == v[MAX_IN_FLIGHT_ENV] == "16"
assert child_env(VARIANT, opts, {})["PYTHONUNBUFFERED"] == "1"
-
-def test_children_run_at_exactly_the_cap_the_budget_reserved(monkeypatch):
- """CQ-3: an explicit --max-in-flight beats the shell's C3D_MAX_IN_FLIGHT (docs/COST.md §23)."""
opts = AbOptions(variant_env={"K": "v"}, max_in_flight=8)
base = {"PATH": "/bin", MAX_IN_FLIGHT_ENV: "32", NESTED_MAX_IN_FLIGHT_ENV: "48"}
for arm in (CONTROL, VARIANT):
@@ -143,8 +139,6 @@ def test_children_run_at_exactly_the_cap_the_budget_reserved(monkeypatch):
monkeypatch.delenv(MAX_IN_FLIGHT_ENV)
assert inherited_max_in_flight() == DEFAULT_MAX_IN_FLIGHT
-
-def test_parse_variant_env():
assert parse_variant_env(["A=1", "B=x=y", "C="]) == {"A": "1", "B": "x=y", "C": ""}
for bad in (["A"], ["=1"]):
with pytest.raises(ValueError):
diff --git a/eval/tests/test_bestofk_report.py b/eval/tests/test_bestofk_report.py
index 1d92b4c6..affc9bbb 100644
--- a/eval/tests/test_bestofk_report.py
+++ b/eval/tests/test_bestofk_report.py
@@ -78,25 +78,18 @@ def test_equal_compute_k_is_taken_per_prompt_not_per_row(tmp_path: Path):
{"prompt_id": "b", "arm": "harness:x", "gen_cost_usd": 2.00},
{"prompt_id": "a", "arm": "oneshot:x", "gen_cost_usd": 0.05},
{"prompt_id": "b", "arm": "oneshot:x", "gen_cost_usd": 0.05},
+ # no recorded generation cost is missing data, not free: counting it would inflate k
+ {"prompt_id": "c", "arm": "oneshot:x", "gen_cost_usd": 0},
+ {"prompt_id": "d", "arm": "oneshot:x"},
]
(tmp_path / "results.jsonl").write_text("\n".join(json.dumps(r) for r in rows))
assert sorted(gen_costs(tmp_path, "harness:")) == [2.00, 2.00], "last row per prompt"
+ assert gen_costs(tmp_path, "oneshot:") == [0.05, 0.05]
h, b, k = equal_compute_k(tmp_path, "oneshot:")
assert (h, b, k) == (2.00, 0.05, 40)
-def test_a_zero_cost_row_is_not_counted_as_free(tmp_path: Path):
- """A row with no recorded generation cost is missing data; counting it would inflate k."""
- rows = [
- {"prompt_id": "a", "arm": "oneshot:x", "gen_cost_usd": 0.05},
- {"prompt_id": "b", "arm": "oneshot:x", "gen_cost_usd": 0},
- {"prompt_id": "c", "arm": "oneshot:x"},
- ]
- (tmp_path / "results.jsonl").write_text("\n".join(json.dumps(r) for r in rows))
- assert gen_costs(tmp_path, "oneshot:") == [0.05]
-
-
def test_the_report_says_when_k_has_not_been_reached(tmp_path: Path):
"""A curve short of equal compute says so, so the last row does not read as the verdict."""
_rep(tmp_path / "reps", "rep01", {"a": 0.2})
diff --git a/eval/tests/test_fixed_eval_language.py b/eval/tests/test_fixed_eval_language.py
index ce9b10a8..c2bf68c7 100644
--- a/eval/tests/test_fixed_eval_language.py
+++ b/eval/tests/test_fixed_eval_language.py
@@ -63,22 +63,6 @@ def test_graphics_cells_are_judged_on_their_frames(monkeypatch, tmp_path):
assert seen["inp"].renders.views[0].path == str(png) and "frames=1" in seen["inp"].extra_context
-def test_graphics_judge_is_the_track_rubric_with_the_photos():
- from bench._fixed_eval import FixedEvaluator
- from codeverse3d.contracts.common import Track
- from codeverse3d.contracts.spec import ReferenceImage, Spec
- from codeverse3d.judges.vlm_judge import LikenessJudge
-
- ev = FixedEvaluator("gemini:gemini-3.1-pro-preview", n_samples=2)
- with_photos = Spec(id="g", track=Track.GRAPHICS, language=Language.GLSL_SHADER, prompt="x", references=[ReferenceImage(path="/p.png")])
- j = ev.judge_for(with_photos)
- assert isinstance(j, LikenessJudge) and j.rubric.name == "shader_v2"
- plain = ev.judge_for(Spec(id="g", track=Track.GRAPHICS, language=Language.GLSL_SHADER, prompt="x"))
- assert plain.rubric.name == "shader_v2" and not isinstance(plain, LikenessJudge)
- obj = ev.judge_for(Spec(id="o", track=Track.STATIC_OBJECT, language=Language.BLENDER, prompt="x"))
- assert obj.rubric.name == "static_object_v1"
-
-
def test_scene_cells_are_judged_on_their_cameras_and_orbit_frames(monkeypatch, tmp_path):
"""2026-09-07: the compare bench had no scene branch — a scene cell built (no GLB) and
`evaluate` returned before judging. A scene is judged on render_scene's frames (authored
diff --git a/eval/tests/test_oneshot.py b/eval/tests/test_oneshot.py
index 4dc00d0a..8e30b78c 100644
--- a/eval/tests/test_oneshot.py
+++ b/eval/tests/test_oneshot.py
@@ -58,16 +58,11 @@ def test_scene_and_shader_prompts_are_their_contract_and_nothing_of_the_harness(
assert not any(s in p for s in harness_only)
- "Here you go:\n```python\nimport bpy\nprint(1)\n```\nDone.",
- "=== FILE: src/model.py ===\nimport bpy\nprint(1)\n=== END FILE ===",
- "import bpy\nprint(1)\n",
-])
-def test_extract_model_file_tolerant(text: str):
- assert extract_model_file(text) == "import bpy\nprint(1)\n"
-
-
-def test_extract_model_file_rejects_prose():
+def test_extract_model_file_is_tolerant_but_rejects_prose():
+ for text in ("Here you go:\n```python\nimport bpy\nprint(1)\n```\nDone.",
+ "=== FILE: src/model.py ===\nimport bpy\nprint(1)\n=== END FILE ===",
+ "import bpy\nprint(1)\n"):
+ assert extract_model_file(text) == "import bpy\nprint(1)\n", text
with pytest.raises(MultiFileParseError):
extract_model_file("Sorry, I cannot do that.")
@@ -82,15 +77,13 @@ def test_claude_argv_disables_tools_and_is_single_turn():
assert argv_m[argv_m.index("--model") + 1] == "opus"
-def test_codex_argv_is_read_only_and_reads_prompt_from_stdin(tmp_path: Path):
+def test_codex_argv_is_read_only_and_forces_a_reasoning_effort(tmp_path: Path):
+ """Read-only sandbox, no MCP, prompt on stdin. Effort: default high
+ (Settings.agents.codex_reasoning_effort); `@effort` on the id wins; '' opts out."""
argv = CodexOneShot("", binary="codex").argv(tmp_path, tmp_path / "last.md")
assert argv[:3] == ["codex", "exec", "--json"]
assert argv[argv.index("--sandbox") + 1] == "read-only" and argv[-1] == "-"
assert "--ephemeral" in argv and "-o" in argv and "mcp_servers" not in " ".join(argv)
-
-
-def test_codex_oneshot_forces_a_reasoning_effort(tmp_path: Path):
- """Default high (Settings.agents.codex_reasoning_effort); `@effort` on the id wins; '' opts out."""
argv = CodexOneShot("gpt-5.6-terra", binary="codex").argv(tmp_path, tmp_path / "last.md")
assert argv[argv.index("--model") + 1] == "gpt-5.6-terra"
assert "model_reasoning_effort=high" in argv and argv[argv.index("-c") + 1] == "model_reasoning_effort=high"
@@ -113,13 +106,11 @@ def test_api_oneshot_uses_injected_chat_model(tmp_path: Path):
r = ApiOneShot("gemini:x", chat_model=M()).generate(oneshot_prompt(_spec()), out_dir=tmp_path / "g")
assert r.ok and r.usage.cost_usd == 0.004 and (tmp_path / "g" / "response.md").is_file() and r.tool_calls == 0
-
-def test_api_oneshot_model_error_is_recorded(tmp_path: Path):
class Boom:
def generate(self, req):
raise RuntimeError("quota")
- r = ApiOneShot("gemini:x", chat_model=Boom()).generate("p", out_dir=tmp_path / "g")
+ r = ApiOneShot("gemini:x", chat_model=Boom()).generate("p", out_dir=tmp_path / "boom")
assert not r.ok and "quota" in r.notes
diff --git a/eval/tests/test_pin_plan.py b/eval/tests/test_pin_plan.py
index 7f861a47..1aaeb4df 100644
--- a/eval/tests/test_pin_plan.py
+++ b/eval/tests/test_pin_plan.py
@@ -41,14 +41,11 @@ def test_the_targets_own_state_survives(tmp_path):
assert state["stages"]["plan"]["result_path"] == str((dst / "stages" / "plan.json").resolve())
-def test_an_unplanned_source_is_refused_by_name(tmp_path):
- (tmp_path / "src_run" / "stages").mkdir(parents=True)
- with pytest.raises(PinError, match="has not planned"):
- seed_plan(tmp_path / "src_run", tmp_path / "dst")
-
-
-def test_a_source_without_a_cached_stage_is_refused(tmp_path):
+def test_an_unplanned_or_uncached_source_is_refused(tmp_path):
"""plan.json but no stage entry: the target would silently re-plan while the report claims a pin."""
+ (tmp_path / "bare" / "stages").mkdir(parents=True)
+ with pytest.raises(PinError, match="has not planned"):
+ seed_plan(tmp_path / "bare", tmp_path / "dst")
src = _planned_run(tmp_path, parts=4)
(src / "run_state.json").write_text(json.dumps({"status": "generating", "stages": {}}))
dst = tmp_path / "dst_run"
diff --git a/eval/tests/test_replay.py b/eval/tests/test_replay.py
index ea6832c5..b38e8684 100644
--- a/eval/tests/test_replay.py
+++ b/eval/tests/test_replay.py
@@ -110,13 +110,10 @@ def test_identity_holds_same_version_verdicts_and_reports_older_ones_as_drift(tm
assert "identity OK: 1 of 1" in capsys.readouterr().out
-def test_a_verdict_written_before_the_stamp_reads_as_version_0(tmp_path):
+def test_a_pre_stamp_verdict_reads_as_version_0_and_an_unjudged_round_is_skipped(tmp_path):
j = aggregate_samples(R, [_sample(0.9)], gates=GATES, acceptance_items=ITEMS)
raw = json.loads(j.raw)
raw.pop("scoring_version", None)
- _write_round(tmp_path, j.model_copy(update={"raw": json.dumps(raw)}))
- assert ro.replay_corpus([tmp_path], rubric_name=R.name).rows[0].scoring_version_stored == 0
-
-
-def test_a_round_without_a_judged_sample_is_skipped(tmp_path):
- assert ro.replay_round(_write_round(tmp_path, None)) is None
+ _write_round(tmp_path / "old", j.model_copy(update={"raw": json.dumps(raw)}))
+ assert ro.replay_corpus([tmp_path / "old"], rubric_name=R.name).rows[0].scoring_version_stored == 0
+ assert ro.replay_round(_write_round(tmp_path / "unjudged", None)) is None
diff --git a/eval/tests/test_scene_stats.py b/eval/tests/test_scene_stats.py
index a26b79d3..09eeff41 100644
--- a/eval/tests/test_scene_stats.py
+++ b/eval/tests/test_scene_stats.py
@@ -30,24 +30,19 @@ def test_a_dead_browser_is_counted_apart_from_a_defect(tmp_path: Path) -> None:
_gate("render_console", False, [DETACHED]),
_gate("scene_placement", False, ["Crate is sunken 0.9 m into Wall"]),
])
+ # `scene_frames` with no frames to look at is the same browser loss reported twice
+ _run(tmp_path, "both", [_gate("render_console", False, [DETACHED]),
+ _gate("scene_frames", False, ["render produced no result: " + DETACHED])])
d = layers(runs(tmp_path))
g = d["gates"]
# the browser loss lands in its own column and does NOT inflate the gate's failures
- assert g["render_console:LOST"] == 1
+ assert g["render_console:LOST"] == 2
assert g["render_console:FAILED"] == 0
assert d["gate_errors"]["render_console"] == 0
+ assert g["scene_frames:FAILED"] == 0 and g["scene_frames:LOST"] == 1
# the real defect in the same round is untouched
- assert g["scene_placement:FAILED"] == 1 and d["gate_errors"]["scene_placement"] == 1
- assert g["rounds_lost_to_the_box"] == 1
-
-
-def test_a_gate_that_failed_ONLY_on_the_browser_is_not_a_failure(tmp_path: Path) -> None:
- """`scene_frames` with no frames to look at is the same browser loss reported twice."""
- _run(tmp_path, "both", [_gate("render_console", False, [DETACHED]),
- _gate("scene_frames", False, ["render produced no result: " + DETACHED])])
- d = layers(runs(tmp_path))
- assert d["gates"]["scene_frames:FAILED"] == 0 and d["gates"]["scene_frames:LOST"] == 1
- assert sum(d["gate_errors"].values()) == 0
+ assert g["scene_placement:FAILED"] == 1 and sum(d["gate_errors"].values()) == d["gate_errors"]["scene_placement"] == 1
+ assert g["rounds_lost_to_the_box"] == 2
def test_the_median_score_is_read_off_the_real_Judgment_shape(tmp_path: Path) -> None:
diff --git a/eval/tests/test_session_stats.py b/eval/tests/test_session_stats.py
index b21b262b..b27e2ea0 100644
--- a/eval/tests/test_session_stats.py
+++ b/eval/tests/test_session_stats.py
@@ -29,47 +29,30 @@ def _run(root: Path, name: str, costs: list[float]) -> Path:
def test_rates_and_costs_over_two_sessions(tmp_path: Path) -> None:
+ """An empty stdout.json is a CLI killed before its stats: killed, not a session — and never
+ doubled through the telemetry symlink. A candidate's own run under ``_cand/`` is not the cell's."""
+ from bench.session_stats import _killed
+
run = _run(tmp_path, "cell_a", [1.0, 3.0, 5.0])
_session(run, "baseline_r00", tools={"build": (10, 0), "joint_sweep": (4, 2)},
prompt=1000, cached=700, requests=5)
_session(run, "refine_r01", tools={"build": (6, 1)}, prompt=1000, cached=900, requests=5)
-
- calls, failed = tool_rates(_sessions(tmp_path))
- assert calls == {"build": 16, "joint_sweep": 4} and failed == {"build": 1, "joint_sweep": 2}
- tok = token_rates(_sessions(tmp_path))
- assert tok["cache_hit"] == 0.8 and tok["uncached_per_request"] == 40 # (2000-1600)/10
- assert round_costs(tmp_path) == [1.0, 3.0, 5.0]
- assert "| 3.000 |" in report([tmp_path]) # the median round, not the mean
-
-
-def test_a_killed_session_is_counted_as_killed_not_as_a_session(tmp_path: Path) -> None:
- """An empty stdout.json is a CLI killed before its stats: killed, not a session — and never doubled."""
- from bench.session_stats import _killed
-
- run = _run(tmp_path, "cell_a", [2.0])
- _session(run, "baseline_r00", tools={"build": (3, 0)}, prompt=100, cached=50, requests=1)
- dead = run / "trajectories" / "refine_r01"
+ dead = run / "trajectories" / "refine_r02"
dead.mkdir(parents=True)
(dead / "stdout.json").write_text("")
- # the telemetry symlink reaches the dead session too: killed must not double either
(run / "telemetry").mkdir()
(run / "telemetry" / "trajectories").symlink_to(run / "trajectories", target_is_directory=True)
+ _session(run / "_cand" / "c1" / "run", "baseline_r00", tools={"build": (99, 9)}, prompt=999, cached=0, requests=9)
- assert len(_sessions(tmp_path)) == 1 and _killed(tmp_path) == 1
- calls, _ = tool_rates(_sessions(tmp_path))
- assert calls == {"build": 3}
- assert "| 1 | 1 |" in report([tmp_path]) # sessions | killed
-
-
-def test_a_sub_workspace_is_not_the_battery_cell_above_it(tmp_path: Path) -> None:
- """A candidate's own run under ``_cand/`` is not the cell's, as in ``find_runs``."""
- run = _run(tmp_path, "cell_a", [1.0])
- _session(run, "baseline_r00", tools={"build": (2, 0)}, prompt=100, cached=50, requests=1)
- sub = run / "_cand" / "c1" / "run"
- _session(sub, "baseline_r00", tools={"build": (99, 9)}, prompt=999, cached=0, requests=9)
-
+ assert len(_sessions(tmp_path)) == 2 and _killed(tmp_path) == 1
calls, failed = tool_rates(_sessions(tmp_path))
- assert dict(calls) == {"build": 2} and failed["build"] == 0
+ assert calls == {"build": 16, "joint_sweep": 4} and failed == {"build": 1, "joint_sweep": 2}
+ tok = token_rates(_sessions(tmp_path))
+ assert tok["cache_hit"] == 0.8 and tok["uncached_per_request"] == 40 # (2000-1600)/10
+ assert round_costs(tmp_path) == [1.0, 3.0, 5.0]
+ text = report([tmp_path])
+ assert "| 3.000 |" in text # the median round, not the mean
+ assert "| 2 | 1 |" in text # sessions | killed
def test_the_coupling_survey_counts_degrees_of_freedom_not_joints(tmp_path: Path) -> None:
@@ -91,6 +74,9 @@ def test_the_coupling_survey_counts_degrees_of_freedom_not_joints(tmp_path: Path
cell = tmp_path / "cells" / "art_hard_umbrella" / "arm" / "run" / "artifacts"
cell.mkdir(parents=True)
(cell / "robot.urdf").write_text(urdf)
+ for where in ("src", "deliverable"): # a run holds robot.urdf thrice: one per run, the built one
+ (cell.parent / where).mkdir()
+ (cell.parent / where / "robot.urdf").write_text(urdf)
(tmp_path / "cells" / "plain" / "arm" / "run" / "artifacts").mkdir(parents=True)
(tmp_path / "cells" / "plain" / "arm" / "run" / "artifacts" / "robot.urdf").write_text(
urdf.replace('<mimic joint="drive" multiplier="1" offset="0"/>', ""))
@@ -123,27 +109,6 @@ def test_the_coupling_survey_also_reads_the_gate_that_judges_the_poses(tmp_path:
assert "| 2 | 2 | 1 | 1 | 0.50 |" in report([tmp_path])
-def test_the_coupling_survey_counts_runs_not_copies_of_the_same_urdf(tmp_path: Path) -> None:
- """A run holds robot.urdf in src/, artifacts/ and deliverable/: one per run, the built one."""
- from bench._records import prompt_of
- from bench.coupling_stats import _urdfs
-
- urdf = """<?xml version="1.0"?>
-<robot name="rig"><link name="base"/><link name="a"/>
- <joint name="drive" type="revolute"><parent link="base"/><child link="a"/>
- <axis xyz="0 0 1"/><limit lower="0" upper="1" effort="1" velocity="1"/></joint>
-</robot>
-"""
- run = tmp_path / "runs" / "cpl_umbrella"
- for where in ("src", "artifacts", "deliverable"):
- (run / where).mkdir(parents=True)
- (run / where / "robot.urdf").write_text(urdf)
-
- found = _urdfs(tmp_path)
- assert [p.parent.name for p in found] == ["artifacts"], "one URDF per run, the built one"
- assert prompt_of(found[0]) == "cpl_umbrella"
-
-
def _sweep(pair: str, depth_m: float, *, poses: list[dict], worst_pose: dict) -> dict:
"""An aggregated `joint_sweep` penetration finding, in the shape `aggregate_findings`
really emits: the pair is `target`, the worst depth is `data["max_depth_m"]`, and
diff --git a/eval/tests/test_skill_targets_readout.py b/eval/tests/test_skill_targets_readout.py
index 50c2fd67..9a89cf3a 100644
--- a/eval/tests/test_skill_targets_readout.py
+++ b/eval/tests/test_skill_targets_readout.py
@@ -37,7 +37,9 @@ CONTRACT = [_finding("contract", "part 'Seat' bbox deviates from the plan (worst
_finding("contract", "'Leg' (each instance) bbox deviates from the plan (worst 1.4× tolerance)")]
-def test_the_readout_counts_the_kinds_the_row_names(tmp_path):
+def test_the_readout_counts_the_kinds_the_row_names_over_the_graded_runs_it_is_defined_for(tmp_path):
+ """A concurrency probe or an e2e smoke run has no gate report; counting it would give
+ a GLB-derived row a different n from the gate-derived rows beside it."""
from bench.skill_targets import battery_rows, load_runs
root = _battery(tmp_path, {
@@ -45,40 +47,18 @@ def test_the_readout_counts_the_kinds_the_row_names(tmp_path):
{"gate": "contract", "findings": CONTRACT}]),
"lamp": _record("blender", [{"gate": "connectivity", "findings": CONNECTIVITY[2:]},
{"gate": "contract", "findings": []}]),
- })
- rows = {r["skill"]: r for r in battery_rows(load_runs(root), list(TARGETS), which="last", cache=None)}
- assert rows["c3d-part-contact"]["n"] == 2
- assert rows["c3d-part-contact"]["mean"] == 1.0 # 2 pairs + 0, INFO ignored
- assert rows["c3d-bbox-contract"]["mean"] == 0.5 # part_bbox only
- assert rows["c3d-repeats-and-mirrors"]["mean"] == 0.5 # instance_bbox only
-
-
-def test_a_row_only_counts_the_languages_it_is_defined_over(tmp_path):
- from bench.skill_targets import battery_rows, load_runs
-
- root = _battery(tmp_path, {
"robot": _record("urdf_blender", [{"gate": "joint_sweep", "findings": [
_finding("joint_sweep", "links 'a' and 'b' overlap by 6.0 mm at pose j=1.0", "error"),
_finding("joint_sweep", "links 'a' and 'c' overlap by 3.0 mm at rest", "warn")]}]),
- "chair": _record("blender", [{"gate": "connectivity", "findings": CONNECTIVITY}]),
- })
- rows = {r["skill"]: r for r in battery_rows(load_runs(root), list(TARGETS), which="last", cache=None)}
- assert rows["c3d-urdf-joints"]["n"] == 1 # the blender run is not eligible
- assert rows["c3d-urdf-joints"]["mean"] == 1.0 # ERRORs only; the rest-pose WARN is not one
- assert rows["c3d-part-contact"]["n"] == 2 # both languages carry a part graph
-
-
-def test_an_ungraded_run_is_not_in_the_population(tmp_path):
- """A concurrency probe or an e2e smoke run has no gate report; counting it would give
- a GLB-derived row a different n from the gate-derived rows beside it."""
- from bench.skill_targets import battery_rows, load_runs
-
- root = _battery(tmp_path, {
- "chair": _record("blender", [{"gate": "connectivity", "findings": CONNECTIVITY}]),
"probe": {"spec": {"language": "blender"}, "rounds": [{"index": 0, "gates": []}]},
})
rows = {r["skill"]: r for r in battery_rows(load_runs(root), list(TARGETS), which="last", cache=None)}
- assert rows["c3d-part-contact"]["n"] == 1
+ assert rows["c3d-part-contact"]["n"] == 3 # both languages carry a part graph; the probe is out
+ assert rows["c3d-part-contact"]["mean"] == pytest.approx(2 / 3) # 2 pairs + 0 + 0, INFO ignored
+ assert rows["c3d-bbox-contract"]["mean"] == pytest.approx(1 / 3) # part_bbox only: chair 1
+ assert rows["c3d-repeats-and-mirrors"]["mean"] == pytest.approx(1 / 3) # instance_bbox only: chair 1
+ assert rows["c3d-urdf-joints"]["n"] == 1 # the blender runs are not eligible
+ assert rows["c3d-urdf-joints"]["mean"] == 1.0 # ERRORs only; the rest-pose WARN is not one
def test_the_ab_mode_pairs_by_prompt(tmp_path):
@@ -90,12 +70,20 @@ def test_the_ab_mode_pairs_by_prompt(tmp_path):
d.mkdir(parents=True)
(d / "record.json").write_text(json.dumps(
_record("blender", [{"gate": "connectivity", "findings": findings}])))
+ # a provider outage leaves `run_a` and `run_a.attempt1` side by side in one cell: pairing
+ # the ungraded one would drop a prompt that actually ran
+ cell = root / "arms" / arm / "cells" / "stool"
+ for leaf, rec in (("run_a", {"spec": {"language": "blender"}, "rounds": []}),
+ ("run_a.attempt1",
+ _record("blender", [{"gate": "connectivity", "findings": CONNECTIVITY}]))):
+ (cell / leaf).mkdir(parents=True)
+ (cell / leaf / "record.json").write_text(json.dumps(rec))
arms = ab_arms(root)
assert arms is not None
rows = {r["skill"]: r for r in ab_rows(arms, list(TARGETS), which="last", cache=None)}
r = rows["c3d-part-contact"]
- assert (r["n"], r["control_mean"], r["variant_mean"], r["mean_delta"]) == (1, 2.0, 1.0, -1.0)
- assert (r["better"], r["worse"], r["tied"]) == (1, 0, 0)
+ assert (r["n"], r["control_mean"], r["variant_mean"], r["mean_delta"]) == (2, 2.0, 1.5, -0.5)
+ assert (r["better"], r["worse"], r["tied"]) == (1, 0, 1)
def test_the_cli_runs_over_a_synthetic_battery(tmp_path, capsys):
@@ -121,23 +109,6 @@ def test_the_confidence_block_says_how_many_pairs_an_effect_needs():
assert confidence([1.0], control_mean=4.0)["sd"] is None
-def test_a_retried_cell_pairs_on_the_attempt_that_reached_a_gate(tmp_path):
- """A provider outage leaves `...flash` and `...flash.attempt1` side by side in one cell;
- pairing the ungraded one would drop a prompt that actually ran."""
- from bench.skill_targets import ab_arms, ab_rows
-
- root = tmp_path / "ab"
- for arm in ("control", "variant"):
- cell = root / "arms" / arm / "cells" / "chair"
- for leaf, rec in (("run_a", {"spec": {"language": "blender"}, "rounds": []}),
- ("run_a.attempt1",
- _record("blender", [{"gate": "connectivity", "findings": CONNECTIVITY}]))):
- (cell / leaf).mkdir(parents=True)
- (cell / leaf / "record.json").write_text(json.dumps(rec))
- rows = {r["skill"]: r for r in ab_rows(ab_arms(root), list(TARGETS), which="last", cache=None)}
- assert rows["c3d-part-contact"]["n"] == 1
-
-
def test_the_shader_preflight_row_reads_the_gate_not_the_raw_driver_json(tmp_path):
"""The raw driver report has errors / warnings and no findings; the row read it and
counted 0 on every run. It reads the round's shader_preflight gate, else the last