0040. Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Amends ADR 0011
(key reuse is 409, not 422). Part of the fleet-wide REST cutover: it is
deployed together with the other services' cutover PRs, because the key
contract and the list envelope are breaking for clients.
Amended by ADR 0043 (2026-11-20): the guideline's replay behaviour is refined per problem type — a refusal is replayed only when its replay class is FINAL or OUTCOME; a RETRYABLE refusal releases the key. Slugs, titles and statuses are unchanged.
Context
The 2026-10-30 portfolio assessment found two spellings of the replay header,
key reuse answered 422 in most services and 409 in one, verb-style command
URLs and unpaginated lists. The fleet standard removes each divergence and a
Spectral ruleset (.spectral.yaml + .spectral/functions/restGuideline.js,
rules R1-R8) enforces it in the api-lint job with --fail-severity=warn.
This service had no verb routes and already keyed its only POST
(/process-paths), so two things changed: the idempotency contract details, and
GET /process-paths, which returned a bare array.
Decision
- Routes. None renamed.
PUT /process-paths/{pathId},DELETE /process-paths/{pathId}andPUT /sites/{siteId}/cpt-scheduleare idempotent by method and take 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 is409idempotency-key-reused. A missing key is400 idempotency-key-required; a key that is not 1-128 printable ASCII characters is400 idempotency-key-invalid.Idempotent-Replayedis not used. - Pagination.
GET /process-pathsreturns{items,nextCursor}and takeslimit(1-500, default 100) and an opaquecursor, plus the existingallfilter. Paging is keyset onpathId, in the Postgres and in-memory repositories, with a stable order. Any other query parameter is400 unknown-query-parameter, so a caller still sendingafteroroffsetfails loudly instead of silently getting page one. - Exemption.
GET /sites/{siteId}/cpt-scheduleis a composite singleton (one schedule per site), declaredx-pagination-exempt: view. - Other adapters. The A2A skill and the MCP tool keep the unpaged
ListPathsread use case. They are not REST, and their output contract is unchanged.
Consequences
- Breaking for REST clients: reuse is
409, andGET /process-pathsis an envelope, not an array. Callers that parse the array (the ops agent and work planning are the known candidates) change in their own PRs in the same set. - Existing stored keys keep working: the lookup is by key alone, so a retry of
the same request replays; only a retry whose body changed gets
409. - The cursor is opaque. Clients must pass back
nextCursoruntouched and stop when it is absent (the last page).