{"name":"preregistered-model-study","title":"Run a preregistered model study","description":"Run a model or prompt comparison whose verdict can be trusted: before any paid call, commit the plan, a freeze of every input by hash, and a dry run proving each arm differs from production only where intended; put every later change in a dated addendum pushed before the calls it governs, or record it as a dated correction if found after them; cap the spend in code; prove the harness reproduces production before measuring; judge with three vendors who can see where each piece of evidence came from; and ship a reproduce script and checksum manifest that rebuild every number offline. Symptoms: compare these models, is the cheaper model good enough, bake-off, A/B this prompt, run an eval before we switch, can we trust this benchmark, the study overspent, the judge rewarded an answer that made things up. Which model runs everyday work is model-routing's; the review round on each study pull request is codex-review-loop's.","compatibility":"Any harness that can run scripts and commit to a repository. Every paid call goes through one research account, not production's: one key, one balance, reporting each call's cost and the key's account; on a shared account or with no balance endpoint the floor is recorded as unavailable. Judging needs three vendors' models on that account. Output is a committed study directory: plan, freeze, addenda, raw responses, scores, report, a reproduce script and a checksum manifest.","allowedTools":"Read Write Edit Grep Glob Bash","license":"MIT","kind":"requestOnly","useWhen":"comparing models or prompts where the verdict will decide what production runs","group":"workflow","lifecycle":"release","version":"1.0.1","author":"crissmoldovan","install":["npx skills add crissmoldovan/agent-skills --skill preregistered-model-study"],"asks":["Before we switch the ticket classifier to the cheaper model, run a preregistered study. Commit the\nplan, the freeze and a dry run before you spend anything, and cap the spend in code. I want to know\nwhether it passes the bars and, separately, whether it is actually better, and what it costs at our\nvolume.","The last comparison's judge preferred the answer that made things up. Rerun the judging with three\nvendors, tag which fields the model wrote or guessed, give each judge a source-only reading too, and\nreport every judge on its own as well as the majority.","Prove the harness sends what production sends before we measure anything. Show me one real item's\nrequest from production and from the control arm, diffed, with the serving provider pinned on both.","We changed the scorer after the first batch of calls. Write the addendum — what changed, why, which\ncalls it governs, which published numbers move — and push it before the next batch runs."],"commands":["# Rebuild every number offline; the script checks the manifest before computing anything.\n./reproduce.sh\n\n# Arm the manifest gate: drop one line, watch the run refuse, restore from a byte copy.\ncp MANIFEST.sha256 MANIFEST.sha256.bak\ntail -n +2 MANIFEST.sha256.bak > MANIFEST.sha256\n./reproduce.sh; echo \"exit $? (expected non-zero)\"\ncp MANIFEST.sha256.bak MANIFEST.sha256 && cmp MANIFEST.sha256 MANIFEST.sha256.bak && ./reproduce.sh"],"documents":[{"path":"references/budget-guard.md","slug":"budget-guard","title":"The budget guard","body":"# The budget guard\n\nThe guard sits between the harness and the provider, and every paid call passes through it. It\nexists because the ways a study overspends are all ordinary: a retry loop nobody bounded, a second\nterminal that started the same run, a balance that read healthy a minute after it was not, a cap\nchecked against what was spent rather than what was about to be. Each part below closes one of\nthem, and each one is armed — watched refusing — before the guard is trusted with a real call.\n\n## Scope: one paying process, one call at a time\n\nThis guard is deliberately single-threaded. **One** paying process holds the study for the whole\nrun, and it admits, sends and settles **one** call at a time: nothing else is in flight while a\ncall is admitted, and every ledger row is written before the next admission. The cap is hard only\nunder that rule.\n\nConcurrency is out of scope: calls in parallel inside the process, two paying processes, balance\nreads running alongside calls, locks on shared storage or across hosts, and taking over another\nprocess's lock. A study that needs any of them needs a different guard, and running one of them\nunder this one voids the cap — two processes that each believe the remaining budget is theirs\nspend twice it, and parallel calls each reserve against a total the others have not yet added to.\n\n## The parts\n\n### 1. One research account, refused if it is production's\n\nEvery paid call the study makes — every arm, every judge — goes through one research account: one\nkey and one balance, such as a multi-vendor gateway's. That is what lets one guard hold the cap and\nthe floor. A study whose providers need separate accounts is out of scope, because each account\nwould need a guard of its own. The account is the study's own, so that a runaway study cannot spend\nproduction's money or exhaust production's rate limit.\n\nUnequal keys do not show that. A provider can issue many keys under one billing organisation or\nproject, and every one of them spends that account's balance and rate limit. A key is a view onto\nits account: one study found that a key's own spend limit was not the account's spendable balance,\nbecause credits are account-wide and shared with every other key on it. So at start-up the guard\ncompares **accounts**: the non-secret account or project identity the provider names for the\nresearch key, against the one it names for production's. Only the provider can bind a key to the\naccount it bills. A billing account written in the plan records which account someone meant the key\nto bill, not which one the provider bills, so it is not a binding. A provider that cannot name the\naccount behind a key is out of scope, and the guard refuses to start. It also compares the two keys'\nhashes in memory, refusing when they are equal, and prints nothing but the outcomes. And it refuses\nwhile the harness holds any other paid credential: a judge called on its own vendor key spends\noutside the balance the guard reads, and that key may be production's.\n\nIf production's identity or key is not readable where the study runs, the check cannot run. Say so,\nand treat it as a reason to run the study somewhere it can — not as a pass.\n\n### 2. One paying process, holding a lock the kernel releases\n\nAt start-up the guard takes an exclusive operating-system lock on a file in the study directory —\nan advisory lock on an open file, such as `flock`, on a local file system — without waiting, and\nholds it until the process exits. A second process that tries to take it fails at once and refuses\nto start.\n\nThe kernel releases the lock when the process exits or dies, so a crashed run never leaves a stale\nlock behind, and there is nothing to take over. A paused process still holds it, so nobody starts\npaying while it might wake up. A file whose mere existence is the lock — an exclusive create — is\nnot this lock: it outlives a dead owner, and the takeover it then invites is out of scope.\n\n### 3. A hard cap, enforced by reserving the worst case before each call\n\nA cap checked after a call has returned is a report on money already spent. Before admitting a\ncall, the guard reserves an **upper bound on what that call can be billed**, and the cap holds only\nif the bound really is one:\n\n```text\nceiling_price(u) = max(list_price(u), list_price(u) * (1 + margin), provider_max_price(u))\n                   for every billable unit u of the model, as its price sheet lists them\nworst_attempt    = request_fee_ceiling + sum over every billable unit u of max_quantity(u) * ceiling_price(u)\nworst(call)      = worst_attempt * max_attempts\n```\n\n- **Every billable unit, not only tokens.** A call can be billed for input and output tokens\n  (reasoning and other hidden tokens included), cache writes priced above ordinary input, a fee per\n  request, images in and out, audio in and out, hosted search or web queries, code execution, file\n  search and other tool invocations — whatever the price sheet lists for that model. The frozen\n  price table lists every unit the call can incur, and `worst_attempt` sums all of them. A\n  reservation that counts tokens alone is exceeded by the first call that also searched the web.\n- **Every unit has a bound, or the call is not admitted.** `max_quantity(u)` comes from the request\n  itself: the output-token limit, the number of images sent, the cap on tool calls, the cap on\n  search queries. A unit whose quantity the request does not cap — an agent allowed unlimited\n  hosted searches — or that the price table does not list cannot be bounded, so the guard refuses\n  the call. Cap it in the request, or leave that feature out of the study.\n- **The price is a ceiling, not the list price.** Settlement (part 5) charges each attempt, unit by\n  unit, the larger of its list cost and its reported cost. A reservation made at list price is\n  therefore exceeded by the first attempt billed above list, and the cap with it. Take the largest\n  of the frozen list price, the list price plus a margin stated in the plan, and the highest price\n  any provider serving that model charges.\n- **The tokens are a bound under the provider's own count.** `max_input_tokens` is the model's\n  context limit, or a counted size plus a stated margin, not a local estimate that another\n  tokeniser can exceed. `max_output_tokens` is the limit sent with the request. Where the provider\n  bills reasoning or other hidden tokens outside that limit, add their limit as well.\n- **The attempts are every attempt the harness makes, and only those.** That includes its own\n  retries and a failed attempt that is still billed. A client library that retries on its own and\n  returns only the last attempt hides the others: they are billed, settlement never sees them, and\n  the call settles below its real cost. So the library's own retries are off, and the guard refuses\n  to start while they are on. A library whose retries cannot be turned off cannot be used for paid\n  calls: no record read afterwards puts back a bound that was never reserved.\n- **Every stage has its own cap.** Each call belongs to a stage — output parity, the main run,\n  judging, or an addendum's output parity, whose cap that addendum registers — and the stage's\n  pre-registered cap is checked in the same admission as the study's. A call that would still fit\n  the study cap but exceed its stage's is refused.\n\nThe invariant, which holds only under the single-process rule above:\n\n```text\nat every admission:   spent + reserved + worst(call) <= cap\n                      stage_spent[s] + stage_reserved[s] + worst(call) <= stage_cap[s]\nfor every call:       settled cost <= worst(call)\n```\n\nUnder this guard nothing is in flight at an admission, so `reserved` holds only reservations whose\noutcome is unknown: a call that threw before it could be settled, or one a crashed run left\nunsettled (part 6). A settled cost above its reservation means the bound was not a\nbound: the guard latches, writes STOP and closes the ledger (part 6).\n\n### 4. A balance floor, read before every admission, that latches\n\nThe floor holds only on an account that is the study's alone. There, where the provider exposes\nthe account's remaining balance, the guard reads it **before every admission** — nothing else is in\nflight at that moment, so the read describes the state the call will start from.\n\n- **Only an account that is the study's alone.** A balance read can lag, and on a shared account the\n  charges it is missing need not be the study's: another key's, or ones from before the study. No\n  ledger of the study's can subtract those, so the test below is no lower bound there: a balance\n  read stale at 120 against a true 100, with a floor of 90, admits a call of 15 and leaves 85. The\n  floor therefore counts only where the research key is the only key the provider lists on the\n  account and the account carries no charge from before the study — in practice, a new account\n  funded for the study. A time stamped on the balance does not rescue a shared account, because\n  another key can spend after it. Anywhere else the floor is unavailable, and the guard refuses to\n  start on a plan that claims one.\n- **The account's balance, never a key's limit.** A key's remaining spend limit can read healthy\n  while the account it draws on is nearly empty, because credits are account-wide (part 1). A\n  provider that reports only a per-key limit has no balance endpoint for this guard.\n- **A call that would cross the floor is not admitted.** The admission needs\n  `balance - unseen_spend - reserved - worst(call) >= floor`. On an account that is the study's\n  alone, every charge a lagging balance may not show yet is the study's own, and no time stamped on\n  the balance says which it includes, so the guard assumes it shows none of them: `unseen_spend` is\n  every cost the study has settled, in this ledger and in any ledger it closed (part 6). Against a balance that is current, that counts the spend twice\n  and halves the room between the starting balance and the floor, which fails closed; set the floor\n  and the caps with it in mind. `reserved` is every reservation still standing: a call whose\n  outcome is unknown (part 5), or one a crashed run left unsettled (part 6), may have been billed\n  without the balance showing it, so its worst case comes off the balance too. A balance already\n  below the floor fails the same test.\n- **It latches.** The first failure sets a latch that refuses every admission for the rest of the\n  run, and writes a STOP flag in the study directory with the reason. A later read that shows the\n  balance recovered does not lift it: balance reads lag, and a run that re-admits on a lagging read\n  spends past the floor on stale data. Only a person removes the STOP flag, after reading why it\n  was written.\n- **A read that fails is a breach.** A balance that could not be read is treated as one below the\n  floor: fail closed.\n\nWhere the provider exposes no balance, or the account is not the study's alone, record in the plan\nthat the floor is unavailable. The study and stage caps then govern alone — they are the hard limit\nin every study — and should be set with that in mind.\n\n### 5. Settle each call, and write it down before the next\n\nEvery attempt is costed, retries and failures included, because a failed attempt can still be\nbilled:\n\n```text\ncost(attempt) = max(list_cost(attempt), reported_cost(attempt))\ncost(call)    = sum of cost(attempt) over every attempt the call made\n```\n\n`list_cost` uses every billable unit the provider reported — tokens, requests, images, audio,\nsearches, tool invocations — and the frozen price table. When the provider reports no cost for an\nattempt, use the list cost; when it reports no usage for a failed attempt, charge that attempt its\n`worst_attempt`. The ledger keeps one row per attempt the provider billed — which is why the client\nlibrary's own retries are off (part 3) — so the spend can be re-added from the raw rows and the\ntotal checked.\n\nThe reservation row is appended and flushed **before** the call is sent, and counted in memory, and\nthe settled rows **after** it and before the next admission. The ledger on disk is then always at\nmost one call behind the truth, and that one call is recorded as reserved. A guard that kept its\nreservation only in memory has been found to under-count after a crash: the restart (part 6) has\nonly the disk to read.\n\nA call that throws — a network error, a timeout, a client library that gives up — may still have\nbeen billed, and nothing says how much. It is not settled, because there is no cost to settle it\nat. Its reservation stays counted at its worst case, in memory and through an unknown-outcome row in\nthe ledger, and the guard never releases it. A person reconciles it against the provider's own\nrecord and writes the outcome into the ledger. A harness that catches the error and admits the next\ncall therefore still has the unknown call's worst case standing against both caps.\n\n### 6. A restart re-derives every invariant from the ledger\n\nA run that stopped — a crash, a kill, a reboot — is resumed by a new process. The ledger is the only\nrecord that survives it, so the new process rebuilds its totals from the ledger and re-derives every\ninvariant the running guard enforced, before it admits anything:\n\n- `spent` and each `stage_spent[s]` are the sums of the settled rows, per stage as well as for the\n  study. Restoring the study's total but not the stage's lets a stage spend past its cap.\n- A reservation with no settlement is a call that may have been billed when the run stopped. It\n  counts at its worst case in `reserved` and in its stage's `stage_reserved[s]`, and is never\n  released by the guard: a person reconciles it against the provider's own record and writes the\n  outcome into the ledger, while no paying process runs.\n- **Every settled call is checked against its reservation again.** A run can die after flushing a\n  settlement above its reservation and before writing the latch it earned, and a person's\n  reconciliation of an unknown call can record more than its worst case. Either way the bound\n  failed and only the ledger shows it. A settled call above its reservation, or with no\n  reservation, latches and writes STOP before anything is admitted.\n- **The totals are checked against the caps again**, the study's and every stage's, and a breach\n  latches the same way.\n- A STOP flag, or a latch recorded in the ledger, refuses the restart until a person clears it.\n\nA reconciliation therefore takes effect only at the next start, which checks it like any other\nsettlement.\n\n**A broken bound closes the ledger for good.** A settlement above its reservation, or a total above\nits cap, stays in the ledger, so every later start finds it again and refuses: clearing STOP does\nnot resume that ledger, and nothing should. Continuing the study takes a dated addendum that\ncorrects the bound and re-freezes what it changed, and a new, empty ledger. Its caps are what the\nold caps had left after everything the closed ledger settled, per stage, with that ledger's\nunsettled calls reconciled first; and where there is a floor, `unseen_spend` goes on counting\neverything the closed ledger settled.\n\n## The admission path\n\n```text\nstart():\n    take the OS lock on <study>/guard.lock without waiting      # held until the process exits\n        or refuse: \"another paying process holds this study\"\n    refuse unless the provider names the research key's account, and it is not production's   # a plan's record is no binding\n    refuse if the research key equals production's              # compared by hash, never printed\n    refuse if the harness holds any paid credential but the research key   # one account, one balance\n    refuse if the client library retries on its own             # every attempt is one the harness makes\n    refuse if the plan has a floor and the account is not the study's alone   # a shared balance bounds nothing\n    spent, stage_spent[s]       = sums of the settled rows       # restore from the ledger\n    unseen_spend                = spent + all that any ledger this study closed settled   # no balance is assumed to show it\n    reserved, stage_reserved[s] = worst cases of reservations with no settlement   # never released here\n    for every settled call in the ledger:                        # re-derive every invariant; assume none\n        if its settled cost > its reservation, or it has no reservation:\n            latched = true; write STOP flag with the reason\n    if spent + reserved > cap, or stage_spent[s] + stage_reserved[s] > stage_cap[s] for any s:\n        latched = true; write STOP flag with the reason\n    if STOP flag exists or the ledger records a latch: refuse\n\ncall(c):                                                         # one at a time: nothing else is in flight\n    if latched:                                               refuse\n    w = worst(c)                                                 # every billable unit, at its bound and ceiling\n    if w is unbounded:                                        refuse        # a unit with no cap or no price\n    s = c.stage\n    if spent + reserved + w > cap:                            refuse        # the study's cap\n    if stage_spent[s] + stage_reserved[s] + w > stage_cap[s]: refuse        # the stage's own cap\n    if floor_available:\n        balance = read the account's balance                     # before this admission, every time; never a key's limit\n        if the read failed or balance - unseen_spend - reserved - w < floor:\n            latched = true; write STOP flag with the reason;  refuse\n    ledger.append(reserved row: c, s, w); flush                  # on disk before the call is sent\n    reserved += w; stage_reserved[s] += w                        # counted in memory until it settles\n    try:\n        attempts = send c                                        # the only call in flight\n    except any error:                                            # the outcome is unknown: it may be billed\n        ledger.append(unknown-outcome row: c, s); flush          # the reservation stays counted, never released here\n        raise                                                    # a call whose bill is unknown is not settled\n    actual = sum(max(list_cost(a), reported_cost(a)) for a in attempts)\n    ledger.append(settled rows: s, one per attempt); flush       # on disk before the next admission\n    reserved -= w; stage_reserved[s] -= w\n    spent += actual; stage_spent[s] += actual; unseen_spend += actual\n    if actual > w:                                               # the bound was not a bound\n        latched = true; write STOP flag with the reason\n```\n\nThere is no lock around the totals because there is nothing to race: one process, one call. That\nsimplicity is the point of the scope rule, and the reason it is a rule — every line above assumes\nit.\n\n## Arming each part\n\nA guard nobody has watched refuse is a claim. Each part takes about a minute to arm, with no paid\ncall and no real key:\n\n| Part | Mutation | Expected |\n|---|---|---|\n| Research key | set both key variables to the same fake value | refuses at start-up, prints no value |\n| Same account, another key | give the research key a second key under production's account or project | refuses at start-up: the account identities match |\n| No account binding | stub a provider that names no account for the research key, and write a billing account into the plan | refuses at start-up: a recorded account is not a binding |\n| Second credential | give one judge its own vendor key beside the research key, then start the run | refuses at start-up |\n| Lock | start a second paying process while the first holds the lock | the second refuses to start |\n| Lock released on death | kill the first process outright, then start another | the new process takes the lock at once: no stale lock, no takeover |\n| Cap | set the cap below one call's worst case | refuses the first admission |\n| Stage cap | admit an output-parity call whose worst case fits the study cap but exceeds the parity stage's cap | refused |\n| Floor | stub the balance read to return less than the floor | latches, writes STOP with the reason, refuses this and every later admission |\n| Floor with an unknown call | let a call throw after its reservation, then stub a lagging balance that does not show it, and admit a call that fits only if the thrown call is forgotten | latches and refuses: the thrown call's worst case comes off the balance |\n| Floor crossing | stub a balance just above the floor, then admit a call whose worst case would cross it | latches and refuses, though the call fits the study cap |\n| Lagging balance | settle a call, then stub a balance that does not show it, and admit a call that fits only if that settled cost is forgotten | latches and refuses: every settled cost comes off the balance |\n| Read failure | stub the balance read to fail | latches and refuses: an unreadable balance is a breach |\n| No balance endpoint | run with the floor marked unavailable; admit a call that fits the caps | admitted on the caps alone |\n| Floor on a shared account | plan a floor on an account that lists a second key, or carries a charge from before the study | refuses at start-up: the floor is unavailable there |\n| Settlement above the reservation | settle a call whose reported cost exceeds its reservation | latches, writes STOP, refuses the next admission |\n| Thrown call | make the send throw after the reservation row is written, catch it, and admit the next call | the thrown call's worst case still counts against the study and stage caps; nothing released it |\n| Restart | kill the process after a reservation row and before its settlement, then start another | the unsettled reservation counts at its worst case, for the study and its stage; settled totals are restored per stage |\n| Restart after an over-settlement | write a settled row above its reservation, with no latch and no STOP flag — a run that died before latching, or a reconciliation above the worst case — then start the run | latches, writes STOP and refuses before admitting anything; clearing STOP and starting again refuses again |\n| Hidden retry | turn the client library's own retries on, at any limit, then start the run | refuses at start-up |\n| Harness retry | stub a transport that fails the first attempt, and let the harness retry | the ledger shows both attempts, each costed, summed into the call |\n| STOP flag | create the flag by hand, then start the run | refuses until a person removes it |\n| Unbounded unit | admit a call whose hosted-search or tool invocations are not capped in the request | refused at admission: the unit has no bound |\n| Unlisted unit | admit a call that can incur a unit the frozen price table does not list | refused at admission |\n| Costing | settle an attempt with reported cost above list but within the ceiling | the ledger records the reported cost, and no latch |\n\nRecord each run's output in the audit, with the mutation that produced it. Restore every stub\nbefore the real run, and check that it is restored by reading the code, not by trusting that the\nnext run passes.\n","bodyHtml":"<h2 id=\"the-budget-guard\">The budget guard</h2>\n<p>The guard sits between the harness and the provider, and every paid call passes through it. It\nexists because the ways a study overspends are all ordinary: a retry loop nobody bounded, a second\nterminal that started the same run, a balance that read healthy a minute after it was not, a cap\nchecked against what was spent rather than what was about to be. Each part below closes one of\nthem, and each one is armed — watched refusing — before the guard is trusted with a real call.</p>\n<h3 id=\"scope-one-paying-process-one-call-at-a-time\">Scope: one paying process, one call at a time</h3>\n<p>This guard is deliberately single-threaded. <strong>One</strong> paying process holds the study for the whole\nrun, and it admits, sends and settles <strong>one</strong> call at a time: nothing else is in flight while a\ncall is admitted, and every ledger row is written before the next admission. The cap is hard only\nunder that rule.</p>\n<p>Concurrency is out of scope: calls in parallel inside the process, two paying processes, balance\nreads running alongside calls, locks on shared storage or across hosts, and taking over another\nprocess&#39;s lock. A study that needs any of them needs a different guard, and running one of them\nunder this one voids the cap — two processes that each believe the remaining budget is theirs\nspend twice it, and parallel calls each reserve against a total the others have not yet added to.</p>\n<h3 id=\"the-parts\">The parts</h3>\n<h4 id=\"1-one-research-account-refused-if-it-is-productions\">1. One research account, refused if it is production&#39;s</h4>\n<p>Every paid call the study makes — every arm, every judge — goes through one research account: one\nkey and one balance, such as a multi-vendor gateway&#39;s. That is what lets one guard hold the cap and\nthe floor. A study whose providers need separate accounts is out of scope, because each account\nwould need a guard of its own. The account is the study&#39;s own, so that a runaway study cannot spend\nproduction&#39;s money or exhaust production&#39;s rate limit.</p>\n<p>Unequal keys do not show that. A provider can issue many keys under one billing organisation or\nproject, and every one of them spends that account&#39;s balance and rate limit. A key is a view onto\nits account: one study found that a key&#39;s own spend limit was not the account&#39;s spendable balance,\nbecause credits are account-wide and shared with every other key on it. So at start-up the guard\ncompares <strong>accounts</strong>: the non-secret account or project identity the provider names for the\nresearch key, against the one it names for production&#39;s. Only the provider can bind a key to the\naccount it bills. A billing account written in the plan records which account someone meant the key\nto bill, not which one the provider bills, so it is not a binding. A provider that cannot name the\naccount behind a key is out of scope, and the guard refuses to start. It also compares the two keys&#39;\nhashes in memory, refusing when they are equal, and prints nothing but the outcomes. And it refuses\nwhile the harness holds any other paid credential: a judge called on its own vendor key spends\noutside the balance the guard reads, and that key may be production&#39;s.</p>\n<p>If production&#39;s identity or key is not readable where the study runs, the check cannot run. Say so,\nand treat it as a reason to run the study somewhere it can — not as a pass.</p>\n<h4 id=\"2-one-paying-process-holding-a-lock-the-kernel-releases\">2. One paying process, holding a lock the kernel releases</h4>\n<p>At start-up the guard takes an exclusive operating-system lock on a file in the study directory —\nan advisory lock on an open file, such as <code>flock</code>, on a local file system — without waiting, and\nholds it until the process exits. A second process that tries to take it fails at once and refuses\nto start.</p>\n<p>The kernel releases the lock when the process exits or dies, so a crashed run never leaves a stale\nlock behind, and there is nothing to take over. A paused process still holds it, so nobody starts\npaying while it might wake up. A file whose mere existence is the lock — an exclusive create — is\nnot this lock: it outlives a dead owner, and the takeover it then invites is out of scope.</p>\n<h4 id=\"3-a-hard-cap-enforced-by-reserving-the-worst-case-before-each-call\">3. A hard cap, enforced by reserving the worst case before each call</h4>\n<p>A cap checked after a call has returned is a report on money already spent. Before admitting a\ncall, the guard reserves an <strong>upper bound on what that call can be billed</strong>, and the cap holds only\nif the bound really is one:</p>\n<pre><code class=\"language-text\">ceiling_price(u) = max(list_price(u), list_price(u) * (1 + margin), provider_max_price(u))\n                   for every billable unit u of the model, as its price sheet lists them\nworst_attempt    = request_fee_ceiling + sum over every billable unit u of max_quantity(u) * ceiling_price(u)\nworst(call)      = worst_attempt * max_attempts\n</code></pre>\n<ul>\n<li><strong>Every billable unit, not only tokens.</strong> A call can be billed for input and output tokens\n(reasoning and other hidden tokens included), cache writes priced above ordinary input, a fee per\nrequest, images in and out, audio in and out, hosted search or web queries, code execution, file\nsearch and other tool invocations — whatever the price sheet lists for that model. The frozen\nprice table lists every unit the call can incur, and <code>worst_attempt</code> sums all of them. A\nreservation that counts tokens alone is exceeded by the first call that also searched the web.</li>\n<li><strong>Every unit has a bound, or the call is not admitted.</strong> <code>max_quantity(u)</code> comes from the request\nitself: the output-token limit, the number of images sent, the cap on tool calls, the cap on\nsearch queries. A unit whose quantity the request does not cap — an agent allowed unlimited\nhosted searches — or that the price table does not list cannot be bounded, so the guard refuses\nthe call. Cap it in the request, or leave that feature out of the study.</li>\n<li><strong>The price is a ceiling, not the list price.</strong> Settlement (part 5) charges each attempt, unit by\nunit, the larger of its list cost and its reported cost. A reservation made at list price is\ntherefore exceeded by the first attempt billed above list, and the cap with it. Take the largest\nof the frozen list price, the list price plus a margin stated in the plan, and the highest price\nany provider serving that model charges.</li>\n<li><strong>The tokens are a bound under the provider&#39;s own count.</strong> <code>max_input_tokens</code> is the model&#39;s\ncontext limit, or a counted size plus a stated margin, not a local estimate that another\ntokeniser can exceed. <code>max_output_tokens</code> is the limit sent with the request. Where the provider\nbills reasoning or other hidden tokens outside that limit, add their limit as well.</li>\n<li><strong>The attempts are every attempt the harness makes, and only those.</strong> That includes its own\nretries and a failed attempt that is still billed. A client library that retries on its own and\nreturns only the last attempt hides the others: they are billed, settlement never sees them, and\nthe call settles below its real cost. So the library&#39;s own retries are off, and the guard refuses\nto start while they are on. A library whose retries cannot be turned off cannot be used for paid\ncalls: no record read afterwards puts back a bound that was never reserved.</li>\n<li><strong>Every stage has its own cap.</strong> Each call belongs to a stage — output parity, the main run,\njudging, or an addendum&#39;s output parity, whose cap that addendum registers — and the stage&#39;s\npre-registered cap is checked in the same admission as the study&#39;s. A call that would still fit\nthe study cap but exceed its stage&#39;s is refused.</li>\n</ul>\n<p>The invariant, which holds only under the single-process rule above:</p>\n<pre><code class=\"language-text\">at every admission:   spent + reserved + worst(call) &lt;= cap\n                      stage_spent[s] + stage_reserved[s] + worst(call) &lt;= stage_cap[s]\nfor every call:       settled cost &lt;= worst(call)\n</code></pre>\n<p>Under this guard nothing is in flight at an admission, so <code>reserved</code> holds only reservations whose\noutcome is unknown: a call that threw before it could be settled, or one a crashed run left\nunsettled (part 6). A settled cost above its reservation means the bound was not a\nbound: the guard latches, writes STOP and closes the ledger (part 6).</p>\n<h4 id=\"4-a-balance-floor-read-before-every-admission-that-latches\">4. A balance floor, read before every admission, that latches</h4>\n<p>The floor holds only on an account that is the study&#39;s alone. There, where the provider exposes\nthe account&#39;s remaining balance, the guard reads it <strong>before every admission</strong> — nothing else is in\nflight at that moment, so the read describes the state the call will start from.</p>\n<ul>\n<li><strong>Only an account that is the study&#39;s alone.</strong> A balance read can lag, and on a shared account the\ncharges it is missing need not be the study&#39;s: another key&#39;s, or ones from before the study. No\nledger of the study&#39;s can subtract those, so the test below is no lower bound there: a balance\nread stale at 120 against a true 100, with a floor of 90, admits a call of 15 and leaves 85. The\nfloor therefore counts only where the research key is the only key the provider lists on the\naccount and the account carries no charge from before the study — in practice, a new account\nfunded for the study. A time stamped on the balance does not rescue a shared account, because\nanother key can spend after it. Anywhere else the floor is unavailable, and the guard refuses to\nstart on a plan that claims one.</li>\n<li><strong>The account&#39;s balance, never a key&#39;s limit.</strong> A key&#39;s remaining spend limit can read healthy\nwhile the account it draws on is nearly empty, because credits are account-wide (part 1). A\nprovider that reports only a per-key limit has no balance endpoint for this guard.</li>\n<li><strong>A call that would cross the floor is not admitted.</strong> The admission needs\n<code>balance - unseen_spend - reserved - worst(call) &gt;= floor</code>. On an account that is the study&#39;s\nalone, every charge a lagging balance may not show yet is the study&#39;s own, and no time stamped on\nthe balance says which it includes, so the guard assumes it shows none of them: <code>unseen_spend</code> is\nevery cost the study has settled, in this ledger and in any ledger it closed (part 6). Against a balance that is current, that counts the spend twice\nand halves the room between the starting balance and the floor, which fails closed; set the floor\nand the caps with it in mind. <code>reserved</code> is every reservation still standing: a call whose\noutcome is unknown (part 5), or one a crashed run left unsettled (part 6), may have been billed\nwithout the balance showing it, so its worst case comes off the balance too. A balance already\nbelow the floor fails the same test.</li>\n<li><strong>It latches.</strong> The first failure sets a latch that refuses every admission for the rest of the\nrun, and writes a STOP flag in the study directory with the reason. A later read that shows the\nbalance recovered does not lift it: balance reads lag, and a run that re-admits on a lagging read\nspends past the floor on stale data. Only a person removes the STOP flag, after reading why it\nwas written.</li>\n<li><strong>A read that fails is a breach.</strong> A balance that could not be read is treated as one below the\nfloor: fail closed.</li>\n</ul>\n<p>Where the provider exposes no balance, or the account is not the study&#39;s alone, record in the plan\nthat the floor is unavailable. The study and stage caps then govern alone — they are the hard limit\nin every study — and should be set with that in mind.</p>\n<h4 id=\"5-settle-each-call-and-write-it-down-before-the-next\">5. Settle each call, and write it down before the next</h4>\n<p>Every attempt is costed, retries and failures included, because a failed attempt can still be\nbilled:</p>\n<pre><code class=\"language-text\">cost(attempt) = max(list_cost(attempt), reported_cost(attempt))\ncost(call)    = sum of cost(attempt) over every attempt the call made\n</code></pre>\n<p><code>list_cost</code> uses every billable unit the provider reported — tokens, requests, images, audio,\nsearches, tool invocations — and the frozen price table. When the provider reports no cost for an\nattempt, use the list cost; when it reports no usage for a failed attempt, charge that attempt its\n<code>worst_attempt</code>. The ledger keeps one row per attempt the provider billed — which is why the client\nlibrary&#39;s own retries are off (part 3) — so the spend can be re-added from the raw rows and the\ntotal checked.</p>\n<p>The reservation row is appended and flushed <strong>before</strong> the call is sent, and counted in memory, and\nthe settled rows <strong>after</strong> it and before the next admission. The ledger on disk is then always at\nmost one call behind the truth, and that one call is recorded as reserved. A guard that kept its\nreservation only in memory has been found to under-count after a crash: the restart (part 6) has\nonly the disk to read.</p>\n<p>A call that throws — a network error, a timeout, a client library that gives up — may still have\nbeen billed, and nothing says how much. It is not settled, because there is no cost to settle it\nat. Its reservation stays counted at its worst case, in memory and through an unknown-outcome row in\nthe ledger, and the guard never releases it. A person reconciles it against the provider&#39;s own\nrecord and writes the outcome into the ledger. A harness that catches the error and admits the next\ncall therefore still has the unknown call&#39;s worst case standing against both caps.</p>\n<h4 id=\"6-a-restart-re-derives-every-invariant-from-the-ledger\">6. A restart re-derives every invariant from the ledger</h4>\n<p>A run that stopped — a crash, a kill, a reboot — is resumed by a new process. The ledger is the only\nrecord that survives it, so the new process rebuilds its totals from the ledger and re-derives every\ninvariant the running guard enforced, before it admits anything:</p>\n<ul>\n<li><code>spent</code> and each <code>stage_spent[s]</code> are the sums of the settled rows, per stage as well as for the\nstudy. Restoring the study&#39;s total but not the stage&#39;s lets a stage spend past its cap.</li>\n<li>A reservation with no settlement is a call that may have been billed when the run stopped. It\ncounts at its worst case in <code>reserved</code> and in its stage&#39;s <code>stage_reserved[s]</code>, and is never\nreleased by the guard: a person reconciles it against the provider&#39;s own record and writes the\noutcome into the ledger, while no paying process runs.</li>\n<li><strong>Every settled call is checked against its reservation again.</strong> A run can die after flushing a\nsettlement above its reservation and before writing the latch it earned, and a person&#39;s\nreconciliation of an unknown call can record more than its worst case. Either way the bound\nfailed and only the ledger shows it. A settled call above its reservation, or with no\nreservation, latches and writes STOP before anything is admitted.</li>\n<li><strong>The totals are checked against the caps again</strong>, the study&#39;s and every stage&#39;s, and a breach\nlatches the same way.</li>\n<li>A STOP flag, or a latch recorded in the ledger, refuses the restart until a person clears it.</li>\n</ul>\n<p>A reconciliation therefore takes effect only at the next start, which checks it like any other\nsettlement.</p>\n<p><strong>A broken bound closes the ledger for good.</strong> A settlement above its reservation, or a total above\nits cap, stays in the ledger, so every later start finds it again and refuses: clearing STOP does\nnot resume that ledger, and nothing should. Continuing the study takes a dated addendum that\ncorrects the bound and re-freezes what it changed, and a new, empty ledger. Its caps are what the\nold caps had left after everything the closed ledger settled, per stage, with that ledger&#39;s\nunsettled calls reconciled first; and where there is a floor, <code>unseen_spend</code> goes on counting\neverything the closed ledger settled.</p>\n<h3 id=\"the-admission-path\">The admission path</h3>\n<pre><code class=\"language-text\">start():\n    take the OS lock on &lt;study&gt;/guard.lock without waiting      # held until the process exits\n        or refuse: &quot;another paying process holds this study&quot;\n    refuse unless the provider names the research key&#39;s account, and it is not production&#39;s   # a plan&#39;s record is no binding\n    refuse if the research key equals production&#39;s              # compared by hash, never printed\n    refuse if the harness holds any paid credential but the research key   # one account, one balance\n    refuse if the client library retries on its own             # every attempt is one the harness makes\n    refuse if the plan has a floor and the account is not the study&#39;s alone   # a shared balance bounds nothing\n    spent, stage_spent[s]       = sums of the settled rows       # restore from the ledger\n    unseen_spend                = spent + all that any ledger this study closed settled   # no balance is assumed to show it\n    reserved, stage_reserved[s] = worst cases of reservations with no settlement   # never released here\n    for every settled call in the ledger:                        # re-derive every invariant; assume none\n        if its settled cost &gt; its reservation, or it has no reservation:\n            latched = true; write STOP flag with the reason\n    if spent + reserved &gt; cap, or stage_spent[s] + stage_reserved[s] &gt; stage_cap[s] for any s:\n        latched = true; write STOP flag with the reason\n    if STOP flag exists or the ledger records a latch: refuse\n\ncall(c):                                                         # one at a time: nothing else is in flight\n    if latched:                                               refuse\n    w = worst(c)                                                 # every billable unit, at its bound and ceiling\n    if w is unbounded:                                        refuse        # a unit with no cap or no price\n    s = c.stage\n    if spent + reserved + w &gt; cap:                            refuse        # the study&#39;s cap\n    if stage_spent[s] + stage_reserved[s] + w &gt; stage_cap[s]: refuse        # the stage&#39;s own cap\n    if floor_available:\n        balance = read the account&#39;s balance                     # before this admission, every time; never a key&#39;s limit\n        if the read failed or balance - unseen_spend - reserved - w &lt; floor:\n            latched = true; write STOP flag with the reason;  refuse\n    ledger.append(reserved row: c, s, w); flush                  # on disk before the call is sent\n    reserved += w; stage_reserved[s] += w                        # counted in memory until it settles\n    try:\n        attempts = send c                                        # the only call in flight\n    except any error:                                            # the outcome is unknown: it may be billed\n        ledger.append(unknown-outcome row: c, s); flush          # the reservation stays counted, never released here\n        raise                                                    # a call whose bill is unknown is not settled\n    actual = sum(max(list_cost(a), reported_cost(a)) for a in attempts)\n    ledger.append(settled rows: s, one per attempt); flush       # on disk before the next admission\n    reserved -= w; stage_reserved[s] -= w\n    spent += actual; stage_spent[s] += actual; unseen_spend += actual\n    if actual &gt; w:                                               # the bound was not a bound\n        latched = true; write STOP flag with the reason\n</code></pre>\n<p>There is no lock around the totals because there is nothing to race: one process, one call. That\nsimplicity is the point of the scope rule, and the reason it is a rule — every line above assumes\nit.</p>\n<h3 id=\"arming-each-part\">Arming each part</h3>\n<p>A guard nobody has watched refuse is a claim. Each part takes about a minute to arm, with no paid\ncall and no real key:</p>\n<table>\n<thead>\n<tr>\n<th>Part</th>\n<th>Mutation</th>\n<th>Expected</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Research key</td>\n<td>set both key variables to the same fake value</td>\n<td>refuses at start-up, prints no value</td>\n</tr>\n<tr>\n<td>Same account, another key</td>\n<td>give the research key a second key under production&#39;s account or project</td>\n<td>refuses at start-up: the account identities match</td>\n</tr>\n<tr>\n<td>No account binding</td>\n<td>stub a provider that names no account for the research key, and write a billing account into the plan</td>\n<td>refuses at start-up: a recorded account is not a binding</td>\n</tr>\n<tr>\n<td>Second credential</td>\n<td>give one judge its own vendor key beside the research key, then start the run</td>\n<td>refuses at start-up</td>\n</tr>\n<tr>\n<td>Lock</td>\n<td>start a second paying process while the first holds the lock</td>\n<td>the second refuses to start</td>\n</tr>\n<tr>\n<td>Lock released on death</td>\n<td>kill the first process outright, then start another</td>\n<td>the new process takes the lock at once: no stale lock, no takeover</td>\n</tr>\n<tr>\n<td>Cap</td>\n<td>set the cap below one call&#39;s worst case</td>\n<td>refuses the first admission</td>\n</tr>\n<tr>\n<td>Stage cap</td>\n<td>admit an output-parity call whose worst case fits the study cap but exceeds the parity stage&#39;s cap</td>\n<td>refused</td>\n</tr>\n<tr>\n<td>Floor</td>\n<td>stub the balance read to return less than the floor</td>\n<td>latches, writes STOP with the reason, refuses this and every later admission</td>\n</tr>\n<tr>\n<td>Floor with an unknown call</td>\n<td>let a call throw after its reservation, then stub a lagging balance that does not show it, and admit a call that fits only if the thrown call is forgotten</td>\n<td>latches and refuses: the thrown call&#39;s worst case comes off the balance</td>\n</tr>\n<tr>\n<td>Floor crossing</td>\n<td>stub a balance just above the floor, then admit a call whose worst case would cross it</td>\n<td>latches and refuses, though the call fits the study cap</td>\n</tr>\n<tr>\n<td>Lagging balance</td>\n<td>settle a call, then stub a balance that does not show it, and admit a call that fits only if that settled cost is forgotten</td>\n<td>latches and refuses: every settled cost comes off the balance</td>\n</tr>\n<tr>\n<td>Read failure</td>\n<td>stub the balance read to fail</td>\n<td>latches and refuses: an unreadable balance is a breach</td>\n</tr>\n<tr>\n<td>No balance endpoint</td>\n<td>run with the floor marked unavailable; admit a call that fits the caps</td>\n<td>admitted on the caps alone</td>\n</tr>\n<tr>\n<td>Floor on a shared account</td>\n<td>plan a floor on an account that lists a second key, or carries a charge from before the study</td>\n<td>refuses at start-up: the floor is unavailable there</td>\n</tr>\n<tr>\n<td>Settlement above the reservation</td>\n<td>settle a call whose reported cost exceeds its reservation</td>\n<td>latches, writes STOP, refuses the next admission</td>\n</tr>\n<tr>\n<td>Thrown call</td>\n<td>make the send throw after the reservation row is written, catch it, and admit the next call</td>\n<td>the thrown call&#39;s worst case still counts against the study and stage caps; nothing released it</td>\n</tr>\n<tr>\n<td>Restart</td>\n<td>kill the process after a reservation row and before its settlement, then start another</td>\n<td>the unsettled reservation counts at its worst case, for the study and its stage; settled totals are restored per stage</td>\n</tr>\n<tr>\n<td>Restart after an over-settlement</td>\n<td>write a settled row above its reservation, with no latch and no STOP flag — a run that died before latching, or a reconciliation above the worst case — then start the run</td>\n<td>latches, writes STOP and refuses before admitting anything; clearing STOP and starting again refuses again</td>\n</tr>\n<tr>\n<td>Hidden retry</td>\n<td>turn the client library&#39;s own retries on, at any limit, then start the run</td>\n<td>refuses at start-up</td>\n</tr>\n<tr>\n<td>Harness retry</td>\n<td>stub a transport that fails the first attempt, and let the harness retry</td>\n<td>the ledger shows both attempts, each costed, summed into the call</td>\n</tr>\n<tr>\n<td>STOP flag</td>\n<td>create the flag by hand, then start the run</td>\n<td>refuses until a person removes it</td>\n</tr>\n<tr>\n<td>Unbounded unit</td>\n<td>admit a call whose hosted-search or tool invocations are not capped in the request</td>\n<td>refused at admission: the unit has no bound</td>\n</tr>\n<tr>\n<td>Unlisted unit</td>\n<td>admit a call that can incur a unit the frozen price table does not list</td>\n<td>refused at admission</td>\n</tr>\n<tr>\n<td>Costing</td>\n<td>settle an attempt with reported cost above list but within the ceiling</td>\n<td>the ledger records the reported cost, and no latch</td>\n</tr>\n</tbody></table>\n<p>Record each run&#39;s output in the audit, with the mutation that produced it. Restore every stub\nbefore the real run, and check that it is restored by reading the code, not by trusting that the\nnext run passes.</p>\n","words":3996},{"path":"references/judging-and-metrics.md","slug":"judging-and-metrics","title":"Judging and metrics","body":"# Judging and metrics\n\nWhere the truth is not in a lookup table, a panel of model judges produces the key the arms are\nscored against. This page covers how that panel is built so that it can see the failure that\nmatters most, how its results are reported, and how the numbers built on it are stated.\n\n## The panel\n\n- **Three judges from three vendors.** An item's verdict is the 2-of-3 majority; on a graded scale,\n  the median. One vendor's blind spots are not another's, and a single judge's taste is not a key.\n- **On the study's one account.** Every judge is called through the same research account as the\n  arms, and so through the guard: a judge on its own vendor key spends outside the balance the guard\n  reads. Data a judge may not receive is not in the study.\n- **One frozen rubric**, the same for every judge, hashed in the freeze.\n- **Blind to the arm.** Answers are labelled neutrally and, where a judge sees more than one, shown\n  in an order shuffled per item, so that position and labels cannot lean on the verdict.\n- **Own-vendor overlap named in the plan.** Where a judge shares a vendor with an arm, the plan says\n  so, and the per-judge report below shows whether it favoured its own.\n\n## Provenance: why a judge misses invention\n\nThe failure that matters most is invention: an answer given where the evidence cannot determine\nit. A judge catches it only if it can tell what the evidence actually says from what a model added.\n\nIn many pipelines the evidence shown to a model is itself partly model-made — a summary an earlier\nstep wrote, attributes an earlier step guessed. Give the judge that same evidence, untagged, and an\nanswer built on a guessed field looks supported: the field is right there. The judge marks the\ninvention correct, and does it fluently. A judge given the same untagged evidence as the model\ncannot detect invented evidence. That is not a weakness of a particular judge; the information it\nwould need is not on the page.\n\nTwo changes put it on the page:\n\n- **Tag every field with where it came from.** The source, or written by a model, or guessed by a\n  model.\n- **Add a source-only reading.** Separately, the judge sees only the source and answers one question\n  per field: can this be determined from the source alone, and if so, what is it?\n\n```text\nEVIDENCE — every line says where it came from\n[source]          title: <...>\n[source]          description: <...>\n[model-written]   summary: <...>        written by an earlier pipeline step\n[model-guessed]   <field>: <...>        inferred; the source does not state it\n\nANSWER UNDER REVIEW\n<field>: <value>\n\nSOURCE-ONLY READING\nUsing only the [source] lines: can <field> be determined?  yes / no / partly\nIf yes, what is it?\n```\n\nAn answer counts as an invention when it gives a value and the source-only reading says the field\ncannot be determined. The verdict on the tagged evidence then says whether the value was at least\nconsistent with what a model had written, which is a different and lesser question.\n\n## Reporting each judge alone\n\nReport the majority, and beside it every judge's own result on every bar. Then ask, for each bar:\nwould the verdict change if any one judge were removed? A verdict that flips without one judge\nrests on that judge, and the report says so. Add the pairwise agreement between judges, and, for a\njudge that shares a vendor with an arm, its verdicts on that arm against its verdicts on the others.\n\n## Keying only where the arms differ\n\nJudging every answer of every arm is the expensive part. Where two arms give the same answer to an\nitem, they get the same verdict, so the item cannot contribute to the difference between them — on\nan **item-wise additive** metric: a sum of per-item scores, each a function of that item and that\nanswer alone, over a denominator that is the same for every arm and fixed before any judging. For\nsuch a metric, judging only the items where the arms' answers differ therefore gives the\n**difference** between arms exactly — and gives no absolute rate at all. Report it that way: a\ndifference, with absolute rates marked not measured, unless the agreeing items are judged too.\n\n**Every other metric is judged on every item.** A median, a precision, an F1 — anything computed\nfrom an arm's whole set of answers — is not a sum over items, and an agreeing item can still move\nit. A rate whose denominator the judges decide is not over a fixed denominator. Invention is one of\nthose: its denominator, the items whose source leaves the field undeterminable, comes from the\nsource-only reading, so invention is never scored under the shortcut.\n\n**One verdict per answer, in both paths.** The panel evaluates each normalised (item, answer) once,\nand every arm that gave that answer reuses the verdict — when every item is judged, and under the\nshortcut alike. A model judge asked twice about the same answer can disagree with itself; judged\nonce per arm, identical answers would get different verdicts, and the judge's own noise would read\nas a difference between arms.\n\nThe shortcut is exact only under conditions that are easy to break:\n\n- \"the same answer\" must mean equal under the scorer's own comparison, field by field where the\n  scorer scores fields;\n- a verdict must depend only on the item and the answer — not on the arm's label, on the position\n  of the answer, or on other answers shown in the same judge prompt (a pairwise judge breaks this);\n- with more than two arms, an item is judged when any arm differs from any other.\n\nBefore relying on it, test it on a fixture. Use a deterministic stand-in judge — a function of the\nitem and the answer — so that the test checks the shortcut's own logic and not the judges' noise.\nScore the fixture with every answer judged, then with the shortcut, and require every difference\nbetween arms, on every metric the shortcut is used for, to be identical. Then break the shortcut —\nkey on the arm label, or compare answers before normalising them — and watch the test fail.\n\n## Metrics\n\n### Invention is a bar\n\nInvention gets its own bar in the plan, with its own predicate: the items whose source leaves the\nfield undeterminable. Folded into accuracy it disappears, because a confident invention and an\nhonest error weigh the same there. Read the definition against real items before freezing it. A\n\"no\" on a field that does not apply to the item — this tool is not waterproof, this document has no\nsignature — is an answer about applicability, not an invented value, and a definition that cannot\ntell the two apart can flip a verdict.\n\nAn arm that abstains more often will look worse on coverage and better on invention. Report both,\nside by side, so that neither number is read alone.\n\n### Denominators match across arms\n\nEvery arm is scored on the same items. A timeout, a refusal or a malformed response is a failure in\nthe arm that produced it, scored as one. It is never an exclusion from that arm alone, which would\nquietly remove an arm's hardest items from its own denominator. Where an item has to go — its\nsource vanished, its ground truth is disputed — it leaves every arm, and the report counts it.\n\n### Every percentage carries its predicate\n\nThe same answers give very different rates over \"all items\", \"items with an answer\" and \"items\nwhose source determines the answer\". Write the predicate and the count beside every percentage:\n\n```text\n4.1% invention — of items whose source leaves the field undeterminable (n = 612, both arms)\n```\n\nA percentage without its predicate cannot be compared with anything, including the same study's\nother percentages.\n\n### Passing the bar is not being better\n\nA non-inferiority bar answers one question: is the candidate safe to switch to? It does not say\nwhich arm is better. Report, for every arm:\n\n| | Bars | Quality (observed) | Harm | Cost per item | Cost at expected volume |\n|---|---|---|---|---|---|\n| A (control) | — | <with predicate> | <invention, consequential errors> | <amount> | <amount> |\n| B | pass / fail per bar | <with predicate> | <...> | <amount> | <amount> |\n\nThen write the recommendation in the terms of the question it answers: \"B is safe to switch to\nunder the registered bars\" and \"B is the better arm on observed quality and harm\" are different\nclaims, and only the evidence for each one supports it.\n","bodyHtml":"<h2 id=\"judging-and-metrics\">Judging and metrics</h2>\n<p>Where the truth is not in a lookup table, a panel of model judges produces the key the arms are\nscored against. This page covers how that panel is built so that it can see the failure that\nmatters most, how its results are reported, and how the numbers built on it are stated.</p>\n<h3 id=\"the-panel\">The panel</h3>\n<ul>\n<li><strong>Three judges from three vendors.</strong> An item&#39;s verdict is the 2-of-3 majority; on a graded scale,\nthe median. One vendor&#39;s blind spots are not another&#39;s, and a single judge&#39;s taste is not a key.</li>\n<li><strong>On the study&#39;s one account.</strong> Every judge is called through the same research account as the\narms, and so through the guard: a judge on its own vendor key spends outside the balance the guard\nreads. Data a judge may not receive is not in the study.</li>\n<li><strong>One frozen rubric</strong>, the same for every judge, hashed in the freeze.</li>\n<li><strong>Blind to the arm.</strong> Answers are labelled neutrally and, where a judge sees more than one, shown\nin an order shuffled per item, so that position and labels cannot lean on the verdict.</li>\n<li><strong>Own-vendor overlap named in the plan.</strong> Where a judge shares a vendor with an arm, the plan says\nso, and the per-judge report below shows whether it favoured its own.</li>\n</ul>\n<h3 id=\"provenance-why-a-judge-misses-invention\">Provenance: why a judge misses invention</h3>\n<p>The failure that matters most is invention: an answer given where the evidence cannot determine\nit. A judge catches it only if it can tell what the evidence actually says from what a model added.</p>\n<p>In many pipelines the evidence shown to a model is itself partly model-made — a summary an earlier\nstep wrote, attributes an earlier step guessed. Give the judge that same evidence, untagged, and an\nanswer built on a guessed field looks supported: the field is right there. The judge marks the\ninvention correct, and does it fluently. A judge given the same untagged evidence as the model\ncannot detect invented evidence. That is not a weakness of a particular judge; the information it\nwould need is not on the page.</p>\n<p>Two changes put it on the page:</p>\n<ul>\n<li><strong>Tag every field with where it came from.</strong> The source, or written by a model, or guessed by a\nmodel.</li>\n<li><strong>Add a source-only reading.</strong> Separately, the judge sees only the source and answers one question\nper field: can this be determined from the source alone, and if so, what is it?</li>\n</ul>\n<pre><code class=\"language-text\">EVIDENCE — every line says where it came from\n[source]          title: &lt;...&gt;\n[source]          description: &lt;...&gt;\n[model-written]   summary: &lt;...&gt;        written by an earlier pipeline step\n[model-guessed]   &lt;field&gt;: &lt;...&gt;        inferred; the source does not state it\n\nANSWER UNDER REVIEW\n&lt;field&gt;: &lt;value&gt;\n\nSOURCE-ONLY READING\nUsing only the [source] lines: can &lt;field&gt; be determined?  yes / no / partly\nIf yes, what is it?\n</code></pre>\n<p>An answer counts as an invention when it gives a value and the source-only reading says the field\ncannot be determined. The verdict on the tagged evidence then says whether the value was at least\nconsistent with what a model had written, which is a different and lesser question.</p>\n<h3 id=\"reporting-each-judge-alone\">Reporting each judge alone</h3>\n<p>Report the majority, and beside it every judge&#39;s own result on every bar. Then ask, for each bar:\nwould the verdict change if any one judge were removed? A verdict that flips without one judge\nrests on that judge, and the report says so. Add the pairwise agreement between judges, and, for a\njudge that shares a vendor with an arm, its verdicts on that arm against its verdicts on the others.</p>\n<h3 id=\"keying-only-where-the-arms-differ\">Keying only where the arms differ</h3>\n<p>Judging every answer of every arm is the expensive part. Where two arms give the same answer to an\nitem, they get the same verdict, so the item cannot contribute to the difference between them — on\nan <strong>item-wise additive</strong> metric: a sum of per-item scores, each a function of that item and that\nanswer alone, over a denominator that is the same for every arm and fixed before any judging. For\nsuch a metric, judging only the items where the arms&#39; answers differ therefore gives the\n<strong>difference</strong> between arms exactly — and gives no absolute rate at all. Report it that way: a\ndifference, with absolute rates marked not measured, unless the agreeing items are judged too.</p>\n<p><strong>Every other metric is judged on every item.</strong> A median, a precision, an F1 — anything computed\nfrom an arm&#39;s whole set of answers — is not a sum over items, and an agreeing item can still move\nit. A rate whose denominator the judges decide is not over a fixed denominator. Invention is one of\nthose: its denominator, the items whose source leaves the field undeterminable, comes from the\nsource-only reading, so invention is never scored under the shortcut.</p>\n<p><strong>One verdict per answer, in both paths.</strong> The panel evaluates each normalised (item, answer) once,\nand every arm that gave that answer reuses the verdict — when every item is judged, and under the\nshortcut alike. A model judge asked twice about the same answer can disagree with itself; judged\nonce per arm, identical answers would get different verdicts, and the judge&#39;s own noise would read\nas a difference between arms.</p>\n<p>The shortcut is exact only under conditions that are easy to break:</p>\n<ul>\n<li>&quot;the same answer&quot; must mean equal under the scorer&#39;s own comparison, field by field where the\nscorer scores fields;</li>\n<li>a verdict must depend only on the item and the answer — not on the arm&#39;s label, on the position\nof the answer, or on other answers shown in the same judge prompt (a pairwise judge breaks this);</li>\n<li>with more than two arms, an item is judged when any arm differs from any other.</li>\n</ul>\n<p>Before relying on it, test it on a fixture. Use a deterministic stand-in judge — a function of the\nitem and the answer — so that the test checks the shortcut&#39;s own logic and not the judges&#39; noise.\nScore the fixture with every answer judged, then with the shortcut, and require every difference\nbetween arms, on every metric the shortcut is used for, to be identical. Then break the shortcut —\nkey on the arm label, or compare answers before normalising them — and watch the test fail.</p>\n<h3 id=\"metrics\">Metrics</h3>\n<h4 id=\"invention-is-a-bar\">Invention is a bar</h4>\n<p>Invention gets its own bar in the plan, with its own predicate: the items whose source leaves the\nfield undeterminable. Folded into accuracy it disappears, because a confident invention and an\nhonest error weigh the same there. Read the definition against real items before freezing it. A\n&quot;no&quot; on a field that does not apply to the item — this tool is not waterproof, this document has no\nsignature — is an answer about applicability, not an invented value, and a definition that cannot\ntell the two apart can flip a verdict.</p>\n<p>An arm that abstains more often will look worse on coverage and better on invention. Report both,\nside by side, so that neither number is read alone.</p>\n<h4 id=\"denominators-match-across-arms\">Denominators match across arms</h4>\n<p>Every arm is scored on the same items. A timeout, a refusal or a malformed response is a failure in\nthe arm that produced it, scored as one. It is never an exclusion from that arm alone, which would\nquietly remove an arm&#39;s hardest items from its own denominator. Where an item has to go — its\nsource vanished, its ground truth is disputed — it leaves every arm, and the report counts it.</p>\n<h4 id=\"every-percentage-carries-its-predicate\">Every percentage carries its predicate</h4>\n<p>The same answers give very different rates over &quot;all items&quot;, &quot;items with an answer&quot; and &quot;items\nwhose source determines the answer&quot;. Write the predicate and the count beside every percentage:</p>\n<pre><code class=\"language-text\">4.1% invention — of items whose source leaves the field undeterminable (n = 612, both arms)\n</code></pre>\n<p>A percentage without its predicate cannot be compared with anything, including the same study&#39;s\nother percentages.</p>\n<h4 id=\"passing-the-bar-is-not-being-better\">Passing the bar is not being better</h4>\n<p>A non-inferiority bar answers one question: is the candidate safe to switch to? It does not say\nwhich arm is better. Report, for every arm:</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>Bars</th>\n<th>Quality (observed)</th>\n<th>Harm</th>\n<th>Cost per item</th>\n<th>Cost at expected volume</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>A (control)</td>\n<td>—</td>\n<td><with predicate></td>\n<td>&lt;invention, consequential errors&gt;</td>\n<td><amount></td>\n<td><amount></td>\n</tr>\n<tr>\n<td>B</td>\n<td>pass / fail per bar</td>\n<td><with predicate></td>\n<td>&lt;...&gt;</td>\n<td><amount></td>\n<td><amount></td>\n</tr>\n</tbody></table>\n<p>Then write the recommendation in the terms of the question it answers: &quot;B is safe to switch to\nunder the registered bars&quot; and &quot;B is the better arm on observed quality and harm&quot; are different\nclaims, and only the evidence for each one supports it.</p>\n","words":1461},{"path":"references/parity-and-controls.md","slug":"parity-and-controls","title":"Parity and controls","body":"# Parity and controls\n\nA study measures the difference between arms. That difference means something only if the control\narm is the system production actually runs, and only if the other things that differ between arms\n— provider, layout, time, inputs — are held still or measured. This page covers both.\n\n## Parity: the control is production's twin\n\nParity has two halves, and a study needs both. They differ in one way that decides when each runs:\nrequest parity costs nothing, and output parity costs money.\n\n| Half | Paid? | When | Committed |\n|---|---|---|---|\n| Request parity | no — built, never sent | inside the dry run | with the dry run, before any paid call |\n| Output parity | yes | the first paid stage, before any arm is measured | its plan and cap before its first call; its result after |\n\n**Request parity is offline, and part of the dry run.** Take a handful of real items production has\nprocessed. Capture the request production sent for each — from production's own request log, or by\nrunning production's request builder in a mode that builds and does not send. Build the control\narm's request for the same items, without sending it, and diff the two. Normalise only what does not reach the model, such as the key order inside\na JSON object. Never normalise array order: the order of messages, examples and tools is part of the\nprompt.\n\nThe differences that turn up are rarely the interesting ones:\n\n- a system prompt that production assembles from two sources and the harness from one;\n- a tool or response-schema definition the harness left out or copied from an older version;\n- a default parameter — temperature, a token limit, a response format — that production sets and\n  the harness inherits from a library default;\n- examples placed before the instructions in one and after them in the other;\n- whitespace or a trailing newline that changes what a prompt cache matches;\n- provider-routing preferences production sends and the harness does not.\n\n**Output parity is paid, and a stage of its own.** It runs only after the dry run is committed, and\nonly under what the plan registered for it: the items, the pass rule — how close the control's\nanswers must come to production's — and a cap of its own inside the study's. Run the control alone\non items production processed under the same frozen prompt and model, and compare its answers with\nwhat production stored. Larger disagreement than the pass rule allows means the harness is not\nproduction yet, or the control run is faulty, and every arm compared against it would inherit the\nfault: the study stops there, with an addendum. The A/A distribution measured later in the run says\nwhether the pass rule's tolerance was reasonable; if it was too loose, say so in an addendum.\n\nAn addendum that changes anything that builds a request runs output parity again, in the same\norder: the addendum and its re-run dry run are pushed first, then output parity runs as the\naddendum's first paid stage, under the pass rule and cap the addendum registers, and its result is\npushed before any later call. A fail stops the study here too.\n\nA control that fails parity is not a slightly worse control. It is a different system, and the\nstudy would be measuring the distance between two systems neither of which is the one being decided\nabout.\n\n## Pinning the serving provider\n\nMany models are served by several providers under one name, and a router may pick among them per\ncall. Providers can differ in quantisation, context limits, default parameters and tokenisation, so\nthe \"same\" model can answer differently depending on who served it. A router can also pick the\nprovider by the shape of the request — its length, its layout, whether it can use a cache — so a\nchange that only touched the layout can move an arm to a different provider without anyone\nchoosing to.\n\n- Pin one provider per arm, in the request itself, and turn off fallbacks for the study. The pin is\n  part of the request, so request parity checks it offline.\n- **Production routing that cannot be pinned is out of scope.** Where production's own request\n  leaves the provider to a router, or lets a fallback move it, the control cannot both equal\n  production's request and carry a pin, and production's stored answers came from providers nobody\n  recorded. This skill does not reproduce the routing to stand in for a pin: such a study is out of\n  scope until production's request pins its provider.\n- Record, per call, the provider that actually served it, from the response's own metadata, from\n  the first paid call — output parity's — onwards.\n- After the run, check every call against its arm's pin. A pin that was not honoured is a finding,\n  recorded in an addendum, and those calls are either rerun or reported separately.\n\n## The A/A distribution\n\nMany models are not deterministic even at temperature zero, and providers change behaviour between\nhours, so the control disagrees with itself. How far it does is not one number. Two runs of the\nbaseline are a single draw from that spread: read as a floor, a lucky draw vetoes a real difference\nand an unlucky one lets noise through as a finding.\n\nEstimate the distribution instead, and say how:\n\n- **Repeated runs.** Run the baseline arm k times over the same items, interleaved with everything\n  else, and take the spread of A-versus-A differences across the pairs of runs. The plan says what\n  k is and why; more runs cost more and narrow the estimate.\n- **Paired resampling.** With fewer runs, resample the items — the same items for both runs of\n  each pair — and recompute the A-versus-A difference each time, giving its distribution and an\n  interval from one or a few pairs of runs.\n\nReport the distribution with its interval and its method: \"95% of A-versus-A differences fall\nwithin +/- f points (k runs, paired resampling over n items)\". A difference between arms inside it\nis reported as \"within noise\", not as a win or a loss. A difference outside it is not thereby\nsignificant — the plan's interval rule decides that — but one inside it is not a finding.\n\nA single A/A comparison is still worth running early. It is a diagnostic: a large disagreement\nshows that the harness, the provider or the sampling is unstable, and is a reason to look before\nspending more. It is not a floor, and it vetoes nothing.\n\n## The layout-only control\n\nA content change often changes the layout too: more messages, a different order, the variable part\nof the prompt moved earlier, a prefix that no longer matches the cache. Layout and caching can move\nquality, latency and cost on their own. When the arm under test changes layout or caching as well\nas content, add an arm that carries the control's content in the candidate's layout:\n\n```text\nA  control content, control layout\nL  control content, candidate layout      <- the layout-only control\nB  candidate content, candidate layout\n\nlayout effect   = L - A\ncontent effect  = B - L\n```\n\nWithout L, a gain that came from the cache or the layout is reported as the content's.\n\n## Interleaving\n\nRun every arm on item 1, then every arm on item 2, rotating which arm goes first so that warm\ncaches and rate-limit back-off do not always favour the same one. Record a timestamp per call. If a\nrun is interrupted, resume it interleaved. Providers drift over hours and days, and arms run on\ndifferent days measure the days as much as the arms.\n\n## Equal inputs\n\nEvery arm gets the same evidence for each item. Before measuring, count, per arm, how many items\nhad each input present. A mismatch — one arm missing a field for a fifth of the items because its\nloader read a different column — is fixed before the run, or the affected items are excluded from\nevery arm so that the denominators still match. An arm that lacked an input lost those items for a\nreason the study is not about.\n\n## Sanity-check the control before trusting it\n\nA control run fresh for the study can carry its own fault: a stale prompt file, a dropped field, a\nparameter left at a default. Every other arm is measured against it, so a broken control makes each\nof them look better than it is. Compare the fresh control run with production's stored outputs for\nthe same items before using it as the baseline, and record the comparison in the audit.\n","bodyHtml":"<h2 id=\"parity-and-controls\">Parity and controls</h2>\n<p>A study measures the difference between arms. That difference means something only if the control\narm is the system production actually runs, and only if the other things that differ between arms\n— provider, layout, time, inputs — are held still or measured. This page covers both.</p>\n<h3 id=\"parity-the-control-is-productions-twin\">Parity: the control is production&#39;s twin</h3>\n<p>Parity has two halves, and a study needs both. They differ in one way that decides when each runs:\nrequest parity costs nothing, and output parity costs money.</p>\n<table>\n<thead>\n<tr>\n<th>Half</th>\n<th>Paid?</th>\n<th>When</th>\n<th>Committed</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Request parity</td>\n<td>no — built, never sent</td>\n<td>inside the dry run</td>\n<td>with the dry run, before any paid call</td>\n</tr>\n<tr>\n<td>Output parity</td>\n<td>yes</td>\n<td>the first paid stage, before any arm is measured</td>\n<td>its plan and cap before its first call; its result after</td>\n</tr>\n</tbody></table>\n<p><strong>Request parity is offline, and part of the dry run.</strong> Take a handful of real items production has\nprocessed. Capture the request production sent for each — from production&#39;s own request log, or by\nrunning production&#39;s request builder in a mode that builds and does not send. Build the control\narm&#39;s request for the same items, without sending it, and diff the two. Normalise only what does not reach the model, such as the key order inside\na JSON object. Never normalise array order: the order of messages, examples and tools is part of the\nprompt.</p>\n<p>The differences that turn up are rarely the interesting ones:</p>\n<ul>\n<li>a system prompt that production assembles from two sources and the harness from one;</li>\n<li>a tool or response-schema definition the harness left out or copied from an older version;</li>\n<li>a default parameter — temperature, a token limit, a response format — that production sets and\nthe harness inherits from a library default;</li>\n<li>examples placed before the instructions in one and after them in the other;</li>\n<li>whitespace or a trailing newline that changes what a prompt cache matches;</li>\n<li>provider-routing preferences production sends and the harness does not.</li>\n</ul>\n<p><strong>Output parity is paid, and a stage of its own.</strong> It runs only after the dry run is committed, and\nonly under what the plan registered for it: the items, the pass rule — how close the control&#39;s\nanswers must come to production&#39;s — and a cap of its own inside the study&#39;s. Run the control alone\non items production processed under the same frozen prompt and model, and compare its answers with\nwhat production stored. Larger disagreement than the pass rule allows means the harness is not\nproduction yet, or the control run is faulty, and every arm compared against it would inherit the\nfault: the study stops there, with an addendum. The A/A distribution measured later in the run says\nwhether the pass rule&#39;s tolerance was reasonable; if it was too loose, say so in an addendum.</p>\n<p>An addendum that changes anything that builds a request runs output parity again, in the same\norder: the addendum and its re-run dry run are pushed first, then output parity runs as the\naddendum&#39;s first paid stage, under the pass rule and cap the addendum registers, and its result is\npushed before any later call. A fail stops the study here too.</p>\n<p>A control that fails parity is not a slightly worse control. It is a different system, and the\nstudy would be measuring the distance between two systems neither of which is the one being decided\nabout.</p>\n<h3 id=\"pinning-the-serving-provider\">Pinning the serving provider</h3>\n<p>Many models are served by several providers under one name, and a router may pick among them per\ncall. Providers can differ in quantisation, context limits, default parameters and tokenisation, so\nthe &quot;same&quot; model can answer differently depending on who served it. A router can also pick the\nprovider by the shape of the request — its length, its layout, whether it can use a cache — so a\nchange that only touched the layout can move an arm to a different provider without anyone\nchoosing to.</p>\n<ul>\n<li>Pin one provider per arm, in the request itself, and turn off fallbacks for the study. The pin is\npart of the request, so request parity checks it offline.</li>\n<li><strong>Production routing that cannot be pinned is out of scope.</strong> Where production&#39;s own request\nleaves the provider to a router, or lets a fallback move it, the control cannot both equal\nproduction&#39;s request and carry a pin, and production&#39;s stored answers came from providers nobody\nrecorded. This skill does not reproduce the routing to stand in for a pin: such a study is out of\nscope until production&#39;s request pins its provider.</li>\n<li>Record, per call, the provider that actually served it, from the response&#39;s own metadata, from\nthe first paid call — output parity&#39;s — onwards.</li>\n<li>After the run, check every call against its arm&#39;s pin. A pin that was not honoured is a finding,\nrecorded in an addendum, and those calls are either rerun or reported separately.</li>\n</ul>\n<h3 id=\"the-aa-distribution\">The A/A distribution</h3>\n<p>Many models are not deterministic even at temperature zero, and providers change behaviour between\nhours, so the control disagrees with itself. How far it does is not one number. Two runs of the\nbaseline are a single draw from that spread: read as a floor, a lucky draw vetoes a real difference\nand an unlucky one lets noise through as a finding.</p>\n<p>Estimate the distribution instead, and say how:</p>\n<ul>\n<li><strong>Repeated runs.</strong> Run the baseline arm k times over the same items, interleaved with everything\nelse, and take the spread of A-versus-A differences across the pairs of runs. The plan says what\nk is and why; more runs cost more and narrow the estimate.</li>\n<li><strong>Paired resampling.</strong> With fewer runs, resample the items — the same items for both runs of\neach pair — and recompute the A-versus-A difference each time, giving its distribution and an\ninterval from one or a few pairs of runs.</li>\n</ul>\n<p>Report the distribution with its interval and its method: &quot;95% of A-versus-A differences fall\nwithin +/- f points (k runs, paired resampling over n items)&quot;. A difference between arms inside it\nis reported as &quot;within noise&quot;, not as a win or a loss. A difference outside it is not thereby\nsignificant — the plan&#39;s interval rule decides that — but one inside it is not a finding.</p>\n<p>A single A/A comparison is still worth running early. It is a diagnostic: a large disagreement\nshows that the harness, the provider or the sampling is unstable, and is a reason to look before\nspending more. It is not a floor, and it vetoes nothing.</p>\n<h3 id=\"the-layout-only-control\">The layout-only control</h3>\n<p>A content change often changes the layout too: more messages, a different order, the variable part\nof the prompt moved earlier, a prefix that no longer matches the cache. Layout and caching can move\nquality, latency and cost on their own. When the arm under test changes layout or caching as well\nas content, add an arm that carries the control&#39;s content in the candidate&#39;s layout:</p>\n<pre><code class=\"language-text\">A  control content, control layout\nL  control content, candidate layout      &lt;- the layout-only control\nB  candidate content, candidate layout\n\nlayout effect   = L - A\ncontent effect  = B - L\n</code></pre>\n<p>Without L, a gain that came from the cache or the layout is reported as the content&#39;s.</p>\n<h3 id=\"interleaving\">Interleaving</h3>\n<p>Run every arm on item 1, then every arm on item 2, rotating which arm goes first so that warm\ncaches and rate-limit back-off do not always favour the same one. Record a timestamp per call. If a\nrun is interrupted, resume it interleaved. Providers drift over hours and days, and arms run on\ndifferent days measure the days as much as the arms.</p>\n<h3 id=\"equal-inputs\">Equal inputs</h3>\n<p>Every arm gets the same evidence for each item. Before measuring, count, per arm, how many items\nhad each input present. A mismatch — one arm missing a field for a fifth of the items because its\nloader read a different column — is fixed before the run, or the affected items are excluded from\nevery arm so that the denominators still match. An arm that lacked an input lost those items for a\nreason the study is not about.</p>\n<h3 id=\"sanity-check-the-control-before-trusting-it\">Sanity-check the control before trusting it</h3>\n<p>A control run fresh for the study can carry its own fault: a stale prompt file, a dropped field, a\nparameter left at a default. Every other arm is measured against it, so a broken control makes each\nof them look better than it is. Compare the fresh control run with production&#39;s stored outputs for\nthe same items before using it as the baseline, and record the comparison in the audit.</p>\n","words":1454},{"path":"references/study-files.md","slug":"study-files","title":"Study files","body":"# Study files\n\nWhat a study directory holds, what each file must say, and the order in which they are\ncommitted. The names are suggestions; the contents and the order are not.\n\n## Layout\n\n```text\n<study>/\n  PLAN.md                 the question, arms, metrics, bars, sample size — first commit\n  FREEZE.json             a hash for every input — committed before any paid call\n  dryrun/control.diff     request parity: the control's request against production's, built\n                          offline — before any paid call\n  dryrun/<arm>.diff       each arm's request against production's — before any paid call\n  parity/                 output parity, the first paid stage: the control's answers against\n                          production's stored ones, under the stage's own cap\n  addenda/<date>-<slug>.md   one per change after the first paid call\n  code/                   harness, budget guard, judge runner, scorer — every file hashed in FREEZE\n  config/                 every configuration the code reads — hashed in FREEZE\n  <lock file>             the dependency lock — hashed in FREEZE, with the runtime's version\n  data/raw/<arm>/         every response, stored as returned, with its cost per attempt\n  data/judges/<judge>/    every judge verdict, stored as returned\n  tables/                 every table in the report, as CSV\n  reviews/round-<n>.md    one record per independent review round\n  audit.md                the timeline, spend per stage, failures, corrections, commits\n  methodology.md          how the study was run, in prose\n  report.md               the verdict, written for the decision\n  reproduce.sh            rebuilds every table offline\n  MANIFEST.sha256         a checksum for every other file reproduce.sh reads; never for itself\n```\n\nKeep the study's code in its own directory and give its modules names no other study and no\nstandard library uses. Two studies that each carry a `score` module, both importable from the\nrepository root, will each run the other's on some machine.\n\n## PLAN\n\n```text\n# PLAN — <study name>\nCommitted before any paid call. Changes after the first paid call go in addenda/.\n\nQuestion:   Can <arm B> replace <arm A> on <task> without losing more than <X> on <metric>,\n            and at what cost?\nDecision:   <what changes if the answer is yes>, decided by <role>.\n\nArms:\n  A (control)  <model> via <pinned provider>, prompt <file>, params <file>\n  B            <model> via <pinned provider>, prompt <file>, params <file>\n  A1..Ak       A run <k> times over the same items, for the A/A distribution (why <k>: <reason>)\n  L            layout-only control: A's content in B's layout (only if layout or caching changes)\n\nItems:      <n> items drawn by <rule> with seed <seed>, from <source>, frozen in FREEZE.json.\nWhy <n>:    the smallest difference worth detecting is <d> points; at <n> items the 95% interval\n            on a difference near zero is about +/- <w> points.\n\nMetrics (each with its predicate):\n  M1 <name>: numerator <...>; denominator <...>; excluded <...> because <...>\n  M2 invention: an answer given where the source cannot determine the field;\n                denominator: items whose source leaves the field undeterminable\n\nBars:\n  M1: point B-A >= -<x> points; interval: lower bound of 95% CI of B-A >= -<y>\n  M2: point B-A <= <x> points;  interval: upper bound <= <y>\n  A bar passes only when both its rules pass.\n\nJudges:     J1 <vendor>, J2 <vendor>, J3 <vendor>; verdict = 2 of 3. J<k> shares a vendor with\n            arm <arm>. Each judge is also reported alone.\nData:       class <class>; every recipient approved for it: <each candidate provider>, <each\n            judge vendor>; artefacts kept <in the clear / where>.\nShortcut:   judge every item / judge only where arms differ, for item-wise additive metrics only\n            (<which>; exactness test: <fixture>); in both, one panel verdict per normalised\n            (item, answer), reused across arms\nOutput parity (the first paid stage):\n            control only, on <n> items drawn by <rule>; pass rule: <agreement with production's\n            stored answers, and how it is measured>; stage cap <amount>, inside the study cap.\n            A fail stops the study with an addendum.\nBudget:     study cap <amount>; stage caps: output parity <amount>, main run <amount>, judging\n            <amount>; balance floor <amount>, read before every admission, on an account that is\n            the study's alone (or \"unavailable\": no balance endpoint, or a shared account); ceiling\n            price per model = the largest of list, list + <margin>%, and the provider's maximum,\n            for every billable unit (tokens, per-request fees, images, audio, hosted search, tool\n            invocations), each capped in the request; one research account (one key, one\n            balance) for every paid call, arms and judges alike, shown not to be production's by\n            the account identity the provider names for each key; one paying process holding an\n            operating-system lock, calls one at a time.\nStop rule:  stop and write an addendum if <condition>.\nNot covered: <item types, providers, volumes this study will not speak to>\n```\n\n## FREEZE\n\nOne entry per input, hashed, with enough identity that a reader can find the same thing again.\n\n```json\n{\n  \"written_on\": \"<sha of the parent commit this file was written on>\",\n  \"items\": { \"file\": \"data/items.jsonl\", \"sha256\": \"<hash>\", \"rule\": \"<selection rule>\", \"seed\": 0 },\n  \"prompts\": [{ \"arm\": \"A\", \"file\": \"prompts/a.txt\", \"sha256\": \"<hash>\" }],\n  \"policies\": [{ \"file\": \"policies/<name>.md\", \"sha256\": \"<hash>\" }],\n  \"judge_prompts\": [{ \"judge\": \"J1\", \"file\": \"judges/rubric.md\", \"sha256\": \"<hash>\" }],\n  \"models\": [{ \"arm\": \"A\", \"model\": \"<model id>\", \"provider\": \"<pinned provider>\" }],\n  \"params\": [{ \"arm\": \"A\", \"file\": \"params/a.json\", \"sha256\": \"<hash>\" }],\n  \"price_tables\": [{ \"file\": \"prices/<provider>.json\", \"sha256\": \"<hash>\", \"covers\": \"every billable unit of every model the study calls\" }],\n  \"code\": [\n    { \"file\": \"code/harness.<ext>\", \"sha256\": \"<hash>\" },\n    { \"file\": \"code/guard.<ext>\", \"sha256\": \"<hash>\" },\n    { \"file\": \"code/judge.<ext>\", \"sha256\": \"<hash>\" },\n    { \"file\": \"code/score.<ext>\", \"sha256\": \"<hash>\" },\n    { \"file\": \"reproduce.sh\", \"sha256\": \"<hash>\" }\n  ],\n  \"config\": [{ \"file\": \"config/<name>\", \"sha256\": \"<hash>\" }],\n  \"runtime\": { \"name\": \"<runtime>\", \"version\": \"<exact version>\", \"lock\": { \"file\": \"<lock file>\", \"sha256\": \"<hash>\" } },\n  \"metric_definitions_checked_against\": [\"<item id>\", \"<item id>\", \"<item id>\"]\n}\n```\n\nThe freeze covers everything the harness and the guard read, not only what the arms are judged on,\nand **every executable and every configuration that can change a request, a spend decision or a\nverdict**: the harness that builds the requests, the guard that admits and settles them, the judge\nrunner, the scorer, `reproduce.sh`, every configuration any of them reads, and the runtime's version\nwith its dependency lock. A freeze of the scorer alone leaves the request builder, the guard and the\njudge runner free to change after the dry run under a freeze that still looks complete. List the\nfiles by walking `code/`, `config/` and every path the code opens, not from memory. The freeze is\ntaken after the budget guard is built and armed, so that the guard it hashes is the one that runs.\nAn addendum that changes a frozen file updates that file's entry in FREEZE.json in the same commit,\nand records the old hash.\n\n**An addendum that changes a frozen file re-runs every gate that read it.** Each gate passed\nagainst the old bytes and says nothing about the new ones. The order is the plan's own:\n\n1. **The offline gates first, pushed with the addendum.** Before any call the addendum governs,\n   every offline gate that read the changed file runs again against the new bytes, and its results\n   are pushed with the addendum: the guard's drills, for the guard or a price table; the dry run,\n   for anything that builds a request; the metric-definition check and the shortcut's exactness\n   test, for the rubric, the judge runner or the scorer; the mutation drills, for the scorer or\n   `reproduce.sh`.\n2. **Then output parity, as the addendum's first paid stage.** Output parity is a paid call the\n   addendum governs, so it cannot be pushed with it. Where the addendum changes anything that builds\n   a request, output parity runs again after that push, as the addendum's first paid stage, under\n   the pass rule and the cap of its own that the addendum registers; and its result is pushed before\n   any later call of the study.\n\nA gate that fails, or cannot run again, stops the study, as the plan's own output parity does. A\ncorrection found after its calls ran makes what the old bytes produced for them — calls, verdicts,\nscores — invalid: none of it counts toward a verdict unless it is produced again under the new\nbytes, once their gates pass.\n\nEach arm's request parameters are hashed, because a sampling parameter changed after the freeze\nchanges the comparison while the prompts still match. Every price table the guard reads is hashed,\nbecause a price changed after the freeze changes every reservation and every settlement, and the\noffline reproduction of the spend with them.\n\nThe last field is not decoration. It names the real items each metric definition was read\nagainst before freezing, including the awkward ones — a field that does not apply, an empty\nsource, a source that contradicts itself.\n\nA file cannot name the commit that adds it: that sha does not exist until the file is committed,\nand writing it in afterwards changes the file and so the sha. The freeze records the commit it was\nwritten on. The commit that adds it is recorded afterwards, in a later record — the audit's\ntimeline in the next commit, or the pull request's description.\n\n## ADDENDUM\n\n```text\n# ADDENDUM <n> — <date> — <slug>\nWritten on: <sha of the parent commit>   Governs calls: <batch or range>   To be pushed before them\n\nWhat changed:  <one paragraph>\nWhy:           <what was found, and how>\nEffect:        <which numbers move, measured: before -> after, or \"none, measured by <command>\">\nGates re-run:  <each offline gate that read a changed file, with its result, pushed with this file>\nOutput parity: <first paid stage: items, pass rule, cap — or \"none: no request changes\">\nAlternatives:  <what else was considered>\n```\n\nAn addendum is pushed to the study's pull request before the first call it governs: the same anchor\nas the plan, because a local commit's date is rewritten by an amend or a rebase. Its own commit, the\nremote's record of the push that carried it, and the time of the first call it governs are recorded\nin the audit once they exist, so that \"pushed before the calls it governs\" can be checked from two\nrecords rather than asserted by one. A change found after its calls ran is recorded the same way,\nmarked \"Pushed after the calls it governs\", with the calls it should have governed. That is a\ncorrection, and it is stated as one.\n\n## reproduce.sh\n\nIt runs offline, with no key, from a clean checkout, and refuses to compute anything if an input,\nthe runtime or a dependency changed.\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\ncd \"$(dirname \"$0\")\"\n\n# 1. Every file FREEZE.json names — code, config, prompts, price tables, the dependency lock — has the\n#    hash FREEZE.json gives it, and a row in the manifest; and the runtime is the frozen one. This\n#    reads the freeze, not the manifest, so a deleted manifest row stops the run here.\n<each \"file\" and \"sha256\" pair in FREEZE.json, printed as \"<sha256>  <file>\"> | shasum -a 256 --check --quiet\n<each \"file\" in FREEZE.json has a row in MANIFEST.sha256, or exit 1>\ntest \"$(<runtime> --version)\" = \"<exact version from FREEZE.json>\" || { echo \"runtime is not the frozen one\" >&2; exit 1; }\n\n# 2. Every input is what the manifest says it is. A changed or missing file stops the run here.\nshasum -a 256 --check --quiet MANIFEST.sha256\n\n# 3. The dependencies come only from the lock step 1 checked, with no network.\n<install the dependencies from the lock file only, from a vendored copy or a local cache, offline>\n\n# 4. Rebuild every table from committed data, offline. The loader opens only manifest-listed\n#    paths, so a file the manifest forgot to list cannot be read silently.\n<runtime> code/score.<ext> --offline --manifest MANIFEST.sha256 --in data --out tables.rebuilt\n\n# 5. The rebuilt tables are byte-identical to the committed ones.\ndiff -r tables tables.rebuilt\nrm -rf tables.rebuilt\necho \"reproduced: every table matches\"\n```\n\nA clean checkout on another machine runs whatever runtime and packages it has installed, so a\nbyte-identical rebuild needs both pinned: the runtime's version checked before anything runs, and the\ndependencies installed only from the lock the freeze hashes — or the whole script run inside a\ncontainer image named by its digest. Where the data classification keeps raw data out of the\nrepository, the manifest lists the private copies by hash, and the script reads them from where the\nplan says they are kept.\n\nThe manifest does not list itself: a file cannot hold its own checksum, because writing it in\nchanges the file. It is anchored the way the plan is, by the commit that adds it and the push that\ncarries it; `reproduce.sh` runs from a clean checkout of that pushed commit, whose hash fixes every\nbyte of the manifest.\n\nThe manifest check in step 2 catches a changed file. It cannot catch a file that was never listed,\nand that is the gap that bites: a file read from another study, changed there, and never noticed\nhere. Close it in the loader: route every read through one function that refuses a path the\nmanifest does not list. A file the study consumes is then either listed or a loud failure.\n\n## The report and the audit\n\nThe report is written for the decision: the verdict per bar, then quality, harm and cost per arm,\nthen each judge alone, the A/A distribution, every correction, and what the study does not cover. Every\narm appears in every chart, the control included.\n\nThe audit is written for the next person to doubt the result. It carries:\n\n- a stage-by-stage timeline, with the commit each stage ran from;\n- the commit that added the PLAN, the FREEZE, the dry run and each addendum, the push that carried\n  it, and the time of the first paid call after each — recorded once those commits exist, since\n  none of those files can name its own;\n- the commit and push that added the manifest, with \"no later call\" in place of a call time: it is\n  written after the calls, so first-call times belong to the files above, which precede them;\n- the spend per stage, from the guard's ledger, against that stage's cap and the study's;\n- every failure — a refused call, a malformed response, a timeout — and how it was scored;\n- every correction, with the outputs before and after, and the addendum or review record that\n  carries it;\n- the checksums, and the one command that verifies them.\n\nRecord each stage as it happens. An audit reconstructed at the end from memory has the shape of an\naudit and the reliability of a recollection.\n","bodyHtml":"<h2 id=\"study-files\">Study files</h2>\n<p>What a study directory holds, what each file must say, and the order in which they are\ncommitted. The names are suggestions; the contents and the order are not.</p>\n<h3 id=\"layout\">Layout</h3>\n<pre><code class=\"language-text\">&lt;study&gt;/\n  PLAN.md                 the question, arms, metrics, bars, sample size — first commit\n  FREEZE.json             a hash for every input — committed before any paid call\n  dryrun/control.diff     request parity: the control&#39;s request against production&#39;s, built\n                          offline — before any paid call\n  dryrun/&lt;arm&gt;.diff       each arm&#39;s request against production&#39;s — before any paid call\n  parity/                 output parity, the first paid stage: the control&#39;s answers against\n                          production&#39;s stored ones, under the stage&#39;s own cap\n  addenda/&lt;date&gt;-&lt;slug&gt;.md   one per change after the first paid call\n  code/                   harness, budget guard, judge runner, scorer — every file hashed in FREEZE\n  config/                 every configuration the code reads — hashed in FREEZE\n  &lt;lock file&gt;             the dependency lock — hashed in FREEZE, with the runtime&#39;s version\n  data/raw/&lt;arm&gt;/         every response, stored as returned, with its cost per attempt\n  data/judges/&lt;judge&gt;/    every judge verdict, stored as returned\n  tables/                 every table in the report, as CSV\n  reviews/round-&lt;n&gt;.md    one record per independent review round\n  audit.md                the timeline, spend per stage, failures, corrections, commits\n  methodology.md          how the study was run, in prose\n  report.md               the verdict, written for the decision\n  reproduce.sh            rebuilds every table offline\n  MANIFEST.sha256         a checksum for every other file reproduce.sh reads; never for itself\n</code></pre>\n<p>Keep the study&#39;s code in its own directory and give its modules names no other study and no\nstandard library uses. Two studies that each carry a <code>score</code> module, both importable from the\nrepository root, will each run the other&#39;s on some machine.</p>\n<h3 id=\"plan\">PLAN</h3>\n<pre><code class=\"language-text\"># PLAN — &lt;study name&gt;\nCommitted before any paid call. Changes after the first paid call go in addenda/.\n\nQuestion:   Can &lt;arm B&gt; replace &lt;arm A&gt; on &lt;task&gt; without losing more than &lt;X&gt; on &lt;metric&gt;,\n            and at what cost?\nDecision:   &lt;what changes if the answer is yes&gt;, decided by &lt;role&gt;.\n\nArms:\n  A (control)  &lt;model&gt; via &lt;pinned provider&gt;, prompt &lt;file&gt;, params &lt;file&gt;\n  B            &lt;model&gt; via &lt;pinned provider&gt;, prompt &lt;file&gt;, params &lt;file&gt;\n  A1..Ak       A run &lt;k&gt; times over the same items, for the A/A distribution (why &lt;k&gt;: &lt;reason&gt;)\n  L            layout-only control: A&#39;s content in B&#39;s layout (only if layout or caching changes)\n\nItems:      &lt;n&gt; items drawn by &lt;rule&gt; with seed &lt;seed&gt;, from &lt;source&gt;, frozen in FREEZE.json.\nWhy &lt;n&gt;:    the smallest difference worth detecting is &lt;d&gt; points; at &lt;n&gt; items the 95% interval\n            on a difference near zero is about +/- &lt;w&gt; points.\n\nMetrics (each with its predicate):\n  M1 &lt;name&gt;: numerator &lt;...&gt;; denominator &lt;...&gt;; excluded &lt;...&gt; because &lt;...&gt;\n  M2 invention: an answer given where the source cannot determine the field;\n                denominator: items whose source leaves the field undeterminable\n\nBars:\n  M1: point B-A &gt;= -&lt;x&gt; points; interval: lower bound of 95% CI of B-A &gt;= -&lt;y&gt;\n  M2: point B-A &lt;= &lt;x&gt; points;  interval: upper bound &lt;= &lt;y&gt;\n  A bar passes only when both its rules pass.\n\nJudges:     J1 &lt;vendor&gt;, J2 &lt;vendor&gt;, J3 &lt;vendor&gt;; verdict = 2 of 3. J&lt;k&gt; shares a vendor with\n            arm &lt;arm&gt;. Each judge is also reported alone.\nData:       class &lt;class&gt;; every recipient approved for it: &lt;each candidate provider&gt;, &lt;each\n            judge vendor&gt;; artefacts kept &lt;in the clear / where&gt;.\nShortcut:   judge every item / judge only where arms differ, for item-wise additive metrics only\n            (&lt;which&gt;; exactness test: &lt;fixture&gt;); in both, one panel verdict per normalised\n            (item, answer), reused across arms\nOutput parity (the first paid stage):\n            control only, on &lt;n&gt; items drawn by &lt;rule&gt;; pass rule: &lt;agreement with production&#39;s\n            stored answers, and how it is measured&gt;; stage cap &lt;amount&gt;, inside the study cap.\n            A fail stops the study with an addendum.\nBudget:     study cap &lt;amount&gt;; stage caps: output parity &lt;amount&gt;, main run &lt;amount&gt;, judging\n            &lt;amount&gt;; balance floor &lt;amount&gt;, read before every admission, on an account that is\n            the study&#39;s alone (or &quot;unavailable&quot;: no balance endpoint, or a shared account); ceiling\n            price per model = the largest of list, list + &lt;margin&gt;%, and the provider&#39;s maximum,\n            for every billable unit (tokens, per-request fees, images, audio, hosted search, tool\n            invocations), each capped in the request; one research account (one key, one\n            balance) for every paid call, arms and judges alike, shown not to be production&#39;s by\n            the account identity the provider names for each key; one paying process holding an\n            operating-system lock, calls one at a time.\nStop rule:  stop and write an addendum if &lt;condition&gt;.\nNot covered: &lt;item types, providers, volumes this study will not speak to&gt;\n</code></pre>\n<h3 id=\"freeze\">FREEZE</h3>\n<p>One entry per input, hashed, with enough identity that a reader can find the same thing again.</p>\n<pre><code class=\"language-json\">{\n  &quot;written_on&quot;: &quot;&lt;sha of the parent commit this file was written on&gt;&quot;,\n  &quot;items&quot;: { &quot;file&quot;: &quot;data/items.jsonl&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot;, &quot;rule&quot;: &quot;&lt;selection rule&gt;&quot;, &quot;seed&quot;: 0 },\n  &quot;prompts&quot;: [{ &quot;arm&quot;: &quot;A&quot;, &quot;file&quot;: &quot;prompts/a.txt&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; }],\n  &quot;policies&quot;: [{ &quot;file&quot;: &quot;policies/&lt;name&gt;.md&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; }],\n  &quot;judge_prompts&quot;: [{ &quot;judge&quot;: &quot;J1&quot;, &quot;file&quot;: &quot;judges/rubric.md&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; }],\n  &quot;models&quot;: [{ &quot;arm&quot;: &quot;A&quot;, &quot;model&quot;: &quot;&lt;model id&gt;&quot;, &quot;provider&quot;: &quot;&lt;pinned provider&gt;&quot; }],\n  &quot;params&quot;: [{ &quot;arm&quot;: &quot;A&quot;, &quot;file&quot;: &quot;params/a.json&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; }],\n  &quot;price_tables&quot;: [{ &quot;file&quot;: &quot;prices/&lt;provider&gt;.json&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot;, &quot;covers&quot;: &quot;every billable unit of every model the study calls&quot; }],\n  &quot;code&quot;: [\n    { &quot;file&quot;: &quot;code/harness.&lt;ext&gt;&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; },\n    { &quot;file&quot;: &quot;code/guard.&lt;ext&gt;&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; },\n    { &quot;file&quot;: &quot;code/judge.&lt;ext&gt;&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; },\n    { &quot;file&quot;: &quot;code/score.&lt;ext&gt;&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; },\n    { &quot;file&quot;: &quot;reproduce.sh&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; }\n  ],\n  &quot;config&quot;: [{ &quot;file&quot;: &quot;config/&lt;name&gt;&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; }],\n  &quot;runtime&quot;: { &quot;name&quot;: &quot;&lt;runtime&gt;&quot;, &quot;version&quot;: &quot;&lt;exact version&gt;&quot;, &quot;lock&quot;: { &quot;file&quot;: &quot;&lt;lock file&gt;&quot;, &quot;sha256&quot;: &quot;&lt;hash&gt;&quot; } },\n  &quot;metric_definitions_checked_against&quot;: [&quot;&lt;item id&gt;&quot;, &quot;&lt;item id&gt;&quot;, &quot;&lt;item id&gt;&quot;]\n}\n</code></pre>\n<p>The freeze covers everything the harness and the guard read, not only what the arms are judged on,\nand <strong>every executable and every configuration that can change a request, a spend decision or a\nverdict</strong>: the harness that builds the requests, the guard that admits and settles them, the judge\nrunner, the scorer, <code>reproduce.sh</code>, every configuration any of them reads, and the runtime&#39;s version\nwith its dependency lock. A freeze of the scorer alone leaves the request builder, the guard and the\njudge runner free to change after the dry run under a freeze that still looks complete. List the\nfiles by walking <code>code/</code>, <code>config/</code> and every path the code opens, not from memory. The freeze is\ntaken after the budget guard is built and armed, so that the guard it hashes is the one that runs.\nAn addendum that changes a frozen file updates that file&#39;s entry in FREEZE.json in the same commit,\nand records the old hash.</p>\n<p><strong>An addendum that changes a frozen file re-runs every gate that read it.</strong> Each gate passed\nagainst the old bytes and says nothing about the new ones. The order is the plan&#39;s own:</p>\n<ol>\n<li><strong>The offline gates first, pushed with the addendum.</strong> Before any call the addendum governs,\nevery offline gate that read the changed file runs again against the new bytes, and its results\nare pushed with the addendum: the guard&#39;s drills, for the guard or a price table; the dry run,\nfor anything that builds a request; the metric-definition check and the shortcut&#39;s exactness\ntest, for the rubric, the judge runner or the scorer; the mutation drills, for the scorer or\n<code>reproduce.sh</code>.</li>\n<li><strong>Then output parity, as the addendum&#39;s first paid stage.</strong> Output parity is a paid call the\naddendum governs, so it cannot be pushed with it. Where the addendum changes anything that builds\na request, output parity runs again after that push, as the addendum&#39;s first paid stage, under\nthe pass rule and the cap of its own that the addendum registers; and its result is pushed before\nany later call of the study.</li>\n</ol>\n<p>A gate that fails, or cannot run again, stops the study, as the plan&#39;s own output parity does. A\ncorrection found after its calls ran makes what the old bytes produced for them — calls, verdicts,\nscores — invalid: none of it counts toward a verdict unless it is produced again under the new\nbytes, once their gates pass.</p>\n<p>Each arm&#39;s request parameters are hashed, because a sampling parameter changed after the freeze\nchanges the comparison while the prompts still match. Every price table the guard reads is hashed,\nbecause a price changed after the freeze changes every reservation and every settlement, and the\noffline reproduction of the spend with them.</p>\n<p>The last field is not decoration. It names the real items each metric definition was read\nagainst before freezing, including the awkward ones — a field that does not apply, an empty\nsource, a source that contradicts itself.</p>\n<p>A file cannot name the commit that adds it: that sha does not exist until the file is committed,\nand writing it in afterwards changes the file and so the sha. The freeze records the commit it was\nwritten on. The commit that adds it is recorded afterwards, in a later record — the audit&#39;s\ntimeline in the next commit, or the pull request&#39;s description.</p>\n<h3 id=\"addendum\">ADDENDUM</h3>\n<pre><code class=\"language-text\"># ADDENDUM &lt;n&gt; — &lt;date&gt; — &lt;slug&gt;\nWritten on: &lt;sha of the parent commit&gt;   Governs calls: &lt;batch or range&gt;   To be pushed before them\n\nWhat changed:  &lt;one paragraph&gt;\nWhy:           &lt;what was found, and how&gt;\nEffect:        &lt;which numbers move, measured: before -&gt; after, or &quot;none, measured by &lt;command&gt;&quot;&gt;\nGates re-run:  &lt;each offline gate that read a changed file, with its result, pushed with this file&gt;\nOutput parity: &lt;first paid stage: items, pass rule, cap — or &quot;none: no request changes&quot;&gt;\nAlternatives:  &lt;what else was considered&gt;\n</code></pre>\n<p>An addendum is pushed to the study&#39;s pull request before the first call it governs: the same anchor\nas the plan, because a local commit&#39;s date is rewritten by an amend or a rebase. Its own commit, the\nremote&#39;s record of the push that carried it, and the time of the first call it governs are recorded\nin the audit once they exist, so that &quot;pushed before the calls it governs&quot; can be checked from two\nrecords rather than asserted by one. A change found after its calls ran is recorded the same way,\nmarked &quot;Pushed after the calls it governs&quot;, with the calls it should have governed. That is a\ncorrection, and it is stated as one.</p>\n<h3 id=\"reproducesh\">reproduce.sh</h3>\n<p>It runs offline, with no key, from a clean checkout, and refuses to compute anything if an input,\nthe runtime or a dependency changed.</p>\n<pre><code class=\"language-bash\">#!/usr/bin/env bash\nset -euo pipefail\ncd &quot;$(dirname &quot;$0&quot;)&quot;\n\n# 1. Every file FREEZE.json names — code, config, prompts, price tables, the dependency lock — has the\n#    hash FREEZE.json gives it, and a row in the manifest; and the runtime is the frozen one. This\n#    reads the freeze, not the manifest, so a deleted manifest row stops the run here.\n&lt;each &quot;file&quot; and &quot;sha256&quot; pair in FREEZE.json, printed as &quot;&lt;sha256&gt;  &lt;file&gt;&quot;&gt; | shasum -a 256 --check --quiet\n&lt;each &quot;file&quot; in FREEZE.json has a row in MANIFEST.sha256, or exit 1&gt;\ntest &quot;$(&lt;runtime&gt; --version)&quot; = &quot;&lt;exact version from FREEZE.json&gt;&quot; || { echo &quot;runtime is not the frozen one&quot; &gt;&amp;2; exit 1; }\n\n# 2. Every input is what the manifest says it is. A changed or missing file stops the run here.\nshasum -a 256 --check --quiet MANIFEST.sha256\n\n# 3. The dependencies come only from the lock step 1 checked, with no network.\n&lt;install the dependencies from the lock file only, from a vendored copy or a local cache, offline&gt;\n\n# 4. Rebuild every table from committed data, offline. The loader opens only manifest-listed\n#    paths, so a file the manifest forgot to list cannot be read silently.\n&lt;runtime&gt; code/score.&lt;ext&gt; --offline --manifest MANIFEST.sha256 --in data --out tables.rebuilt\n\n# 5. The rebuilt tables are byte-identical to the committed ones.\ndiff -r tables tables.rebuilt\nrm -rf tables.rebuilt\necho &quot;reproduced: every table matches&quot;\n</code></pre>\n<p>A clean checkout on another machine runs whatever runtime and packages it has installed, so a\nbyte-identical rebuild needs both pinned: the runtime&#39;s version checked before anything runs, and the\ndependencies installed only from the lock the freeze hashes — or the whole script run inside a\ncontainer image named by its digest. Where the data classification keeps raw data out of the\nrepository, the manifest lists the private copies by hash, and the script reads them from where the\nplan says they are kept.</p>\n<p>The manifest does not list itself: a file cannot hold its own checksum, because writing it in\nchanges the file. It is anchored the way the plan is, by the commit that adds it and the push that\ncarries it; <code>reproduce.sh</code> runs from a clean checkout of that pushed commit, whose hash fixes every\nbyte of the manifest.</p>\n<p>The manifest check in step 2 catches a changed file. It cannot catch a file that was never listed,\nand that is the gap that bites: a file read from another study, changed there, and never noticed\nhere. Close it in the loader: route every read through one function that refuses a path the\nmanifest does not list. A file the study consumes is then either listed or a loud failure.</p>\n<h3 id=\"the-report-and-the-audit\">The report and the audit</h3>\n<p>The report is written for the decision: the verdict per bar, then quality, harm and cost per arm,\nthen each judge alone, the A/A distribution, every correction, and what the study does not cover. Every\narm appears in every chart, the control included.</p>\n<p>The audit is written for the next person to doubt the result. It carries:</p>\n<ul>\n<li>a stage-by-stage timeline, with the commit each stage ran from;</li>\n<li>the commit that added the PLAN, the FREEZE, the dry run and each addendum, the push that carried\nit, and the time of the first paid call after each — recorded once those commits exist, since\nnone of those files can name its own;</li>\n<li>the commit and push that added the manifest, with &quot;no later call&quot; in place of a call time: it is\nwritten after the calls, so first-call times belong to the files above, which precede them;</li>\n<li>the spend per stage, from the guard&#39;s ledger, against that stage&#39;s cap and the study&#39;s;</li>\n<li>every failure — a refused call, a malformed response, a timeout — and how it was scored;</li>\n<li>every correction, with the outputs before and after, and the addendum or review record that\ncarries it;</li>\n<li>the checksums, and the one command that verifies them.</li>\n</ul>\n<p>Record each stage as it happens. An audit reconstructed at the end from memory has the shape of an\naudit and the reliability of a recollection.</p>\n","words":2388}],"body":"# Run a preregistered model study\n\nA model comparison rarely fails at the arithmetic. It fails before the first call, when the\nquestion was never written down and the bar drifts to wherever the results land. Or it fails\nquietly in the middle: the harness was not sending what production sends, the \"same\" model was\nserved by a different provider, a judge rewarded an answer that invented its evidence because it\nwas shown the same untagged evidence the model had, or one rule definition counted \"this does not\napply\" as an invention and flipped the winner. Each of these produces a clean table. Nothing in\nthe table says which of them happened.\n\nThis skill makes the verdict checkable by someone who was not there. The mechanism is ordinary:\ndecide in writing before spending, freeze the inputs by hash, prove the harness is production's\ntwin, cap the spend in code rather than in intention, judge in a way that can see invention, and\nship the numbers with a script that rebuilds them. The discipline is the hard part. Every rule\nbelow is here because leaving it out once produced a confident recommendation that was wrong.\n\nIt runs studies and writes them up. It does not change what production runs: a verdict is an\ninput to that decision, handed on, not the decision itself.\n\n## What a verdict rests on\n\nFive artefacts, committed in this order. The order is the point: each one is evidence only\nbecause it existed before the thing it constrains.\n\n- **PLAN** — the question as a decision, the arms, the metrics with their predicates, the bars\n  (each with a point rule and an interval rule), the sample size and why, and the invention bar.\n- **FREEZE** — a hash of every input the study consumes: items, prompts, each arm's parameters,\n  policies, rubrics, model and provider pins, the price tables the guard reads; and of every\n  executable and configuration that can change a request, a spend decision or a verdict, with the\n  runtime's version and the dependency lock.\n- **DRY RUN** — built offline, with nothing sent: the control's request beside production's for the\n  same items, proving request parity, and every arm's request beside it, with every difference\n  listed and each one intended.\n- **ADDENDA** — every change after the first paid call, dated, with its reason: pushed before the\n  calls it governs, or, when found after them, recorded as a correction and never backdated.\n- **REPRODUCTION** — a `reproduce.sh` that rebuilds every number offline from committed data, and\n  a checksum manifest covering every other file it reads.\n\nThe first three are committed and pushed to the study's pull request before the study's first paid\ncall, which is output parity's: a stage of its own, with the items, pass rule and cap the plan gave\nit. The remote's push record is what makes \"decided before\" checkable, not the commit's own date,\nwhich an amend or a rebase rewrites: a plan pushed only after the results arrived cannot be told\napart from a plan written to fit them, and a reader is right to assume the worse case.\n\n### What this skill does not own\n\n| The job | Whose it is | What this skill does with it |\n|---|---|---|\n| Choosing which model runs which piece of everyday work | `model-routing` | Produces evidence such a choice can cite; sets no routing. |\n| The independent review round on each study pull request | `codex-review-loop` | Hands it each PR; records every round's corrections in the study. |\n| Placing the research key in a secret store | `secure-credential-setup` | Names the key it needs, and the check that refuses production's. |\n| Recording the decision the verdict feeds | `decision-journal` | Hands over the verdict with its bars, its caveats and its cost. |\n| Changing production to follow the verdict | `land-complex-change` | Stops at the recommendation; the switch is another change. |\n| Reporting progress while paid calls run | `report-progress` | Supplies the spend, the counts and the state of the lock. |\n| Finding out how production builds its request | `investigate-codebase` | Asks it, then freezes the answer. |\n\nInstall the companions with `npx skills add crissmoldovan/agent-skills`.\n\n## When to Use\n\n- A cheaper, newer or different model is proposed for a task production already runs, and\n  someone will act on the answer.\n- A prompt, policy, schema or retrieval change has to be shown not to make things worse before\n  it ships.\n- Several candidates are being compared, and the comparison will be cited in a decision, a\n  report or a pull request.\n- An earlier comparison is disputed — \"the judge liked the wrong answer\", \"the control looks\n  off\", \"that was not a fair test\" — and has to be rerun so that the dispute can be settled.\n- Paid calls are involved, and an overspend would be a problem in itself.\n\nDo not use it for a quick look at whether a model can do a task at all: a handful of calls in a\nnotebook is fine for that, as long as nobody quotes the result as a verdict. Do not use it to\nchoose routing for everyday work (`model-routing`), or to make the production change a verdict\nrecommends (`land-complex-change`). And do not use it when the task has no ground truth and no\njudge could tell a good answer from a bad one. Say so instead: a preregistered study of an\nunmeasurable question is ceremony around a guess.\n\n## Prerequisites\n\n1. **The question, written as a decision.** \"Can arm B replace arm A on task T without losing\n   more than X on metric M, and at what cost?\" — not \"which model is better\".\n   **Complete when:** the question names the decision it feeds and who makes it.\n2. **Production's request path, readable.** The code or configuration that builds the request\n   production sends today: system prompt, message layout, tool and schema definitions,\n   parameters, provider routing.\n   **Complete when:** you can rebuild one real production request for one real item, byte for\n   byte, from that code — or you know you cannot, and finding out why is the study's first task.\n3. **One research account that is not production's.** One key and one balance for every paid\n   call, arms and judges alike — a multi-vendor gateway, for example — that reports each call's\n   cost and names the account a key bills. Providers that need separate accounts, or cannot name\n   that account, are out of scope: a billing account written in the plan binds no key to it.\n   **Complete when:** the key is in a secret store, and a check refuses to run unless the account\n   the provider names for the key is not production's, or while the harness holds any other paid\n   credential.\n4. **A study directory under version control.** Everything the study writes lands there and is\n   committed, as prerequisite 7 allows: plan, freeze, addenda, raw responses, scores, report.\n   **Complete when:** the directory exists on a branch, and the plan is in its first commit.\n5. **Three judges from three vendors.** The plan says which judge, if any, shares a vendor with\n   which arm, because every judge is also reported alone.\n   **Complete when:** each judge is reachable, and each is named in the plan with its vendor.\n6. **A budget, agreed in numbers.** A study cap, and a floor on the account's remaining balance —\n   or, with no balance endpoint or on an account not the study's alone, the floor recorded as\n   unavailable.\n   **Complete when:** the cap is a number someone agreed to, and the floor is one too or is recorded\n   as unavailable, both in the plan.\n7. **The data classified.** Production requests, items and responses can carry customer data,\n   credentials or sensitive tool output, and a committed file is readable by everyone with access\n   to the repository. Wherever this skill says *committed*, it means as the class allows: in the\n   clear, or in approved private or encrypted storage with its hash committed in its place. The\n   study uses only data that every recipient — each candidate provider and each judge vendor — is\n   approved to receive; otherwise this skill does not apply, and redaction comes before the study.\n   **Complete when:** before any paid call, the plan names the data's class, that every recipient\n   is approved for it, and where each artefact carrying it is kept.\n\n## Procedure\n\n1. **Write the PLAN, and commit it before any paid call.** It holds the question and the decision\n   it feeds; the arms, each by model, provider, prompt and parameters, with the control named;\n   every metric with its predicate — what counts in the numerator, what in the denominator, what\n   is excluded and why; and the bars. A bar has a **point rule** (\"B's error rate no more than 2\n   points above A's\") and an **interval rule** (\"the upper bound of the 95% interval of the\n   difference below 4 points\"), because a point estimate inside the bar with an interval\n   straddling it is not a pass. **Invention** — answering where the truth cannot be determined\n   from the evidence — is a bar of its own, counted and capped like any other harm. The sample\n   size comes with its reason: the smallest difference worth detecting, and the interval width\n   that size will give. Output parity (step 5) is registered here as a stage of its own, with its\n   items, its pass rule and its own cap inside the study's. Templates are in\n   [study files](references/study-files.md).\n   **Complete when:** the plan is pushed to the study's pull request, and no paid call by this\n   study's harness predates the push (production's stored outputs do, by design).\n\n2. **Build the budget guard in code, and arm it before it guards anything.** An intention does not\n   stop a retry loop at two in the morning. The guard is single-threaded by design, and its parts\n   are detailed with a sketch in [the budget guard](references/budget-guard.md):\n   - **One paying process, one call at a time.** The process holds an exclusive lock the kernel\n     releases when it exits or dies — `flock` or its equivalent — for the whole run, and admits,\n     sends and settles calls strictly one at a time. The cap is hard only under this rule.\n     Concurrency is out of scope: parallel calls, a second process, locks on shared storage and\n     lock takeover each void it.\n   - **One research key for every paid call**, refused at start-up unless the account the provider\n     names for it is not production's — never by unequal keys alone, nor by the plan's say-so — or\n     while the harness holds any other paid credential.\n   - **A hard study cap**, enforced by reserving before each call an upper bound on what it can be\n     billed: every billable unit — tokens, per-request fees, images, audio, hosted search and tool\n     invocations — at its maximum quantity and a ceiling price (the largest of the list price, a\n     stated margin over it, and the provider's maximum), for every attempt it may make; the client\n     library's own retries are off, or the guard refuses to start. A unit with no cap in the\n     request, or missing from the price table, makes the call unadmittable. A call is admitted\n     only while `spent + reserved + worst <= cap`, and while its stage — output parity, the main\n     run, judging — stays within its own pre-registered cap too. A cap checked after the call is a\n     report, not a cap.\n   - **A balance floor, read before every admission, that latches**, only on an account that is the\n     study's alone: the research key its only key, no charge from before the study. A call is\n     admitted only if the account's balance just read — never a key's own limit — less everything\n     the study has settled, which no balance is assumed to show yet, and every reservation still\n     standing, stays at or above the floor after the call's worst case. A read below that, or a read\n     that fails, latches the run and writes a STOP flag with the reason; a later, healthier read does\n     not lift it. On a shared account, or with no balance endpoint, the plan says the floor is\n     unavailable and the hard caps govern alone.\n   - **Settle each call before the next.** The cost is the larger of the list-price and the\n     provider-reported cost for every attempt, retries and failures included, summed. A settled\n     cost above its reservation latches, writes STOP and closes the ledger: continuing takes an\n     addendum and a new ledger. The reservation row is on disk before the call is sent, and the\n     settled rows before the next admission.\n   - **Restart by re-deriving every invariant from the ledger.** A new process restores the study's\n     and every stage's totals from the settled rows, counts any reservation without a settlement at\n     its worst case, checks every settled call against its reservation again — a run can die between\n     a settlement and the latch it earned — and every total against its cap, latching on a breach,\n     and refuses while a STOP flag or a recorded latch stands.\n\n   Then arm it. Set the cap below one call's worst case and watch it refuse. Stub the balance below\n   the floor and watch it latch and write STOP. Settle a call above its reservation and watch it\n   latch. Kill the run between a reservation and its settlement, restart, and watch the reservation\n   counted at its worst case. Write a settlement above its reservation with no latch, restart, and\n   watch it latch. Start a second paying process and watch it refuse the lock.\n   **Complete when:** each part has been watched refusing, every stub is restored before the\n   freeze, and the evidence is in the study's audit log.\n\n3. **FREEZE every input by hash.** Items, with their selection rule and seed; prompts; each arm's\n   request parameters; policies; rubrics; judge prompts; model identifiers with their provider\n   pins; every price table the budget guard reads; and every executable and configuration that can\n   change a request, a spend decision or a verdict — harness, the guard armed in step 2, judge\n   runner, scorer, `reproduce.sh` — with the runtime's version and the dependency lock. Before\n   freezing, read every metric's definition against a handful of real items, the awkward ones\n   included. A definition that counts \"this field does not apply\" as an invented answer will flip\n   a verdict, and only a real example shows that it does.\n   **Complete when:** every input the run will read, and every file of code and configuration it\n   runs, has a hash in the committed freeze, and each metric definition was checked against items\n   named in the plan.\n\n4. **Prove request parity and dry-run every arm, offline, and commit it before any paid call.**\n   Build — without sending — the request production sends and the request each arm would send,\n   for the same real items ([parity and controls](references/parity-and-controls.md)). The\n   control's request must equal production's: the same system prompt, message layout, tool and\n   schema definitions, parameters and provider pin. Each other arm's request may differ from it\n   only where the plan intends — the model, the prompt under test — and nothing else: not a\n   reordered message, a dropped schema field, a changed temperature. Pin the serving provider in\n   every arm's request: different providers of the \"same\" model can answer differently, and a\n   router may pick the provider by the request's layout, so a layout change can silently change who\n   serves the call. Where production's own request leaves its provider to a router or a fallback,\n   the control cannot equal it and be pinned: such a study is out of scope.\n   **Complete when:** the request-parity diff and every arm's diff are committed, every line of\n   difference is intended, and this study's harness has made no paid call.\n\n5. **Prove output parity as the first paid stage, under its own pre-registered cap.** Run the\n   control arm alone on the items the plan named for this stage, and compare its answers with what\n   production stored for them, against the pass rule the plan gave. Check the provider that served\n   every call against the pin. The stage spends only within its own cap, inside the study's, and\n   the guard enforces that cap at every admission. A control that fails its pass rule stops the\n   study here, with an addendum, because everything measured against it would compare two systems\n   neither of which is production's.\n   **Complete when:** the stage ran under its own cap, its plan committed before its first call;\n   every call was served by the pinned provider; and the result against its pass rule is committed\n   — or the study stopped with an addendum saying why.\n\n6. **Run, with the controls that make a difference readable.**\n   - **An A/A distribution, not a single draw.** Run the baseline arm several times over the same\n     items, or resample paired item-level differences between baseline runs, and estimate how far\n     the control differs from itself — a distribution with its interval, not one number. A\n     difference between arms inside that distribution is not a finding. A single A/A comparison is\n     a diagnostic, able to show that the harness is unstable, but never a floor and never a veto.\n   - **A layout-only control** whenever a content change can also change the prompt's layout or\n     its caching: an arm that carries the layout change without the content change, so the two\n     effects can be told apart.\n   - **Arms interleaved per item.** Every arm answers item 1, then every arm answers item 2.\n     Running arm A on Monday and arm B on Tuesday measures Tuesday.\n   - **The same inputs for every arm.** An arm that lacked an input for some items lost those\n     items for a reason the study is not about.\n\n   **Complete when:** every baseline repeat, every arm and every control have run over the frozen\n   items, interleaved; the A/A distribution is estimated with its interval and its method; and\n   every response is stored raw with its cost.\n\n7. **Put every change after the first paid call in a dated ADDENDUM, pushed before the calls it\n   governs.** A scorer bug fixed, an item dropped because its source vanished, an arm added, a bar\n   clarified: each gets the date, what changed, why, which calls and numbers it affects, and the\n   commit it was written on. It is pushed to the study's pull request before the first call it\n   governs — the plan's anchor, not a local commit. A file cannot name the commit that adds it, so\n   the audit records the addendum's commit, its push and the first call it governs. An addendum that\n   changes a frozen file re-runs every gate that read the old bytes: the offline ones before any call\n   it governs, pushed with it; then, if a request changed, output parity as its first paid stage,\n   under a cap and pass rule it registers, pushed before any later call. A change discovered after\n   its calls ran is recorded as a correction to those calls. It is never backdated, and what it\n   invalidates counts toward no verdict until redone.\n   **Complete when:** every change since the first paid call has an addendum; each one made before\n   its calls was pushed before the first call it governs, its offline gates re-run and pushed with\n   it and, where a request changed, its output parity pushed before any later call; each found after\n   them is marked as a correction to them, never backdated, and every call, judge verdict and score\n   it invalidated was redone or excluded before any bar's verdict.\n\n8. **Judge with three vendors, and let the judges see provenance**\n   ([judging and metrics](references/judging-and-metrics.md)).\n   - Three judges from three vendors, all on the one account; the verdict is the 2-of-3 majority.\n   - **Tag the evidence with where it came from.** Every field shown to a judge says whether the\n     source holds it or a model wrote or guessed it, and each judge gets a second, source-only\n     reading as well. A judge shown the same untagged evidence as the model cannot tell an\n     invented fact from a sourced one; it grades the invention as correct, fluently.\n   - **Report each judge alone** beside the majority, so a verdict that rests on one judge's taste,\n     or on a judge favouring its own vendor, is visible.\n   - **One panel verdict per normalised (item, answer)**, reused by every arm that gave that answer.\n   - **Judge only where the arms differ**, if cost forces it, and only on item-wise additive\n     metrics — never invention, whose denominator the judges decide; before relying on it, prove on\n     a fixture that the shortcut gives exactly the verdicts that judging everything gives.\n\n   **Complete when:** for each item-wise additive metric the plan named for the shortcut, every\n   item where the arms differ has three raw judge verdicts, and for every other metric, invention\n   always among them, every item does; the majority and each judge alone are reported; and any\n   shortcut has a passing exactness test.\n\n9. **Score against the bars as registered, and report more than the bars.**\n   - Invention is reported against its own bar: not folded into accuracy, not left to a footnote.\n   - Denominators match across arms: the same items, or a stated reason why not, with the count\n     on each side.\n   - Every percentage carries its predicate beside it: \"4.1% of the items whose source determines\n     the answer (n = 612)\", never a bare \"4.1%\".\n   - **Passing the bar is not being better.** A non-inferiority bar answers \"is it safe to switch?\"\n     Beside it, report the observed quality, the harm and the cost per item and at the expected\n     volume, so that a reader can see which arm is better and not only which one passed.\n\n   **Complete when:** every bar has a pass or a fail with its point and its interval, and quality,\n   harm and cost per arm stand beside the bars, each percentage with its predicate.\n\n10. **Make every number rebuildable offline.** `reproduce.sh` rebuilds every table and figure from\n    committed data, with no network and no key. A checksum manifest lists every file it consumes,\n    including files read from other studies, but itself, which its pushed commit anchors; the script\n    checks every frozen file and the runtime against the freeze itself, then the manifest, before it\n    computes anything. No module in the study may share a name with a standard-library module or\n    with another study's module, or the reproduction runs different code depending on where it was\n    started.\n    **Complete when:** a clean checkout runs `reproduce.sh` offline to byte-identical outputs, and\n    the manifest covers every other file the run opened.\n\n11. **Arm every gate by mutation, and watch each one fail.** Tamper with one row of raw data;\n    remove one manifest line; mutate one scorer rule. Run the reproduction after each and watch it\n    refuse. Restore from a byte copy taken before the mutation, never from version control, which\n    discards any uncommitted work in the same file along with the mutation.\n    **Complete when:** each gate has a recorded failing run under a named mutation, and a passing\n    run after a restore that was checked by content.\n\n12. **Review every study pull request independently, and record corrections in the open.** Each PR\n    gets an independent review round (`codex-review-loop`). A finding that changes a published\n    number becomes a correction — what was wrong, what changed, which numbers moved and by how\n    much — in an addendum or in the round's review record. It is never repaired silently in place.\n    **Complete when:** every PR has its review record, and every number that changed after it was\n    published carries its correction.\n\n13. **Write the report for the decision, and say what the study cannot tell.** The verdict per bar;\n    quality, harm and cost per arm; each judge alone; the A/A distribution; every correction; and what\n    the study did not cover — item types it did not sample, providers it did not pin, volume it\n    did not price.\n    **Complete when:** the report answers the plan's question in the plan's terms, and a reader can\n    trace every number in it to `reproduce.sh`.\n\n## Usage Examples\n\n```text\nBefore we switch the ticket classifier to the cheaper model, run a preregistered study. Commit the\nplan, the freeze and a dry run before you spend anything, and cap the spend in code. I want to know\nwhether it passes the bars and, separately, whether it is actually better, and what it costs at our\nvolume.\n```\n\n```text\nThe last comparison's judge preferred the answer that made things up. Rerun the judging with three\nvendors, tag which fields the model wrote or guessed, give each judge a source-only reading too, and\nreport every judge on its own as well as the majority.\n```\n\n```text\nProve the harness sends what production sends before we measure anything. Show me one real item's\nrequest from production and from the control arm, diffed, with the serving provider pinned on both.\n```\n\n```text\nWe changed the scorer after the first batch of calls. Write the addendum — what changed, why, which\ncalls it governs, which published numbers move — and push it before the next batch runs.\n```\n\n```bash\n# Rebuild every number offline; the script checks the manifest before computing anything.\n./reproduce.sh\n\n# Arm the manifest gate: drop one line, watch the run refuse, restore from a byte copy.\ncp MANIFEST.sha256 MANIFEST.sha256.bak\ntail -n +2 MANIFEST.sha256.bak > MANIFEST.sha256\n./reproduce.sh; echo \"exit $? (expected non-zero)\"\ncp MANIFEST.sha256.bak MANIFEST.sha256 && cmp MANIFEST.sha256 MANIFEST.sha256.bak && ./reproduce.sh\n```\n\n## What it looks like\n\nSpecimens, not prompts.\n\n### A result a reader can check\n\n```text\nBar 2 — invention: an answer given where the source cannot determine it\n  predicate: items whose source leaves the field undeterminable; same items in both arms\n             (n = <n> per arm)\n  arm A <a>%   arm B <b>%   difference B-A <d> points, 95% interval [<lo>, <hi>]\n  bar (from PLAN, commit <sha>): B-A <= 1.0 point and upper bound <= 2.0\n  result: FAIL — the upper bound is above 2.0\n  each judge alone: J1 FAIL, J2 FAIL, J3 pass; majority FAIL\n  A/A distribution (<k> baseline runs, paired resampling): 95% of A-vs-A differences within +/- <f> points\n  rebuilt by: reproduce.sh -> tables/bar-2.csv\n```\n\nEvery number has its predicate, its interval and its source; the bar is quoted from a commit that\npredates the calls; the judges are visible one by one; and the A/A distribution says how much of\nthe difference the control produces against itself.\n\n### The same result, reported badly\n\n```text\nModel B hallucinates slightly less than A (3.9% vs 4.1%) and costs 60% less, so it's the winner.\n```\n\nNo predicate: nobody can tell what the 3.9% is a share of. No interval or A/A distribution: the gap\ncould be the control disagreeing with itself. \"Winner\" answers a bar that only asked whether B was\nsafe to switch to. No judge is visible, so it may rest on one judge's taste; no number is rebuilt.\n\n## Pitfalls\n\n- **The bar that moved.** A threshold chosen after the results are in always fits them. Only a\n  committed plan with an earlier timestamp separates a bar from a description of the outcome.\n- **A rule definition nobody read against an example.** Counting a \"no\" on a field that does not\n  apply the same as an invented \"yes\" flipped one study's winner. The definition read sensibly;\n  a single real item showed what it did.\n- **A passed gate written up as the winner.** Non-inferiority says \"no worse than the control by\n  more than X\". It says nothing about which arm is better, and a report that calls the passing arm\n  \"better\" has answered a question the study never asked.\n- **A judge that cannot see invention.** Given the same untagged evidence as the model, a judge\n  reads a guessed field as a sourced one and marks the answer correct. Provenance tags and a\n  source-only reading are what let it notice.\n- **A control that was not production.** A reordered message, a missing schema field or a default\n  parameter makes the control a different system, and a fault in a fresh control run makes every\n  other arm look better. Compare it with production's stored outputs before trusting it.\n- **The \"same\" model from a different provider.** Providers serving one model name can answer\n  differently, and a router that picks by request layout can move an arm to another provider\n  when only its layout changed.\n- **A reservation that is not a bound.** A cap checked after the call reports money already spent;\n  a reservation at list price, or counting tokens only, is exceeded by the first call billed above\n  list or that also searched the web, and the cap with it. Reserve every billable unit at a ceiling\n  price, first.\n- **Parity paid for before it was planned.** A control run \"just to check parity\" spends before any\n  plan constrains it. Request parity is free, in the dry run; output parity is a capped paid stage.\n- **More than one call in flight.** Two paying processes, or parallel calls in one, each reserve\n  against a total the others have not added to yet, and together spend past the cap. This guard's\n  cap is hard only for one process, one call at a time.\n- **One A/A pair taken as the noise floor.** Two runs are one draw of how far the control differs\n  from itself. Treated as a hard floor, it vetoes real differences on a lucky draw and passes\n  noise on an unlucky one.\n- **A reproduction that read more than its manifest.** A file read from another study changed\n  underneath, unlisted; a module named like a standard-library one, or another study's, ran\n  different code depending on the directory the reproduction was started from.\n\n## Verification\n\n- [ ] The question is written as a decision, naming who makes it.\n- [ ] PLAN, FREEZE and DRY RUN were each pushed to the study's pull request before its first paid\n      call, and the remote's push record shows it.\n- [ ] Every bar has a point rule and an interval rule, and invention has a bar of its own.\n- [ ] Every metric definition was read against named real items before it was frozen.\n- [ ] The data was classified before any paid call, every recipient is approved for it, and every\n      artefact carrying it is kept where its class allows.\n- [ ] The freeze hashes every executable and configuration that can change a request, a spend\n      decision or a verdict, with the runtime's version and the dependency lock.\n- [ ] Every paid call went through the one research account, not production's, and the checks that\n      refuse production's account, by the account the provider names for each key, and any other\n      paid credential ran.\n- [ ] One paying process held an operating-system lock for the run, and calls were admitted, sent\n      and settled strictly one at a time.\n- [ ] Before each call the guard reserved an upper bound on its bill — every billable unit at its\n      bound and a ceiling price, for every attempt, the client library's own retries off — and\n      checked the study cap and the call's stage cap; a unit with no cap or no price was refused.\n- [ ] On an account that is the study's alone, with a balance endpoint, the account's balance was\n      read before every admission, less everything the study settled, and a call that would cross\n      the floor, a balance below it, or a failed read latched the run and wrote STOP; elsewhere the\n      plan records the floor as unavailable and the caps govern alone.\n- [ ] Each call was settled, at the larger of list and reported cost per attempt, before the next\n      admission; a settlement above its reservation latched the guard.\n- [ ] A restart restored the study's and every stage's totals from the ledger, with unsettled\n      reservations at their worst case, and rechecked every settled call against its reservation\n      and every total against its cap before admitting anything. Each part was watched refusing.\n- [ ] Request parity was proven offline, in the dry run, before the study's first paid call: the\n      control's request equals production's, with the provider pinned in every arm's request and in\n      production's own; every dry-run difference from production's request is intended.\n- [ ] Output parity ran as the first paid stage, under a cap and pass rule committed before its\n      first call, and every call was served by the pinned provider.\n- [ ] The A/A distribution was estimated from repeated baseline runs or paired resampling, with its\n      interval; no single A/A pair was used as a floor or a veto; a layout-only control ran where\n      layout or caching could change; arms were interleaved per item; every arm had the same inputs.\n- [ ] Every change after the first paid call has a dated addendum: one made before its calls was\n      pushed before them, its offline gates re-run and pushed with it and, where a request changed,\n      its output parity pushed before any later call; one found after them is marked as a\n      correction, never backdated, and every call, judge verdict and score it invalidated was\n      redone or excluded before any bar's verdict.\n- [ ] Three judges from three vendors scored every item where the arms differ for each item-wise\n      additive metric the plan named for the shortcut, its absolute rate reported as not measured,\n      and every item for every other metric, invention always among them; the majority and each\n      judge alone are reported; judges saw provenance tags and a source-only reading. A shortcut\n      has a passing exactness test on a fixture.\n- [ ] Denominators match across arms, and every percentage carries its predicate.\n- [ ] The report gives quality, harm and cost beside the bars, and does not call a passing arm\n      better on the strength of the bar alone.\n- [ ] `reproduce.sh` rebuilds every number offline, byte-identically, from a clean checkout, under\n      the frozen runtime and dependency lock.\n- [ ] The manifest covers every other consumed input, files from other studies included.\n- [ ] Each gate was armed by a named mutation, watched failing, and restored from a byte copy.\n- [ ] No study module shadows a standard-library module or another study's module.\n- [ ] Every study PR has a review record, and every number that changed after publication carries\n      its correction.\n\n## Deeper reading\n\n- [Study files](references/study-files.md): the directory layout, the PLAN, FREEZE and ADDENDUM\n  templates, the shape of `reproduce.sh` and the manifest, and what the report and the audit carry.\n- [The budget guard](references/budget-guard.md): its single-process scope, the parts, a sketch of\n  the admission path, the restart, and how to arm each part.\n- [Parity and controls](references/parity-and-controls.md): request and output parity, pinning\n  providers, the A/A distribution, the layout-only control, and interleaving.\n- [Judging and metrics](references/judging-and-metrics.md): the panel, provenance, each judge alone,\n  the shortcut and its exactness test, invention, denominators and predicates.\n","bodyHtml":"<h2 id=\"run-a-preregistered-model-study\">Run a preregistered model study</h2>\n<p>A model comparison rarely fails at the arithmetic. It fails before the first call, when the\nquestion was never written down and the bar drifts to wherever the results land. Or it fails\nquietly in the middle: the harness was not sending what production sends, the &quot;same&quot; model was\nserved by a different provider, a judge rewarded an answer that invented its evidence because it\nwas shown the same untagged evidence the model had, or one rule definition counted &quot;this does not\napply&quot; as an invention and flipped the winner. Each of these produces a clean table. Nothing in\nthe table says which of them happened.</p>\n<p>This skill makes the verdict checkable by someone who was not there. The mechanism is ordinary:\ndecide in writing before spending, freeze the inputs by hash, prove the harness is production&#39;s\ntwin, cap the spend in code rather than in intention, judge in a way that can see invention, and\nship the numbers with a script that rebuilds them. The discipline is the hard part. Every rule\nbelow is here because leaving it out once produced a confident recommendation that was wrong.</p>\n<p>It runs studies and writes them up. It does not change what production runs: a verdict is an\ninput to that decision, handed on, not the decision itself.</p>\n<h3 id=\"what-a-verdict-rests-on\">What a verdict rests on</h3>\n<p>Five artefacts, committed in this order. The order is the point: each one is evidence only\nbecause it existed before the thing it constrains.</p>\n<ul>\n<li><strong>PLAN</strong> — the question as a decision, the arms, the metrics with their predicates, the bars\n(each with a point rule and an interval rule), the sample size and why, and the invention bar.</li>\n<li><strong>FREEZE</strong> — a hash of every input the study consumes: items, prompts, each arm&#39;s parameters,\npolicies, rubrics, model and provider pins, the price tables the guard reads; and of every\nexecutable and configuration that can change a request, a spend decision or a verdict, with the\nruntime&#39;s version and the dependency lock.</li>\n<li><strong>DRY RUN</strong> — built offline, with nothing sent: the control&#39;s request beside production&#39;s for the\nsame items, proving request parity, and every arm&#39;s request beside it, with every difference\nlisted and each one intended.</li>\n<li><strong>ADDENDA</strong> — every change after the first paid call, dated, with its reason: pushed before the\ncalls it governs, or, when found after them, recorded as a correction and never backdated.</li>\n<li><strong>REPRODUCTION</strong> — a <code>reproduce.sh</code> that rebuilds every number offline from committed data, and\na checksum manifest covering every other file it reads.</li>\n</ul>\n<p>The first three are committed and pushed to the study&#39;s pull request before the study&#39;s first paid\ncall, which is output parity&#39;s: a stage of its own, with the items, pass rule and cap the plan gave\nit. The remote&#39;s push record is what makes &quot;decided before&quot; checkable, not the commit&#39;s own date,\nwhich an amend or a rebase rewrites: a plan pushed only after the results arrived cannot be told\napart from a plan written to fit them, and a reader is right to assume the worse case.</p>\n<h4 id=\"what-this-skill-does-not-own\">What this skill does not own</h4>\n<table>\n<thead>\n<tr>\n<th>The job</th>\n<th>Whose it is</th>\n<th>What this skill does with it</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Choosing which model runs which piece of everyday work</td>\n<td><code>model-routing</code></td>\n<td>Produces evidence such a choice can cite; sets no routing.</td>\n</tr>\n<tr>\n<td>The independent review round on each study pull request</td>\n<td><code>codex-review-loop</code></td>\n<td>Hands it each PR; records every round&#39;s corrections in the study.</td>\n</tr>\n<tr>\n<td>Placing the research key in a secret store</td>\n<td><code>secure-credential-setup</code></td>\n<td>Names the key it needs, and the check that refuses production&#39;s.</td>\n</tr>\n<tr>\n<td>Recording the decision the verdict feeds</td>\n<td><code>decision-journal</code></td>\n<td>Hands over the verdict with its bars, its caveats and its cost.</td>\n</tr>\n<tr>\n<td>Changing production to follow the verdict</td>\n<td><code>land-complex-change</code></td>\n<td>Stops at the recommendation; the switch is another change.</td>\n</tr>\n<tr>\n<td>Reporting progress while paid calls run</td>\n<td><code>report-progress</code></td>\n<td>Supplies the spend, the counts and the state of the lock.</td>\n</tr>\n<tr>\n<td>Finding out how production builds its request</td>\n<td><code>investigate-codebase</code></td>\n<td>Asks it, then freezes the answer.</td>\n</tr>\n</tbody></table>\n<p>Install the companions with <code>npx skills add crissmoldovan/agent-skills</code>.</p>\n<h3 id=\"when-to-use\">When to Use</h3>\n<ul>\n<li>A cheaper, newer or different model is proposed for a task production already runs, and\nsomeone will act on the answer.</li>\n<li>A prompt, policy, schema or retrieval change has to be shown not to make things worse before\nit ships.</li>\n<li>Several candidates are being compared, and the comparison will be cited in a decision, a\nreport or a pull request.</li>\n<li>An earlier comparison is disputed — &quot;the judge liked the wrong answer&quot;, &quot;the control looks\noff&quot;, &quot;that was not a fair test&quot; — and has to be rerun so that the dispute can be settled.</li>\n<li>Paid calls are involved, and an overspend would be a problem in itself.</li>\n</ul>\n<p>Do not use it for a quick look at whether a model can do a task at all: a handful of calls in a\nnotebook is fine for that, as long as nobody quotes the result as a verdict. Do not use it to\nchoose routing for everyday work (<code>model-routing</code>), or to make the production change a verdict\nrecommends (<code>land-complex-change</code>). And do not use it when the task has no ground truth and no\njudge could tell a good answer from a bad one. Say so instead: a preregistered study of an\nunmeasurable question is ceremony around a guess.</p>\n<h3 id=\"prerequisites\">Prerequisites</h3>\n<ol>\n<li><strong>The question, written as a decision.</strong> &quot;Can arm B replace arm A on task T without losing\nmore than X on metric M, and at what cost?&quot; — not &quot;which model is better&quot;.\n<strong>Complete when:</strong> the question names the decision it feeds and who makes it.</li>\n<li><strong>Production&#39;s request path, readable.</strong> The code or configuration that builds the request\nproduction sends today: system prompt, message layout, tool and schema definitions,\nparameters, provider routing.\n<strong>Complete when:</strong> you can rebuild one real production request for one real item, byte for\nbyte, from that code — or you know you cannot, and finding out why is the study&#39;s first task.</li>\n<li><strong>One research account that is not production&#39;s.</strong> One key and one balance for every paid\ncall, arms and judges alike — a multi-vendor gateway, for example — that reports each call&#39;s\ncost and names the account a key bills. Providers that need separate accounts, or cannot name\nthat account, are out of scope: a billing account written in the plan binds no key to it.\n<strong>Complete when:</strong> the key is in a secret store, and a check refuses to run unless the account\nthe provider names for the key is not production&#39;s, or while the harness holds any other paid\ncredential.</li>\n<li><strong>A study directory under version control.</strong> Everything the study writes lands there and is\ncommitted, as prerequisite 7 allows: plan, freeze, addenda, raw responses, scores, report.\n<strong>Complete when:</strong> the directory exists on a branch, and the plan is in its first commit.</li>\n<li><strong>Three judges from three vendors.</strong> The plan says which judge, if any, shares a vendor with\nwhich arm, because every judge is also reported alone.\n<strong>Complete when:</strong> each judge is reachable, and each is named in the plan with its vendor.</li>\n<li><strong>A budget, agreed in numbers.</strong> A study cap, and a floor on the account&#39;s remaining balance —\nor, with no balance endpoint or on an account not the study&#39;s alone, the floor recorded as\nunavailable.\n<strong>Complete when:</strong> the cap is a number someone agreed to, and the floor is one too or is recorded\nas unavailable, both in the plan.</li>\n<li><strong>The data classified.</strong> Production requests, items and responses can carry customer data,\ncredentials or sensitive tool output, and a committed file is readable by everyone with access\nto the repository. Wherever this skill says <em>committed</em>, it means as the class allows: in the\nclear, or in approved private or encrypted storage with its hash committed in its place. The\nstudy uses only data that every recipient — each candidate provider and each judge vendor — is\napproved to receive; otherwise this skill does not apply, and redaction comes before the study.\n<strong>Complete when:</strong> before any paid call, the plan names the data&#39;s class, that every recipient\nis approved for it, and where each artefact carrying it is kept.</li>\n</ol>\n<h3 id=\"procedure\">Procedure</h3>\n<ol>\n<li><p><strong>Write the PLAN, and commit it before any paid call.</strong> It holds the question and the decision\nit feeds; the arms, each by model, provider, prompt and parameters, with the control named;\nevery metric with its predicate — what counts in the numerator, what in the denominator, what\nis excluded and why; and the bars. A bar has a <strong>point rule</strong> (&quot;B&#39;s error rate no more than 2\npoints above A&#39;s&quot;) and an <strong>interval rule</strong> (&quot;the upper bound of the 95% interval of the\ndifference below 4 points&quot;), because a point estimate inside the bar with an interval\nstraddling it is not a pass. <strong>Invention</strong> — answering where the truth cannot be determined\nfrom the evidence — is a bar of its own, counted and capped like any other harm. The sample\nsize comes with its reason: the smallest difference worth detecting, and the interval width\nthat size will give. Output parity (step 5) is registered here as a stage of its own, with its\nitems, its pass rule and its own cap inside the study&#39;s. Templates are in\n<a href=\"references/study-files.md\">study files</a>.\n<strong>Complete when:</strong> the plan is pushed to the study&#39;s pull request, and no paid call by this\nstudy&#39;s harness predates the push (production&#39;s stored outputs do, by design).</p>\n</li>\n<li><p><strong>Build the budget guard in code, and arm it before it guards anything.</strong> An intention does not\nstop a retry loop at two in the morning. The guard is single-threaded by design, and its parts\nare detailed with a sketch in <a href=\"references/budget-guard.md\">the budget guard</a>:</p>\n<ul>\n<li><strong>One paying process, one call at a time.</strong> The process holds an exclusive lock the kernel\nreleases when it exits or dies — <code>flock</code> or its equivalent — for the whole run, and admits,\nsends and settles calls strictly one at a time. The cap is hard only under this rule.\nConcurrency is out of scope: parallel calls, a second process, locks on shared storage and\nlock takeover each void it.</li>\n<li><strong>One research key for every paid call</strong>, refused at start-up unless the account the provider\nnames for it is not production&#39;s — never by unequal keys alone, nor by the plan&#39;s say-so — or\nwhile the harness holds any other paid credential.</li>\n<li><strong>A hard study cap</strong>, enforced by reserving before each call an upper bound on what it can be\nbilled: every billable unit — tokens, per-request fees, images, audio, hosted search and tool\ninvocations — at its maximum quantity and a ceiling price (the largest of the list price, a\nstated margin over it, and the provider&#39;s maximum), for every attempt it may make; the client\nlibrary&#39;s own retries are off, or the guard refuses to start. A unit with no cap in the\nrequest, or missing from the price table, makes the call unadmittable. A call is admitted\nonly while <code>spent + reserved + worst &lt;= cap</code>, and while its stage — output parity, the main\nrun, judging — stays within its own pre-registered cap too. A cap checked after the call is a\nreport, not a cap.</li>\n<li><strong>A balance floor, read before every admission, that latches</strong>, only on an account that is the\nstudy&#39;s alone: the research key its only key, no charge from before the study. A call is\nadmitted only if the account&#39;s balance just read — never a key&#39;s own limit — less everything\nthe study has settled, which no balance is assumed to show yet, and every reservation still\nstanding, stays at or above the floor after the call&#39;s worst case. A read below that, or a read\nthat fails, latches the run and writes a STOP flag with the reason; a later, healthier read does\nnot lift it. On a shared account, or with no balance endpoint, the plan says the floor is\nunavailable and the hard caps govern alone.</li>\n<li><strong>Settle each call before the next.</strong> The cost is the larger of the list-price and the\nprovider-reported cost for every attempt, retries and failures included, summed. A settled\ncost above its reservation latches, writes STOP and closes the ledger: continuing takes an\naddendum and a new ledger. The reservation row is on disk before the call is sent, and the\nsettled rows before the next admission.</li>\n<li><strong>Restart by re-deriving every invariant from the ledger.</strong> A new process restores the study&#39;s\nand every stage&#39;s totals from the settled rows, counts any reservation without a settlement at\nits worst case, checks every settled call against its reservation again — a run can die between\na settlement and the latch it earned — and every total against its cap, latching on a breach,\nand refuses while a STOP flag or a recorded latch stands.</li>\n</ul>\n<p>Then arm it. Set the cap below one call&#39;s worst case and watch it refuse. Stub the balance below\nthe floor and watch it latch and write STOP. Settle a call above its reservation and watch it\nlatch. Kill the run between a reservation and its settlement, restart, and watch the reservation\ncounted at its worst case. Write a settlement above its reservation with no latch, restart, and\nwatch it latch. Start a second paying process and watch it refuse the lock.\n<strong>Complete when:</strong> each part has been watched refusing, every stub is restored before the\nfreeze, and the evidence is in the study&#39;s audit log.</p>\n</li>\n<li><p><strong>FREEZE every input by hash.</strong> Items, with their selection rule and seed; prompts; each arm&#39;s\nrequest parameters; policies; rubrics; judge prompts; model identifiers with their provider\npins; every price table the budget guard reads; and every executable and configuration that can\nchange a request, a spend decision or a verdict — harness, the guard armed in step 2, judge\nrunner, scorer, <code>reproduce.sh</code> — with the runtime&#39;s version and the dependency lock. Before\nfreezing, read every metric&#39;s definition against a handful of real items, the awkward ones\nincluded. A definition that counts &quot;this field does not apply&quot; as an invented answer will flip\na verdict, and only a real example shows that it does.\n<strong>Complete when:</strong> every input the run will read, and every file of code and configuration it\nruns, has a hash in the committed freeze, and each metric definition was checked against items\nnamed in the plan.</p>\n</li>\n<li><p><strong>Prove request parity and dry-run every arm, offline, and commit it before any paid call.</strong>\nBuild — without sending — the request production sends and the request each arm would send,\nfor the same real items (<a href=\"references/parity-and-controls.md\">parity and controls</a>). The\ncontrol&#39;s request must equal production&#39;s: the same system prompt, message layout, tool and\nschema definitions, parameters and provider pin. Each other arm&#39;s request may differ from it\nonly where the plan intends — the model, the prompt under test — and nothing else: not a\nreordered message, a dropped schema field, a changed temperature. Pin the serving provider in\nevery arm&#39;s request: different providers of the &quot;same&quot; model can answer differently, and a\nrouter may pick the provider by the request&#39;s layout, so a layout change can silently change who\nserves the call. Where production&#39;s own request leaves its provider to a router or a fallback,\nthe control cannot equal it and be pinned: such a study is out of scope.\n<strong>Complete when:</strong> the request-parity diff and every arm&#39;s diff are committed, every line of\ndifference is intended, and this study&#39;s harness has made no paid call.</p>\n</li>\n<li><p><strong>Prove output parity as the first paid stage, under its own pre-registered cap.</strong> Run the\ncontrol arm alone on the items the plan named for this stage, and compare its answers with what\nproduction stored for them, against the pass rule the plan gave. Check the provider that served\nevery call against the pin. The stage spends only within its own cap, inside the study&#39;s, and\nthe guard enforces that cap at every admission. A control that fails its pass rule stops the\nstudy here, with an addendum, because everything measured against it would compare two systems\nneither of which is production&#39;s.\n<strong>Complete when:</strong> the stage ran under its own cap, its plan committed before its first call;\nevery call was served by the pinned provider; and the result against its pass rule is committed\n— or the study stopped with an addendum saying why.</p>\n</li>\n<li><p><strong>Run, with the controls that make a difference readable.</strong></p>\n<ul>\n<li><strong>An A/A distribution, not a single draw.</strong> Run the baseline arm several times over the same\nitems, or resample paired item-level differences between baseline runs, and estimate how far\nthe control differs from itself — a distribution with its interval, not one number. A\ndifference between arms inside that distribution is not a finding. A single A/A comparison is\na diagnostic, able to show that the harness is unstable, but never a floor and never a veto.</li>\n<li><strong>A layout-only control</strong> whenever a content change can also change the prompt&#39;s layout or\nits caching: an arm that carries the layout change without the content change, so the two\neffects can be told apart.</li>\n<li><strong>Arms interleaved per item.</strong> Every arm answers item 1, then every arm answers item 2.\nRunning arm A on Monday and arm B on Tuesday measures Tuesday.</li>\n<li><strong>The same inputs for every arm.</strong> An arm that lacked an input for some items lost those\nitems for a reason the study is not about.</li>\n</ul>\n<p><strong>Complete when:</strong> every baseline repeat, every arm and every control have run over the frozen\nitems, interleaved; the A/A distribution is estimated with its interval and its method; and\nevery response is stored raw with its cost.</p>\n</li>\n<li><p><strong>Put every change after the first paid call in a dated ADDENDUM, pushed before the calls it\ngoverns.</strong> A scorer bug fixed, an item dropped because its source vanished, an arm added, a bar\nclarified: each gets the date, what changed, why, which calls and numbers it affects, and the\ncommit it was written on. It is pushed to the study&#39;s pull request before the first call it\ngoverns — the plan&#39;s anchor, not a local commit. A file cannot name the commit that adds it, so\nthe audit records the addendum&#39;s commit, its push and the first call it governs. An addendum that\nchanges a frozen file re-runs every gate that read the old bytes: the offline ones before any call\nit governs, pushed with it; then, if a request changed, output parity as its first paid stage,\nunder a cap and pass rule it registers, pushed before any later call. A change discovered after\nits calls ran is recorded as a correction to those calls. It is never backdated, and what it\ninvalidates counts toward no verdict until redone.\n<strong>Complete when:</strong> every change since the first paid call has an addendum; each one made before\nits calls was pushed before the first call it governs, its offline gates re-run and pushed with\nit and, where a request changed, its output parity pushed before any later call; each found after\nthem is marked as a correction to them, never backdated, and every call, judge verdict and score\nit invalidated was redone or excluded before any bar&#39;s verdict.</p>\n</li>\n<li><p><strong>Judge with three vendors, and let the judges see provenance</strong>\n(<a href=\"references/judging-and-metrics.md\">judging and metrics</a>).</p>\n<ul>\n<li>Three judges from three vendors, all on the one account; the verdict is the 2-of-3 majority.</li>\n<li><strong>Tag the evidence with where it came from.</strong> Every field shown to a judge says whether the\nsource holds it or a model wrote or guessed it, and each judge gets a second, source-only\nreading as well. A judge shown the same untagged evidence as the model cannot tell an\ninvented fact from a sourced one; it grades the invention as correct, fluently.</li>\n<li><strong>Report each judge alone</strong> beside the majority, so a verdict that rests on one judge&#39;s taste,\nor on a judge favouring its own vendor, is visible.</li>\n<li><strong>One panel verdict per normalised (item, answer)</strong>, reused by every arm that gave that answer.</li>\n<li><strong>Judge only where the arms differ</strong>, if cost forces it, and only on item-wise additive\nmetrics — never invention, whose denominator the judges decide; before relying on it, prove on\na fixture that the shortcut gives exactly the verdicts that judging everything gives.</li>\n</ul>\n<p><strong>Complete when:</strong> for each item-wise additive metric the plan named for the shortcut, every\nitem where the arms differ has three raw judge verdicts, and for every other metric, invention\nalways among them, every item does; the majority and each judge alone are reported; and any\nshortcut has a passing exactness test.</p>\n</li>\n<li><p><strong>Score against the bars as registered, and report more than the bars.</strong></p>\n<ul>\n<li>Invention is reported against its own bar: not folded into accuracy, not left to a footnote.</li>\n<li>Denominators match across arms: the same items, or a stated reason why not, with the count\non each side.</li>\n<li>Every percentage carries its predicate beside it: &quot;4.1% of the items whose source determines\nthe answer (n = 612)&quot;, never a bare &quot;4.1%&quot;.</li>\n<li><strong>Passing the bar is not being better.</strong> A non-inferiority bar answers &quot;is it safe to switch?&quot;\nBeside it, report the observed quality, the harm and the cost per item and at the expected\nvolume, so that a reader can see which arm is better and not only which one passed.</li>\n</ul>\n<p><strong>Complete when:</strong> every bar has a pass or a fail with its point and its interval, and quality,\nharm and cost per arm stand beside the bars, each percentage with its predicate.</p>\n</li>\n<li><p><strong>Make every number rebuildable offline.</strong> <code>reproduce.sh</code> rebuilds every table and figure from\ncommitted data, with no network and no key. A checksum manifest lists every file it consumes,\nincluding files read from other studies, but itself, which its pushed commit anchors; the script\nchecks every frozen file and the runtime against the freeze itself, then the manifest, before it\ncomputes anything. No module in the study may share a name with a standard-library module or\nwith another study&#39;s module, or the reproduction runs different code depending on where it was\nstarted.\n<strong>Complete when:</strong> a clean checkout runs <code>reproduce.sh</code> offline to byte-identical outputs, and\nthe manifest covers every other file the run opened.</p>\n</li>\n<li><p><strong>Arm every gate by mutation, and watch each one fail.</strong> Tamper with one row of raw data;\nremove one manifest line; mutate one scorer rule. Run the reproduction after each and watch it\nrefuse. Restore from a byte copy taken before the mutation, never from version control, which\ndiscards any uncommitted work in the same file along with the mutation.\n<strong>Complete when:</strong> each gate has a recorded failing run under a named mutation, and a passing\nrun after a restore that was checked by content.</p>\n</li>\n<li><p><strong>Review every study pull request independently, and record corrections in the open.</strong> Each PR\ngets an independent review round (<code>codex-review-loop</code>). A finding that changes a published\nnumber becomes a correction — what was wrong, what changed, which numbers moved and by how\nmuch — in an addendum or in the round&#39;s review record. It is never repaired silently in place.\n<strong>Complete when:</strong> every PR has its review record, and every number that changed after it was\npublished carries its correction.</p>\n</li>\n<li><p><strong>Write the report for the decision, and say what the study cannot tell.</strong> The verdict per bar;\nquality, harm and cost per arm; each judge alone; the A/A distribution; every correction; and what\nthe study did not cover — item types it did not sample, providers it did not pin, volume it\ndid not price.\n<strong>Complete when:</strong> the report answers the plan&#39;s question in the plan&#39;s terms, and a reader can\ntrace every number in it to <code>reproduce.sh</code>.</p>\n</li>\n</ol>\n<h3 id=\"usage-examples\">Usage Examples</h3>\n<pre><code class=\"language-text\">Before we switch the ticket classifier to the cheaper model, run a preregistered study. Commit the\nplan, the freeze and a dry run before you spend anything, and cap the spend in code. I want to know\nwhether it passes the bars and, separately, whether it is actually better, and what it costs at our\nvolume.\n</code></pre>\n<pre><code class=\"language-text\">The last comparison&#39;s judge preferred the answer that made things up. Rerun the judging with three\nvendors, tag which fields the model wrote or guessed, give each judge a source-only reading too, and\nreport every judge on its own as well as the majority.\n</code></pre>\n<pre><code class=\"language-text\">Prove the harness sends what production sends before we measure anything. Show me one real item&#39;s\nrequest from production and from the control arm, diffed, with the serving provider pinned on both.\n</code></pre>\n<pre><code class=\"language-text\">We changed the scorer after the first batch of calls. Write the addendum — what changed, why, which\ncalls it governs, which published numbers move — and push it before the next batch runs.\n</code></pre>\n<pre><code class=\"language-bash\"># Rebuild every number offline; the script checks the manifest before computing anything.\n./reproduce.sh\n\n# Arm the manifest gate: drop one line, watch the run refuse, restore from a byte copy.\ncp MANIFEST.sha256 MANIFEST.sha256.bak\ntail -n +2 MANIFEST.sha256.bak &gt; MANIFEST.sha256\n./reproduce.sh; echo &quot;exit $? (expected non-zero)&quot;\ncp MANIFEST.sha256.bak MANIFEST.sha256 &amp;&amp; cmp MANIFEST.sha256 MANIFEST.sha256.bak &amp;&amp; ./reproduce.sh\n</code></pre>\n<h3 id=\"what-it-looks-like\">What it looks like</h3>\n<p>Specimens, not prompts.</p>\n<h4 id=\"a-result-a-reader-can-check\">A result a reader can check</h4>\n<pre><code class=\"language-text\">Bar 2 — invention: an answer given where the source cannot determine it\n  predicate: items whose source leaves the field undeterminable; same items in both arms\n             (n = &lt;n&gt; per arm)\n  arm A &lt;a&gt;%   arm B &lt;b&gt;%   difference B-A &lt;d&gt; points, 95% interval [&lt;lo&gt;, &lt;hi&gt;]\n  bar (from PLAN, commit &lt;sha&gt;): B-A &lt;= 1.0 point and upper bound &lt;= 2.0\n  result: FAIL — the upper bound is above 2.0\n  each judge alone: J1 FAIL, J2 FAIL, J3 pass; majority FAIL\n  A/A distribution (&lt;k&gt; baseline runs, paired resampling): 95% of A-vs-A differences within +/- &lt;f&gt; points\n  rebuilt by: reproduce.sh -&gt; tables/bar-2.csv\n</code></pre>\n<p>Every number has its predicate, its interval and its source; the bar is quoted from a commit that\npredates the calls; the judges are visible one by one; and the A/A distribution says how much of\nthe difference the control produces against itself.</p>\n<h4 id=\"the-same-result-reported-badly\">The same result, reported badly</h4>\n<pre><code class=\"language-text\">Model B hallucinates slightly less than A (3.9% vs 4.1%) and costs 60% less, so it&#39;s the winner.\n</code></pre>\n<p>No predicate: nobody can tell what the 3.9% is a share of. No interval or A/A distribution: the gap\ncould be the control disagreeing with itself. &quot;Winner&quot; answers a bar that only asked whether B was\nsafe to switch to. No judge is visible, so it may rest on one judge&#39;s taste; no number is rebuilt.</p>\n<h3 id=\"pitfalls\">Pitfalls</h3>\n<ul>\n<li><strong>The bar that moved.</strong> A threshold chosen after the results are in always fits them. Only a\ncommitted plan with an earlier timestamp separates a bar from a description of the outcome.</li>\n<li><strong>A rule definition nobody read against an example.</strong> Counting a &quot;no&quot; on a field that does not\napply the same as an invented &quot;yes&quot; flipped one study&#39;s winner. The definition read sensibly;\na single real item showed what it did.</li>\n<li><strong>A passed gate written up as the winner.</strong> Non-inferiority says &quot;no worse than the control by\nmore than X&quot;. It says nothing about which arm is better, and a report that calls the passing arm\n&quot;better&quot; has answered a question the study never asked.</li>\n<li><strong>A judge that cannot see invention.</strong> Given the same untagged evidence as the model, a judge\nreads a guessed field as a sourced one and marks the answer correct. Provenance tags and a\nsource-only reading are what let it notice.</li>\n<li><strong>A control that was not production.</strong> A reordered message, a missing schema field or a default\nparameter makes the control a different system, and a fault in a fresh control run makes every\nother arm look better. Compare it with production&#39;s stored outputs before trusting it.</li>\n<li><strong>The &quot;same&quot; model from a different provider.</strong> Providers serving one model name can answer\ndifferently, and a router that picks by request layout can move an arm to another provider\nwhen only its layout changed.</li>\n<li><strong>A reservation that is not a bound.</strong> A cap checked after the call reports money already spent;\na reservation at list price, or counting tokens only, is exceeded by the first call billed above\nlist or that also searched the web, and the cap with it. Reserve every billable unit at a ceiling\nprice, first.</li>\n<li><strong>Parity paid for before it was planned.</strong> A control run &quot;just to check parity&quot; spends before any\nplan constrains it. Request parity is free, in the dry run; output parity is a capped paid stage.</li>\n<li><strong>More than one call in flight.</strong> Two paying processes, or parallel calls in one, each reserve\nagainst a total the others have not added to yet, and together spend past the cap. This guard&#39;s\ncap is hard only for one process, one call at a time.</li>\n<li><strong>One A/A pair taken as the noise floor.</strong> Two runs are one draw of how far the control differs\nfrom itself. Treated as a hard floor, it vetoes real differences on a lucky draw and passes\nnoise on an unlucky one.</li>\n<li><strong>A reproduction that read more than its manifest.</strong> A file read from another study changed\nunderneath, unlisted; a module named like a standard-library one, or another study&#39;s, ran\ndifferent code depending on the directory the reproduction was started from.</li>\n</ul>\n<h3 id=\"verification\">Verification</h3>\n<ul>\n<li><input disabled=\"\" type=\"checkbox\"> The question is written as a decision, naming who makes it.</li>\n<li><input disabled=\"\" type=\"checkbox\"> PLAN, FREEZE and DRY RUN were each pushed to the study&#39;s pull request before its first paid\ncall, and the remote&#39;s push record shows it.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Every bar has a point rule and an interval rule, and invention has a bar of its own.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Every metric definition was read against named real items before it was frozen.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The data was classified before any paid call, every recipient is approved for it, and every\nartefact carrying it is kept where its class allows.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The freeze hashes every executable and configuration that can change a request, a spend\ndecision or a verdict, with the runtime&#39;s version and the dependency lock.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Every paid call went through the one research account, not production&#39;s, and the checks that\nrefuse production&#39;s account, by the account the provider names for each key, and any other\npaid credential ran.</li>\n<li><input disabled=\"\" type=\"checkbox\"> One paying process held an operating-system lock for the run, and calls were admitted, sent\nand settled strictly one at a time.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Before each call the guard reserved an upper bound on its bill — every billable unit at its\nbound and a ceiling price, for every attempt, the client library&#39;s own retries off — and\nchecked the study cap and the call&#39;s stage cap; a unit with no cap or no price was refused.</li>\n<li><input disabled=\"\" type=\"checkbox\"> On an account that is the study&#39;s alone, with a balance endpoint, the account&#39;s balance was\nread before every admission, less everything the study settled, and a call that would cross\nthe floor, a balance below it, or a failed read latched the run and wrote STOP; elsewhere the\nplan records the floor as unavailable and the caps govern alone.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Each call was settled, at the larger of list and reported cost per attempt, before the next\nadmission; a settlement above its reservation latched the guard.</li>\n<li><input disabled=\"\" type=\"checkbox\"> A restart restored the study&#39;s and every stage&#39;s totals from the ledger, with unsettled\nreservations at their worst case, and rechecked every settled call against its reservation\nand every total against its cap before admitting anything. Each part was watched refusing.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Request parity was proven offline, in the dry run, before the study&#39;s first paid call: the\ncontrol&#39;s request equals production&#39;s, with the provider pinned in every arm&#39;s request and in\nproduction&#39;s own; every dry-run difference from production&#39;s request is intended.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Output parity ran as the first paid stage, under a cap and pass rule committed before its\nfirst call, and every call was served by the pinned provider.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The A/A distribution was estimated from repeated baseline runs or paired resampling, with its\ninterval; no single A/A pair was used as a floor or a veto; a layout-only control ran where\nlayout or caching could change; arms were interleaved per item; every arm had the same inputs.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Every change after the first paid call has a dated addendum: one made before its calls was\npushed before them, its offline gates re-run and pushed with it and, where a request changed,\nits output parity pushed before any later call; one found after them is marked as a\ncorrection, never backdated, and every call, judge verdict and score it invalidated was\nredone or excluded before any bar&#39;s verdict.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Three judges from three vendors scored every item where the arms differ for each item-wise\nadditive metric the plan named for the shortcut, its absolute rate reported as not measured,\nand every item for every other metric, invention always among them; the majority and each\njudge alone are reported; judges saw provenance tags and a source-only reading. A shortcut\nhas a passing exactness test on a fixture.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Denominators match across arms, and every percentage carries its predicate.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The report gives quality, harm and cost beside the bars, and does not call a passing arm\nbetter on the strength of the bar alone.</li>\n<li><input disabled=\"\" type=\"checkbox\"> <code>reproduce.sh</code> rebuilds every number offline, byte-identically, from a clean checkout, under\nthe frozen runtime and dependency lock.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The manifest covers every other consumed input, files from other studies included.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Each gate was armed by a named mutation, watched failing, and restored from a byte copy.</li>\n<li><input disabled=\"\" type=\"checkbox\"> No study module shadows a standard-library module or another study&#39;s module.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Every study PR has a review record, and every number that changed after publication carries\nits correction.</li>\n</ul>\n<h3 id=\"deeper-reading\">Deeper reading</h3>\n<ul>\n<li><a href=\"references/study-files.md\">Study files</a>: the directory layout, the PLAN, FREEZE and ADDENDUM\ntemplates, the shape of <code>reproduce.sh</code> and the manifest, and what the report and the audit carry.</li>\n<li><a href=\"references/budget-guard.md\">The budget guard</a>: its single-process scope, the parts, a sketch of\nthe admission path, the restart, and how to arm each part.</li>\n<li><a href=\"references/parity-and-controls.md\">Parity and controls</a>: request and output parity, pinning\nproviders, the A/A distribution, the layout-only control, and interleaving.</li>\n<li><a href=\"references/judging-and-metrics.md\">Judging and metrics</a>: the panel, provenance, each judge alone,\nthe shortcut and its exactness test, invention, denominators and predicates.</li>\n</ul>\n","outline":["What a verdict rests on","When to Use","Prerequisites","Procedure","Usage Examples","What it looks like","Pitfalls","Verification","Deeper reading"],"words":5816}
