ADR 0010: Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Applies the fleet REST API guideline (warehouse-docs, REST guideline, rules R1-R8) to this
context. Supersedes the :reoptimise custom method and the (route, key) idempotency store of
ADR 0002 and the REST description in
ADR 0006 and ADR 0009.
Context
The fleet had three command-URL styles, two spellings of the replay header, key reuse answered 422, and unpaginated lists. The guideline removes each divergence with a hard cutover: no aliases, no dual routes, no toggles.
Decision
- Nouns, not verbs (R1, R2).
POST /assignments/{assignmentId}:reoptimisebecomesPOST /assignments/{assignmentId}/reoptimisations(a transition resource). The operationIdreoptimiseAssignment, the status codes and the body do not change.TestRetiredRoutesAreGonepins the old paths. - Idempotency (R3-R6, R8). Every POST (and PATCH, none exist) sits behind
RequireIdempotencyKey. The key is global: the stored row is found by key alone (tableidempotency_keys, primary keykey, migration 0002) and compared by fingerprint = method + path + SHA-256 of the body. Same fingerprint replays the stored answer withIdempotency-Replayed: true; another fingerprint is409 idempotency-key-reused. A missing key is400 idempotency-key-required; a key that is not 1 to 128 printable ASCII characters is400 idempotency-key-invalid(it was422 validation-failed). The key row commits in the same transaction as the aggregate change and its outbox rows (the store already joined the unit of work; only the key changed). A 5xx or a panic rolls back and is never stored.Idempotent-Replayedis retired. - Pagination (R7).
GET /assignmentsanswers{items, nextCursor}withlimit(1-500, default 100) and an opaquecursor(the sharedpagepackage, copied underinternal/adapters/inbound/http/page). Keyset order isassignmentId(unique, so ties cannot occur) in both the Postgres and the in-memory repository; the adapter asks the use case forlimit + 1rows (repository.FetchLimit). Badlimitis400 invalid-limit, badcursor400 invalid-cursor, any undeclared query parameter400 unknown-query-parameter. - Exemptions: none. Both collection reads paginate (REST) or keep their own bound (below).
- MCP and A2A keep their own tool and skill schemas (
assignmentslist,limit1..500);limitis the documented bound and they return the firstlimitassignments by id. They validatelimitthemselves because the use case now acceptslimit + 1for the REST page probe.
Consequences
- Breaking: new URL, new list envelope, key now global. Deploy with the REST cutover set.
- Migration 0002 deletes stored idempotency rows (at most 24 hours old, all for the retired route).
- Consumers: the repo's
web/remote (route, key,items); no sibling service calls this REST API.
Addendum 2026-11-20: idempotency replay classes
Point 2 says the stored outcome is replayed whatever it is below 500. What a repeat under the same key answers now depends on the replay class of the first answer: only a 2xx and a FINAL refusal are replayed, a RETRYABLE refusal releases the key. The Decision text above is unchanged; ADR 0019 holds the rule and the class of every problem type.