margin-referee 0.1.2__tar.gz → 0.1.4__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.
Files changed (38) hide show
  1. margin_referee-0.1.4/PKG-INFO +215 -0
  2. margin_referee-0.1.4/README.md +200 -0
  3. margin_referee-0.1.4/margin_referee/__init__.py +2 -0
  4. margin_referee-0.1.4/margin_referee/cases.py +465 -0
  5. margin_referee-0.1.4/margin_referee/cli.py +279 -0
  6. {margin_referee-0.1.2 → margin_referee-0.1.4}/margin_referee/endpoints.py +14 -2
  7. margin_referee-0.1.4/margin_referee/experiments.py +181 -0
  8. margin_referee-0.1.4/margin_referee/hurdle.py +158 -0
  9. margin_referee-0.1.4/margin_referee/ontology_sql.py +252 -0
  10. margin_referee-0.1.4/margin_referee/receipt.py +178 -0
  11. margin_referee-0.1.4/margin_referee/replay.py +346 -0
  12. margin_referee-0.1.4/margin_referee.egg-info/PKG-INFO +215 -0
  13. {margin_referee-0.1.2 → margin_referee-0.1.4}/margin_referee.egg-info/SOURCES.txt +11 -1
  14. margin_referee-0.1.4/margin_referee.egg-info/requires.txt +6 -0
  15. {margin_referee-0.1.2 → margin_referee-0.1.4}/pyproject.toml +4 -2
  16. margin_referee-0.1.4/tests/test_experiments.py +104 -0
  17. margin_referee-0.1.4/tests/test_hurdle.py +95 -0
  18. margin_referee-0.1.4/tests/test_ontology_sql.py +256 -0
  19. margin_referee-0.1.4/tests/test_receipt.py +114 -0
  20. margin_referee-0.1.4/tests/test_receipt_spec.py +36 -0
  21. margin_referee-0.1.4/tests/test_referee.py +176 -0
  22. margin_referee-0.1.4/tests/test_tool_change.py +135 -0
  23. margin_referee-0.1.2/PKG-INFO +0 -67
  24. margin_referee-0.1.2/README.md +0 -54
  25. margin_referee-0.1.2/margin_referee/__init__.py +0 -2
  26. margin_referee-0.1.2/margin_referee/cases.py +0 -214
  27. margin_referee-0.1.2/margin_referee/cli.py +0 -87
  28. margin_referee-0.1.2/margin_referee/replay.py +0 -152
  29. margin_referee-0.1.2/margin_referee.egg-info/PKG-INFO +0 -67
  30. margin_referee-0.1.2/margin_referee.egg-info/requires.txt +0 -3
  31. margin_referee-0.1.2/tests/test_referee.py +0 -80
  32. {margin_referee-0.1.2 → margin_referee-0.1.4}/LICENSE +0 -0
  33. {margin_referee-0.1.2 → margin_referee-0.1.4}/margin_referee/stats.py +0 -0
  34. {margin_referee-0.1.2 → margin_referee-0.1.4}/margin_referee.egg-info/dependency_links.txt +0 -0
  35. {margin_referee-0.1.2 → margin_referee-0.1.4}/margin_referee.egg-info/entry_points.txt +0 -0
  36. {margin_referee-0.1.2 → margin_referee-0.1.4}/margin_referee.egg-info/top_level.txt +0 -0
  37. {margin_referee-0.1.2 → margin_referee-0.1.4}/setup.cfg +0 -0
  38. {margin_referee-0.1.2 → margin_referee-0.1.4}/tests/test_cases.py +0 -0
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: margin-referee
3
+ Version: 0.1.4
4
+ Summary: Can you ship this AI change? A verdict on a model, prompt, tool or host change from your own eval cases, with a receipt anyone can verify.
5
+ License: MIT
6
+ Keywords: llm,evals,model-selection,agents,promptfoo,langfuse,braintrust
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest>=7; extra == "dev"
12
+ Provides-Extra: verify
13
+ Requires-Dist: cryptography>=42; extra == "verify"
14
+ Dynamic: license-file
15
+
16
+ # margin-referee
17
+
18
+ Can you ship this change? Ask your own eval set.
19
+
20
+ `margin-referee` tests a change on the cases you already have (a promptfoo results file, a
21
+ Braintrust, LangSmith or Langfuse dataset export, or JSONL): a new model, a new system prompt, a
22
+ changed tool list, or the same model on another endpoint. It runs what you use today and the
23
+ candidate, grades both with each case's own check, and answers promote (ship it), a refusal (don't),
24
+ or hold (not enough cases to tell). What the change does to cost is one line of the answer. No
25
+ account, no backend, no telemetry.
26
+
27
+ Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
28
+ (https://github.com/trymargin/margin-referee).
29
+
30
+ ```
31
+ pip install margin-referee
32
+ margin-referee fit cases.jsonl
33
+ OPENROUTER_API_KEY=... margin-referee replay cases.jsonl \
34
+ --baseline openai/gpt-4.1 --candidate openai/gpt-6-luna --cap 1
35
+ ```
36
+
37
+ ## Why another eval tool
38
+
39
+ Because "the candidate scored higher on our evals" is how most bad switches start. Three things
40
+ make it unreliable, and this tool corrects for each:
41
+
42
+ - **Small sets lie.** The verdict is a paired test on the cases both models ran. Only the cases
43
+ they disagree on carry evidence, and a clean sweep on 20 cases proves nothing. `fit` tells you,
44
+ for free and before anything runs, how many cases you need: about 100 against a current model
45
+ that passes everything, and more as its pass rate falls.
46
+ - **The best of several looks better than it is.** Try four models on the same cases and keep the
47
+ winner, and you have mostly found noise. The bar rises with every candidate you try on
48
+ overlapping cases (remembered in `~/.margin-referee/ledger.json`), so renaming or trimming the
49
+ cases does not reset it. To confirm a winner, replay it alone on cases none of them saw.
50
+ - **Half-graded cases flatter the candidate.** A case with a check this tool cannot run (an LLM
51
+ rubric, say) is left out and counted, never half-graded. An answer cut off by the output limit,
52
+ or a call that errored, is unanswered, not a fail, and any unanswered case blocks a promotion.
53
+ It does not hide a loss: if the change is still worse than the bar allows with every unanswered
54
+ case counted as a win for the candidate, the answer is `do_not_ship`, not `not_enough_evidence`.
55
+
56
+ ## What `replay` also does
57
+
58
+ - **It stops paying once the answer is clear.** From 40 cases on, the replay stops as soon as the
59
+ answer is already `do_not_ship`: even the reading most favourable to the candidate misses the
60
+ bar. Each look is held to a stricter test (Bonferroni across the planned looks), so looking often
61
+ cannot manufacture a loss. It never stops early for ship; `stopped_early` says when it stopped,
62
+ and `--no-early-stop` runs every case. (Borrowed from VERDICT, `verdict-gate`.)
63
+ - **Reliability, with `--repeats 3`** (1 to 5). Each case runs that many times per side and passes
64
+ only if every run passed (pass^k); the paired test reads that strict result. `reliability` gives
65
+ pass@1 and pass^k per side, the cases that flipped between runs, and an estimate of the repeats
66
+ needed to see a 1-point gap. Spend scales with the repeats.
67
+ - **Traffic weights.** Give a case a `weight` (or `metadata.weight`: its share of traffic, or a
68
+ count) and `weighted` reports the same cases weighted by traffic, including the share of traffic
69
+ on the cases that got worse. It is a weighting of the same cases, not a new test: the decision
70
+ stays on the unweighted paired test.
71
+
72
+ ## Testing a tool change
73
+
74
+ A tool description is a prompt the model reads on every call. Rewrite one, or add or remove a
75
+ tool, and the agent may start calling the wrong tool. To test that before it ships, give each
76
+ JSONL case the tools the call offers and say which tool it should call:
77
+
78
+ ```
79
+ {"id": "refund-policy", "input": "How long do I have to return shoes?",
80
+ "tools": [{"type": "function", "function": {"name": "search_kb", "description": "Search.",
81
+ "parameters": {"type": "object", "properties": {"query": {"type": "string"}}}}}],
82
+ "check": "tool-call", "expected": "search_kb"}
83
+ ```
84
+
85
+ - `tools` is an OpenAI-style function tool list, and `tool_choice` is optional. Both are sent
86
+ with every call, as they are.
87
+ - `check: "tool-call"` passes when the model's first tool call is the `expected` tool. To check
88
+ arguments too, write pairs separated by `;`, such as
89
+ `name=lookup_order;args.order_id=A1042`. Values compare as text, ignoring case.
90
+ - No tool call is a fail. A call whose arguments cannot be read, or an endpoint that does not
91
+ report tool calls, leaves the case unanswered. It is never counted as a pass.
92
+
93
+ Then put the new tool list in a file and replay with `--candidate-tools`. The candidate gets
94
+ that list in place of each case's tools; the baseline keeps the case's own. The model can stay
95
+ the same:
96
+
97
+ ```
98
+ cd examples/tool_change
99
+ OPENROUTER_API_KEY=... margin-referee replay cases.jsonl \
100
+ --baseline openai/gpt-4.1 --candidate openai/gpt-4.1 \
101
+ --candidate-tools candidate_tools.json --cap 1
102
+ ```
103
+
104
+ `examples/tool_change` has three cases and a `candidate_tools.json` that rewrites two vague
105
+ descriptions. Three cases show the format and prove nothing: the verdict on them is
106
+ `not_enough_evidence`, and `fit` says how many cases you need. Each tool list you try counts as
107
+ a candidate, the same as a prompt. Tool cases run on OpenRouter and on OpenAI-compatible, Azure
108
+ OpenAI and Vertex AI endpoints; a Bedrock endpoint leaves them unanswered for now. A promptfoo
109
+ results file carries no tool list, so write tool cases as JSONL.
110
+
111
+ ## A second opinion on a comparison you already ran
112
+
113
+ Ran the baseline and a cheaper model as two Braintrust experiments (by hand, or with Loop)?
114
+ `check` reads both, pairs the cases, and gives the same verdict, without calling a model:
115
+
116
+ ```
117
+ margin-referee check baseline.jsonl candidate.jsonl --scorer correct
118
+ BRAINTRUST_API_KEY=... margin-referee check bt:<baseline id> bt:<candidate id> --scorer correct
119
+ ```
120
+
121
+ A pass is the named score at or above `--threshold` (default 1.0, full credit only). Pass
122
+ `--candidates N` when several models were tried on the same cases. A case one experiment lacks
123
+ blocks the promotion. With no `metrics.estimated_cost` in the exports, it says whether quality
124
+ held but claims no saving. Exit code 0 means promote.
125
+
126
+ ## The verdict on a Hurdle suite
127
+
128
+ Ran a [Hurdle](https://github.com/togethercomputer/hurdle) suite with and without a skill, or on
129
+ two models? `hurdle` reads the runs it saved and says whether the difference is real:
130
+
131
+ ```
132
+ margin-referee hurdle .hurdle --compare condition --baseline baseline --candidate with-skill
133
+ margin-referee hurdle .hurdle --compare model --baseline <model now> --candidate <model to try>
134
+ ```
135
+
136
+ A task passes only if every repeat passed, and `repeats_passed` shows each side's count. A run
137
+ Hurdle marked incomplete or unknown leaves its task unanswered, which blocks a promotion.
138
+
139
+ ## Judging an ontology layer: NVIDIA ontology-sql-eval
140
+
141
+ Ran [ontology-sql-eval](https://github.com/NVIDIA/ontology-sql-eval) to compare a schema-only
142
+ prompt with the ontology-grounded agent? `ontology-sql` reads the two arms' result files and
143
+ says whether to ship the layer. It calls no model and needs nothing of NVIDIA's installed:
144
+
145
+ ```
146
+ margin-referee ontology-sql runs
147
+ margin-referee ontology-sql runs/full_20261126 --price-in 5 --price-out 25 --json
148
+ ```
149
+
150
+ It reads `<run>/control/<dataset>.jsonl` and `<run>/treatment/<dataset>.jsonl`, pairs the
151
+ questions by `task_id`, and applies the referee's rules, which are stricter than the harness's
152
+ own report:
153
+
154
+ - A pass is the verifier's positive verdict. A wrong result, a query that errored or timed out,
155
+ or no SQL in the answer is a fail.
156
+ - A gold query that did not run, a run with no model output, an unknown error, or a question
157
+ one arm has no row for is unanswered. It is listed with its reason, counts as neither a pass
158
+ nor a fail, and blocks a promotion. The harness scores some of these as misses, so its
159
+ accuracy and this one can differ on the same run.
160
+ - Tokens per question come from the per-call capture block on each row when the run recorded
161
+ one, otherwise from the ontology arm's own totals. Cost is those tokens times the
162
+ `--price-in` and `--price-out` you give (USD per million tokens). The files carry no price,
163
+ so without both flags cost reads `not_recorded` and nothing is guessed.
164
+ - The ontology arm makes many more calls per question. If the pass rate only holds, the answer
165
+ is `not_enough_evidence`: a layer that is not cheaper ships on a proven gain. If the gain is
166
+ proven it reads `ship_if_worth_the_cost`, with the questions won and lost and the 95% bound
167
+ on the gain, and the decision to pay is yours.
168
+ - Results are also read per `difficulty` (or `db_id`; choose with `--segment-by`), so a gain
169
+ overall cannot hide a loss on the hard questions.
170
+
171
+ `--baseline-arm` and `--candidate-arm` name the two folders, or two rollout files, if yours are
172
+ called something else. Swap them to ask the opposite question: can the layer be dropped?
173
+
174
+ Not checked against a real run: the file layout and field names were read from the harness
175
+ source at commit `871bb924` (2026-11-26) and the tests use rows made in that shape.
176
+
177
+ ## A receipt for the verdict
178
+
179
+ `replay`, `check`, `hurdle` and `ontology-sql` take `--receipt out.json`. It writes the verdict as an
180
+ [in-toto Statement](https://github.com/in-toto/attestation) in a DSSE envelope: the decision, the
181
+ bar, the paired counts and gap, how many candidates were tried, cost per case, each segment, and a
182
+ list of what the record does not show. A receipt you write this way is **unsigned** and says
183
+ `assuranceLevel: self-run`. It is your own claim in a format someone else can read.
184
+
185
+ A receipt Margin's hosted service issues is signed with Ed25519. Check one with:
186
+
187
+ ```
188
+ pip install 'margin-referee[verify]'
189
+ margin-referee verify receipt.json --key-url https://trymargin.io/.well-known/margin-receipt-key
190
+ ```
191
+
192
+ Exit 0 means the holder of that key signed it and nobody edited it since. It is a signed record,
193
+ not a certification: it does not show the grader is right, that the cases cover production, or
194
+ what a person decided to ship.
195
+
196
+ ## What it runs on
197
+
198
+ - **OpenRouter**, with your own key: any model it serves.
199
+ - **A model in your own account**, with `--candidate-endpoint` or `--baseline-endpoint` and a
200
+ JSON object: `bedrock` (region, model, a Bedrock API key), `vertex_ai` (project, region, model,
201
+ access token), `azure_openai` (resource, deployment, key) or `openai_compatible` (base URL,
202
+ model, key: a fine-tune, vLLM, a self-hosted model). Your credential is used for that run only,
203
+ and you give your own per-token price, so a negotiated discount counts.
204
+ - **A prompt change**: `--candidate-system` replays the candidate with a new system prompt. Each
205
+ prompt you try counts as a candidate.
206
+ - **A tool change**: `--candidate-tools` replays the candidate with a new tool list (see
207
+ "Testing a tool change").
208
+
209
+ ## What it does not do
210
+
211
+ It does not open the pull request, watch the change after you merge it, keep the history across
212
+ your team, or let your agents call it with a spend limit. That is
213
+ [Margin](https://trymargin.io), which runs this same test.
214
+
215
+ MIT licensed.
@@ -0,0 +1,200 @@
1
+ # margin-referee
2
+
3
+ Can you ship this change? Ask your own eval set.
4
+
5
+ `margin-referee` tests a change on the cases you already have (a promptfoo results file, a
6
+ Braintrust, LangSmith or Langfuse dataset export, or JSONL): a new model, a new system prompt, a
7
+ changed tool list, or the same model on another endpoint. It runs what you use today and the
8
+ candidate, grades both with each case's own check, and answers promote (ship it), a refusal (don't),
9
+ or hold (not enough cases to tell). What the change does to cost is one line of the answer. No
10
+ account, no backend, no telemetry.
11
+
12
+ Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
13
+ (https://github.com/trymargin/margin-referee).
14
+
15
+ ```
16
+ pip install margin-referee
17
+ margin-referee fit cases.jsonl
18
+ OPENROUTER_API_KEY=... margin-referee replay cases.jsonl \
19
+ --baseline openai/gpt-4.1 --candidate openai/gpt-6-luna --cap 1
20
+ ```
21
+
22
+ ## Why another eval tool
23
+
24
+ Because "the candidate scored higher on our evals" is how most bad switches start. Three things
25
+ make it unreliable, and this tool corrects for each:
26
+
27
+ - **Small sets lie.** The verdict is a paired test on the cases both models ran. Only the cases
28
+ they disagree on carry evidence, and a clean sweep on 20 cases proves nothing. `fit` tells you,
29
+ for free and before anything runs, how many cases you need: about 100 against a current model
30
+ that passes everything, and more as its pass rate falls.
31
+ - **The best of several looks better than it is.** Try four models on the same cases and keep the
32
+ winner, and you have mostly found noise. The bar rises with every candidate you try on
33
+ overlapping cases (remembered in `~/.margin-referee/ledger.json`), so renaming or trimming the
34
+ cases does not reset it. To confirm a winner, replay it alone on cases none of them saw.
35
+ - **Half-graded cases flatter the candidate.** A case with a check this tool cannot run (an LLM
36
+ rubric, say) is left out and counted, never half-graded. An answer cut off by the output limit,
37
+ or a call that errored, is unanswered, not a fail, and any unanswered case blocks a promotion.
38
+ It does not hide a loss: if the change is still worse than the bar allows with every unanswered
39
+ case counted as a win for the candidate, the answer is `do_not_ship`, not `not_enough_evidence`.
40
+
41
+ ## What `replay` also does
42
+
43
+ - **It stops paying once the answer is clear.** From 40 cases on, the replay stops as soon as the
44
+ answer is already `do_not_ship`: even the reading most favourable to the candidate misses the
45
+ bar. Each look is held to a stricter test (Bonferroni across the planned looks), so looking often
46
+ cannot manufacture a loss. It never stops early for ship; `stopped_early` says when it stopped,
47
+ and `--no-early-stop` runs every case. (Borrowed from VERDICT, `verdict-gate`.)
48
+ - **Reliability, with `--repeats 3`** (1 to 5). Each case runs that many times per side and passes
49
+ only if every run passed (pass^k); the paired test reads that strict result. `reliability` gives
50
+ pass@1 and pass^k per side, the cases that flipped between runs, and an estimate of the repeats
51
+ needed to see a 1-point gap. Spend scales with the repeats.
52
+ - **Traffic weights.** Give a case a `weight` (or `metadata.weight`: its share of traffic, or a
53
+ count) and `weighted` reports the same cases weighted by traffic, including the share of traffic
54
+ on the cases that got worse. It is a weighting of the same cases, not a new test: the decision
55
+ stays on the unweighted paired test.
56
+
57
+ ## Testing a tool change
58
+
59
+ A tool description is a prompt the model reads on every call. Rewrite one, or add or remove a
60
+ tool, and the agent may start calling the wrong tool. To test that before it ships, give each
61
+ JSONL case the tools the call offers and say which tool it should call:
62
+
63
+ ```
64
+ {"id": "refund-policy", "input": "How long do I have to return shoes?",
65
+ "tools": [{"type": "function", "function": {"name": "search_kb", "description": "Search.",
66
+ "parameters": {"type": "object", "properties": {"query": {"type": "string"}}}}}],
67
+ "check": "tool-call", "expected": "search_kb"}
68
+ ```
69
+
70
+ - `tools` is an OpenAI-style function tool list, and `tool_choice` is optional. Both are sent
71
+ with every call, as they are.
72
+ - `check: "tool-call"` passes when the model's first tool call is the `expected` tool. To check
73
+ arguments too, write pairs separated by `;`, such as
74
+ `name=lookup_order;args.order_id=A1042`. Values compare as text, ignoring case.
75
+ - No tool call is a fail. A call whose arguments cannot be read, or an endpoint that does not
76
+ report tool calls, leaves the case unanswered. It is never counted as a pass.
77
+
78
+ Then put the new tool list in a file and replay with `--candidate-tools`. The candidate gets
79
+ that list in place of each case's tools; the baseline keeps the case's own. The model can stay
80
+ the same:
81
+
82
+ ```
83
+ cd examples/tool_change
84
+ OPENROUTER_API_KEY=... margin-referee replay cases.jsonl \
85
+ --baseline openai/gpt-4.1 --candidate openai/gpt-4.1 \
86
+ --candidate-tools candidate_tools.json --cap 1
87
+ ```
88
+
89
+ `examples/tool_change` has three cases and a `candidate_tools.json` that rewrites two vague
90
+ descriptions. Three cases show the format and prove nothing: the verdict on them is
91
+ `not_enough_evidence`, and `fit` says how many cases you need. Each tool list you try counts as
92
+ a candidate, the same as a prompt. Tool cases run on OpenRouter and on OpenAI-compatible, Azure
93
+ OpenAI and Vertex AI endpoints; a Bedrock endpoint leaves them unanswered for now. A promptfoo
94
+ results file carries no tool list, so write tool cases as JSONL.
95
+
96
+ ## A second opinion on a comparison you already ran
97
+
98
+ Ran the baseline and a cheaper model as two Braintrust experiments (by hand, or with Loop)?
99
+ `check` reads both, pairs the cases, and gives the same verdict, without calling a model:
100
+
101
+ ```
102
+ margin-referee check baseline.jsonl candidate.jsonl --scorer correct
103
+ BRAINTRUST_API_KEY=... margin-referee check bt:<baseline id> bt:<candidate id> --scorer correct
104
+ ```
105
+
106
+ A pass is the named score at or above `--threshold` (default 1.0, full credit only). Pass
107
+ `--candidates N` when several models were tried on the same cases. A case one experiment lacks
108
+ blocks the promotion. With no `metrics.estimated_cost` in the exports, it says whether quality
109
+ held but claims no saving. Exit code 0 means promote.
110
+
111
+ ## The verdict on a Hurdle suite
112
+
113
+ Ran a [Hurdle](https://github.com/togethercomputer/hurdle) suite with and without a skill, or on
114
+ two models? `hurdle` reads the runs it saved and says whether the difference is real:
115
+
116
+ ```
117
+ margin-referee hurdle .hurdle --compare condition --baseline baseline --candidate with-skill
118
+ margin-referee hurdle .hurdle --compare model --baseline <model now> --candidate <model to try>
119
+ ```
120
+
121
+ A task passes only if every repeat passed, and `repeats_passed` shows each side's count. A run
122
+ Hurdle marked incomplete or unknown leaves its task unanswered, which blocks a promotion.
123
+
124
+ ## Judging an ontology layer: NVIDIA ontology-sql-eval
125
+
126
+ Ran [ontology-sql-eval](https://github.com/NVIDIA/ontology-sql-eval) to compare a schema-only
127
+ prompt with the ontology-grounded agent? `ontology-sql` reads the two arms' result files and
128
+ says whether to ship the layer. It calls no model and needs nothing of NVIDIA's installed:
129
+
130
+ ```
131
+ margin-referee ontology-sql runs
132
+ margin-referee ontology-sql runs/full_20261126 --price-in 5 --price-out 25 --json
133
+ ```
134
+
135
+ It reads `<run>/control/<dataset>.jsonl` and `<run>/treatment/<dataset>.jsonl`, pairs the
136
+ questions by `task_id`, and applies the referee's rules, which are stricter than the harness's
137
+ own report:
138
+
139
+ - A pass is the verifier's positive verdict. A wrong result, a query that errored or timed out,
140
+ or no SQL in the answer is a fail.
141
+ - A gold query that did not run, a run with no model output, an unknown error, or a question
142
+ one arm has no row for is unanswered. It is listed with its reason, counts as neither a pass
143
+ nor a fail, and blocks a promotion. The harness scores some of these as misses, so its
144
+ accuracy and this one can differ on the same run.
145
+ - Tokens per question come from the per-call capture block on each row when the run recorded
146
+ one, otherwise from the ontology arm's own totals. Cost is those tokens times the
147
+ `--price-in` and `--price-out` you give (USD per million tokens). The files carry no price,
148
+ so without both flags cost reads `not_recorded` and nothing is guessed.
149
+ - The ontology arm makes many more calls per question. If the pass rate only holds, the answer
150
+ is `not_enough_evidence`: a layer that is not cheaper ships on a proven gain. If the gain is
151
+ proven it reads `ship_if_worth_the_cost`, with the questions won and lost and the 95% bound
152
+ on the gain, and the decision to pay is yours.
153
+ - Results are also read per `difficulty` (or `db_id`; choose with `--segment-by`), so a gain
154
+ overall cannot hide a loss on the hard questions.
155
+
156
+ `--baseline-arm` and `--candidate-arm` name the two folders, or two rollout files, if yours are
157
+ called something else. Swap them to ask the opposite question: can the layer be dropped?
158
+
159
+ Not checked against a real run: the file layout and field names were read from the harness
160
+ source at commit `871bb924` (2026-11-26) and the tests use rows made in that shape.
161
+
162
+ ## A receipt for the verdict
163
+
164
+ `replay`, `check`, `hurdle` and `ontology-sql` take `--receipt out.json`. It writes the verdict as an
165
+ [in-toto Statement](https://github.com/in-toto/attestation) in a DSSE envelope: the decision, the
166
+ bar, the paired counts and gap, how many candidates were tried, cost per case, each segment, and a
167
+ list of what the record does not show. A receipt you write this way is **unsigned** and says
168
+ `assuranceLevel: self-run`. It is your own claim in a format someone else can read.
169
+
170
+ A receipt Margin's hosted service issues is signed with Ed25519. Check one with:
171
+
172
+ ```
173
+ pip install 'margin-referee[verify]'
174
+ margin-referee verify receipt.json --key-url https://trymargin.io/.well-known/margin-receipt-key
175
+ ```
176
+
177
+ Exit 0 means the holder of that key signed it and nobody edited it since. It is a signed record,
178
+ not a certification: it does not show the grader is right, that the cases cover production, or
179
+ what a person decided to ship.
180
+
181
+ ## What it runs on
182
+
183
+ - **OpenRouter**, with your own key: any model it serves.
184
+ - **A model in your own account**, with `--candidate-endpoint` or `--baseline-endpoint` and a
185
+ JSON object: `bedrock` (region, model, a Bedrock API key), `vertex_ai` (project, region, model,
186
+ access token), `azure_openai` (resource, deployment, key) or `openai_compatible` (base URL,
187
+ model, key: a fine-tune, vLLM, a self-hosted model). Your credential is used for that run only,
188
+ and you give your own per-token price, so a negotiated discount counts.
189
+ - **A prompt change**: `--candidate-system` replays the candidate with a new system prompt. Each
190
+ prompt you try counts as a candidate.
191
+ - **A tool change**: `--candidate-tools` replays the candidate with a new tool list (see
192
+ "Testing a tool change").
193
+
194
+ ## What it does not do
195
+
196
+ It does not open the pull request, watch the change after you merge it, keep the history across
197
+ your team, or let your agents call it with a spend limit. That is
198
+ [Margin](https://trymargin.io), which runs this same test.
199
+
200
+ MIT licensed.
@@ -0,0 +1,2 @@
1
+ """margin-referee: can you ship this AI change? Ask your own eval cases."""
2
+ __version__ = "0.1.4"