ADR 0010: Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Follows ADR 0005 (the
transactional idempotency design the middleware keeps) and
ADR 0006 (Idempotency-Key is required on every
deployment). Implements the fleet standard "Warehouse REST API Guideline" (warehouse-docs); it is a
breaking change that ships with the whole REST cutover set.
2026-11-20 pointer. ADR 0013 supersedes the "stored 2xx or 4xx" of item 2: a refusal is stored only when its problem type is FINAL (or OUTCOME); a RETRYABLE refusal is not stored and its key is released. The rest of this ADR stands.
Context
The 2026-10-30 application portfolio assessment found two spellings of the replay header, key reuse
answered 422 in most services and 409 in one, three command-URL styles and unpaginated lists.
This service already had noun-only routes (no :verb suffix, no verb segment), already kept its only
POST (POST /recommendations, a read-only simulation) behind the route-scoped Idempotency
middleware, and already paged its only collection (GET /hints) with limit/cursor and
{items, nextCursor}. What it lacked: a replay marker, 409 for key reuse, an OpenAPI document that
described them, and a declared status for two list-shaped reads that are not collections.
Decision
The service follows the guideline, with no alias, no toggle and no coexistence of old and new:
- URLs name things, never actions (R1, R2). No route changes: there is nothing to rename and no operation id moves, so MCP and A2A mappings are untouched. Status codes and bodies of every existing operation are unchanged.
- Every POST and PATCH is idempotent (R3 to R6, R8).
POST /recommendationswas already wrapped; there is no PATCH. The middleware changed minimally:- the replay header is
Idempotency-Replayed: true, set on every replay (a stored 2xx or 4xx, and the winner's answer handed to the loser of a race) and never on a first execution; - the same key with a different method, path or body is
409 Conflict, problem typeidempotency-key-reused(it was422); the fingerprint is method + path + SHA-256 of the body; - a missing key is
400 idempotency-key-required; a key that is not 1 to 128 printable ASCII characters is400 idempotency-key-invalid(an over-long key used to be reported asidempotency-key-required); - a 5xx is rolled back and never stored, and the key row commits in the same transaction as the aggregate change and its outbox rows (unchanged).
- the replay header is
- OpenAPI (R3 to R5, R8).
POST /recommendationsdocuments400,409(the sharedConflictresponse, which also coversconcurrent-modificationof the policyPUT) andIdempotency-Replayed(components/headers/IdempotencyReplayed) on its 200; the422response no longer describes key reuse. - Collections (R7).
GET /hintsalready pages:limit(1 to 500, default 100), opaquecursor, keyset order(issued_at, hint_id)descending,{items, nextCursor},400 invalid-limit/invalid-cursor. Nothing changed. - Enforcement.
.spectral.yamlruns the sharedrest-guidelinerule (.spectral/functions/restGuideline.js) in the existingapi-lintjob with--fail-severity=warn; the baseline was 5 findings (R4, R5, R7 x2, R8) and is 0.
Exemptions
GET /sites/{siteId}/policy:x-pagination-exempt: view. It returns one composite resource, the site's current policy, whose representation merely contains an array (eligibleTaskTypes).GET /reports/hint-adoption:x-pagination-exempt: report. A read model bounded by afrom/towindow of at most 366 days at a fixeddaygranularity, served by the separateti-reportsbinary. The ruleset already skips/reports/structurally; the marker makes the exemption explicit.GET /reports/freshnessis a singleton and needs no marker.
Consumers changed in the same change
None needed. The only HTTP client in this repository is its own web remote (web/src/api.ts): it
issues only GET and the idempotent-by-method PUT /sites/{siteId}/policy, no POST or PATCH, and it
already reads GET /hints from items and follows nextCursor. The service calls no sibling over
HTTP, and the MCP and A2A adapters call use cases directly, so there is no outbound adapter, seed
script or recorded fixture to migrate.
Consequences
- Breaking. Clients that treated
422as the key-reuse answer, or that relied on an over-long key beingidempotency-key-required, must change. This PR must deploy together with the REST cutover set of the fleet. - A client may now distinguish a replay from a first execution by
Idempotency-Replayed: true, and a key-reuse bug from a business409by the problem typeidempotency-key-reused. - The generated REST reference (
docs/docs/api-reference/rest) is regenerated from the spec with the CI recipe.