The change receipt now has an OpenAPI description, generated types and drift checks
The receipt that tells an agent whether its change landed is now described in OpenAPI 3.1 in the public nerudo/nerudo repository, with TypeScript types generated from it, and the landing gate fails when the description, the types, the example receipts and the forge's Rust struct disagree.
Scripted demonstration
An agent learns whether its change landed by reading the change receipt. Until T-389, the receipt's shape existed only as the forge's Rust struct, ChangeRec. The MCP server read it untyped, so a change to that struct could change what agents were told unnoticed. T-389 describes the receipt in OpenAPI 3.1 in the public nerudo/nerudo repository, generates TypeScript types from that description, and makes the landing gate fail when the description, the types, a set of example receipts and the forge's struct disagree. The API itself did not change.
The first two figures are signed-out captures of production nerudo.dev, showing the files at the deployed commit 4388649. The last three are scripted local runs of that commit's check in a terminal session started only for the capture, with a scratch home and no shell profile. They run on a scratch copy of the package whose files match the commit byte for byte. That machine has Node 26; CI uses Node 22.
What the description covers
packages/contracts/openapi/forge.json names the three routes that return a receipt. GET /v1/trunks/{trunk}/changes/{change} serves the agent that sent the change. GET /v1/repos/{owner}/{repo}/changes/{change} is the receipt URL a push prints. GET /t/{trunk}/api/changes/{change} is the route the web app reads. Each route takes rev and wait (at most 60 seconds), and the spec says how each one authenticates. The first two accept an agent key header or a bearer token. The app route accepts a share key or a personal key, and a public repository needs no key.
The Receipt schema is closed: an unknown field is an error. The same holds for the land request, Unland, Producer, Size and Decision. The schema lists the six states: queued, awaiting_seal, awaiting_allowance, awaiting_pick, landed and ejected. Its description states the rule agents rely on: state == landed with a seq is the only proof that a change is on main.

The first figure shows the Receipt schema's required fields and that description at 4388649.
packages/contracts/forge-api.ts holds the TypeScript that openapi-typescript 7.13.0, pinned with a lockfile, generates from the spec.

The second figure shows the generated Receipt type: seq is number | null, and trunk_commit is an Oid or null.
How drift is caught
Six example receipts in packages/contracts/examples connect the two sides: queued, awaiting a seal, landed, ejected, one with every field set, and an old record from before PR numbers, sizes, producers and decisions. On the Rust side, the forge's receipt_contract test in apps/forge/src/types.rs builds ChangeRec values and asserts that each one serializes to exactly its example file. The gate's cargo test --workspace runs it. On the spec side, a new qa step, "forge API contract", runs npm ci and npm run check in packages/contracts.
The check does four things. It regenerates the types in a temporary directory and fails if forge-api.ts differs. It validates every example against the Receipt schema, using ajv in strict mode. It requires examples in the queued, awaiting_seal, landed and ejected states. It fails when a property of the receipt's schemas appears in no example. Four fields that the HTTP handler adds and ChangeRec does not hold (runner_checks, runner_checks_truncated, stall and ci) are exempt from that last rule.

In the third figure, npm ci installs 35 packages from the lockfile. The check then reports that forge-api.ts is current and that all six examples match and show every property, and it exits with status 0.

The fourth figure uses a small fault script written for this capture, which prints each change it makes. It changes the spec's allowance from string or null to integer or null. The check exits with status 1 because forge-api.ts is out of date. After npm run generate, the type reads number | null, and the check fails again on the maximal example: data/allowance must be integer,null. Regenerating the types does not let a wrong spec through, because the examples still hold what ChangeRec sends.

In the fifth figure, the spec gains a merged_by field that no example shows. The check fails with "Receipt: no example shows merged_by" and points to receipt_contract. Then the subject field is removed from the queued example, as if the forge had stopped sending it. The check fails with "data must have required property 'subject'". After the files are restored, the check passes again.
Limits
The receipt_contract test was not run for this post, because the capture machine has no Rust toolchain. The landed commit's message records cargo test --workspace passing with it, and the test failing when an example drifts from ChangeRec. The fifth figure edits an example file directly. In the repository, the Rust test would also reject that edit, because the file would no longer be what ChangeRec serializes.
No production receipt was fetched or validated against the schema for this post. Nothing in the apps imports forge-api.ts yet: the MCP server and the web app still read the receipt without these types. The spec leaves reason, stall, ci and the runner checks open, except that reason must have a kind. Only the receipt routes are described, and this change adds no check for breaking changes between versions of the spec. Decision 0006, which records OpenAPI as the format, is still proposed.
Walkthrough details
Two figures are signed-out headless captures of production nerudo.dev showing packages/contracts/openapi/forge.json and packages/contracts/forge-api.ts at the deployed commit 4388649. Three are scripted local runs of that commit's npm run check in a terminal session started only for the capture, with a scratch home and no shell profile, on a scratch copy of packages/contracts whose files match the commit byte for byte, with deliberate faults applied by a small script written for the capture. Nothing signed in; the forge's Rust test was not run.
- Open packages/contracts/openapi/forge.json at 4388649 on nerudo.dev signed out, at the Receipt schema's required fields and description.
- Open packages/contracts/forge-api.ts at 4388649 on nerudo.dev signed out, at the generated Receipt type.
- Recreate the eleven files the check reads from 4388649 in a scratch directory and confirm each SHA-256 matches the commit.
- In a capture-only terminal session, run npm ci and npm run check on the unchanged copy.
- Change Receipt.allowance to integer or null in the spec, run the check, regenerate the types, run the check again, and restore.
- Add a merged_by property to Receipt, regenerate the types, run the check, and restore.
- Remove subject from the queued example, run the check, restore, and run the check once more.
Captured · Product view · Verification source