0048. Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Amends ADR 0023
(reuse is now 409, not 422, and the middleware wraps every POST, not only
POST /orders) and ADR 0038
(every command carries a key, not only POST /orders). Part of the fleet-wide
REST cutover: it ships and is deployed together with the other services'
cutover PRs, because the new routes and the key contract are breaking for every
client.
2026-11-19: what a retry replays is narrowed by ADR 0054: a 2xx and a refusal that is final for the request are replayed; a refusal that depends on state that can change is not stored and its key is released.
Context
The 2026-10-30 portfolio assessment measured two spellings of the replay header,
key reuse answered 422 in most services and 409 in one, three command-URL
styles (:verb, verb sub-paths, sub-resources) and unpaginated lists. The fleet
standard removes each divergence and is enforced by a Spectral ruleset
(.spectral.yaml + .spectral/functions/restGuideline.js, rules R1-R8) in the
api-lint job with --fail-severity=warn.
Before this ADR only POST /orders was idempotent. POST /orders/{id}/release
and POST /orders/{id}/retry-allocation were protected only by the optimistic
version check (ADR 0024), which stops a double effect but answers the retry
with a confusing 409 concurrent-modification.
Decision
- Routes. The two verb routes become transition resources, with the same
status codes and bodies:
POST /orders/{id}/releasetoPOST /orders/{id}/releasesandPOST /orders/{id}/retry-allocationtoPOST /orders/{id}/allocation-retries.operationIds are unchanged. The old routes are removed, not aliased (TestRetiredRoutesAreGone). - Idempotency on every POST.
POST /orders,/releasesand/allocation-retriesall sit behind the middleware, and each use case joins the unit of work, so the key row, the order change and the outbox rows commit together. The optimistic-concurrency check stays as a second line of defence.DELETE /orders/{id}is idempotent by method and takes no middleware. - Key contract. The key is global (looked up by key alone, compared by
method + path + SHA-256 of the body). Same key and same request replays the
stored answer with
Idempotency-Replayed: true; same key and a different request is409problemidempotency-key-reused; a missing key is400 idempotency-key-required; a key that is not 1-128 printable ASCII is400 idempotency-key-invalid.Idempotent-Replayedis retired. - Pagination.
GET /planned-capacityis a read model bounded by a window and carriesx-pagination-exempt: report.GET /orders/{id}is a single resource.
Consequences
- Breaking for clients: the two routes moved, reuse is
409, andreleaseandretry-allocationnow require a key. network-fulfillment (which callsPOST /ordersand the release route) and e2e-tests change in their own PRs. - A retry of a
releaseafter a timeout now replays the first answer instead of failing withconcurrent-modification. - Existing in-flight keys keep working: a key first used before the deploy is
looked up by key alone, so it replays; only a retry whose body changed gets
409.