mozenjii-evalgate 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ # environments and secrets
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ .venv/
6
+ venv/
7
+
8
+ # python
9
+ __pycache__/
10
+ *.py[cod]
11
+ .pytest_cache/
12
+ .coverage
13
+ coverage.xml
14
+ htmlcov/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ *.egg-info/
18
+ dist/
19
+ build/
20
+
21
+ # data and run output
22
+ data/raw/
23
+ data/cache/
24
+ runs/
25
+ *.sqlite
26
+ *.log
27
+
28
+ # editors and OS
29
+ .vscode/
30
+ .idea/
31
+ .DS_Store
32
+ Thumbs.db
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ### 0.1.0 candidate
6
+
7
+ - Versioned JSONL datasets and results files, deterministic scorers, and a CLI for running
8
+ and comparing targets across slices.
9
+ - Paired statistical intervals with explicit tolerance and coverage gaps, correction for
10
+ multiple slices, and published false-pass and false-fail rates.
11
+ - A GitHub Action that compares base and head results and reports the gate verdict.
12
+ - Local Ollama capture with a dry run, a call budget, optional output redaction, and offline
13
+ replay. The public Iris example exercises capture and replay end to end.
14
+ - Isolated distribution builds with release verification and GitHub Actions Trusted Publishing
15
+ support.
16
+ - Local binary rubric scoring and offline replay, judge calibration from independently supplied
17
+ labels, and paired probes and ensemble comparison when the corresponding evidence is present.
18
+ - Reviewed case mining and promotion, with strict protection for deterministic binary cases
19
+ that previously passed, plus a reproducible seeded-regression benchmark and power planner.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mozenjii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,287 @@
1
+ Metadata-Version: 2.5
2
+ Name: mozenjii-evalgate
3
+ Version: 0.1.0
4
+ Summary: A CI check for LLM features: it fails a pull request when quality drops on a slice, and says whether the drop is real or noise.
5
+ Project-URL: Source, https://github.com/mozenjii/evalgate
6
+ Author: Mozenjii
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: ci,evaluation,llm,regression,statistics
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: jsonschema<5,>=4.23
17
+ Requires-Dist: numpy<3,>=2.1
18
+ Requires-Dist: pydantic<3,>=2.9
19
+ Requires-Dist: typer<1,>=0.15
20
+ Description-Content-Type: text/markdown
21
+
22
+ # evalgate
23
+
24
+ A CI check for LLM features. It fails a pull request when quality drops on any slice of your data,
25
+ and tells you whether the drop is real or just noise.
26
+
27
+ ## The problem
28
+
29
+ When you change a prompt, swap a model or tweak a retriever, a handful of spot checks usually look
30
+ fine. Meanwhile some other part of your traffic gets worse and nothing in CI notices, because model
31
+ output isn't deterministic and "the tests pass" doesn't mean much for free text. Teams end up
32
+ shipping on gut feeling and finding the regressions from user complaints.
33
+
34
+ ## Try it
35
+
36
+ The repository ships a 120-item synthetic triage set and a keyword classifier in two versions. The
37
+ second has two warranty cues removed, so it's worse on the warranty slice and identical everywhere
38
+ else. No model is involved, so this runs instantly and identically on any machine.
39
+
40
+ ```bash
41
+ uv sync --all-groups
42
+ config=examples/triage/evalgate.toml
43
+ uv run evalgate run --config $config --label v1 --out v1.jsonl
44
+ uv run evalgate run --config $config --label v2 --out v2.jsonl --target target:classify_v2
45
+ uv run evalgate compare v1.jsonl v2.jsonl --config $config
46
+ ```
47
+
48
+ ```
49
+ evalgate: regression found
50
+ 1 regressed / 2 not guarded / 0 ok
51
+ Comparing `v2` against `v1` on `triage` v1 (120 items).
52
+
53
+ Gate slices:
54
+ slice scorer n difference (95% CI) rules out drops over tolerance verdict
55
+ intent=warranty exact_match 40 -60.0 (-73.7 to -44.6) - 5.0 regressed
56
+ intent=billing exact_match 40 +0.0 (-8.8 to +8.8) 8.8 5.0 not guarded
57
+ intent=refunds exact_match 40 +0.0 (-8.8 to +8.8) 8.8 5.0 not guarded
58
+ ```
59
+
60
+ It finds the regression in the slice that has it. Look at the other two lines though: nothing
61
+ changed in billing or refunds, and it still won't call them a pass. Forty items with no
62
+ disagreements can rule out a drop of 8.8 points, not the 5 the tolerance asks for, and the report
63
+ says exactly that. Most tools would print three green ticks there, and two of them would mean
64
+ nothing. The fix is yours to choose: add items, or widen the tolerance on purpose.
65
+
66
+ That's the whole idea. A slice that can't answer is never reported as a pass. Whether it fails the
67
+ build is a policy you set: by default it warns, and `on_inconclusive = "fail"` makes it block.
68
+
69
+ | Exit code | Meaning |
70
+ |---|---|
71
+ | 0 | Nothing regressed. Slices that are not guarded are reported, and only warn by default. |
72
+ | 1 | A gate slice regressed by more than its tolerance. |
73
+ | 2 | Nothing regressed, but a gate slice is not guarded and the policy is `fail`. |
74
+ | 3 | The check could not run: a bad config, a missing file, a target that won't import. |
75
+
76
+ ## Use it on pull requests
77
+
78
+ Add an `evalgate.toml` and a dataset to your repository (the [example](examples/triage/evalgate.toml)
79
+ shows every part), then:
80
+
81
+ ```yaml
82
+ on: pull_request
83
+
84
+ permissions:
85
+ contents: read
86
+ pull-requests: write
87
+
88
+ jobs:
89
+ evalgate:
90
+ runs-on: ubuntu-latest
91
+ steps:
92
+ - uses: actions/checkout@v5
93
+ - uses: actions/setup-python@v5
94
+ with:
95
+ python-version: "3.12"
96
+ - run: pip install -r requirements.txt # your project's own dependencies
97
+ - uses: mozenjii/evalgate@main
98
+ ```
99
+
100
+ The action runs your target on the pull request's base commit and on its head, each in its own
101
+ checkout, compares them, writes the report to the job summary and keeps one comment on the pull
102
+ request up to date. It installs into your workflow's Python on purpose: your target runs inside
103
+ evalgate, so it needs your dependencies beside it. A pull request from a fork gets a read-only
104
+ token, so it gets the job summary but no comment.
105
+
106
+ The [local Ollama walkthrough](docs/ollama.md) shows how to estimate calls, record a run at
107
+ zero provider cost, and replay it offline in the CLI or Action.
108
+
109
+ ## Bring your own outputs
110
+
111
+ evalgate doesn't have to call your model. If your pipeline already produces outputs, write them as
112
+ a results file, one JSON object per line, and compare two of them:
113
+
114
+ ```json
115
+ {"id": "billing-000", "output": "billing"}
116
+ {"id": "billing-001", "output": "refunds", "latency_ms": 412.5}
117
+ ```
118
+
119
+ Scoring happens at comparison time, against the dataset, so the file only needs ids and outputs.
120
+ Unknown fields are refused rather than ignored, because a mistyped `ouput` would otherwise read as
121
+ an item that produced nothing.
122
+
123
+ ## What's built
124
+
125
+ - **Versioned datasets.** JSONL plus a manifest, with a content hash over the items so an edit that
126
+ nobody meant to make is caught rather than silently changing what a run means. Every item records
127
+ where it came from — hand-written, mined from logs, synthetic, or promoted from a production
128
+ failure — and which slice it's in. Both are required; an item that declares neither is refused
129
+ rather than filed under "unknown".
130
+ - **Deterministic scorers.** Exact match, regex, JSON schema, set F1, edit similarity, or your own
131
+ function. Each declares whether it's binary or continuous, because that picks the statistical test
132
+ and inferring it from the values is silently wrong on a slice where everything passed.
133
+ - **Paired statistics, chosen by measuring them.** Binary scorers get Tango's score interval.
134
+ Continuous ones get a BCa bootstrap over the paired differences, except where fewer than eight
135
+ items moved: there the bootstrap can't see the change, so an exact count bound takes over. Never
136
+ two independent means. Each choice beat the alternatives on measured error at the tolerance;
137
+ the numbers are below.
138
+ - **Two errors, two controls.** A check passes only if every gate slice passes, so a false pass
139
+ needs no correction. It fails if any slice regresses, so false failures grow with the number of
140
+ slices; those are held down with a Holm correction, and the report names any slice it held
141
+ back. Watch slices use Benjamini-Hochberg.
142
+ - **Non-inferiority, not significance.** The gate asks "is this at most δ worse?" and reads the lower
143
+ bound of the interval. A significance test on a forty-item slice passes almost everything, which is
144
+ how a green check comes to mean nothing. δ is per slice and is a person's judgement, recorded next
145
+ to the verdict.
146
+ - **Results files.** One JSON object per item, with output, latency, tokens and cost. Each records a
147
+ hash of the input it answered: in CI the baseline runs from the base commit, so if a pull request
148
+ edits an item's question, the two answers are left out and listed instead of being compared as if
149
+ they answered the same thing. A crash counts as a failure, not a missing item.
150
+ - **Every slice gets an answer.** Gate slices can fail the build; watch slices are reported only.
151
+ A declared slice with no items, or one paired item, is reported as a gap rather than dropped, so
152
+ the report is never quietly shorter than the config.
153
+ - **A config file** holds everything a person decides. Tolerances have no default: how much worse a
154
+ slice may get is a judgement about that slice, and a default would be a number nobody chose.
155
+ - **A CLI and a GitHub Action** that turn all of that into a pull-request comment and an exit code.
156
+ - **Local model capture and replay.** The Ollama runner estimates live calls before it runs,
157
+ enforces a call cap and can redact outputs before persistence. The Action replays saved outputs
158
+ and reports missing recordings.
159
+
160
+ ## Judge, calibration, and benchmarks
161
+
162
+ The implementation includes a [local binary judge](docs/judge.md), a [calibration workflow](docs/calibration.md)
163
+ for independent human labels, [trace review and case promotion](docs/cases.md), and a
164
+ [seeded regression benchmark and power planner](docs/benchmark.md). The judge still needs a
165
+ human-labelled validation study. The benchmark results describe a synthetic paired population.
166
+
167
+ See the [release guide](docs/release.md) for building and verifying distribution candidates.
168
+
169
+ EvalGate's code is [MIT-licensed](LICENSE). The [Iris data](docs/ollama.md) carries its
170
+ source license and attribution.
171
+
172
+ ## How I know the statistics are right
173
+
174
+ A tool that judges other tools needs its own evaluation, and I'd rather show that than assert it.
175
+
176
+ I wrote the mathematics down first, in [docs/statistics.md](docs/statistics.md). Then the
177
+ statistics are checked against scipy and statsmodels by an oracle written from that document alone,
178
+ with no sight of the implementation it judges: 1,229 cases covering Tango's interval against a
179
+ numerical maximum-likelihood reference, the p-values at each tolerance, the count bound,
180
+ Clopper-Pearson, Holm and Benjamini-Hochberg, the jackknife acceleration and the BCa bootstrap. `src/evalgate/stats.py` imports neither scipy nor
181
+ statsmodels — one of the oracle's own tests parses the module to enforce it — because otherwise
182
+ "it agrees with scipy" would be a statement about nothing. That's why the exact binomial tails and
183
+ the Clopper-Pearson inversion are written out here instead of imported.
184
+
185
+ A passing oracle proves nothing on its own, so I check it can fail: shrinking Tango's variance by
186
+ 10% breaks it, and so does moving the bootstrap threshold from eight items to seven.
187
+
188
+ It caught three real defects in my first implementation. The bootstrap drew a fresh random stream
189
+ when no seed was given, so two runs of the same commit could reach different verdicts — on the
190
+ default path, which is the exact failure a CI gate exists to prevent. The bias correction counted
191
+ resample means strictly below the observed mean, which is fine on continuous data and systematically
192
+ wrong once scores take few distinct values. And my own contract contradicted itself about the
193
+ zero-discordance bound.
194
+
195
+ Agreeing with scipy only shows the code computes what I asked for. Whether I asked for the right
196
+ thing is a separate question, so I measured how often each method is wrong at exactly the
197
+ tolerance, where both errors are hardest to avoid. That found two worse problems. The binary
198
+ interval I had shipped treated the disagreement rate as known; when a change breaks items and
199
+ fixes none, it called a slice that was truly 10 points worse "safe" up to 48% of the time, and it
200
+ got worse with more data. And on continuous scores, a slice where nothing happened to move came
201
+ out as a zero-width interval, so it passed every time. Both are replaced, and the measurements
202
+ that caught them are now a committed script.
203
+
204
+ The same discipline applies to the build gates: format, lint, types, documentation links and tests
205
+ behind one command, each one watched failing on purpose, which `tools/verify_gates.py` re-checks so
206
+ it can't rot.
207
+
208
+ ## Results
209
+
210
+ Nothing goes in this table until a committed script in this repo produces it. The full tables are
211
+ in [docs/error-rates.md](docs/error-rates.md), written by `tools/error_rates.py`; CI regenerates
212
+ them and fails if they've drifted from the code.
213
+
214
+ | Measurement | How | Result |
215
+ |---|---|---|
216
+ | False pass at the tolerance, binary slice | Exact, 66 cells, n 10 to 500 | worst 3.1% (nominal 2.5%); the interval it replaced reached 47.8% |
217
+ | False fail at the tolerance, binary slice | Exact, same cells | worst 4.9%, at n = 200 when every disagreement goes one way |
218
+ | False pass at the tolerance, continuous slice | Simulated, 16 settings, n 10 to 100 | worst 3.1% |
219
+ | False fail across 10 gate slices | Simulated | 2.7% with Holm, 21.1% without |
220
+ | Judge agreement with human labels, per rubric | Labelled set, second rater on a subset | not measured |
221
+ | Detection rate on injected regressions, by size | Known regressions in the demo feature | not measured |
222
+ | False alarms on reruns of unchanged code | Repeated reruns | not measured |
223
+ | Cost and time per pull request check | Metered | not measured |
224
+
225
+ ## Design notes
226
+
227
+ **Say when a slice can't be tested.** A slice of 25 items can't detect a five-point drop however you
228
+ test it. Thin slices show up as a coverage gap rather than a green tick, and that's load-bearing
229
+ rather than tasteful: the verdict function sees an interval and never the item count, so if a slice
230
+ with zero disagreements reported a zero-width interval it would pass by arithmetic instead of by
231
+ evidence.
232
+
233
+ **Don't trust the judge until it's calibrated.** Judges drift towards longer answers, first positions
234
+ and their own model family. I'll measure agreement per rubric and run position-swap and length
235
+ probes. Where a cheap judge scores a large set and humans label a small one, prediction-powered
236
+ inference can correct the judge's bias and still give honest intervals.
237
+
238
+ **Record and replay model calls.** Replayed runs make CI cheap and reproducible. Live reruns are what
239
+ measure the noise floor.
240
+
241
+ ## Roadmap
242
+
243
+ - [x] Dataset format, slices and provenance
244
+ - [x] Deterministic scorers
245
+ - [x] Paired comparison, non-inferiority verdicts and the CLI
246
+ - [x] Config file, results files, and a GitHub Action that comments on the pull request
247
+ - [x] The statistics settled by evidence: interval error at the tolerance, a correction across
248
+ slices, published error rates
249
+ - [x] A real model: record-and-replay, redaction, a budget cap, no network in tests
250
+ - [ ] A release: PyPI package and a tagged action
251
+ - [x] Local LLM judge and tools for human calibration
252
+ - [ ] Human-labelled validation study
253
+ - [x] Reviewed failure-to-case promotion and offline log mining
254
+ - [x] Synthetic seeded-regression benchmark and write-up
255
+
256
+ ## Development
257
+
258
+ Requires [uv](https://docs.astral.sh/uv/). The interpreter and every tool version are pinned, so a
259
+ fresh checkout runs the same toolchain I do.
260
+
261
+ ```bash
262
+ uv sync --all-groups
263
+ uv run python tools/check.py
264
+ ```
265
+
266
+ That one command runs every gate: formatting, lint, types, documentation links, and tests against a
267
+ coverage floor. It's exactly what CI runs, so a gate can't exist in one place and be missing from the
268
+ other. Pass a gate name to run one while you work, for example `uv run python tools/check.py types`.
269
+
270
+ A gate that has never failed isn't known to work, so there's a second command that makes each one
271
+ fail on purpose and requires it to notice:
272
+
273
+ ```bash
274
+ uv run python tools/verify_gates.py
275
+ ```
276
+
277
+ Tested on Python 3.11 and 3.12.
278
+
279
+ ## Related projects
280
+
281
+ Part of a set of six projects about building LLM systems you can trust:
282
+ [evalgate](https://github.com/mozenjii/evalgate),
283
+ [policylens](https://github.com/mozenjii/policylens),
284
+ [docproof](https://github.com/mozenjii/docproof),
285
+ [tollgate](https://github.com/mozenjii/tollgate),
286
+ [redline](https://github.com/mozenjii/redline),
287
+ [casefile](https://github.com/mozenjii/casefile).
@@ -0,0 +1,266 @@
1
+ # evalgate
2
+
3
+ A CI check for LLM features. It fails a pull request when quality drops on any slice of your data,
4
+ and tells you whether the drop is real or just noise.
5
+
6
+ ## The problem
7
+
8
+ When you change a prompt, swap a model or tweak a retriever, a handful of spot checks usually look
9
+ fine. Meanwhile some other part of your traffic gets worse and nothing in CI notices, because model
10
+ output isn't deterministic and "the tests pass" doesn't mean much for free text. Teams end up
11
+ shipping on gut feeling and finding the regressions from user complaints.
12
+
13
+ ## Try it
14
+
15
+ The repository ships a 120-item synthetic triage set and a keyword classifier in two versions. The
16
+ second has two warranty cues removed, so it's worse on the warranty slice and identical everywhere
17
+ else. No model is involved, so this runs instantly and identically on any machine.
18
+
19
+ ```bash
20
+ uv sync --all-groups
21
+ config=examples/triage/evalgate.toml
22
+ uv run evalgate run --config $config --label v1 --out v1.jsonl
23
+ uv run evalgate run --config $config --label v2 --out v2.jsonl --target target:classify_v2
24
+ uv run evalgate compare v1.jsonl v2.jsonl --config $config
25
+ ```
26
+
27
+ ```
28
+ evalgate: regression found
29
+ 1 regressed / 2 not guarded / 0 ok
30
+ Comparing `v2` against `v1` on `triage` v1 (120 items).
31
+
32
+ Gate slices:
33
+ slice scorer n difference (95% CI) rules out drops over tolerance verdict
34
+ intent=warranty exact_match 40 -60.0 (-73.7 to -44.6) - 5.0 regressed
35
+ intent=billing exact_match 40 +0.0 (-8.8 to +8.8) 8.8 5.0 not guarded
36
+ intent=refunds exact_match 40 +0.0 (-8.8 to +8.8) 8.8 5.0 not guarded
37
+ ```
38
+
39
+ It finds the regression in the slice that has it. Look at the other two lines though: nothing
40
+ changed in billing or refunds, and it still won't call them a pass. Forty items with no
41
+ disagreements can rule out a drop of 8.8 points, not the 5 the tolerance asks for, and the report
42
+ says exactly that. Most tools would print three green ticks there, and two of them would mean
43
+ nothing. The fix is yours to choose: add items, or widen the tolerance on purpose.
44
+
45
+ That's the whole idea. A slice that can't answer is never reported as a pass. Whether it fails the
46
+ build is a policy you set: by default it warns, and `on_inconclusive = "fail"` makes it block.
47
+
48
+ | Exit code | Meaning |
49
+ |---|---|
50
+ | 0 | Nothing regressed. Slices that are not guarded are reported, and only warn by default. |
51
+ | 1 | A gate slice regressed by more than its tolerance. |
52
+ | 2 | Nothing regressed, but a gate slice is not guarded and the policy is `fail`. |
53
+ | 3 | The check could not run: a bad config, a missing file, a target that won't import. |
54
+
55
+ ## Use it on pull requests
56
+
57
+ Add an `evalgate.toml` and a dataset to your repository (the [example](examples/triage/evalgate.toml)
58
+ shows every part), then:
59
+
60
+ ```yaml
61
+ on: pull_request
62
+
63
+ permissions:
64
+ contents: read
65
+ pull-requests: write
66
+
67
+ jobs:
68
+ evalgate:
69
+ runs-on: ubuntu-latest
70
+ steps:
71
+ - uses: actions/checkout@v5
72
+ - uses: actions/setup-python@v5
73
+ with:
74
+ python-version: "3.12"
75
+ - run: pip install -r requirements.txt # your project's own dependencies
76
+ - uses: mozenjii/evalgate@main
77
+ ```
78
+
79
+ The action runs your target on the pull request's base commit and on its head, each in its own
80
+ checkout, compares them, writes the report to the job summary and keeps one comment on the pull
81
+ request up to date. It installs into your workflow's Python on purpose: your target runs inside
82
+ evalgate, so it needs your dependencies beside it. A pull request from a fork gets a read-only
83
+ token, so it gets the job summary but no comment.
84
+
85
+ The [local Ollama walkthrough](docs/ollama.md) shows how to estimate calls, record a run at
86
+ zero provider cost, and replay it offline in the CLI or Action.
87
+
88
+ ## Bring your own outputs
89
+
90
+ evalgate doesn't have to call your model. If your pipeline already produces outputs, write them as
91
+ a results file, one JSON object per line, and compare two of them:
92
+
93
+ ```json
94
+ {"id": "billing-000", "output": "billing"}
95
+ {"id": "billing-001", "output": "refunds", "latency_ms": 412.5}
96
+ ```
97
+
98
+ Scoring happens at comparison time, against the dataset, so the file only needs ids and outputs.
99
+ Unknown fields are refused rather than ignored, because a mistyped `ouput` would otherwise read as
100
+ an item that produced nothing.
101
+
102
+ ## What's built
103
+
104
+ - **Versioned datasets.** JSONL plus a manifest, with a content hash over the items so an edit that
105
+ nobody meant to make is caught rather than silently changing what a run means. Every item records
106
+ where it came from — hand-written, mined from logs, synthetic, or promoted from a production
107
+ failure — and which slice it's in. Both are required; an item that declares neither is refused
108
+ rather than filed under "unknown".
109
+ - **Deterministic scorers.** Exact match, regex, JSON schema, set F1, edit similarity, or your own
110
+ function. Each declares whether it's binary or continuous, because that picks the statistical test
111
+ and inferring it from the values is silently wrong on a slice where everything passed.
112
+ - **Paired statistics, chosen by measuring them.** Binary scorers get Tango's score interval.
113
+ Continuous ones get a BCa bootstrap over the paired differences, except where fewer than eight
114
+ items moved: there the bootstrap can't see the change, so an exact count bound takes over. Never
115
+ two independent means. Each choice beat the alternatives on measured error at the tolerance;
116
+ the numbers are below.
117
+ - **Two errors, two controls.** A check passes only if every gate slice passes, so a false pass
118
+ needs no correction. It fails if any slice regresses, so false failures grow with the number of
119
+ slices; those are held down with a Holm correction, and the report names any slice it held
120
+ back. Watch slices use Benjamini-Hochberg.
121
+ - **Non-inferiority, not significance.** The gate asks "is this at most δ worse?" and reads the lower
122
+ bound of the interval. A significance test on a forty-item slice passes almost everything, which is
123
+ how a green check comes to mean nothing. δ is per slice and is a person's judgement, recorded next
124
+ to the verdict.
125
+ - **Results files.** One JSON object per item, with output, latency, tokens and cost. Each records a
126
+ hash of the input it answered: in CI the baseline runs from the base commit, so if a pull request
127
+ edits an item's question, the two answers are left out and listed instead of being compared as if
128
+ they answered the same thing. A crash counts as a failure, not a missing item.
129
+ - **Every slice gets an answer.** Gate slices can fail the build; watch slices are reported only.
130
+ A declared slice with no items, or one paired item, is reported as a gap rather than dropped, so
131
+ the report is never quietly shorter than the config.
132
+ - **A config file** holds everything a person decides. Tolerances have no default: how much worse a
133
+ slice may get is a judgement about that slice, and a default would be a number nobody chose.
134
+ - **A CLI and a GitHub Action** that turn all of that into a pull-request comment and an exit code.
135
+ - **Local model capture and replay.** The Ollama runner estimates live calls before it runs,
136
+ enforces a call cap and can redact outputs before persistence. The Action replays saved outputs
137
+ and reports missing recordings.
138
+
139
+ ## Judge, calibration, and benchmarks
140
+
141
+ The implementation includes a [local binary judge](docs/judge.md), a [calibration workflow](docs/calibration.md)
142
+ for independent human labels, [trace review and case promotion](docs/cases.md), and a
143
+ [seeded regression benchmark and power planner](docs/benchmark.md). The judge still needs a
144
+ human-labelled validation study. The benchmark results describe a synthetic paired population.
145
+
146
+ See the [release guide](docs/release.md) for building and verifying distribution candidates.
147
+
148
+ EvalGate's code is [MIT-licensed](LICENSE). The [Iris data](docs/ollama.md) carries its
149
+ source license and attribution.
150
+
151
+ ## How I know the statistics are right
152
+
153
+ A tool that judges other tools needs its own evaluation, and I'd rather show that than assert it.
154
+
155
+ I wrote the mathematics down first, in [docs/statistics.md](docs/statistics.md). Then the
156
+ statistics are checked against scipy and statsmodels by an oracle written from that document alone,
157
+ with no sight of the implementation it judges: 1,229 cases covering Tango's interval against a
158
+ numerical maximum-likelihood reference, the p-values at each tolerance, the count bound,
159
+ Clopper-Pearson, Holm and Benjamini-Hochberg, the jackknife acceleration and the BCa bootstrap. `src/evalgate/stats.py` imports neither scipy nor
160
+ statsmodels — one of the oracle's own tests parses the module to enforce it — because otherwise
161
+ "it agrees with scipy" would be a statement about nothing. That's why the exact binomial tails and
162
+ the Clopper-Pearson inversion are written out here instead of imported.
163
+
164
+ A passing oracle proves nothing on its own, so I check it can fail: shrinking Tango's variance by
165
+ 10% breaks it, and so does moving the bootstrap threshold from eight items to seven.
166
+
167
+ It caught three real defects in my first implementation. The bootstrap drew a fresh random stream
168
+ when no seed was given, so two runs of the same commit could reach different verdicts — on the
169
+ default path, which is the exact failure a CI gate exists to prevent. The bias correction counted
170
+ resample means strictly below the observed mean, which is fine on continuous data and systematically
171
+ wrong once scores take few distinct values. And my own contract contradicted itself about the
172
+ zero-discordance bound.
173
+
174
+ Agreeing with scipy only shows the code computes what I asked for. Whether I asked for the right
175
+ thing is a separate question, so I measured how often each method is wrong at exactly the
176
+ tolerance, where both errors are hardest to avoid. That found two worse problems. The binary
177
+ interval I had shipped treated the disagreement rate as known; when a change breaks items and
178
+ fixes none, it called a slice that was truly 10 points worse "safe" up to 48% of the time, and it
179
+ got worse with more data. And on continuous scores, a slice where nothing happened to move came
180
+ out as a zero-width interval, so it passed every time. Both are replaced, and the measurements
181
+ that caught them are now a committed script.
182
+
183
+ The same discipline applies to the build gates: format, lint, types, documentation links and tests
184
+ behind one command, each one watched failing on purpose, which `tools/verify_gates.py` re-checks so
185
+ it can't rot.
186
+
187
+ ## Results
188
+
189
+ Nothing goes in this table until a committed script in this repo produces it. The full tables are
190
+ in [docs/error-rates.md](docs/error-rates.md), written by `tools/error_rates.py`; CI regenerates
191
+ them and fails if they've drifted from the code.
192
+
193
+ | Measurement | How | Result |
194
+ |---|---|---|
195
+ | False pass at the tolerance, binary slice | Exact, 66 cells, n 10 to 500 | worst 3.1% (nominal 2.5%); the interval it replaced reached 47.8% |
196
+ | False fail at the tolerance, binary slice | Exact, same cells | worst 4.9%, at n = 200 when every disagreement goes one way |
197
+ | False pass at the tolerance, continuous slice | Simulated, 16 settings, n 10 to 100 | worst 3.1% |
198
+ | False fail across 10 gate slices | Simulated | 2.7% with Holm, 21.1% without |
199
+ | Judge agreement with human labels, per rubric | Labelled set, second rater on a subset | not measured |
200
+ | Detection rate on injected regressions, by size | Known regressions in the demo feature | not measured |
201
+ | False alarms on reruns of unchanged code | Repeated reruns | not measured |
202
+ | Cost and time per pull request check | Metered | not measured |
203
+
204
+ ## Design notes
205
+
206
+ **Say when a slice can't be tested.** A slice of 25 items can't detect a five-point drop however you
207
+ test it. Thin slices show up as a coverage gap rather than a green tick, and that's load-bearing
208
+ rather than tasteful: the verdict function sees an interval and never the item count, so if a slice
209
+ with zero disagreements reported a zero-width interval it would pass by arithmetic instead of by
210
+ evidence.
211
+
212
+ **Don't trust the judge until it's calibrated.** Judges drift towards longer answers, first positions
213
+ and their own model family. I'll measure agreement per rubric and run position-swap and length
214
+ probes. Where a cheap judge scores a large set and humans label a small one, prediction-powered
215
+ inference can correct the judge's bias and still give honest intervals.
216
+
217
+ **Record and replay model calls.** Replayed runs make CI cheap and reproducible. Live reruns are what
218
+ measure the noise floor.
219
+
220
+ ## Roadmap
221
+
222
+ - [x] Dataset format, slices and provenance
223
+ - [x] Deterministic scorers
224
+ - [x] Paired comparison, non-inferiority verdicts and the CLI
225
+ - [x] Config file, results files, and a GitHub Action that comments on the pull request
226
+ - [x] The statistics settled by evidence: interval error at the tolerance, a correction across
227
+ slices, published error rates
228
+ - [x] A real model: record-and-replay, redaction, a budget cap, no network in tests
229
+ - [ ] A release: PyPI package and a tagged action
230
+ - [x] Local LLM judge and tools for human calibration
231
+ - [ ] Human-labelled validation study
232
+ - [x] Reviewed failure-to-case promotion and offline log mining
233
+ - [x] Synthetic seeded-regression benchmark and write-up
234
+
235
+ ## Development
236
+
237
+ Requires [uv](https://docs.astral.sh/uv/). The interpreter and every tool version are pinned, so a
238
+ fresh checkout runs the same toolchain I do.
239
+
240
+ ```bash
241
+ uv sync --all-groups
242
+ uv run python tools/check.py
243
+ ```
244
+
245
+ That one command runs every gate: formatting, lint, types, documentation links, and tests against a
246
+ coverage floor. It's exactly what CI runs, so a gate can't exist in one place and be missing from the
247
+ other. Pass a gate name to run one while you work, for example `uv run python tools/check.py types`.
248
+
249
+ A gate that has never failed isn't known to work, so there's a second command that makes each one
250
+ fail on purpose and requires it to notice:
251
+
252
+ ```bash
253
+ uv run python tools/verify_gates.py
254
+ ```
255
+
256
+ Tested on Python 3.11 and 3.12.
257
+
258
+ ## Related projects
259
+
260
+ Part of a set of six projects about building LLM systems you can trust:
261
+ [evalgate](https://github.com/mozenjii/evalgate),
262
+ [policylens](https://github.com/mozenjii/policylens),
263
+ [docproof](https://github.com/mozenjii/docproof),
264
+ [tollgate](https://github.com/mozenjii/tollgate),
265
+ [redline](https://github.com/mozenjii/redline),
266
+ [casefile](https://github.com/mozenjii/casefile).