ADR-0145 — A documented operation is one the router answers
Status: Accepted · Date: 2026-08-31 · Supersedes: —
Context
ADR-0143
measured shared/contracts/openapi.yaml's schemas against the structs that
serialise them, and
ADR-0144 widened that
measurement from names to types and nullability. Both left the same thing open,
in as many words: "whether every route in the document exists, and whether
every route in the router is in the document, is the larger half of the same
finding".
It is larger because a types package is not a client. A generated client is a method per operation, and an operation has three parts a document can lie about: that it exists, that it is spelled the way the router spells it, and that it is reached with — or without — a credential. The schemas being true makes the payloads right; the paths being untrue makes the calls wrong.
Measured, the document is in better shape than the schemas were, and wrong in one place that matters more than a missing route:
- Every one of the 226 declared operations is served. Nothing documents an endpoint that no longer exists — a real risk, and not this document's.
- Nine client operations are served and undocumented, all of them routes
that landed after the document was last topped up: five from track 006's
collaboration surface (comments, presence, the activity feed) and four AI
collection reads whose sibling
POSTandDELETEare both documented. - Ten operations declare the wrong authentication. Three type catalogues —
/api/v1/biolink-blocks/types,/api/v1/qr-codes/types,/api/v1/pixels/types— declaresecurity: []and are registered inside the/api/v1scope that appliesmiddleware.BearerAuth. Seven publicauthroutes — activation, re-activation, the captcha, the legal texts and the three OAuth operations — declare nothing and so inherit the document's bearer default, though the router serves them with no authentication at all.
The last group is the finding ADR-0143 predicted would land on the generator
rather than on the document. apps/api/scripts/gen_openapi_paths.py decides
publicness from a hand-maintained prefix list, and /api/v1/auth is not on it —
so every auth route it has ever emitted was emitted requiring a token to
register, and re-running the generator would write the same seven back.
Decision
The router is the truth, and npm run check:contract-paths holds the document
to it. scripts/check-contract-paths.mjs reads chi's nesting in
apps/api/cmd/server/main.go — r.Route prefixes, r.Group scopes, and the
r.Use(middleware.BearerAuth…) a scope applies to everything under it — and
compares it to the paths: block, on four rules:
- P1 — every operation the document declares is served by a route.
- P2 — every client-facing operation the router serves is declared, or is
a row in
scripts/contract-paths-ledger.json. - P3 — every ledger row still names a live gap at a route that exists; a row whose gap is closed is deleted in the commit that documented it, which makes the count a ratchet rather than an allowlist.
- P4 — a documented operation declares the security the router enforces: no
security: []on a bearer-authenticated route, and no inherited bearer default on one served without authentication.
P2's scope is the client surface the document declares for itself:
/api/v1/* and the payment /webhook/* callbacks. Admin, observability and the
public render paths are documented where useful and are not required to be —
but P1 holds them the moment they appear, because a documented admin route that
no longer exists is the same lie as a documented client one.
P4 has no ledger escape, for C4 and C5's reason: a path can be undocumented for a reason — the route landed this week — and a documented route's authentication cannot be wrong for one.
The ten P4 failures are corrected in this commit, and the generator with
them: PUBLIC_PREFIXES gains /api/v1/auth, with PRIVATE_EXCEPTIONS keeping
the 2FA pair private, since those two are spelled under /auth/ but registered
inside the authenticated group.
Consequences
No served byte moves. Ten document edits and a generator's prefix list; the router is untouched. What changes is what a client generated from the document would do — send the credential the three type catalogues require, and stop demanding one to register an account.
The remainder is nine rows and a number: 205 of 214 client operations are declared. The rows drain the way the schemas' did, and P3 deletes each one in
the commit that documents it.
The generator emits stubs, and a stub is not a document. Its entries carry a
generic additionalProperties: true body and a tag guessed from the first path
segment. That is enough for coverage and not enough for generation, which is why
the nine rows are drained by hand rather than by re-running it.
Watched failing six ways before it was trusted: an operation the document
declares and no route serves (P1), an undocumented route with its ledger row
removed (P2), a ledger row whose gap is closed (P3), a row naming a route that
does not exist (P3), security: [] restored onto a bearer-authenticated
operation (P4), and its inverse — the security: [] taken off a public one,
which is the defect this commit fixed, arriving again.
Source: docs/decisions/0145-a-documented-operation-is-one-the-router-answers.md