44. Adopt the fleet REST API guideline
Status
2026-11-20: the replay sentence of decision 2 (a replay returns the stored answer verbatim) holds for a
2xxand for a refusal whose problem type isFINALorOUTCOME; aRETRYABLErefusal is not stored and its key is released (ADR 0046).
Accepted (2026-11-01). Amends ADR 0019
(key reuse is 409, not 422; the key is global; the two excluded commands are
now keyed) and ADR 0006 (the route).
Does not touch auth (ADR 0015 still stands).
Context
The fleet REST API guideline (warehouse-docs) fixes three divergences between
services: command URLs (:verb, verb segments), the idempotency contract
(header spelling, reuse status, which POSTs are keyed) and unpaginated lists.
It is enforced by a Spectral ruleset (.spectral.yaml) in the api-lint job.
The cutover is a hard one: no aliases, no dual routes, no toggles; all services
deploy together.
Decision
- Noun routes.
POST /locations/importbecomesPOST /location-imports(a batch job noun, STANDARD 1.3e) andPOST /locations/{locationCode}/decommissionbecomesPOST /locations/{locationCode}/decommissionings(a transition resource, 1.4). Status codes and bodies are unchanged (200import report,204decommissioning).operationIds are unchanged, so MCP and A2A mappings do not move. The old routes answer 404/405 (TestRetiredRoutesAreGone). - Every POST is idempotent. All ten POST routes sit behind
RequireIdempotencyKey, including the import and the decommissioning that ADR 0019 excluded. The key is 1-128 printable ASCII characters (otherwise400 idempotency-key-invalid; missing is400 idempotency-key-required), it is looked up by key alone (global, not per route), and the fingerprint is method + path + SHA-256(body). A replay returns the stored answer verbatim withIdempotency-Replayed: true(neverIdempotent-Replayed); the same key with a different fingerprint is409 idempotency-key-reused. The key row commits in the same transaction as the aggregate change and its outbox rows; a 5xx or a panic rolls all of it back and is never stored.PUTroutes take no key (idempotent by method, none of them appends). - Keyset pagination. Every collection
GETtakeslimit(1-500, default 100) andcursorand answers{items, nextCursor}; rows are ordered by (sort key, id) and the cursor is base64url JSON frominternal/adapters/inbound/http/page.invalid-limit,invalid-cursorandunknown-query-parameterare400problems, so a client still sending a retired paging parameter fails loudly. - Contract job.
schemathesis.tomlwidens onlypositive_data_acceptancewith400for each pagedoperationId(cursoris opaque to OpenAPI).
Paginated collections
GET /sites, /site-roles/transfer-defaults, /sites/{siteCode}/zones,
/sites/{siteCode}/locations?role=, /sites/{siteCode}/structures,
/zones/{zoneId}/aisles, /zones/{zoneId}/cross-aisles, /location-types,
/placement-rules.
Exemptions (x-pagination-exempt: view)
| Operation | Why |
|---|---|
GET /sites/{siteCode}/layout | One composite resource (the nested zone/aisle/slot tree) that merely contains arrays |
GET /zones/{zoneId}/grid | One composite resource: the zone's rendering grid |
GET /zones/{zoneId}/travel-graph | One composite resource: the zone's nodes and edges |
GET /distance | One computed answer (a route between two slots), not a list of resources |
Consequences
- Breaking for every caller: the two routes, the list envelope, a key on
import and decommissioning,
409for key reuse. Known callers:e2e-tests(cmd/warehouse-day), thefacility-mferemote (changed in this PR),warehouse-infraseed, and consumers of the lists listed above. - The in-repo web remote follows
nextCursor(useFetchAll) and no longer sends the_rcache-busting query parameter, which collections now reject. - Paging is applied in the HTTP adapter over the repositories' complete result (ordered by (sort key, id)); pushing the keyset predicate into SQL is a later optimisation that changes no contract.