32. Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Part of the fleet REST guideline cutover set: it must deploy together with the other services' cutover PRs (order-management in particular, whose release route this context calls).
Context
The fleet REST API guideline (warehouse-docs, REST guideline) makes four rules
mandatory for every apis/openapi.yaml, enforced by the rest-guideline
Spectral rule in .spectral.yaml (R1-R8):
- URLs are nouns: no
:verbsuffix and no verb path segment; a command is aPUTof an attribute, aDELETE, or aPOSTcreating a noun (a transition resource such as/orders/{id}/releases). - Every
POSTandPATCHrequiresIdempotency-Key(1-128 printable ASCII). The fingerprint is method + path + SHA-256 of the body; the same key and fingerprint replays the stored answer withIdempotency-Replayed: true; the same key with another fingerprint is409 idempotency-key-reused; a missing key is400 idempotency-key-required. 2xx and 4xx are stored, a 5xx is not. - Every collection
GETpages withlimit(1-500, default 100) and an opaque keysetcursor, answers{ "items": [...], "nextCursor": "..." }, and rejects an undeclared query parameter with400 unknown-query-parameter. - Consumers send the key, read
itemsand follow (or bound)nextCursor.
This context had no idempotency middleware (its one write,
POST /network-orders/{networkRef}/shipment-confirmation, ADR 0014, relied on
the domain's own "already CONFIRMED" rule), answered its two lists under
per-resource keys (networkOrders, capabilityOffers) without paging, and
called order-management's retired POST /orders/{id}/release.
Decision
- Routes. None of this context's own routes is renamed: the rename map has
no entry for it, and
shipment-confirmationis already a noun. - Idempotency.
POST /network-orders/{networkRef}/shipment-confirmationsits behindinboundhttp.Idempotent, route-scoped. Records live in theidempotency_keystable (migration 0012), keyed by the key ALONE (global, not per route), kept at least 24 hours. Concurrent requests with one key are serialized by the primary key: one claims, the others wait and replay its answer. The key is required (required: true): Postgres is the only runtime (ADR 0025), so the middleware is active in every mode. - Deviation: the key row does not join the order's unit of work. The use
case is a saga that commits in phases around two external calls (it asks the
network for a label BEFORE the transaction that saves
CONFIRMEDand writes the outbox rows, and submits the confirmation AFTER it, ADR 0014). Forcing one transaction around the whole request would hold a database transaction open across network calls and hide the intermediate state from the sweeps. The key is therefore claimed before the handler runs, completed after it answers, and released on a 5xx or panic. Duplicate execution across replicas is still prevented by the claim (first insert wins, the loser waits and replays), and the domain rule (an order alreadyCONFIRMEDis answered 204 without a second submission or event) still covers a crash between the order's commit and the key's completion. - Pagination.
GET /network-orders(unanswered working set) is ordered by (acknowledgeBy,networkRef);GET /capability-offersby (sku,siteId). Both use the fleetpagehelper copied verbatim tointernal/adapters/inbound/http/page, in the Postgres and in-memory repositories alike. No exemptions are declared. The MCP and A2A tools keep their own (unchanged) schemas and read the repositories directly. - Consumers in this repository.
internal/adapters/outbound/ordermanagement/planner.go: release isPOST /orders/{id}/releaseswith a stable keynetful-release-<id>. (2026-11-19: a refusal on the keyed calls is read by order-management's replay class, see ADR 0037.)web/(netfulfil_mfe remote): readsitems, calls withlimit=500and reports a returnednextCursor(guideline 5.2, bounded single page).- BDD, unit and integration HTTP clients send a fresh key per submit.
Consequences
- Breaking for every client of the two lists and of the POST; it must ship in the same set as the other cutover PRs.
- A retried shipment confirmation with the same key now replays the first
answer byte for byte, including a 4xx (
confirm-before-acknowledgereplays even after the order was acknowledged): a new user action needs a new key. make checkcovers the middleware with the in-memory store; the-tags=integrationsuite covers it over real Postgres (fresh key, replay withIdempotency-Replayed, 409 reuse, 400 missing key, 4xx cached, N concurrent requests producing oneNetworkOrderShipmentConfirmed).