ADR 0007: Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Amends ADR 0002 A6, A12 and A13 (routes, listing, idempotency). Mirrors the fleet "Warehouse REST API Guideline" (warehouse-docs).
Context
The fleet measured divergent REST conventions: three command-URL styles (:verb
custom methods, verb sub-paths, sub-resources), two spellings of the replay header,
key reuse answered 422 in most services and 409 in one, and unpaginated lists.
This service had :revise, :publish, :retire, :discard, :move, :rename
custom methods, Idempotent-Replayed, 422 idempotency-key-reused, a per-route key
and an after/next page.
Decision
Hard cutover, no aliases, no dual routes, no toggles; enforced by .spectral.yaml
(rest-guideline, rules R1 to R8) in the api-lint job.
-
Noun routes.
Old New POST /product-contents/{id}:revisePOST /product-contents/{id}/revisionsPOST /product-contents/{id}:publishPOST /product-contents/{id}/publicationsPOST /product-contents/{id}:retirePOST /product-contents/{id}/retirementsPOST /product-contents/{id}:discardDELETE /product-contents/{id}/draftPOST /categories:publishPOST /category-tree-publicationsPOST /categories/{id}:movePUT /categories/{id}/parentPOST /categories/{id}:renamePUT /categories/{id}/nameoperationIds, status codes and bodies are unchanged. ThePUTandDELETEroutes are idempotent by method and take no middleware. -
Idempotency. Every
POSTsits behind the key middleware (noPATCHexists).Idempotency-Keyis 1 to 128 printable ASCII characters (400 idempotency-key-requiredwhen absent,400 idempotency-key-invalidwhen malformed). The key is GLOBAL: records are looked up by key alone and compared by fingerprint (method + path + SHA-256 of the body); a different fingerprint is409 idempotency-key-reused, a replay carriesIdempotency-Replayed: trueandIdempotent-Replayedis retired. The key row is written in the SAME transaction as the aggregate change and the outbox rows (the Postgres store joins the unit of work); 2xx and 4xx are stored for 24 hours, a 5xx or panic rolls back and is not stored. The existingidempotency_keystable is reused with theroutecolumn held constant (''), so no migration is needed.2026-11-20 — ADR 0009: "2xx and 4xx are stored" is now per problem type: every catalogue entry declares a replay class (FINAL, OUTCOME, RETRYABLE); a RETRYABLE refusal (nothing committed, the answer depends on state that can change) is not stored and its key is released. See ADR 0009.
-
Pagination.
GET /product-contentstakeslimit(1 to 500, default 100) and an opaquecursor(base64url JSON of the sort key and id) and answers{items, nextCursor}; keyset ordercatalogItemId, in Postgres and in memory. Problems:400 invalid-limit,400 invalid-cursor,400 unknown-query-parameter(the retiredafter,offset,nextTokenfail loudly). -
Exemption.
GET /categoriesisx-pagination-exempt: view: the CategoryTree is ONE versioned aggregate (at most four levels), so one response is one consistent snapshot of one tree version; paging would let a page straddle two versions.
Consequences
- Breaking for every client: it deploys together with the REST cutover set of the fleet.
- No in-repo caller needed changing (no web remote, no outbound HTTP client); the
A2A/MCP adapter exposes
GetProductContentonly. - The
Idempotent-Replayedheader and422reuse answer no longer exist anywhere.