Notes
Receipts, not claims
Nov 16, 2026 · Bradley Leatherwood

Notes
Nov 16, 2026 · Bradley Leatherwood


We run a lot of agents in parallel. Each works in its own GitSpace workspace and opens pull requests that are tested, explained and reviewed before a person looks at them. That part works. What broke was CI.
Every agent PR then went through the full suite again on CI: typecheck, lint, golden files and six test jobs, a median of 46 billed job-minutes per push. The agent had usually run the same checks minutes earlier, on the same commit. In the week before we changed anything, 83% of our CI spend was pull-request checks, and most of that was CI repeating work that had already passed.
This note covers what we did about it. CI no longer redoes the work. It checks receipts.
"Tests pass" in a PR description is a claim. CI exists because claims are cheap. But a full re-run isn't the only way to check one.
A receipt is a stored result for one task (one package's typecheck, one test shard) whose cache key covers every input to that task: source files, lockfile, toolchain versions, the operating system, the time zone, the environment variables tests read, and the exact arguments the task runs with. A receipt only counts if a machine we trust wrote it.
So when a PR is ready, CI asks one question for each of its roughly 170 tasks: is there a trusted result for exactly these inputs? If there is, the work was done, and done on this code. If there isn't, CI says so.
We built it on Nx's task cache. Nx Cloud would have hosted it, but it prices by CI pipeline run. With the number of runs agents create, we estimated that at about $500 a month on top of the runner bill. Nx 24 supports a self-hosted remote cache, so ours is a small Cloudflare Worker in front of R2.
A receipt is only as good as whoever wrote it. The rules:
refs/heads/develop.ci label run on a PR from this repository writes, but only after the cache confirms the token came from that labelled run and that the author, the labeller and anyone re-running it can push. Forks and outside contributors stay read-only.Each receipt records who wrote it. The PR shows receipts: All 171 tasks proven by machine:<host>, or which tasks are still missing.
The idea is simple. The work was making a shared development machine and CI compute the same hash for the same work, and never the same hash for different work. Our rule: a wrong input should cause a miss, never a stale hit. Getting there meant finding every place the two environments quietly disagreed:
verify now refuses to run under a Bun CI doesn't use. Later (#1431), machines also stopped picking up whichever bun came first on PATH; on our Linux machine that was a bootstrap Bun 1.4.0 instead of the 1.4.4 CI runs. Each machine now exposes its own pinned Bun 1.4.4.TZ set at runtime to the processes it starts, so the cache client now passes its environment to them explicitly.verify now starts from a freshly built graph.verify now regenerates install-time output before each tier.--. They're part of a task's hash, so verify invokes every task exactly as CI does, shard flags and reporters included.verify. The wrappers now add a path only if it's missing (#1431).Three near-misses were worse, because they would have passed:
The first version gated every ready PR on receipts and failed when any were missing. That was the wrong signal. On one PR, marked ready before anyone ran verify, a red quick checks sat at the top of the page even after full CI had proven everything. A missing receipt doesn't mean broken code. It means not proven yet.
So we changed the PR flow to work like this:
preview label.quick checks: formatting, the changeset check, and Rust when Rust inputs changed. It fails only on those.receipts is a commit status, not a job. It's pending until every task is proven, and every new push sets it back to pending. Pending is yellow, not red.bun run verify on a machine and add the verify label; CI checks the receipts in about a minute. Or add the ci label and CI runs the full suite itself. Either way, the run removes the label when it starts (#1426), so a later push needs a button pressed again. A forgotten ci label no longer reruns full CI on every push.machine:<host>, or CI (run <id>).ci run leaves receipts behind (#1520). On a PR from someone with write access, it writes its results to the cache as ci:pr-<number>#<run>, under the same first-writer-wins rule. A later verify, or CI after a small push, replays them instead of doing the work again. Forks and outside contributors stay read-only.On a machine that has already proven a source, verify is cheap: on our Linux machine a repeat run took 19 seconds, with all 171 tasks replayed from receipts. Only tasks whose inputs changed run again.
We measured every Actions run from October 26 to November 14: each job's start and end from the GitHub API, rounded up to whole minutes, at Blacksmith's list rate for its runner. The changes landed in four steps, so the table has five periods. It stops when #1520 changed the ci label again; the two days since are too few to read.
| Period | Span | PR CI per day | All CI per day | Median ready-PR run | PR CI per merged PR |
|---|---|---|---|---|---|
| Before (full CI on every PR push, drafts included) | 7.7 days | $23.52 | $28.30 | 46 job-min, $0.73 | $7.82 |
| Drafts run nothing (#1319) | 4.4 days | $37.44 | $46.16 | 36 job-min, $0.56 | $4.72 |
| Receipts (#1377) | 14.5 h | $40.54 | $48.07 | 12 job-min, $0.15 | $2.72 |
| One quick-checks job (#1409) | 13.6 h | $9.80 | $14.37 | 12 job-min, $0.18 | $0.79 |
ci is a button, receipts pending (#1426) | 5.8 days | $9.05 | $14.17 | 1 job-min, $0.004 | $1.82 |
Spend per day went up after drafts stopped running CI. Mostly that's because we were merging more: about 3 PRs a day before, almost 8 after, and around 15 a day while receipts were new. Per merged PR, every step cut the cost. Over the full week after #1426, CI per merged PR was 77% lower than before we started, and all CI per day was half.
Drafts alone account for a lot of runs. From November 2 to 8, 222 Check Build runs started on draft PRs. 174 of them ran no job at all, 40 were previews someone asked for with the label, and 8 were one-minute jobs cancelling superseded runs. None ran a check or a test. 38 of the 57 PRs opened in those days started as drafts.
The first 18 hours after #1426 looked like the finished picture: five verify runs, each about a minute of CI, no ci label at all, and $0.10 of PR CI per merged PR. The rest of the week didn't hold that. The ci label was pressed 80 times, against 23 verify runs. A median ci run is 30 job-minutes, 40 cents and 9 minutes, and those runs were 59% of that week's PR CI spend. Most proofs came from CI doing the work, not from a receipt.
ci and paid full price, and we haven't yet separated how often that was the machine being unavailable and how often it was habit. A large toolchain change (#1499) also landed mid-week and changed every task's inputs.ci run's results were thrown away. PR runs had read-only cache tokens, so after a small push the next proof started from scratch. Trusted ci runs now write receipts, which should make the second proof of a PR cheap whichever way the first one came. We haven't measured that yet.CI went from doing the work to auditing it. The checks still have to pass on exactly this code, but they can pass anywhere we trust, and CI's job is to confirm that they did. Local compute stopped being a convenience and became a resource agents spend deliberately: run verify once, at the end, then press the button.
If you run agents, or just a busy monorepo, against CI you pay for by the minute: