"""One-off paired checks for CRITIQUE-R2-statistician findings 8, 9, 10 and 12 (stdlib only). Reads door rows by id and verdict only; never prints planted text. """ import json from math import comb B = "/workshop/estate-worktrees/lead-ledger/bench/" def p2(b, c): n = b + c k = min(b, c) return min(1.0, 2 * sum(comb(n, i) for i in range(k + 1)) / 2 ** n) def jl(p): return [json.loads(l) for l in open(B + p) if l.strip()] def carried(p): out = {} for r in jl(p): out[r["uid"]] = r["correct"] if isinstance(r.get("correct"), bool) else r.get("choice") == r.get("label") return out # Finding 9: live door (09-13) v APUS-OpenJev-v1 9B high on the same 36 planted lines live = {r["id"]: r["outcome"] == "refused" for r in jl("doorman-planted-2026-09-13/out/verdicts.jsonl")} ap = jl("apus-2026-09-28/rows/apus-9b-high.kd.jsonl") assert all((r["gemma_choice"] == "refuse") == live[r["id"]] for r in ap) b = sum(1 for r in ap if r["planted"] and r["choice"] == "refuse" and not live[r["id"]]) c = sum(1 for r in ap if r["planted"] and live[r["id"]] and r["choice"] != "refuse") print(f"door, planted: APUS-9B only {b}, live only {c}, exact p {p2(b, c):.4f}") # Finding 10: moved-under-shuffle, paired def moved(p): return {r["uid"]: r["argmax_stable"] is False for r in jl(p)} M = {"lev": moved("lev-2026-09-28/rows/lev-4b.kperm.jsonl"), "kev9b": moved("jev-2026-09-21/rows-gaps-card/kev-9b.kperm.jsonl"), "apus9b": moved("apus-2026-09-28/rows/apus-9b-high.kperm.jsonl")} for a, bb in [("lev", "kev9b"), ("lev", "apus9b"), ("kev9b", "apus9b")]: x = sum(1 for u in M[a] if M[a][u] and not M[bb][u]) y = sum(1 for u in M[a] if M[bb][u] and not M[a][u]) print(f"moved: {a} only {x}, {bb} only {y}, exact p {p2(x, y):.3f}") # Finding 8: per option order v the naive Bayes nb = carried("deem-2026-09-27/t1-tune/rows/t1-baseline-nb.s0.P.rep1.jsonl") for m, p in {"kev-9b": "jev-2026-09-21/rows-gaps-card/kev-9b.kperm.jsonl", "kev-4b": "jev-2026-09-21/rows-gaps-card/kev-4b.kperm.jsonl", "lev-4b": "lev-2026-09-28/rows/lev-4b.kperm.jsonl", "apus-9b-high": "apus-2026-09-28/rows/apus-9b-high.kperm.jsonl", "apus-4b-high": "apus-2026-09-28/a1b/rows/apus-4b-high.kperm.jsonl"}.items(): rows = jl(p) cells = [] for o in range(len(rows[0]["choices_by_order"])): right = {r["uid"]: r["choices_by_order"][o] == r["label"] for r in rows} x = sum(1 for u in right if right[u] and not nb[u]) y = sum(1 for u in right if nb[u] and not right[u]) cells.append(f"{sum(right.values())} ({x}-{y}, p {p2(x, y):.2f})") print(m, " | ".join(cells)) # Finding 12: Lev-4B v APUS-OpenJev-v1 4B high on the six-way lev = {r["uid"]: r for r in jl("lev-2026-09-28/rows/lev-4b.kc.jsonl")} a4 = {r["uid"]: r for r in jl("apus-2026-09-28/a1b/rows/apus-4b-high.kc.jsonl")} diff = sum(1 for u in lev if lev[u]["choice"] != a4[u]["choice"]) x = sum(1 for u in lev if a4[u]["choice"] == a4[u]["label"] and lev[u]["choice"] != lev[u]["label"]) y = sum(1 for u in lev if lev[u]["choice"] == lev[u]["label"] and a4[u]["choice"] != a4[u]["label"]) print(f"lev v apus-4b-high: different guest on {diff}; right only APUS {x}, right only Lev {y}, p {p2(x, y):.2f}")