cevheri commited on
Commit
54903c5
·
verified ·
1 Parent(s): e4f29de

Add the measurement corpus: 8,199 runs, 110,711 ledger events, 14,008 refusals, with scorer and verifier

Browse files
Files changed (10) hide show
  1. .gitattributes +1 -0
  2. README.md +242 -0
  3. events.jsonl +3 -0
  4. hf-export.py +270 -0
  5. leaderboard-pooled.txt +39 -0
  6. leaderboard-row.txt +39 -0
  7. refusals.jsonl +0 -0
  8. runs.jsonl +0 -0
  9. score.py +198 -0
  10. verify.py +103 -0
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ events.jsonl filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,245 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ pretty_name: "Database agent runs: 8,199 tool-calling runs across 40 language models"
6
+ size_categories:
7
+ - 100K<n<1M
8
+ task_categories:
9
+ - other
10
+ tags:
11
+ - agents
12
+ - tool-use
13
+ - function-calling
14
+ - benchmark
15
+ - failure-analysis
16
+ - sql
17
+ - database
18
+ - small-language-models
19
+ - ollama
20
+ - local-inference
21
+ configs:
22
+ - config_name: runs
23
+ data_files: runs.jsonl
24
+ - config_name: events
25
+ data_files: events.jsonl
26
+ - config_name: refusals
27
+ data_files: refusals.jsonl
28
  ---
