The OpenAPI lockfile and the wire contract are the compatibility authority
Status
Section titled “Status”Accepted.
2026-05-27 (the date the lockfile was first committed; the enforcement steps were added over the following weeks).
Context
Section titled “Context”The HTTP API has many consumers that the platform team does not release together:
- the console, whose TypeScript client is generated from the API description;
- the SDKs (Go, TypeScript, PHP, Java and others), several of them generated or hand-written against the same shapes;
- every webhook subscriber, which depends on the delivery envelope and signature;
- applications running in other organisations’ environments, upgraded on their own schedule.
Small changes that look harmless are breaking for those consumers: renaming a JSON field, changing an
enum’s string value, turning a nullable field into a required one, returning a body where the contract
says 204 No Content, changing 422 to 400, changing a pagination shape, or renaming an
operationId (generated clients use operationId as a method name, so a rename renames a method and
breaks the build).
A convention that says “do not do that” is not enough. Handlers are generated from typed Go code, so a change to a struct tag in a refactor changes the API with no one meaning to.
Decision
Section titled “Decision”Make the compatibility surface a committed artefact that CI compares against the live code, and make the written rules the standing authority over style preferences.
api/openapi.lock.jsonis the OpenAPI document generated from the registered routes, committed to the repository.make api-diffregenerates the document and fails if it differs from the lockfile; it is part ofmake ci. An intentional change is recorded withmake api-bump, which puts the diff in code review where a reviewer sees it as a change to the contract.- Each operation carries its SDK class in the lockfile (
x-sdk: app | admin, absent for internal routes). The application-facing surface is exactly thex-sdk: appoperations. Routes that the server mounts as plain handlers (batch ingest, the OAuth endpoints) are described by spec-only stubs so they are in the lock too. - Downstream generation reads the lockfile: the console’s TypeScript client is regenerated and
diffed (
make frontend-types-verify), and the SDK generators take their input from the same file. Regenerating must not produce a diff unless the contract deliberately changed. docs/wire-contract.mdlists what counts as a breaking change and fixes the details the OpenAPI document cannot express: RFC 3339 timestamps with six-digit microseconds, the{error, message}error envelope and the status mapping (no422), pagination postures per endpoint, screaming-snake-case enums with lenient parsing, and the null-versus-missing posture per field.- The code convention backs it up: if a Go-idiomatic change would alter a response shape, an OpenAPI definition, a JSON field name or a stored row layout, do not make it. API redesign is a separate, versioned effort, and an exception needs sign-off from the owner of the affected consumer.
The routes that are served by plain handlers and absent from the lock (login, session, discovery) are listed by hand in the wire-contract page, so their absence is deliberate rather than accidental.
Consequences
Section titled “Consequences”Good
- A contract change is visible as a diff to one file, in the pull request that causes it.
- Generated clients cannot drift from the server without CI saying so.
- Contributors can refactor internals freely, because the lock is the test.
- New SDKs and the conformance material have one description to start from.
Bad
- Cleaning up an awkward name or shape is expensive. Examples that remain on purpose: a
$schemafield on every response that no client needs, and some inconsistent pagination postures between endpoints. - The lockfile records shape, not behaviour. Rules such as ordering, idempotency or permission checks need their own tests and are written into the wire-contract page.
- Routes outside the lock (the chi-mounted auth and session endpoints) rely on documentation and tests instead of the diff.
Alternatives considered
Section titled “Alternatives considered”- Semantic versioning of the API with a deprecation window. Still possible for a deliberate change, but it does not catch the accidental one, which is the common failure.
- Contract tests only (record and replay). Useful alongside, but replay tests cover chosen requests, while the lock covers every operation.
- Write the OpenAPI document by hand and generate server stubs from it. Rejected because it loses the property that the documented API is the API that runs.