"""E1/V1: the benchmark and the product do not measure the same tools. Find out exactly where. Measured 2026-11-21: on the SAME 60 held-out questions and the SAME model, the benchmark harness scores 0.767 and the shipped agent 0.483. The benchmark drives `bench_agent.call_tool` (its own SQL helpers); the product drives `dragon_harness`. So the benchmark was never a prediction of the product, and the gap is a tool-semantics gap. This compares the two implementations call-for-call, on the arguments the model actually produces, and names every divergence. That is the licensed basis for aligning them. """ import json, pathlib, sys, time sys.path.insert(0, "/home/marimo/dragon_fsds"); sys.path.insert(0, "/home/marimo/da") import bench_agent as ba from dragon_harness import resolve_filer as hr_resolve, query_financials as hr_query, candidate_tags as hr_cands W = pathlib.Path("/home/marimo/dragon_fsds") QS = json.loads((W/"verdict_v7/questions_families_seed11.json").read_text())["questions"] rows, diverge = [], 0 for q in QS[:20]: name = q["name"] adsh, ddate, qtrs = q["adsh"], q["ddate"], q["qtrs"] rec = {"question": q["question"][:80], "diffs": []} def cmp(label, a, b): global diverge ok = a == b if not ok: diverge += 1 rec["diffs"].append({"call": label, "bench_agent": str(a)[:160], "dragon_harness": str(b)[:160], "same": ok}) # resolve_filer try: A = ba.call_tool("resolve_filer", {"name": name}) except Exception as e: A = f"EXC {type(e).__name__}" try: B = hr_resolve(name=name).to_dicts() except Exception as e: B = f"EXC {type(e).__name__}" cmp("resolve_filer(name)", (A if isinstance(A, str) else len(A)), (B if isinstance(B, str) else len(B))) # candidate_tags try: A2 = ba.call_tool("candidate_tags", {"adsh": adsh, "ddate": str(ddate), "qtrs": qtrs}) except Exception as e: A2 = f"EXC {type(e).__name__}" try: B2 = hr_cands(adsh=adsh, ddate=str(ddate), qtrs=qtrs) B2 = B2.to_dicts() if hasattr(B2, "to_dicts") else B2 except Exception as e: B2 = f"EXC {type(e).__name__}" cmp("candidate_tags", (A2 if isinstance(A2, str) else len(A2)), (B2 if isinstance(B2, str) else len(B2))) rows.append(rec) out = {"n": len(rows), "divergent_comparisons": diverge, "conclusion": ("the two implementations differ" if diverge else "they agree on these arguments - the gap is elsewhere"), "rows": rows, "next": ("align the shipped tools with the arithmetic of the benchmark's helpers at the points " "named in `rows`, then re-measure V1 (j1) - the gate is answer_ok >= 0.70 through the product")} (W/"tool_align.json").write_text(json.dumps(out, indent=1, default=str)) print("TOOL ALIGN", json.dumps({k: v for k, v in out.items() if k != "rows"})[:400]) for r in rows[:6]: for d in r["diffs"]: if not d["same"]: print(" DIFF", d["call"], "| bench:", d["bench_agent"], "| harness:", d["dragon_harness"])