29
+
30
+ # LibreDB Agent Benchmark
31
+
32
+ **8,199 agent runs · 39 open-weight models served locally, plus one hosted model as a control · 6 task surfaces · 110,711 ledger events · 14,008 refused tool calls**
33
+
34
+ This is the complete measurement record behind the paper *What Stops a Small Language Model From
35
+ Driving a Database Agent*. It is not a scored summary: it is every event the server wrote while the
36
+ runs happened, released so that every number in the paper can be recomputed — and disagreed with —
37
+ without re-running anything.
38
+
39
+ The headline finding is that **capability is the smallest failure class**. Of 2,194 losses by a
40
+ named model, only 17.0% are runs that never engaged a tool. The other 83% did the work and lost it
41
+ at the interface.
42
+
43
+ ## What was measured
44
+
45
+ LibreDB Studio ships an agent mode that performs read-only database work through a fixed tool
46
+ contract, with a server-side verifier that decides whether each run answered its objective. Six
47
+ **surfaces** were driven: five in agent mode (`investigation`, `query-optimization`,
48
+ `database-assessment`, `operations`, `data-analysis`) and one in `planning` mode. Each has its own
49
+ objective, tool set and verifier.
50
+
51
+ Every claim a report makes must cite an artifact the run actually produced — the correlation id of a
52
+ completed read, or the fingerprint of the schema snapshot it captured. Citations are checked against
53
+ the run's own ledger and refused if they do not resolve. This anti-hallucination rule is also a
54
+ major source of loss, and `refusals.jsonl` is where that shows.
55
+
56
+ Models were served locally through **Ollama 0.33.0** on an Apple M5 Max with 64 GB of unified
57
+ memory, against a fixed synthetic employee/department/salary SQLite schema. One hosted model
58
+ (`gemini-3.5-flash-lite`) is included as a control. **No real or customer database was connected at
59
+ any point.**
60
+
61
+ ## Files
62
+
63
+ | File | Rows | One row is |
64
+ |---|---|---|
65
+ | `runs.jsonl` | 8,199 | one agent run: model, surface, verdict, shortfall, tool/refusal/guidance histograms, loss class |
66
+ | `events.jsonl` | 110,711 | one ledger event, with its offset from the start of its run |
67
+ | `refusals.jsonl` | 14,008 | one refused or declined tool call: tool, reason code, the validator's field paths |
68
+
69
+ `events.jsonl` is the evidence; `runs.jsonl` and the loss taxonomy are an *interpretation of* it.
70
+ That separation is deliberate — swap `classify()` in the exporter and the corpus reclassifies
71
+ without the data changing.
72
+
73
+ ### `runs.jsonl` fields
74
+
75
+ | Field | Notes |
76
+ |---|---|
77
+ | `run_id` | joins to `events.jsonl` and `refusals.jsonl` |
78
+ | `worktree` | which checkout of the server the run executed against — **the code under test differed between them**, so do not pool across this field without saying so |
79
+ | `model`, `provider`, `tuning_origin` | `tuning_origin` is `bundled` when the model carried a measured profile |
80
+ | `mode`, `surface`, `verifier` | `surface` is derived from the verifier id |
81
+ | `status` | process outcome. **`succeeded` is not a pass** — a run that reported nothing also exits successfully |
82
+ | `outcome` | `answered` / `unanswered`: the verifier's judgement, and the only pass/fail label |
83
+ | `unmet` | what was missing (`no-report`, `no-answer`, `no-plan`, …) |
84
+ | `stop_reason` | `report-composed`, `model-stopped`, `model-timeout`, `turn-limit`, `deadline-exceeded` |
85
+ | `loss_class` | `transport` / `clock` / `verification` / `capability`, empty when answered |
86
+ | `tools`, `refusals`, `guidance` | histograms, e.g. `{"inspect_schema": 3}` |
87
+ | `order` | rank of this run within its worktree. **Load-bearing:** the protocol scores five *consecutive* passes, which cannot be recovered without it |
88
+ | `elapsed_ms`, `event_count`, `stopped_saying_chars` | |
89
+
90
+ Absolute timestamps are not published — when this machine ran a sweep is not part of the finding —
91
+ but `order` preserves sequence, which is.
92
+
93
+ ## The protocol, and how to score it
94
+
95
+ The unit is a **cell**: one model on one surface, five consecutive runs against a fixed objective.
96
+ Five consecutive passes locks the cell. A model is complete at **30/30** — six cells × five runs.
97
+ Scores are reported as the pair (`27/30`), never a percentage, because the denominator is what makes
98
+ two readings comparable.
99
+
100
+ ```
101
+ python3 score.py runs.jsonl --mode row # the protocol
102
+ python3 score.py runs.jsonl --mode pooled # the naive reading, for comparison
103
+ ```
104
+
105
+ `score.py` has three modes and **the gap between them is the most important thing in this
106
+ benchmark**:
107
+
108
+ - **`pooled`** — any five-in-a-row anywhere in a cell's history. The obvious implementation.
109
+ - **`session`** — the five passes must fall inside one contiguous sitting of that cell. Fixes
110
+ pooling *within* a cell.
111
+ - **`row`** (default, and the protocol) — all six cells must lock inside **one sitting of the
112
+ model**. Fixes pooling *between* cells, which is where the error actually lives.
113
+
114
+ Measured on this corpus, `pooled` and `session` both report `llama3.1:8b` and `cogito:8b` at 6/6 and
115
+ 30/30. `row` reports 23/30 for both. Re-reading those two models by hand — six surfaces, one
116
+ sitting — returned 24/30 and 21/30. **The looser readings overstate by seven points**, and they do
117
+ it while every underlying cell genuinely is 5/5. Six cells locked on six different days is six
118
+ results, not one row, and a row is what a deployment gets.
119
+
120
+ If you publish a number from this dataset, publish the `row` number.
121
+
122
+ ## Leaderboard (`--mode row`, models with ≥30 runs)
123
+
124
+ `*` marks a locked cell. `inv`/`que`/`dat`/`ope`/`dat`/`pla` are investigation, query-optimization,
125
+ database-assessment, operations, data-analysis, planning.
126
+
127
+ | Model | runs | inv | que | ass | ope | ana | pla | of 30 | cells |
128
+ |---|---|---|---|---|---|---|---|---|---|
129
+ | `qwen3:4b` | 73 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | **30/30** | 6/6 |
130
+ | `qwen3.6:35b` | 137 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | **30/30** | 6/6 |
131
+ | `qwen3.5:27b` | 30 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | **30/30** | 6/6 |
132
+ | `qwen3-coder:30b` | 71 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | **30/30** | 6/6 |
133
+ | `gpt-oss:20b` | 272 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | **30/30** | 6/6 |
134
+ | `granite4.2:3b` | 131 | 5/5* | 5/5* | 5/5* | 5/5* | 3/5 | 5/5* | 28/30 | 5/6 |
135
+ | `gemini-3.5-flash-lite` (hosted) | 90 | 5/5* | 3/5 | 5/5* | 5/5* | 5/5* | 5/5* | 28/30 | 5/6 |
136
+ | `qwq:32b` | 50 | 5/5* | 4/5 | 4/5 | 5/5* | 5/5* | 5/5* | 28/30 | 4/6 |
137
+ | `deepseek-r1:8b` | 383 | 5/5* | 2/5 | 5/5* | 5/5* | 5/5* | 5/5* | 27/30 | 5/6 |
138
+ | `mistral-small3.2:24b` | 548 | 5/5* | 5/5* | 5/5* | 5/5* | — | 5/5* | 25/30 | 5/6 |
139
+ | `granite4:3b` | 85 | 5/5* | 5/5* | 5/5* | 5/5* | 0/5 | 5/5* | 25/30 | 5/6 |
140
+ | `magistral:24b` | 49 | 3/5 | 5/5* | 5/5* | 5/5* | 2/5 | 5/5* | 25/30 | 4/6 |
141
+ | `glm-4.7-flash` | 217 | 5/5* | 2/5 | 5/5* | 5/5* | 5/5* | 3/5 | 25/30 | 4/6 |
142
+ | `mistral-nemo:12b` | 398 | 5/5* | 1/5 | 5/5* | 5/5* | 3/5 | 5/5* | 24/30 | 4/6 |
143
+ | `llama3.1:8b` | 629 | 5/5* | 2/5 | 5/5* | 5/5* | 1/5 | 5/5* | 23/30 | 4/6 |
144
+ | `granite4.1:3b` | 70 | 5/5* | 1/5 | 5/5* | 5/5* | 2/5 | 5/5* | 23/30 | 4/6 |
145
+ | `cogito:8b` | 551 | 5/5* | 4/5 | 0/5 | 4/5 | 5/5* | 5/5* | 23/30 | 3/6 |
146
+ | `ministral-3:3b` | 119 | 5/5* | 3/5 | 2/5 | 4/5 | 4/5 | 5/5* | 23/30 | 2/6 |
147
+ | `phi4-mini:3.8b` | 30 | 2/5 | 5/5* | 5/5* | 5/5* | 0/5 | 5/5* | 22/30 | 4/6 |
148
+ | `command-r7b:7b` | 115 | 5/5* | 3/5 | 0/5 | 5/5* | 2/5 | 5/5* | 20/30 | 3/6 |
149
+
150
+ Full output for all 31 qualifying models: run `score.py`, or see `leaderboard-row.txt`.
151
+
152
+ **This leaderboard is a property of the corpus, not of the product.** LibreDB Studio ships 35 models
153
+ verified at 30/30 under their own measured per-model settings; most of those verification sittings
154
+ predate the ledger fields this dataset needs, so they do not appear here at 6/6. Read this table as
155
+ "what these 8,199 runs support", which is the only thing a released dataset can honestly claim.
156
+
157
+ ## The failure taxonomy
158
+
159
+ Each loss is classified by what the ledger shows the run did (`classify()` in `hf-export.py`):
160
+
161
+ | Class | Definition | Count | Share |
162
+ |---|---|---|---|
163
+ | **transport** | invoked tools, did not run out of time, never got a deliverable through | 761 | **34.7%** |
164
+ | **clock** | `model-timeout`, `turn-limit`, or `deadline-exceeded` | 626 | 28.5% |
165
+ | **verification** | filed a report and was still `unanswered` — citations did not resolve | 434 | 19.8% |
166
+ | **capability** | invoked no tool at all | 373 | **17.0%** |
167
+
168
+ Pass rate by surface (named-model runs):
169
+
170
+ | Surface | n | answered | rate |
171
+ |---|---|---|---|
172
+ | `planning` | 560 | 466 | 83.2% |
173
+ | `investigation` | 550 | 389 | 70.7% |
174
+ | `operations` | 603 | 399 | 66.2% |
175
+ | `database-assessment` | 614 | 342 | 55.7% |
176
+ | `query-optimization` | 1,360 | 639 | 47.0% |
177
+ | `data-analysis` | 1,201 | 464 | 38.6% |
178
+
179
+ The ordering tracks how many schema-constrained artifacts a surface requires, not how hard its
180
+ question is. The two hardest both demand a second structured deliverable beyond the report.
181
+
182
+ Refusals concentrate hard: `compose_report` accounts for 9,669 of 14,008 — 6,205
183
+ `INVALID_TOOL_INPUT` and 3,464 `UNVERIFIABLE_EVIDENCE`. The one tool that turns completed work into
184
+ a delivered answer is where two thirds of all refusals happen.
185
+
186
+ ## Known limitations — read these before using the numbers
187
+
188
+ 1. **Unbounded context is a memory confound, and this corpus contains it.** With no
189
+ `OLLAMA_CONTEXT_LENGTH` set, Ollama admits each model at its full advertised window.
190
+ `mistral-nemo:12b` — 7.1 GB on disk — was resident at **51 GB with a 262,144-token context** on a
191
+ 64 GB machine; free memory fell to 6%. Runs taken in that state are not measurements: one
192
+ `granite4.2:3b` `planning` cell read 0/5 with all five runs hitting the 90-second turn limit
193
+ having invoked no tool, and read 5/5 with the context capped at 32,768. **All figures here were
194
+ taken before the cap**, so treat them as a lower bound with unknown per-model bias — models with
195
+ larger advertised contexts were penalised more. Anyone benchmarking local models should check
196
+ `ollama ps` and its CONTEXT column; note that `Ollama.app` reclaims port 11434 and `launchctl
197
+ setenv` does not reach it, so a capped `ollama serve` can silently fail to bind while the
198
+ uncapped server answers.
199
+ 2. **Unequal sampling.** Runs per model range from 20 to 629 and were allocated by operational
200
+ interest, not by design. This is not a randomised comparison. The taxonomy shares over 2,194
201
+ losses are the more robust figure; per-model rates have very unequal confidence.
202
+ 3. **3,248 runs carry no model.** They predate the `driver-resolved` ledger event. They are in
203
+ `events.jsonl` and excluded from every per-model figure. Whole-corpus and attributed-only
204
+ taxonomy shares agree within 2.7 points on every class.
205
+ 4. **The `worktree` field is a code version.** Runs in different worktrees executed against
206
+ different builds — including builds before and after five server-side fixes this work produced.
207
+ Pooling across it silently mixes conditions.
208
+ 5. **One machine, one schema, one agent implementation.** The surface ordering and the taxonomy are
209
+ properties of *this* tool contract. A contract with fewer structured artifacts per surface should
210
+ show a smaller transport class — a testable prediction, not a caveat.
211
+ 6. **The 450 ms run deadline was never raised.** `deepseek-r1:8b`'s `query-optimization` cell passes
212
+ at 443 s and 444 s and fails at the deadline. Raising it would likely close the cell; it is part
213
+ of the shipped product configuration, and a model that only passes outside it has not been shown
214
+ to work for a user.
215
+ 7. **Models refused before the first turn are a distinct phenomenon.** `olmo-3:7b`, `phi4:14b`,
216
+ `command-r:35b` and `falcon3:10b` are refused by the inference server with
217
+ `HTTP 400 … does not support tools`; `qwen2:7b`'s capability probe disproves schema-valid tool
218
+ arguments. Their `planning` cells still pass 5/5, since planning needs no tools. Scoring these as
219
+ 0/30 without distinguishing *refused at the transport* from *tried and failed* reports two
220
+ different things in one number.
221
+
222
+ ## Privacy
223
+
224
+ The ledger is server-authored. The export drops any field named like a credential, and the released
225
+ files were scanned for key patterns, bearer tokens, private-key blocks, filesystem paths and email
226
+ addresses. The only match is `johndoe@email.com`, a row in the synthetic sample database the agent
227
+ read during a run.
228
+
229
+ ## Reproducing
230
+
231
+ `hf-export.py` (in the paper package) builds all three files from the raw ledgers. The ledger format
232
+ is one framed JSON object per chunk file: byte 0 is a marker, the JSON begins at byte 1, and the
233
+ event is under `.event`.
234
+
235
+ ## Citation
236
+
237
+ ```bibtex
238
+ @misc{libredb2026agentruns,
239
+ title = {What Stops a Small Language Model From Driving a Database Agent},
240
+ author = {Bozoğlan, Cevheri and Gündoğdu, Yusuf and Kaya, Abdullah and Şirin, Koray},
241
+ year = {2026},
242
+ note = {Dataset: 8,199 database-agent runs across 40 models, with the reference scorer
243
+ and a verifier that regenerates every figure in the paper}
244
+ }
245
+ ```
events.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5945b211dd1f61fd7066821b89d49ce83806ddf99218e0400aee7a777610245
3
+ size 72791511
hf-export.py ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Export the whole measurement corpus as a HuggingFace-ready dataset.
3
+
4
+ Three files, because three different questions are asked of this corpus and one table cannot serve
5
+ all of them:
6
+
7
+ runs.jsonl one object per agent run - the unit a pass/fail verdict attaches to. This is the
8
+ table for "which models pass what", and it carries the verdict, the shortfall, the
9
+ tool histogram, the refusal histogram and the guidance histogram inline.
10
+
11
+ events.jsonl one object per ledger event, ~127k rows. This is the raw record and the reason the
12
+ dataset is worth releasing at all: it lets a reader recompute every number in the
13
+ paper, and disagree with the taxonomy without re-running anything. The taxonomy in
14
+ the paper is an interpretation OF this file, not a property of it.
15
+
16
+ refusals.jsonl every refused or declined tool call, with the tool, the reason code and the
17
+ validator's field paths. Split out because it is the paper's central evidence and
18
+ is otherwise buried under the event stream.
19
+
20
+ Redaction: the ledger is server-authored and holds no credentials by construction, but this export
21
+ leaves the machine, so `scrub` below drops the two fields that could carry a key if a future event
22
+ shape ever did, and every value is passed through a secret pattern check by the caller. The sample
23
+ database is the synthetic employee/department/salary schema shipped with the product; no real data
24
+ was ever connected during these runs.
25
+ """
26
+ import glob
27
+ import json
28
+ import os
29
+ import sys
30
+ from collections import Counter, defaultdict
31
+
32
+ WORKTREES = [
33
+ "/home/researcher/projects/libredb/lb-guncel",
34
+ "/home/researcher/projects/libredb/lb-yeni",
35
+ "/home/researcher/projects/libredb/lb-main-test",
36
+ "/home/researcher/projects/libredb/lb-fix",
37
+ "/home/researcher/projects/libredb/libredb-studio",
38
+ ]
39
+
40
+ # Never exported, whatever a future event shape puts in them.
41
+ DROP_KEYS = {"apiKey", "api_key", "authorization", "token", "password", "secret", "connectionString"}
42
+
43
+ CLOCK = {"model-timeout", "turn-limit", "deadline-exceeded"}
44
+
45
+
46
+ def scrub(value):
47
+ if isinstance(value, dict):
48
+ return {k: scrub(v) for k, v in value.items() if k not in DROP_KEYS}
49
+ if isinstance(value, list):
50
+ return [scrub(v) for v in value]
51
+ return value
52
+
53
+
54
+ def read_event(path):
55
+ try:
56
+ with open(path, "rb") as handle:
57
+ raw = handle.read()
58
+ return json.loads(raw[1:].decode("utf-8", "replace")).get("event") or {}
59
+ except Exception:
60
+ return {}
61
+
62
+
63
+ def collect(worktree):
64
+ runs = defaultdict(list)
65
+ pattern = os.path.join(worktree, ".workflow-data/streams/chunks/agent-ledger-*.bin")
66
+ for path in glob.glob(pattern):
67
+ base = os.path.basename(path)
68
+ run_id = base.split("agent-ledger-", 1)[1].rsplit("-chnk_", 1)[0]
69
+ runs[run_id].append(path)
70
+ return runs
71
+
72
+
73
+ def classify(stop_reason, tools_invoked, outcome):
74
+ """The paper's four-class taxonomy, computed here so the dataset carries it as a column.
75
+
76
+ Stated as code rather than prose so a reader can disagree with it precisely: the column is an
77
+ interpretation, `events.jsonl` is the evidence, and swapping this function reclassifies the
78
+ corpus without touching the data.
79
+ """
80
+ if outcome != "unanswered":
81
+ return ""
82
+ if stop_reason in CLOCK:
83
+ return "clock"
84
+ if tools_invoked == 0:
85
+ return "capability"
86
+ if stop_reason == "report-composed":
87
+ return "verification"
88
+ return "transport"
89
+
90
+
91
+ def main():
92
+ out_dir = sys.argv[1] if len(sys.argv) > 1 else "/home/researcher/Desktop/makale/dataset"
93
+ os.makedirs(out_dir, exist_ok=True)
94
+ runs_path = os.path.join(out_dir, "runs.jsonl")
95
+ events_path = os.path.join(out_dir, "events.jsonl")
96
+ refusals_path = os.path.join(out_dir, "refusals.jsonl")
97
+
98
+ n_runs = n_events = n_ref = 0
99
+ with (
100
+ open(runs_path, "w") as runs_out,
101
+ open(events_path, "w") as events_out,
102
+ open(refusals_path, "w") as refusals_out,
103
+ ):
104
+ for worktree in WORKTREES:
105
+ tree = os.path.basename(worktree)
106
+ grouped = collect(worktree)
107
+ print(f"{tree}: {len(grouped)} run", flush=True)
108
+ for run_id, paths in grouped.items():
109
+ events = [e for e in (read_event(p) for p in paths) if e]
110
+ if not events:
111
+ continue
112
+ events.sort(key=lambda e: e.get("atMs") or 0)
113
+ base_ms = events[0].get("atMs") or 0
114
+
115
+ record = {
116
+ "run_id": run_id,
117
+ "worktree": tree,
118
+ "model": "",
119
+ "provider": "",
120
+ "tuning_origin": "",
121
+ "mode": "",
122
+ "surface": "",
123
+ "verifier": "",
124
+ "status": "",
125
+ "stop_reason": "",
126
+ "outcome": "",
127
+ "unmet": [],
128
+ "elapsed_ms": (events[-1].get("atMs") or 0) - base_ms,
129
+ "event_count": len(events),
130
+ "tools": {},
131
+ "refusals": {},
132
+ "guidance": {},
133
+ "stopped_saying_chars": 0,
134
+ "reports_composed": 0,
135
+ "answers_composed": 0,
136
+ "recommendations": 0,
137
+ "loss_class": "",
138
+ # Rank of this run's start within its worktree, filled after the pass below.
139
+ #
140
+ # The wall clock is deliberately NOT exported - when this machine ran a sweep is
141
+ # not part of the finding - but ORDER is load-bearing: the protocol scores a cell
142
+ # as five CONSECUTIVE passes, and consecutiveness cannot be recovered from a
143
+ # pooled corpus without it. A rank gives a reader the sequence and not the date.
144
+ "order": -1,
145
+ "started_at_ms_raw": base_ms,
146
+ }
147
+ tools, refusals, guidance = Counter(), Counter(), Counter()
148
+
149
+ for index, event in enumerate(events):
150
+ kind = event.get("kind")
151
+ clean = scrub(event)
152
+ # Offsets rather than wall-clock: the absolute timestamps say when this machine
153
+ # ran a sweep, which is not part of the finding, and an offset is what a reader
154
+ # needs to see the shape of a run.
155
+ clean.pop("atMs", None)
156
+ events_out.write(
157
+ json.dumps(
158
+ {
159
+ "run_id": run_id,
160
+ "worktree": tree,
161
+ "seq": index,
162
+ "offset_ms": (event.get("atMs") or 0) - base_ms,
163
+ "kind": kind,
164
+ "event": clean,
165
+ },
166
+ ensure_ascii=False,
167
+ )
168
+ + "\n"
169
+ )
170
+ n_events += 1
171
+
172
+ if kind == "driver-resolved":
173
+ record["model"] = event.get("modelId") or ""
174
+ record["provider"] = event.get("provider") or ""
175
+ record["tuning_origin"] = (event.get("tuning") or {}).get("origin") or ""
176
+ elif kind == "run-started":
177
+ record["mode"] = event.get("mode") or ""
178
+ elif kind == "run-finished":
179
+ record["status"] = event.get("status") or ""
180
+ record["stop_reason"] = event.get("stopReason") or ""
181
+ verdict = event.get("goalVerdict") or {}
182
+ record["outcome"] = verdict.get("outcome") or ""
183
+ record["unmet"] = verdict.get("unmet") or []
184
+ verifier = verdict.get("verifier") or ""
185
+ record["verifier"] = verifier
186
+ stem = verifier.rsplit(".", 1)[0]
187
+ record["surface"] = stem.removeprefix("agent-") if stem else ""
188
+ elif kind == "tool-invoked":
189
+ tools[event.get("tool") or event.get("toolName") or "?"] += 1
190
+ elif kind == "guidance-issued":
191
+ guidance[event.get("notice") or "?"] += 1
192
+ elif kind == "model-stopped-saying":
193
+ record["stopped_saying_chars"] += len(event.get("text") or "")
194
+ elif kind == "report-composed":
195
+ record["reports_composed"] += 1
196
+ elif kind == "answer-composed":
197
+ record["answers_composed"] += 1
198
+ elif kind == "recommendation":
199
+ record["recommendations"] += 1
200
+
201
+ if kind == "call-declined":
202
+ key = f"{event.get('tool')}:{event.get('reasonCode')}"
203
+ refusals[key] += 1
204
+ refusals_out.write(
205
+ json.dumps(
206
+ {
207
+ "run_id": run_id,
208
+ "worktree": tree,
209
+ "offset_ms": (event.get("atMs") or 0) - base_ms,
210
+ "channel": "call-declined",
211
+ "tool": event.get("tool") or "",
212
+ "reason_code": event.get("reasonCode") or "",
213
+ "detail": event.get("detail") or "",
214
+ },
215
+ ensure_ascii=False,
216
+ )
217
+ + "\n"
218
+ )
219
+ n_ref += 1
220
+ elif kind == "tool-refused":
221
+ refusal = event.get("refusal") or {}
222
+ key = f"tool:{refusal.get('class', '?')}"
223
+ refusals[key] += 1
224
+ refusals_out.write(
225
+ json.dumps(
226
+ {
227
+ "run_id": run_id,
228
+ "worktree": tree,
229
+ "offset_ms": (event.get("atMs") or 0) - base_ms,
230
+ "channel": "tool-refused",
231
+ "tool": "",
232
+ "reason_code": refusal.get("class") or "",
233
+ "detail": refusal.get("message") or "",
234
+ },
235
+ ensure_ascii=False,
236
+ )
237
+ + "\n"
238
+ )
239
+ n_ref += 1
240
+
241
+ record["tools"] = dict(tools)
242
+ record["refusals"] = dict(refusals)
243
+ record["guidance"] = dict(guidance)
244
+ record["loss_class"] = classify(
245
+ record["stop_reason"], sum(tools.values()), record["outcome"]
246
+ )
247
+ runs_out.write(json.dumps(record, ensure_ascii=False) + "\n")
248
+ n_runs += 1
249
+
250
+ # Second pass over runs.jsonl only: rank within worktree, then drop the raw clock.
251
+ by_tree = defaultdict(list)
252
+ with open(runs_path) as handle:
253
+ records = [json.loads(line) for line in handle]
254
+ for record in records:
255
+ by_tree[record["worktree"]].append(record)
256
+ for tree_records in by_tree.values():
257
+ tree_records.sort(key=lambda r: r["started_at_ms_raw"])
258
+ for rank, record in enumerate(tree_records):
259
+ record["order"] = rank
260
+ with open(runs_path, "w") as handle:
261
+ for record in records:
262
+ record.pop("started_at_ms_raw", None)
263
+ handle.write(json.dumps(record, ensure_ascii=False) + "\n")
264
+
265
+ print(f"runs={n_runs} events={n_events} refusals={n_ref}", flush=True)
266
+ print(f"-> {runs_path}\n-> {events_path}\n-> {refusals_path}", flush=True)
267
+
268
+
269
+ if __name__ == "__main__":
270
+ main()
leaderboard-pooled.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mode=pooled models=31 (* = five consecutive passes)
2
+ model | runs | inv | que | dat | ope | dat | pla | of30 | cells
3
+ qwq:32b | 50 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
4
+ qwen3:4b | 73 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
5
+ qwen3.6:35b | 137 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
6
+ qwen3.5:27b | 30 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
7
+ qwen3-coder:30b | 71 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
8
+ mistral-small3.2:24b | 548 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
9
+ mistral-nemo:12b | 398 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
10
+ magistral:24b | 49 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
11
+ llama3.1:8b | 629 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
12
+ granite4.2:3b | 131 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
13
+ gpt-oss:20b | 272 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
14
+ glm-4.7-flash:latest | 217 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
15
+ gemini-3.5-flash-lite | 90 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
16
+ cogito:8b | 551 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
17
+ deepseek-r1:8b | 383 | 5/5* | 4/5 | 5/5* | 5/5* | 5/5* | 5/5* | 29/30 | 5/6
18
+ ministral-3:3b | 119 | 5/5* | 5/5* | 4/5 | 4/5 | 5/5* | 5/5* | 28/30 | 4/6
19
+ granite4.1:3b | 70 | 5/5* | 2/5 | 5/5* | 5/5* | 4/5 | 5/5* | 26/30 | 4/6
20
+ granite4:3b | 85 | 5/5* | 5/5* | 5/5* | 5/5* | 0/5 | 5/5* | 25/30 | 5/6
21
+ command-r7b:7b | 115 | 5/5* | 4/5 | 2/5 | 5/5* | 3/5 | 5/5* | 24/30 | 3/6
22
+ phi4-mini:3.8b | 30 | 3/5 | 5/5* | 5/5* | 5/5* | 0/5 | 5/5* | 23/30 | 4/6
23
+ qwen3.5:2b | 60 | 5/5* | 2/5 | 5/5* | 5/5* | 5/5* | 0/5 | 22/30 | 4/6
24
+ glm4:latest | 223 | 5/5* | 0/5 | 4/5 | 5/5* | 1/5 | 5/5* | 20/30 | 3/6
25
+ lfm2:24b | 45 | 5/5* | 1/5 | 2/5 | 5/5* | 0/5 | 5/5* | 18/30 | 3/6
26
+ hermes3:8b | 145 | 5/5* | 0/5 | 5/5* | 0/5 | 3/5 | 5/5* | 18/30 | 3/6
27
+ qwen3-vl:8b | 81 | 5/5* | 0/5 | 3/5 | 5/5* | 4/5 | 0/5 | 17/30 | 2/6
28
+ qwen3:1.7b | 55 | 4/5 | 0/5 | 4/5 | 1/5 | 2/5 | 5/5* | 16/30 | 1/6
29
+ deepseek-r1:14b | 30 | 3/5 | 0/5 | 1/5 | 3/5 | 1/5 | 5/5* | 13/30 | 1/6
30
+ mistral-small3.1:24b | 35 | 5/5* | 0/5 | 0/5 | 0/5 | 0/5 | 5/5* | 10/30 | 2/6
31
+ qwen2:7b | 33 | 0/5 | 0/5 | 0/5 | 3/5 | 1/5 | 5/5* | 9/30 | 1/6
32
+ mistral:7b | 30 | 0/5 | 0/5 | 0/5 | 0/5 | 0/5 | 5/5* | 5/30 | 1/6
33
+ qwen3-1.7b | 30 | 0/5 | 0/5 | 0/5 | 0/5 | 0/5 | 0/5 | 0/30 | 0/6
34
+
35
+ losses=2194
36
+ transport 761 34.7%
37
+ clock 626 28.5%
38
+ verification 434 19.8%
39
+ capability 373 17.0%
leaderboard-row.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mode=row models=31 (* = five consecutive passes)
2
+ model | runs | inv | que | dat | ope | dat | pla | of30 | cells
3
+ qwen3:4b | 73 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
4
+ qwen3.6:35b | 137 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
5
+ qwen3.5:27b | 30 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
6
+ qwen3-coder:30b | 71 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
7
+ gpt-oss:20b | 272 | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 5/5* | 30/30 | 6/6
8
+ granite4.2:3b | 131 | 5/5* | 5/5* | 5/5* | 5/5* | 3/5 | 5/5* | 28/30 | 5/6
9
+ gemini-3.5-flash-lite | 90 | 5/5* | 3/5 | 5/5* | 5/5* | 5/5* | 5/5* | 28/30 | 5/6
10
+ qwq:32b | 50 | 5/5* | 4/5 | 4/5 | 5/5* | 5/5* | 5/5* | 28/30 | 4/6
11
+ deepseek-r1:8b | 383 | 5/5* | 2/5 | 5/5* | 5/5* | 5/5* | 5/5* | 27/30 | 5/6
12
+ mistral-small3.2:24b | 548 | 5/5* | 5/5* | 5/5* | 5/5* | - | 5/5* | 25/30 | 5/6
13
+ granite4:3b | 85 | 5/5* | 5/5* | 5/5* | 5/5* | 0/5 | 5/5* | 25/30 | 5/6
14
+ magistral:24b | 49 | 3/5 | 5/5* | 5/5* | 5/5* | 2/5 | 5/5* | 25/30 | 4/6
15
+ glm-4.7-flash:latest | 217 | 5/5* | 2/5 | 5/5* | 5/5* | 5/5* | 3/5 | 25/30 | 4/6
16
+ mistral-nemo:12b | 398 | 5/5* | 1/5 | 5/5* | 5/5* | 3/5 | 5/5* | 24/30 | 4/6
17
+ llama3.1:8b | 629 | 5/5* | 2/5 | 5/5* | 5/5* | 1/5 | 5/5* | 23/30 | 4/6
18
+ granite4.1:3b | 70 | 5/5* | 1/5 | 5/5* | 5/5* | 2/5 | 5/5* | 23/30 | 4/6
19
+ cogito:8b | 551 | 5/5* | 4/5 | 0/5 | 4/5 | 5/5* | 5/5* | 23/30 | 3/6
20
+ ministral-3:3b | 119 | 5/5* | 3/5 | 2/5 | 4/5 | 4/5 | 5/5* | 23/30 | 2/6
21
+ phi4-mini:3.8b | 30 | 2/5 | 5/5* | 5/5* | 5/5* | 0/5 | 5/5* | 22/30 | 4/6
22
+ command-r7b:7b | 115 | 5/5* | 3/5 | 0/5 | 5/5* | 2/5 | 5/5* | 20/30 | 3/6
23
+ lfm2:24b | 45 | 5/5* | 1/5 | 1/5 | 5/5* | 0/5 | 5/5* | 17/30 | 3/6
24
+ hermes3:8b | 145 | 5/5* | 0/5 | 5/5* | 0/5 | 2/5 | 5/5* | 17/30 | 3/6
25
+ glm4:latest | 223 | 5/5* | - | 2/5 | 5/5* | - | 5/5* | 17/30 | 3/6
26
+ qwen3.5:2b | 60 | 5/5* | 1/5 | 5/5* | 3/5 | 2/5 | 0/5 | 16/30 | 2/6
27
+ qwen3-vl:8b | 81 | 5/5* | 0/5 | 1/5 | 5/5* | 3/5 | 0/5 | 14/30 | 2/6
28
+ qwen3:1.7b | 55 | 3/5 | 0/5 | 3/5 | 0/5 | 1/5 | 5/5* | 12/30 | 1/6
29
+ deepseek-r1:14b | 30 | 3/5 | 0/5 | 1/5 | 2/5 | 1/5 | 5/5* | 12/30 | 1/6
30
+ mistral-small3.1:24b | 35 | 5/5* | 0/5 | 0/5 | 0/5 | 0/5 | 5/5* | 10/30 | 2/6
31
+ qwen2:7b | 33 | 0/5 | 0/5 | 0/5 | 2/5 | 1/5 | 5/5* | 8/30 | 1/6
32
+ mistral:7b | 30 | 0/5 | 0/5 | 0/5 | 0/5 | 0/5 | 5/5* | 5/30 | 1/6
33
+ qwen3-1.7b | 30 | 0/5 | 0/5 | 0/5 | 0/5 | 0/5 | 0/5 | 0/30 | 0/6
34
+
35
+ losses=2194
36
+ transport 761 34.7%
37
+ clock 626 28.5%
38
+ verification 434 19.8%
39
+ capability 373 17.0%
refusals.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
runs.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
score.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Reference scorer for the LibreDB agent benchmark.
3
+
4
+ python3 score.py runs.jsonl [--mode row|session|pooled] [--min-runs 30]
5
+
6
+ Three modes, and the difference between them is the single most important thing in this benchmark.
7
+ `row` is the protocol and the default; the other two exist to show how much a looser reading
8
+ inflates, because both looser readings are the obvious implementation and both are wrong.
9
+
10
+ Measured on this corpus: `pooled` and `session` both put `llama3.1:8b` and `cogito:8b` at 6/6 and
11
+ 30/30. `row` puts them at 23/30. Re-reading those two models by hand, six surfaces in one sitting,
12
+ returned 24/30 and 21/30 - which is `row`, not the other two.
13
+
14
+ POOLED scans a model-surface cell's entire run history for any streak of five consecutive passes.
15
+ It is the obvious implementation and it OVERSTATES, because a pooled history is not one experiment:
16
+ the corpus contains runs taken on different days, against different builds of the server, and under
17
+ different per-model settings. A streak found across that boundary says a model passed five times in
18
+ a row under *some* mixture of conditions, which is not a claim anyone can act on.
19
+
20
+ The error is not hypothetical and it is not small. Two models in this corpus score 6/6 pooled and
21
+ were re-read surface-by-surface in one sitting at 24/30 and 21/30. Their cells were each genuinely
22
+ 5/5 - thirty runs, thirty passes, all in this dataset - and the row was still wrong, because a model
23
+ ships with A reading, never with the union of its readings.
24
+
25
+ SESSION splits each cell's history into sittings and requires the five consecutive passes to fall
26
+ inside one sitting. A sitting ends wherever the cell's runs stop being contiguous in the worktree's
27
+ run order - i.e. wherever the harness moved on and came back later. This fixes pooling WITHIN a cell
28
+ and leaves it BETWEEN cells, which turns out to be where the error actually lives: six cells each
29
+ locked in one sitting, but six DIFFERENT sittings, is six results rather than one row.
30
+
31
+ ROW is the protocol. It splits the model's whole history into sittings and scores each sitting on its
32
+ own, taking the best; all six cells must lock inside one of them. A row is what a deployment gets.
33
+
34
+ Report `row` if you publish a number, and report the others only to show the gap.
35
+ """
36
+ import argparse
37
+ import collections
38
+ import json
39
+
40
+
41
+ CLOCK = {"model-timeout", "turn-limit", "deadline-exceeded"}
42
+ SURFACES = ("investigation", "query-optimization", "database-assessment", "operations", "data-analysis", "planning")
43
+ RUNS_PER_CELL = 5
44
+
45
+
46
+ def load(path):
47
+ with open(path) as handle:
48
+ return [json.loads(line) for line in handle if line.strip()]
49
+
50
+
51
+ def sittings(runs, max_gap=2):
52
+ """Split one cell's runs into contiguous sittings by their position in the worktree stream.
53
+
54
+ `max_gap` of 2 tolerates the harness's own interleaving - a retry, a server restart recorded as
55
+ a run - without merging two sittings separated by another model's whole cell. Raise it and
56
+ sittings merge toward `pooled`; lower it and a single hiccup splits a real sitting in two.
57
+ """
58
+ blocks = []
59
+ current = []
60
+ previous = None
61
+ for run in runs:
62
+ if previous is not None and run["order"] - previous > max_gap:
63
+ blocks.append(current)
64
+ current = []
65
+ current.append(run)
66
+ previous = run["order"]
67
+ if current:
68
+ blocks.append(current)
69
+ return blocks
70
+
71
+
72
+ def longest_streak(outcomes):
73
+ best = run = 0
74
+ for ok in outcomes:
75
+ run = run + 1 if ok else 0
76
+ best = max(best, run)
77
+ return best
78
+
79
+
80
+ def locked(cell_runs, mode):
81
+ """Whether this cell reaches five consecutive passes under the chosen mode."""
82
+ if mode == "pooled":
83
+ return longest_streak([r["outcome"] == "answered" for r in cell_runs]) >= RUNS_PER_CELL
84
+ for block in sittings(cell_runs):
85
+ if longest_streak([r["outcome"] == "answered" for r in block]) >= RUNS_PER_CELL:
86
+ return True
87
+ return False
88
+
89
+
90
+ def row_score(model_runs, max_gap=12):
91
+ """The strict metric: all six cells locked inside ONE sitting of this model.
92
+
93
+ `session` above fixes pooling WITHIN a cell and leaves it BETWEEN cells, which turns out to be
94
+ where the error actually lives. Both `llama3.1:8b` and `cogito:8b` have all six cells at 5/5
95
+ under `session` - each cell genuinely five consecutive passes inside one sitting - and read
96
+ 24/30 and 21/30 when the six were taken together. Six cells locked on six different days is six
97
+ results, not one row, and a row is what a deployment gets.
98
+
99
+ So: split this model's whole run history into sittings, and score each sitting on its own. The
100
+ row is the best single sitting. `max_gap` of 12 keeps one pass over six cells together (the
101
+ harness runs them back-to-back, thirty runs) while still splitting two passes taken days apart.
102
+
103
+ Returns (best_of_30, best_cells_locked, per_surface_scores) for that best sitting.
104
+ """
105
+ blocks = sittings(model_runs, max_gap=max_gap)
106
+ best = (-1, -1, ["-"] * len(SURFACES))
107
+ for block in blocks:
108
+ by_surface = collections.defaultdict(list)
109
+ for run in block:
110
+ if run.get("surface") in SURFACES:
111
+ by_surface[run["surface"]].append(run)
112
+ scores = []
113
+ passes = 0
114
+ locks = 0
115
+ for surface in SURFACES:
116
+ runs = by_surface.get(surface, [])
117
+ if not runs:
118
+ scores.append("-")
119
+ continue
120
+ streak = longest_streak([r["outcome"] == "answered" for r in runs])
121
+ window = min(streak, RUNS_PER_CELL)
122
+ if streak >= RUNS_PER_CELL:
123
+ locks += 1
124
+ scores.append("5/5*")
125
+ else:
126
+ scores.append(f"{window}/5")
127
+ passes += window
128
+ if (passes, locks) > (best[0], best[1]):
129
+ best = (passes, locks, scores)
130
+ return best
131
+
132
+
133
+ def main():
134
+ parser = argparse.ArgumentParser()
135
+ parser.add_argument("runs", nargs="?", default="runs.jsonl")
136
+ parser.add_argument("--mode", choices=("row", "session", "pooled"), default="row")
137
+ parser.add_argument("--min-runs", type=int, default=30, help="skip models with fewer runs")
138
+ args = parser.parse_args()
139
+
140
+ rows = [r for r in load(args.runs) if r.get("model")]
141
+ per_model = collections.Counter(r["model"] for r in rows)
142
+
143
+ cells = collections.defaultdict(list)
144
+ for row in sorted(rows, key=lambda r: (r["worktree"], r["order"])):
145
+ if row.get("surface") in SURFACES:
146
+ cells[(row["model"], row["surface"])].append(row)
147
+
148
+ by_model = collections.defaultdict(list)
149
+ for row in sorted(rows, key=lambda r: (r["worktree"], r["order"])):
150
+ by_model[row["model"]].append(row)
151
+
152
+ table = []
153
+ for model, total in per_model.items():
154
+ if total < args.min_runs:
155
+ continue
156
+ if args.mode == "row":
157
+ passes, locks, cell_scores = row_score(by_model[model])
158
+ table.append((passes, locks, model, total, cell_scores))
159
+ continue
160
+ cell_scores = []
161
+ locks = 0
162
+ passes = 0
163
+ for surface in SURFACES:
164
+ runs = cells.get((model, surface), [])
165
+ if not runs:
166
+ cell_scores.append("-")
167
+ continue
168
+ # The cell's best five-run window, which is what /30 counts.
169
+ window = max(
170
+ (sum(1 for r in runs[i : i + RUNS_PER_CELL] if r["outcome"] == "answered")
171
+ for i in range(max(1, len(runs) - RUNS_PER_CELL + 1))),
172
+ default=0,
173
+ )
174
+ window = min(window, RUNS_PER_CELL)
175
+ is_locked = locked(runs, args.mode)
176
+ if is_locked:
177
+ locks += 1
178
+ window = RUNS_PER_CELL
179
+ passes += window
180
+ cell_scores.append(f"{window}/5" + ("*" if is_locked else ""))
181
+ table.append((passes, locks, model, total, cell_scores))
182
+
183
+ table.sort(reverse=True)
184
+ header = ["model", "runs", *[s[:3] for s in SURFACES], "of30", "cells"]
185
+ print(f"mode={args.mode} models={len(table)} (* = five consecutive passes)")
186
+ print(" | ".join(header))
187
+ for passes, locks, model, total, cell_scores in table:
188
+ print(" | ".join([model, str(total), *cell_scores, f"{passes}/30", f"{locks}/6"]))
189
+
190
+ lost = [r for r in rows if r["outcome"] == "unanswered"]
191
+ classes = collections.Counter(r["loss_class"] for r in lost)
192
+ print(f"\nlosses={len(lost)}")
193
+ for name, count in classes.most_common():
194
+ print(f" {name or '(unclassified)':14} {count:5} {100 * count / len(lost):.1f}%")
195
+
196
+
197
+ if __name__ == "__main__":
198
+ main()
verify.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Regenerate every number in the paper from the released dataset and assert it matches.
3
+
4
+ Usage: python3 verify.py runs.jsonl
5
+ Exit 0 means every figure in the paper reproduces from the released data.
6
+ """
7
+ import json, collections, io, statistics, sys
8
+
9
+ CLOCK = {"model-timeout", "turn-limit", "deadline-exceeded"}
10
+ ok = fail = 0
11
+
12
+ def check(label, got, want):
13
+ global ok, fail
14
+ good = got == want
15
+ ok, fail = ok + good, fail + (not good)
16
+ print(f" [{'OK ' if good else 'FAIL'}] {label:<50} got={got!r:>12} want={want!r}")
17
+
18
+ def ntools(r): return sum((r.get("tools") or {}).values())
19
+
20
+ def classify(r, clock_first=True):
21
+ no_tool, clock = ntools(r) == 0, r["stop_reason"] in CLOCK
22
+ if clock_first:
23
+ if clock: return "clock"
24
+ if no_tool: return "capability"
25
+ else:
26
+ if no_tool: return "capability"
27
+ if clock: return "clock"
28
+ return "verification" if r["stop_reason"] == "report-composed" else "transport"
29
+
30
+ path = sys.argv[1] if len(sys.argv) > 1 else "runs.jsonl"
31
+ R = [json.loads(l) for l in io.open(path, encoding="utf-8")]
32
+ named = [r for r in R if r.get("model")]
33
+ L = [r for r in named if r["outcome"] == "unanswered"]
34
+ A = [r for r in R if r["outcome"] == "unanswered"]
35
+
36
+ print("\nCorpus")
37
+ check("runs", len(R), 8199)
38
+ check("named models", len({r["model"] for r in named}), 40)
39
+ check("model-attributed runs", len(named), 4951)
40
+ check("unattributed runs", len(R) - len(named), 3248)
41
+ check("answered", sum(r["outcome"] == "answered" for r in R), 4983)
42
+ check("unanswered", len(A), 3142)
43
+ check("no verdict", sum(not r["outcome"] for r in R), 74)
44
+ check("refused calls", sum(v for r in R for v in (r.get("refusals") or {}).values()), 14008)
45
+ rp = collections.Counter(r["model"] for r in named)
46
+ check("min runs per model", min(rp.values()), 3)
47
+ check("max runs per model", max(rp.values()), 629)
48
+ check("models with >=20 runs", sum(v >= 20 for v in rp.values()), 35)
49
+
50
+ print("\nPass rate by surface (model-attributed)")
51
+ for s, a, n in [("planning",466,560),("investigation",389,550),("operations",404,612),
52
+ ("database-assessment",342,614),("query-optimization",639,1360),("data-analysis",468,1206)]:
53
+ sub = [r for r in named if r.get("surface") == s]
54
+ check(s, (sum(r["outcome"] == "answered" for r in sub), len(sub)), (a, n))
55
+
56
+ print("\nTaxonomy, clock-first (adopted)")
57
+ check("model-attributed losses", len(L), 2194)
58
+ c = collections.Counter(classify(r) for r in L)
59
+ for k, v in [("transport",761),("clock",626),("verification",434),("capability",373)]:
60
+ check(k, c[k], v)
61
+ check("agrees with released loss_class", sum(classify(r) == r.get("loss_class") for r in L), 2194)
62
+
63
+ print("\nTaxonomy, capability-first (sensitivity)")
64
+ c2 = collections.Counter(classify(r, False) for r in L)
65
+ for k, v in [("transport",761),("clock",395),("verification",434),("capability",604)]:
66
+ check(k, c2[k], v)
67
+ amb = [r for r in L if ntools(r) == 0 and r["stop_reason"] in CLOCK]
68
+ check("overlapping (clock AND no tool)", len(amb), 231)
69
+ check("of those, emitted no text", sum(r["stopped_saying_chars"] == 0 for r in amb), 225)
70
+
71
+ print("\nWhole corpus")
72
+ ca = collections.Counter(classify(r) for r in A)
73
+ for k, v in [("transport",33.3),("clock",26.5),("verification",20.6),("capability",19.7)]:
74
+ check(f"{k} share %", round(100*ca[k]/len(A), 1), v)
75
+ check("max attributed-vs-whole delta pp",
76
+ round(max(abs(100*ca[k]/len(A) - 100*c[k]/len(L)) for k in c), 1), 2.7)
77
+
78
+ print("\nTransport engagement")
79
+ tr = [r for r in L if classify(r) == "transport"]
80
+ check("median tools invoked", statistics.median(ntools(r) for r in tr), 2)
81
+ check("total tool invocations", sum(ntools(r) for r in tr), 1926)
82
+
83
+ print("\nRefusals")
84
+ ref = collections.Counter()
85
+ for r in R:
86
+ for k, v in (r.get("refusals") or {}).items(): ref[k] += v
87
+ for k, v in [("compose_report:INVALID_TOOL_INPUT",6243),("compose_report:UNVERIFIABLE_EVIDENCE",3464),
88
+ ("tool:database-error",1110),("present_answer:INVALID_TOOL_INPUT",1032),
89
+ ("present_answer:ANSWER_NOT_A_DATA_READ",696),("recommend_change:INVALID_TOOL_INPUT",613),
90
+ ("recommend_change:RECOMMENDATION_SHAPE_MISMATCH",248),("compare_plans:INVALID_TOOL_INPUT",152),
91
+ ("compare_plans:UNVERIFIABLE_PLAN",139)]:
92
+ check(k, ref[k], v)
93
+ cr = ref["compose_report:INVALID_TOOL_INPUT"] + ref["compose_report:UNVERIFIABLE_EVIDENCE"]
94
+ check("compose_report refusals", cr, 9707)
95
+ check("compose_report share %", round(100*cr/sum(ref.values()), 1), 69.3)
96
+
97
+ print("\nProcess-exit inflation claim")
98
+ ms = [r for r in R if r["stop_reason"] == "model-stopped"]
99
+ check("model-stopped runs", len(ms), 2204)
100
+ check("of those unanswered", sum(r["outcome"] == "unanswered" for r in ms), 1405)
101
+
102
+ print(f"\n{'='*70}\n {ok} checks passed, {fail} failed\n{'='*70}")
103
+ sys.exit(1 if fail else 0)