ADR-0144 — Agreeing about a name is half a contract
Status: Accepted · Date: 2026-08-31 · Supersedes: —
Context
ADR-0143
set the condition for the standing repair that would generate types from
shared/contracts/openapi.yaml: nothing is generated until the ledger is
empty. Three slices emptied it — the account schema, the two link schemas, the
QR code, plan and payment schemas — and check:contract-parity reports every
property of all six gated schemas agreeing with the field that serves it.
That claim was narrower than it sounded. C1 and C2 compare names: a property the struct does not serve, a field the schema does not declare. They say nothing about what the property is, and the corrections went in by hand.
The third slice found what that costs. Payment.payment_id was declared an
integer; the field behind it is ExternalID string — the processor's own
reference — while the row's own identifier is id. Payment.status was
declared a string with four named states; the column is a SMALLINT and the
struct an int. Both properties had been named correctly all along, so a
ledger built on names never saw them, and a client generated from that document
would compile against number and 'pending' | 'completed' and fail on the
first response it read.
Nullability is the same finding one axis over. encoding/json marshals a nil
pointer to null; twenty-four of the gated fields are pointers, and a generated client
that does not know which cannot know where a null is a value rather than a bug.
Decision
The gate reads the type and the nullability, not only the name. Two rules join C1–C3, both evaluated on every property the two sides already agree exists:
- C4. A property is declared as the type its field serialises — every
integer width
integer, every floatnumber, atime.Timea string withformat: date-time, aJSONMapan object. A$refresolves to the referenced schema's own type. A Go type the mapping table does not carry is a failure, not a silent pass: the field that introduces one teaches the gate what it serialises to, in the commit that adds it. - C5. A pointer is
nullable: trueand nothing else is. Both directions fail — a non-nullable declaration on a pointer is a promise the server breaks, and anullable: trueon a value field is a null the caller must handle and will never see.
C4 and C5 have no ledger escape, which is where they part from C1 and C2. A
name can disagree for a reason the repository must live with: the wire is
frozen outside /api/v2/, so a rename waits and the row records the wait. A
type has no such excuse once the name is right — the document is either
describing the bytes the server sends or it is not, and there is no release to
wait for.
This is the widening ADR-0018's gate took at 002 phase 04, one subject over: the gate that reads only names measures the drift that is easiest to see, and the drift that survives it is the expensive kind.
Consequences
The scoreboard means more than it did, with the same number on it: 117 of 117 properties agree in name, type and nullability, and the success line now says so. Nothing about the document changed in this commit — the three slices had already made all five rules hold, which is why the widening lands green.
The generated package is now the next act, and it is unblocked. The
condition ADR-0143 set was an empty ledger; what a generator actually needs is
this, because it emits types rather than names. A payment_id: number in a
generated client is worse than no client at all: it compiles.
A new field costs two more lines of thought. Adding a column and a struct field now means declaring the property with the right type and the right nullability or the build fails — which is the point, and it is cheaper at the commit that adds it than at the release that discovers it.
The paths are still not gated. Whether every route in the document exists
and every route in the router is in the document remains the larger half of the
same finding, over apps/api/scripts/gen_openapi_paths.py rather than the
schemas, and stays an open item under the same standing repair.
Watched failing six ways before it was trusted: a declared type that is not
what the field serialises (C4), a $ref resolving to the wrong wire type (C4),
a timestamp declared without format: date-time (C4), a Go type the mapping
table does not carry (C4), a pointer the contract does not call nullable (C5),
and a value field the contract does call nullable (C5).
Source: docs/decisions/0144-agreeing-about-a-name-is-half-a-contract.md