Official Codebase of 3DCodeVerse
Python
bench: one stats.decide for every paired report — better/worse only when the t-interval excludes zero, plus ab_plan's regression veto
gaoypengf6de27841bf1
diff --git a/eval/bench/_ab_report.py b/eval/bench/_ab_report.pyindex 20fe3cf0..7598e315 100644--- a/eval/bench/_ab_report.py+++ b/eval/bench/_ab_report.py@@ -7,7 +7,7 @@ fixed judge — that is the whole point of the rig. Anything that breaks the pathe decision instead of leaning it: a missing arm is a missing measurement, not azero (``docs/EVAL.md`` §7).-The verdict rule is deliberately blunt and stated once, in :func:`verdict_of`, so a+The verdict is ``bench.stats.decide`` — the one rule every paired report uses (N84) — so areport can never be argued into "keep" by hand."""@@ -22,25 +22,18 @@ from pydantic import BaseModel, Fieldfrom bench._compare_report import CellResult, arm_statsfrom bench._jsonl import latest-from bench.stats import mean_ci, n_to_resolve, sign_test+from bench.stats import REGRESSION_DELTA, decide, n_to_resolve, sign_testCONTROL = "control"VARIANT = "variant"ARMS = (CONTROL, VARIANT)-#: a paired delta at or below this is a regression on that prompt. Wider than the-#: fixed judge's own sample noise (n_samples 2 on pro, ~±0.02), so one unlucky verdict-#: is not a regression but a real loss on one prompt is.-REGRESSION_DELTA = -0.03-#: mean paired delta needed to call the change a win / a loss (symmetric)+#: the effect a battery should be able to resolve: ``n_for_power`` is the pairs this spread needs+#: before the t-interval fits inside itKEEP_DELTA = 0.02-REVERT_DELTA = -0.02-#: this many regressing prompts is a revert even when the mean looks fine-REVERT_REGRESSIONS = 2-# The rule above is the protocol and no report can argue itself out of it, but alone it is-# dangerously confident: two A/A runs of one prompt printed "keep" (+0.344) and "revert"-# (-0.100) from identical code (docs/EVAL.md §8). So every summary states the paired 95 %-# t-interval and the sign test beside it (bench/stats.py) — reported, never enforced.+# Until 2026-09-24 the verdict was its own threshold rule (keep iff mean >= +0.02 and no regression),+# and two A/A runs of one prompt printed "keep" (+0.344) and "revert" (-0.100) from identical code+# (docs/EVAL.md §8). It is now ``stats.decide``: keep only when the interval excludes zero.class PairOutcome(BaseModel):@@ -79,7 +72,7 @@ class Verdict(BaseModel):if self.n_pairs == 0:return ""if self.se_delta is None:- return ("one pair cannot separate a change from run-to-run noise: two A/A runs of this rig "+ return (f"{self.n_pairs} pair(s) cannot separate a change from run-to-run noise: two A/A runs of this rig ""(identical arms, same prompt) measured +0.344 and -0.100 — 'keep' and 'revert' from ""nothing at all.")if self.separated:@@ -123,31 +116,24 @@ def pair_up(rows: list[CellResult], prompt_order: list[tuple[str, str]] | None =def verdict_of(pairs: list[PairOutcome]) -> Verdict:- """keep iff mean delta >= +0.02 AND no regression; revert iff mean delta <= -0.02- OR >= 2 regressions; otherwise inconclusive. No pairs is inconclusive, never keep."""- deltas = [p.delta for p in pairs if p.paired and p.delta is not None]- regressions = [p.prompt_id for p in pairs if p.regression]+ """``stats.decide`` over the paired deltas: keep = better, revert = worse, else inconclusive.+ No pairs is inconclusive, never keep."""+ deltas = {p.prompt_id: p.delta for p in pairs if p.paired and p.delta is not None}if not deltas:return Verdict(decision="inconclusive", n_pairs=0, mean_delta=None, median_delta=None,reason="no prompt has both arms scored")- mean, median = round(statistics.fmean(deltas), 4), round(statistics.median(deltas), 4)+ d = decide(deltas, veto_regressions=True)+ xs = list(deltas.values())# the SIGN is far cheaper to move than the mean: 7 of 8 one way is p = 0.07, a bar an# eight-prompt battery clears where a ±0.02 mean at a paired sd near 0.23 never will- ci = mean_ci(deltas)- up, down, sign_p = sign_test(deltas)- v = Verdict(decision="inconclusive", n_pairs=len(deltas), mean_delta=mean, median_delta=median,- regressions=regressions, n_up=up, n_down=down, sign_p=sign_p, separated=ci.separated)- if ci.sd is not None: # one pair has no spread to state- v.sd_delta, v.se_delta, v.ci_half = round(ci.sd, 4), round(ci.se, 4), round(ci.half, 4)- v.n_for_power = n_to_resolve(ci.sd, KEEP_DELTA)- if mean <= REVERT_DELTA or len(regressions) >= REVERT_REGRESSIONS:- v.decision, v.reason = "revert", (f"mean delta {mean:+.3f} <= {REVERT_DELTA:+.2f}" if mean <= REVERT_DELTA- else f"{len(regressions)} regressions (>= {REVERT_REGRESSIONS})")- elif mean >= KEEP_DELTA and not regressions:- v.decision, v.reason = "keep", f"mean delta {mean:+.3f} >= {KEEP_DELTA:+.2f} and no regression"- else:- v.reason = (f"mean delta {mean:+.3f} inside ({REVERT_DELTA:+.2f}, {KEEP_DELTA:+.2f})" if not regressions- else f"mean delta {mean:+.3f} but {len(regressions)} regression(s): {', '.join(regressions)}")+ up, down, sign_p = sign_test(xs)+ v = Verdict(decision={"better": "keep", "worse": "revert"}.get(d.outcome, "inconclusive"), n_pairs=len(xs),+ mean_delta=round(statistics.fmean(xs), 4), median_delta=round(statistics.median(xs), 4),+ regressions=[p.prompt_id for p in pairs if p.regression], reason=d.reason,+ n_up=up, n_down=down, sign_p=sign_p, separated=d.ci is not None and d.ci.separated)+ if d.ci is not None and d.ci.sd is not None:+ v.sd_delta, v.se_delta, v.ci_half = round(d.ci.sd, 4), round(d.ci.se, 4), round(d.ci.half, 4)+ v.n_for_power = n_to_resolve(d.ci.sd, KEEP_DELTA)return v@@ -208,8 +194,9 @@ def render_summary(pairs: list[PairOutcome], rows: list[CellResult], *, title: sdropped = sum(a.infra_failed for a in arms)lines += ["", f"n_infra_failed: {dropped}" + (" — re-run with `--redo-status infra_failed` before trusting the verdict"if dropped else ""), "",- "Rule: keep iff mean delta >= +0.02 and no regression; revert iff mean delta <= -0.02 or >= 2 regressions; "- "else inconclusive. A prompt counts only when BOTH arms were scored by the fixed judge.", ""]+ "Rule (bench/stats.decide): keep iff the 95 % t-interval of the mean delta excludes zero above it and no "+ "prompt regressed; revert iff it excludes zero below it; else inconclusive. A prompt counts only when "+ "BOTH arms were scored by the fixed judge.", ""]return "\n".join(lines)@@ -224,7 +211,6 @@ def write_report(out: Path, rows: list[CellResult], prompt_order: list[tuple[strreturn v-__all__ = ["ARMS", "CONTROL", "KEEP_DELTA", "REGRESSION_DELTA", "REVERT_DELTA",- "REVERT_REGRESSIONS", "VARIANT",+__all__ = ["ARMS", "CONTROL", "KEEP_DELTA", "REGRESSION_DELTA", "VARIANT","PairOutcome", "Verdict", "pair_up", "render_summary", "verdict_of","write_report"]diff --git a/eval/bench/ab_view.py b/eval/bench/ab_view.pyindex 5b407e5c..bfa61d20 100644--- a/eval/bench/ab_view.py+++ b/eval/bench/ab_view.py@@ -30,7 +30,7 @@ for _p in (Path(__file__).resolve().parents[2] / "harness", Path(__file__).resolsys.path.insert(0, str(_p)) # this tree's codeverse3d (harness/) + the `bench` package (eval/)from bench._jsonl import latest # noqa: E402-from bench.stats import mean_ci # noqa: E402+from bench.stats import MIN_PAIRS, decide # noqa: E402from codeverse3d.addons import select # noqa: E402from codeverse3d.record.record import load_record # noqa: E402from codeverse3d.workspace import Workspace # noqa: E402@@ -97,15 +97,6 @@ def load_run(run_dir: Path, arm: str) -> Run:return r-#: scored pairs below which this function will not name a winner, whatever the numbers-#: say. A reference harness on the same model tier measured a run-to-run score sd of-#: 0.159 against a re-judge sd of 0.013, giving a minimum detectable effect of 0.081 at-#: n=30 — and it published, then retracted, several prompt findings because a promising-#: first replicate turned out to be noise pointing the right way (interpenetration −0.40-#: in replicate 1, +0.03 in replicate 2, pooled p=0.405).-MIN_PAIRS = 3--def paired_by_brief(a: list[Run], b: list[Run]) -> dict[str, tuple[Run | None, Run | None]]:"""``{brief: (A run, B run)}`` — the pairing the page shows and the verdict reads. Abrief run twice in one arm (a redo) is its LAST run, the rule of every bench journal."""@@ -114,22 +105,24 @@ def paired_by_brief(a: list[Run], b: list[Run]) -> dict[str, tuple[Run | None, Rdef verdict(a: list[Run], b: list[Run]) -> tuple[str, str]:- """(headline, why): B − A per paired brief and the 95 % t-interval of its mean- (``bench/stats.py``) — no winner unless that interval excludes zero."""- deltas = [rb.picked - ra.picked for ra, rb in paired_by_brief(a, b).values()- if ra is not None and rb is not None and ra.picked is not None and rb.picked is not None]- if len(deltas) < MIN_PAIRS:+ """(headline, why): B − A per paired brief, decided by ``bench.stats.decide`` — the one paired+ rule (N84): no winner unless the 95 % t-interval excludes zero over enough pairs."""+ deltas = {k: rb.picked - ra.picked for k, (ra, rb) in paired_by_brief(a, b).items()+ if ra is not None and rb is not None and ra.picked is not None and rb.picked is not None}+ d = decide(deltas)+ if d.too_few:scored_a, scored_b = (sum(x.picked is not None for x in rs) for rs in (a, b))return ("Inconclusive — not enough scored pairs",f"{len(deltas)} brief(s) scored in both arms (arm A scored {scored_a} of {len(a)} runs, arm B "f"{scored_b} of {len(b)}); this needs at least {MIN_PAIRS} before a winner is named. A run that ""died before it scored is not an observation about the arm — it is a missing one.")- ci = mean_ci(deltas)- if not ci.separated:+ ci = d.ci+ assert ci is not None and ci.half is not None+ if d.outcome == "inconclusive":return (f"Inconclusive — Δ {ci.mean:+.3f} ± {ci.half:.3f} includes zero",f"B − A over {ci.n} paired briefs: the 95 % t-interval of the mean includes zero — the pairs ""disagree with each other by more than the mean moved, so this is not evidence.")- return (f"B {'wins' if ci.mean > 0 else 'loses'} by {ci.mean:+.3f} ± {ci.half:.3f}",+ return (f"B {'wins' if d.outcome == 'better' else 'loses'} by {ci.mean:+.3f} ± {ci.half:.3f}",f"B − A over {ci.n} paired briefs, 95 % t-interval. Worth a confirming replicate before it is believed.")diff --git a/eval/bench/paired_compare.py b/eval/bench/paired_compare.pyindex 568ab1d6..9ffcf47f 100644--- a/eval/bench/paired_compare.py+++ b/eval/bench/paired_compare.py@@ -3,8 +3,9 @@``bench/_compare_report.py`` tabulates arms; this answers the paper's question — *is theharness lift separated from noise?* — the way the retired compare report framed it: everycomparison carries its paired standard error, a 95 % confidence interval and the exact-two-sided sign test, and a comparison whose interval crosses zero is labelled-``unsupported`` however good the mean looks.+two-sided sign test, and the verdict is ``bench.stats.decide`` — the one paired rule every+report uses (N84): ``better`` / ``worse`` only when the interval excludes zero, else+``inconclusive`` however good the mean looks.python bench/paired_compare.py bench/out/compare_v4 # writes paired.md + paired.json@@ -36,7 +37,7 @@ for _p in (REPO, Path(__file__).resolve().parents[1]): # its codeverse3d +from bench._ab_report import _fmt as _f # noqa: E402from bench._compare_report import CellResult # noqa: E402from bench._jsonl import latest, read_jsonl # noqa: E402-from bench.stats import mean_ci, sign_test # noqa: E402+from bench.stats import MIN_PAIRS, decide, mean_ci, sign_test # noqa: E402class PairedStats(BaseModel):@@ -65,7 +66,7 @@ class PairedStats(BaseModel):pass_rate_oneshot: float | None = Nonebuild_ok_harness: float | None = Nonebuild_ok_oneshot: float | None = None- verdict: str = Field(default="", description="supported | unsupported | too few pairs")+ verdict: str = Field(default="", description="harness better | worse | inconclusive (stats.decide) | too few pairs")deltas: dict[str, float] = Field(default_factory=dict, description="prompt id → harness − one-shot")@@ -131,12 +132,11 @@ def paired(cells: dict[tuple[str, str], CellResult], harness_arm: str, oneshot_ast.pass_rate_oneshot = round(sum(op) / len(op), 4) if op else Nonest.build_ok_harness = round(sum(hb) / st.n, 4)st.build_ok_oneshot = round(sum(ob) / st.n, 4)- if ci.half is None:- st.verdict = "too few pairs"- return st- st.sd_delta, st.se_delta = round(ci.sd, 4), round(ci.se, 4)- st.ci95_low, st.ci95_high = round(st.mean_delta - ci.half, 4), round(st.mean_delta + ci.half, 4)- st.verdict = "supported" if ci.separated else "unsupported"+ d = decide(st.deltas)+ st.verdict = "too few pairs" if d.too_few else d.outcome+ if ci.half is not None:+ st.sd_delta, st.se_delta = round(ci.sd, 4), round(ci.se, 4)+ st.ci95_low, st.ci95_high = round(st.mean_delta - ci.half, 4), round(st.mean_delta + ci.half, 4)return st@@ -206,7 +206,8 @@ def render_markdown(stats: list[PairedStats], title: str, gates: list[ArmGateStalines = [f"# paired harness − one-shot — {title}", "","Mean Δ with its paired 95 % t-interval and the exact two-sided sign test over prompts scored on BOTH arms; ""`infra` = pairs dropped to a provider outage, `unscored` = pairs dropped to a cell with no score for any other reason. "- "A comparison is **supported** only when the interval excludes zero.", "",+ "The verdict (`bench/stats.decide`) is **better** / **worse** only when the interval excludes zero over at least "+ f"{MIN_PAIRS} pairs.", "","`degraded` = pairs whose harness cell is storm-degraded (kept in every row except `all −degraded`, where they are excluded).", "","| harness arm | one-shot arm | tier | n | infra | unscored | degraded | harness | one-shot | Δ | 95 % CI | W/L/T | sign p | pass h/o | build h/o | verdict |","|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|"]@@ -230,7 +231,7 @@ def rows_from_bench_run(out_dir: Path, arm: str) -> list[CellResult]:``compare_backends`` writes one journal with an ``arm`` column; ``bench run`` writes adirectory per arm with ``id`` / ``score_picked`` (``score_final`` before 2026-09-22). Two of those directories are a pairedcomparison — same prompts, one thing different — and this lets the statistics below- (paired CI, exact sign test, the "unsupported when the interval crosses zero" rule) be+ (paired CI, exact sign test, the one ``stats.decide`` rule) bethe same for both shapes rather than recomputed by hand."""rows: list[CellResult] = []diff --git a/eval/bench/stats.py b/eval/bench/stats.pyindex 84444b32..e7c9393f 100644--- a/eval/bench/stats.py+++ b/eval/bench/stats.py@@ -11,8 +11,9 @@ from __future__ import annotationsimport mathimport statistics-from collections.abc import Sequence+from collections.abc import Mapping, Sequencefrom dataclasses import dataclass+from typing import Literal# two-sided 97.5 % Student-t quantiles by degrees of freedom (df 1..30, then 40/60/120, ∞);# a table, not scipy: the [urdf] extra is optional and this must run on a [dev] install@@ -60,6 +61,52 @@ def mean_ci(xs: Sequence[float]) -> MeanCI:return MeanCI(n=len(xs), mean=mean, sd=sd, se=se, half=t975(len(xs) - 1) * se)+#: paired deltas below which no report names a winner, whatever the numbers say. A reference+#: harness on the same model tier measured a run-to-run score sd of 0.159 against a re-judge sd of+#: 0.013 and published, then retracted, several findings because a promising first replicate was+#: noise pointing the right way (interpenetration -0.40 in replicate 1, +0.03 in replicate 2).+MIN_PAIRS = 3+#: a paired delta at or below this is a regression on that prompt. Wider than the fixed judge's own+#: sample noise (n_samples 2 on pro, ~±0.02), so one unlucky verdict is not a regression but a real+#: loss on one prompt is.+REGRESSION_DELTA = -0.03+++@dataclass(frozen=True)+class Decision:+ """One paired comparison, decided: ``better`` / ``worse`` (B − A) or ``inconclusive``."""++ outcome: Literal["better", "worse", "inconclusive"]+ reason: str+ ci: MeanCI | None+ regressions: tuple[str, ...] = ()++ @property+ def too_few(self) -> bool:+ return self.ci is None+++def decide(deltas: Mapping[str, float], *, veto_regressions: bool = False) -> Decision:+ """THE rule for "is B better than A?" over paired deltas (``key`` → B − A), used by the A/B+ summary (``_ab_report``), the harness-vs-one-shot table (``paired_compare``) and the blind A/B+ page (``ab_view``) — N84: on ``[0.25, 0.01, 0.00, 0.02]`` the three said keep / unsupported /+ inconclusive. Better or worse only when the 95 % t-interval excludes zero over at least+ :data:`MIN_PAIRS` pairs. ``veto_regressions`` is the A/B rig's extra condition on a switch it+ would keep: a better mean never outvotes a prompt at or below :data:`REGRESSION_DELTA`."""+ if len(deltas) < MIN_PAIRS:+ return Decision("inconclusive", f"{len(deltas)} paired prompt(s) — at least {MIN_PAIRS} are needed", None)+ ci = mean_ci(list(deltas.values()))+ regs = tuple(k for k, d in deltas.items() if d <= REGRESSION_DELTA)+ band = f"mean delta {ci.mean:+.3f} ± {ci.half:.3f} (95 % t-interval, n={ci.n})"+ if not ci.separated:+ return Decision("inconclusive", f"{band} includes zero", ci, regs)+ if ci.mean < 0:+ return Decision("worse", f"{band} excludes zero", ci, regs)+ if veto_regressions and regs:+ return Decision("inconclusive", f"{band} excludes zero, but {len(regs)} regression(s): {', '.join(regs)}", ci, regs)+ return Decision("better", f"{band} excludes zero and no prompt regressed", ci, regs)++def n_to_resolve(sd: float, width: float) -> int:"""How many pairs a spread of ``sd`` needs before the t-interval's half-width fitsinside ``width`` — the honest answer to "would one more prompt settle this?"."""diff --git a/eval/docs/EVAL.md b/eval/docs/EVAL.mdindex 2b9db692..c250cfa9 100644--- a/eval/docs/EVAL.md+++ b/eval/docs/EVAL.md@@ -355,12 +355,18 @@ Rules that follow from it:`bench/ab_plan.py` runs one switch as control-vs-variant, paired per prompt, both armslaunched together so the weather matches, both scored by the same fixed judge. The-verdict rule is blunt on purpose (`bench/_ab_report.verdict_of`, stated once):--> keep iff mean paired delta ≥ +0.02 **and** no prompt at ≤ −0.03; revert iff mean ≤ −0.02-> **or** ≥ 2 such prompts; else inconclusive. A prompt counts only when BOTH arms scored.--**That rule is a screen, not a proof, and the numbers say by how much.** Measured+verdict is `bench/stats.decide`, the one paired rule of every report (owner, 2026-09-24, N84):++> keep iff the 95 % t-interval of the mean paired delta excludes zero above it, over at least 3+> pairs, **and** no prompt is at ≤ −0.03 (the A/B rig's regression veto); revert iff it excludes+> zero below it; else inconclusive. A prompt counts only when BOTH arms scored.+> `paired_compare` says better / worse / inconclusive and `ab_view` B wins / loses / Inconclusive+> by the same rule (without the veto).++Until 2026-09-24 the A/B rule was a threshold — keep iff mean ≥ +0.02 and no regression; revert+iff mean ≤ −0.02 or ≥ 2 regressions — and on `[0.25, 0.01, 0.00, 0.02]` it said keep where+`paired_compare` said unsupported and `ab_view` inconclusive. Summaries written before then carry+the old word. **That threshold rule was a screen, not a proof, and the numbers say by how much.** Measured2026-08-24 with two A/A runs — arms identical by construction — on the *same* prompt`ctrl_med_dining_chair` at rounds 1, `gemini-cli:gemini-3.6-flash`, fixed judge`gemini-3.1-pro-preview` n=2:diff --git a/eval/tests/test_ab_plan.py b/eval/tests/test_ab_plan.pyindex 8192434d..0c87fb11 100644--- a/eval/tests/test_ab_plan.py+++ b/eval/tests/test_ab_plan.py@@ -59,10 +59,10 @@ def _pairs(*deltas: float) -> list[PairOutcome]:# ----------------------------------------------------------------------------- verdict rule@pytest.mark.parametrize("deltas, decision, regressions", [((0.03, 0.02, 0.01, 0.04), "keep", []),- ((0.10, 0.10, 0.10, -0.03), "inconclusive", ["p3"]), # one regression blocks a keep- ((0.01, 0.02, 0.02, 0.01), "inconclusive", []), # a mean just under the bar+ ((0.08, 0.08, 0.09, -0.03), "inconclusive", ["p3"]), # one regression vetoes a keep+ ((0.08, 0.08, 0.09, 0.08), "keep", []), # ... the same gain without it is kept((-0.02, -0.02, -0.02), "revert", []),- ((0.20, 0.20, -0.03, -0.05), "revert", ["p2", "p3"]), # mean +0.08 but two prompts lost+ ((0.20, 0.20, -0.03, -0.05), "inconclusive", ["p2", "p3"]), # mean +0.08, the interval includes zero((-0.019, 0.0), "inconclusive", []),])def test_the_verdict_rule(deltas, decision, regressions):@@ -99,15 +99,15 @@ def test_a_verdict_carries_its_noise_beside_the_word():v = verdict_of(_pairs(0.10, 0.11, 0.09, 0.12))assert v.decision == "keep" and v.separated and v.caution == ""v = verdict_of(_pairs(0.344))- assert v.decision == "keep", "the blunt rule still fires — that is exactly the danger"- assert v.sd_delta is None and not v.separated and "one pair cannot separate" in v.caution+ assert v.decision == "inconclusive", "the old threshold rule said keep — exactly the danger"+ assert v.sd_delta is None and not v.separated and "1 pair(s) cannot separate" in v.cautiondef 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+ assert "keep iff the 95 % t-interval" in md and "(none)" in md# an A/A run is labelled so nobody reads it as a decisionmd = 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@@ -207,13 +207,13 @@ def test_a_relative_battery_path_reaches_the_workers_absolute(tmp_path: Path, modef test_driver_runs_pairs_in_prompt_order_and_writes_the_verdict(tmp_path: Path):b = Battery.load(BATTERY)ids = [p.id for p in b.prompts[:3]]- fake = FakeCells({(ids[0], VARIANT): 0.55, (ids[1], VARIANT): 0.53, (ids[2], VARIANT): 0.52})+ fake = FakeCells({(ids[0], VARIANT): 0.54, (ids[1], VARIANT): 0.53, (ids[2], VARIANT): 0.53})opts = AbOptions(variant_env={"C3D_PLAN_BRIEF": "on"}, ids=ids)v = run_ab(BATTERY, tmp_path, opts, run_cell_fn=fake)# both arms of prompt N before anything of prompt N+1assert [c[0] for c in fake.calls] == [i for i in ids for _ in range(2)]assert {c[1] for c in fake.calls} == {CONTROL, VARIANT}- assert v.decision == "keep" and v.n_pairs == 3 and v.mean_delta == pytest.approx(0.0333, abs=1e-3)+ assert v.decision == "keep" and v.n_pairs == 3 and v.mean_delta == pytest.approx(0.0333, abs=1e-3), vrows = _journal(tmp_path)assert len(rows) == 6# the env reached only the variant cells@@ -291,7 +291,7 @@ def test_cli_report_only_rebuilds_from_results(tmp_path: Path, capsys):opts = AbOptions(variant_env={"C3D_SKILLS": "0"}, rounds=1) # skills are on by default: the variant turns them off(tmp_path / "ab.json").write_text(json.dumps({"options": json.loads(opts.model_dump_json())}))assert main(["--prompts", str(BATTERY), "--out", str(tmp_path), "--report-only"]) == 0- assert "verdict: revert" in capsys.readouterr().out+ assert "verdict: inconclusive" in capsys.readouterr().out # one pair decides nothingassert (tmp_path / "pairs.json").is_file()summary = (tmp_path / "summary.md").read_text()assert "variant env: `C3D_SKILLS=0`" in summary and "n_infra_failed: 0" in summarydiff --git a/eval/tests/test_paired_compare.py b/eval/tests/test_paired_compare.pyindex 05dfefa1..8fe4f207 100644--- a/eval/tests/test_paired_compare.py+++ b/eval/tests/test_paired_compare.py@@ -41,17 +41,17 @@ def test_paired_stats_ci_sign_test_and_drops():assert st.mean_delta == round((0.22 + 0.2 + 0.3 + 0.05 - 0.05 + 0.35) / 6, 4)assert st.ci95_low is not None and st.ci95_high is not None and st.ci95_low < st.mean_delta < st.ci95_highassert st.ci95_high - st.mean_delta == round(t975(5) * st.se_delta, 4) or abs((st.ci95_high - st.mean_delta) - t975(5) * st.se_delta) < 1e-3- assert st.verdict == "supported" and st.pass_rate_harness == round(4 / 6, 4) and st.pass_rate_oneshot == 0.0+ assert st.verdict == "better" and st.pass_rate_harness == round(4 / 6, 4) and st.pass_rate_oneshot == 0.0-def test_interval_crossing_zero_is_unsupported_and_tiers_split():+def test_interval_crossing_zero_is_inconclusive_and_tiers_split():rows = []for i, (h, o, t) in enumerate([(0.8, 0.7, "easy"), (0.6, 0.7, "easy"), (0.9, 0.5, "hard"), (0.5, 0.8, "hard")]):rows += [_cell(f"p{i}", HA, h, tier=t), _cell(f"p{i}", OA, o, tier=t)]stats = analyse(rows)by = {(s.tier): s for s in stats}assert set(by) == {"all", "easy", "hard"}- assert by["all"].n == 4 and by["all"].verdict == "unsupported" and by["all"].ci95_low < 0 < by["all"].ci95_high+ assert by["all"].n == 4 and by["all"].verdict == "inconclusive" and by["all"].ci95_low < 0 < by["all"].ci95_highassert by["easy"].n == 2 and by["hard"].n == 2 and by["hard"].wins == 1 and by["hard"].losses == 1diff --git a/eval/tests/test_stats.py b/eval/tests/test_stats.pyindex e49a1fea..d3841d30 100644--- a/eval/tests/test_stats.py+++ b/eval/tests/test_stats.py@@ -39,3 +39,32 @@ def test_correlation_needs_three_points_and_a_spread():assert correlation([1, 2, 3], [2, 4, 6.5]) == pytest.approx(4.5 / math.sqrt(2 * 61 / 6))assert correlation([1, 2, 3], [3, 1, 2], ranked=True) == pytest.approx(-0.5)assert correlation([1, 2], [1, 2]) is None and correlation([1, 1, 1], [1, 2, 3]) is None++[email protected]("deltas, outcome", [+ ((0.25, 0.01, 0.00, 0.02), "inconclusive"), # N84: keep / unsupported / inconclusive before+ ((0.10, 0.11, 0.09, 0.12), "better"),+ ((-0.10, -0.12, -0.09), "worse"),+ ((0.30, 0.30), "inconclusive"), # below MIN_PAIRS: no winner, however consistent+])+def test_every_paired_report_decides_by_one_rule(deltas, outcome):+ """The A/B summary, the harness-vs-one-shot table and the blind A/B page reach one decision."""+ from bench._ab_report import PairOutcome, verdict_of+ from bench._compare_report import CellResult+ from bench.ab_view import Run+ from bench.ab_view import verdict as ab_view_verdict+ from bench.paired_compare import paired+ from bench.stats import decide++ assert decide({f"p{i}": d for i, d in enumerate(deltas)}).outcome == outcome+ ab = verdict_of([PairOutcome(prompt_id=f"p{i}", paired=True, delta=d) for i, d in enumerate(deltas)])+ assert ab.decision == {"better": "keep", "worse": "revert"}.get(outcome, "inconclusive")+ cells = {}+ for i, d in enumerate(deltas):+ for arm, score in (("harness:h", 0.5 + d), ("oneshot:o", 0.5)):+ cells[(f"p{i}", arm)] = CellResult(prompt_id=f"p{i}", arm=arm, kind=arm.split(":")[0], score=score, status="scored")+ assert paired(cells, "harness:h", "oneshot:o").verdict == (outcome if len(deltas) >= 3 else "too few pairs")+ a = [Run(slug=f"a{i}", arm="a", brief=f"b{i}", picked=0.5) for i in range(len(deltas))]+ b = [Run(slug=f"b{i}", arm="b", brief=f"b{i}", picked=0.5 + d) for i, d in enumerate(deltas)]+ head, _ = ab_view_verdict(a, b)+ assert head.startswith({"better": "B wins", "worse": "B loses"}.get(outcome, "Inconclusive")), head