Skip to main content

passgate: Pass once is luck. Pass^N is a gate.

A statistical reliability gate for LLM evals: a candidate must clear a Wilson-bound pass bar on every evaluation round, not just on average.

pip install passgate && passgate gate rounds.json --threshold 0.9 --min-rounds 3

Needs Python 3.9 or newer, nothing else (standard library only). rounds.json is one entry per eval round (example below).

A real run on three rounds. Exit code 1, so CI fails:

passgate: 1/3 round(s) clear Wilson-lower >= 0.900 (lower bound of the two-sided 95% Wilson interval, ~97.5% one-sided; min 3 rounds)
  FAIL baseline-eval-set: 93/100 = 0.930 (lower 0.863)
  FAIL adversarial-set: 95/100 = 0.950 (lower 0.888)
  PASS regression-set: 116/120 = 0.967 (lower 0.917)
verdict: FAIL

Pasted from a real run in a temporary folder. 93/100 does not certify 0.9 at 95% confidence: you need more data or a lower bar.

  • Every round has to clear the bar. Each round's conservative pass rate (lower bound of the Wilson score interval) must reach your threshold. Averaging hides the weak round; this does not.
  • Plan and compare. passgate plan says how many trials a round needs; passgate compare tests a candidate against a baseline (pooled z-test, Fisher's exact, or paired McNemar).
  • Fits CI. Reads JSON, CSV or JUnit XML, --json for machines, --markdown appends to $GITHUB_STEP_SUMMARY.

CI PyPI License Python

Limits up front

  • The bar is the lower bound of the two-sided 95% Wilson interval (about 97.5% one-sided): conservative, not exactly 95%.
  • pass^N here means every round clears the bar. It is not tau-bench's pass^k (all k trials of one task succeed).
  • plan is a planning estimate, not a power calculation: at the expected rate a round of that size still fails some of the time.
  • compare exits 0 only when the improvement is significant at --alpha; "inconclusive" exits 1 like "not better".
  • Exit codes: 0 passed, 1 the gate failed (or compare found no significant improvement), 2 the input could not be used (missing or malformed file, bad number, --alpha outside 0 to 1).

More detail in Notes. Changes: CHANGELOG.md.

Eval flakiness is the quiet killer: a prompt scores 91% once, ships, and regresses. passgate requires each round's conservative pass-rate estimate to clear your bar, so a candidate that needs 3 good rounds to ship must produce 3 good rounds.

Install

pip install passgate

The gate

passgate gate rounds.json --threshold 0.9 --min-rounds 3

rounds.json (or .csv) holds one entry per round:

[
  { "label": "baseline-eval-set", "trials": 100, "passes": 93 },
  { "label": "adversarial-set",   "trials": 100, "passes": 95 },
  { "label": "regression-set",    "trials": 120, "passes": 116 }
]

A .xml file is read as JUnit XML (pytest --junitxml, most eval runners and CI): each <testsuite> is one round, failures and errors are fails, skipped cases are not counted as trials.

pytest evals/ --junitxml=rounds.xml && passgate gate rounds.xml --threshold 0.9 --min-rounds 3

Output is a per-round scoreboard and a verdict; exit code 1 fails CI:

passgate: 1/3 round(s) clear Wilson-lower >= 0.900 (lower bound of the two-sided 95% Wilson interval, ~97.5% one-sided; min 3 rounds)
  FAIL baseline-eval-set: 93/100 = 0.930 (lower 0.863)
  FAIL adversarial-set: 95/100 = 0.950 (lower 0.888)
  PASS regression-set: 116/120 = 0.967 (lower 0.917)
verdict: FAIL

Note what the gate does: 93/100 does not certify ≥ 0.9 at 95% confidence with 100 trials — you need more data or a lower bar. That is the point: the bar scales with evidence, not vibes. Add --json for machines.

How many trials do I need?

passgate plan --threshold 0.9 --expected-rate 0.95
passgate plan: 140 trials per round to clear Wilson-lower >= 0.900
assumptions:
  - each round scores exactly floor(expected_rate * n) passes (133/140); real rounds vary
  - planning estimate, not a power calculation: at that true rate a round of this size will still fail some of the time, so add margin
  - bar = lower bound of the two-sided 95% Wilson interval

plan returns the smallest round size that could clear the bar if the round scored exactly the rate you expect. It is not a power calculation. A flawless round (the default --expected-rate 1.0) needs 35 trials to clear 0.9. If the expected rate is at or below the threshold, no round size can clear it, and plan exits 2.

Candidate vs baseline

passgate compare --candidate 93/100 --candidate 95/100 \
                 --baseline  85/100 --baseline  88/100

Pooled two-proportion z-test with a one-sided p-value, plus Fisher's exact p (exact hypergeometric enumeration — right for small rounds where the normal approximation lies). Exit 0 only when the improvement is statistically significant at --alpha (default 0.05). The verdict uses the z-test; Fisher's p is reported alongside as a cross-check, not used for the verdict.

Paired: the same cases run by both

When candidate and baseline ran the same eval cases, the pooled test above throws away the pairing. Use --paired with one JSON line per case:

{"id": "case-001", "candidate": true,  "baseline": false}
{"id": "case-002", "candidate": true,  "baseline": true}
passgate compare --paired cases.jsonl

This runs an exact McNemar test: b = cases only the candidate passed, c = cases only the baseline passed, and the one-sided p-value is P(X >= b) for X ~ Binomial(b + c, 1/2), computed from exact integer binomial sums. Cases both passed or both failed carry no information about which is better and are ignored. The output shows b, c and the discordant count. With no discordant cases the verdict is inconclusive. Duplicate ids, or candidate/baseline values that are not true/false, exit 2.

Markdown summary

gate and compare take --markdown PATH to append a markdown table and the verdict to a file. It appends rather than overwrites, so it works with GitHub's $GITHUB_STEP_SUMMARY:

passgate gate rounds.json --threshold 0.9 --markdown "$GITHUB_STEP_SUMMARY"

Python API

from passgate import Round, evaluate_rounds, compare

result = evaluate_rounds(
    [Round(trials=100, passes=93), Round(trials=100, passes=95)],
    threshold=0.9, confidence=0.95, min_rounds=2,
)
assert result.passed, str(result)

cmp = compare([Round(100, 93)], [Round(100, 85)])
print(cmp.verdict)  # candidate-better | baseline-better | inconclusive

CI

- run: pip install passgate
- run: python run_evals.py --out rounds.json   # your eval runner
- run: passgate gate rounds.json --threshold 0.9 --min-rounds 3

Notes

  • Wilson interval (not Wald): behaves correctly near 0% and 100%, where the naive interval explodes.
  • The bar is the lower bound of the two-sided 95% Wilson interval (--confidence 0.95). That is equivalent to a ~97.5% one-sided bound: conservative, not exactly 95%.
  • pass^N here means every round clears the bar. It is not tau-bench's pass^k (all k trials of the same task succeed).
  • gate fails when rounds < --min-rounds, so "we only ran it once" cannot pass a 3-round gate.
  • Pure stdlib — no scipy, no pandas.

License

MIT — see LICENSE.

Metadata

Release files for passgate 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for passgate 0.2.2
File Size Uploaded Provenance Actions
passgate-0.2.2.tar.gz 21.4 kB Without provenance Details for passgate-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for passgate 0.2.2
File Interpreter ABI Platform Actions
passgate-0.2.2-py3-none-any.whl Python 3 none any Details for passgate-0.2.2-py3-none-any.whl

Total release size: 36.4 kB

Release files / passgate-0.2.2.tar.gz

Download URL passgate-0.2.2.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
089a123badd6babcba50f27f890f09d3be40a9aff9927afebad628806e1b9e16
BLAKE2b-256 checksum
How to use checksums
dfb0d0e7ab1b20fa0906e42fddd7ea45d126419859d8eb26b336157f8a12af35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / passgate-0.2.2-py3-none-any.whl

Download URL passgate-0.2.2-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05b06ed86982fc9b04246586f8b097fa7161301ba95c9b659adeb40a130c3206
BLAKE2b-256 checksum
How to use checksums
2a619f5dd4c50cdb0fe75061280c2d0581dac7112021841b01893645d4ec2881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for passgate 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page