"""Recompute every number in the time-to-green results section from the two published CSVs. What it does: reads the 60-row results file (the task file's fourteen columns, one row per attempt) and the per-attempt token ledger, checks that the two agree run by run, and prints the tables the article shows: per-model time-to-green, the token totals, the list-price estimate, permission refusals, the caps that were never reached, and the three times for every task and model. Inputs (download both next to this script, or pass the paths): time-to-green-results-2026-10-30.csv 60 rows, columns as in time-to-green-ten-small-tasks-method.csv time-to-green-token-ledger-2026-10-30.csv 60 rows, token counts and Claude Code's cost estimate per attempt Run: python time-to-green-results.py [results.csv] [ledger.csv] Standard library only (Python 3.8+). Quartiles are statistics.quantiles(n=4, method="inclusive"). """ from __future__ import annotations import csv import statistics as st import sys RESULTS = sys.argv[1] if len(sys.argv) > 1 else "time-to-green-results-2026-10-30.csv" LEDGER = sys.argv[2] if len(sys.argv) > 2 else "time-to-green-token-ledger-2026-10-30.csv" TOKEN_KINDS = ("input_tokens", "cache_creation_input_tokens", "cache_read_input_tokens", "output_tokens") def quartiles(xs): q1, q2, q3 = st.quantiles(sorted(xs), n=4, method="inclusive") return q2, q1, q3 def notes_field(notes: str, key: str) -> str: for part in notes.split("; "): if part.startswith(key + "="): return part[len(key) + 1:] raise KeyError(key) def main() -> None: res = list(csv.DictReader(open(RESULTS, newline="", encoding="utf-8"))) led = {r["run_id"]: r for r in csv.DictReader(open(LEDGER, newline="", encoding="utf-8"))} assert len(res) == len(led) == 60, (len(res), len(led)) runs = [] for r in res: lg = led[notes_field(r["notes"], "run")] # the two files must tell the same story for every attempt assert lg["task"] == r["task_id"] and lg["model_id"] == r["model"], lg["run_id"] assert float(lg["wall_s"]) == float(r["seconds_to_green"] or lg["wall_s"]), lg["run_id"] assert int(lg["num_turns"]) == int(r["turns"]) and int(lg["tool_calls"]) == int(r["tool_calls"]), lg["run_id"] assert lg["outcome"] == r["outcome"] and abs(float(lg["total_cost_usd"]) - float(r["cost_usd"])) < 1e-9 assert sum(int(lg[k]) for k in TOKEN_KINDS) == int(lg["total_tokens"]), lg["run_id"] runs.append({"task": r["task_id"], "model": r["model"], "rep": int(lg["rep"]), "start": lg["start_utc"], "end": lg["end_utc"], "outcome": r["outcome"], "green": r["outcome"] == "green", "secs": float(lg["wall_s"]), "turns": int(lg["num_turns"]), "calls": int(lg["tool_calls"]), "tokens": int(lg["total_tokens"]), "cost": float(lg["total_cost_usd"]), "denials": int(lg["permission_denials"]), "tampered": lg["tampered"] != "no", "basis": lg["cost_basis"], "version": r["harness_version"], **{k: int(lg[k]) for k in TOKEN_KINDS}, "thinking": int(lg["thinking_tokens"])}) models = sorted({r["model"] for r in runs}) tasks = sorted({r["task"] for r in runs}) print(f"attempts: {len(runs)} ({len(tasks)} tasks x {len(runs) // len(tasks) // len(models)} repeats x " f"{len(models)} models); Claude Code {', '.join(sorted({r['version'] for r in runs}))}") print(f"window: {min(r['start'] for r in runs)} to {max(r['end'] for r in runs)}; " f"agent time {sum(r['secs'] for r in runs):,.0f} s") outcomes = {o: sum(r["outcome"] == o for r in runs) for o in sorted({r["outcome"] for r in runs})} print(f"outcomes: {outcomes}; tasks/ changed in {sum(r['tampered'] for r in runs)} attempts; " f"cost basis {sorted({r['basis'] for r in runs})}") print("\nmodel | attempts | green | time-to-green median (IQR) s | fastest-slowest s | median turns | " "median tool calls | median tokens | median est. $ | est. $ per green") for m in models + ["all"]: rs = [r for r in runs if m in ("all", r["model"])] g = [r for r in rs if r["green"]] med, q1, q3 = quartiles([r["secs"] for r in g]) print(f"{m} | {len(rs)} | {len(g)} | {med:.1f} ({q1:.1f}-{q3:.1f}) | {min(r['secs'] for r in g):.1f}-" f"{max(r['secs'] for r in g):.1f} | {st.median(r['turns'] for r in rs):g} | " f"{st.median(r['calls'] for r in rs):g} | {st.median(r['tokens'] for r in rs):,.0f} | " f"{st.median(r['cost'] for r in rs):.3f} | {sum(r['cost'] for r in rs) / len(g):.3f}") print("\ntokens | uncached input | cache write | cache read | output | total | cache-read share | est. $ (list)") for m in models + ["all"]: rs = [r for r in runs if m in ("all", r["model"])] t = {k: sum(r[k] for r in rs) for k in TOKEN_KINDS} tot = sum(t.values()) print(f"{m} | {t['input_tokens']:,} | {t['cache_creation_input_tokens']:,} | " f"{t['cache_read_input_tokens']:,} | {t['output_tokens']:,} | {tot:,} | " f"{100 * t['cache_read_input_tokens'] / tot:.0f}% | {sum(r['cost'] for r in rs):.2f}") print("\npermission refusals | refusals | attempts with one or more") for m in models + ["all"]: rs = [r for r in runs if m in ("all", r["model"])] print(f"{m} | {sum(r['denials'] for r in rs)} | {sum(r['denials'] > 0 for r in rs)} of {len(rs)}") print(f"\ncaps (30 turns, $2.00, 900 s) | most turns {max(r['turns'] for r in runs)} | " f"highest est. ${max(r['cost'] for r in runs):.3f} | slowest {max(r['secs'] for r in runs):.1f} s") print("\ntask | " + " | ".join(f"{m}: three attempts s (median)" for m in models)) faster = {m: 0 for m in models} for t in tasks: cells, meds = [], {} for m in models: rs = sorted((r for r in runs if r["task"] == t and r["model"] == m), key=lambda r: r["rep"]) meds[m] = st.median(r["secs"] for r in rs) cells.append(", ".join(f"{r['secs']:.0f}" for r in rs) + f" ({meds[m]:.1f})") faster[min(meds, key=meds.get)] += 1 print(f"{t} | " + " | ".join(cells)) print("faster median, tasks won: " + ", ".join(f"{m} {n}" for m, n in faster.items())) if __name__ == "__main__": main()