43. The reports binary's routes are a contract: apis/openapi-reports.yaml
Status
Accepted. Decided 2026-10-12 (fleet gap-fix wave, decision D18: every
*-reports binary's routes go into apis/openapi-reports.yaml, the
convention labor-performance started). Extends
ADR-0012 (the analytical data product
and its separate reader); that ADR's body is not edited.
Context
ADR-0012 split the Throughput & Lease-Health data product into a writer
(cmd/fulfillment-projector) and a read-only reader
(cmd/fulfillment-reports, default :8092, :8080 in the chart). The
reader serves three routes (NewReportsRouter in
internal/adapters/inbound/http/reports_handler.go): GET /healthz,
GET /reports/throughput and GET /reports/throughput/freshness. The MCP
report tools (get_fulfillment_throughput_report, get_on_time_to_cpt) and
other contexts (the console, warehouse-ops-agent) call them.
None of these routes was in a spec. apis/openapi.yaml describes
cmd/execution only. The shape lived in a hand-written page
(Throughput report) and in the
handler's DTOs, so nothing linted it, nothing rendered it and nothing failed
when the handler and the documentation disagreed.
Decision
- A second OpenAPI 3.0.3 file,
apis/openapi-reports.yaml, specifies every route ofcmd/fulfillment-reports:getReportsHealthz,getThroughputReport(queryfrom,torequired RFC 3339;taskType,stationIdoptional exact match;granularityoptional, onlyhour) andgetThroughputFreshness; theThroughputRowwith the ten fields the handler emits,Freshness,Statusand the RFC 7807Problem(ADR-0005) with the two reports problem types (invalid-report-query400,report-store-error500). No security scheme (ADR-0022). It describes what already ships: no route, field or status changes. - Linted by the
api-lintCI job with the same.spectral.yamlas the OLTP spec. - Rendered as a generated Reports API reference: a second
docusaurus-plugin-openapi-docsconfig (fulfillmentReports, outputdocs/docs/api-reference/rest-reports) andgen-api-docs:all/clean-api-docs:allscripts. Thedocs-api-driftjob regenerates both specs and fails on any change or untracked page. - Contract-tested against the real router. Schemathesis (the
contractjob) bootscmd/executionin memory;cmd/fulfillment-reportsrefuses to start without an analytical database. So two Go tests in thetestjob read the spec instead:TestReportsSpecAndRouterAgreewalks the chi router and fails when a route is served but not specified, or specified but not served.TestReportsResponsesConformToSpecdrives every documented status of every operation with a stub store and fails on an undeclared status or media type, a missing required property or an undocumented property (rows included).
Consequences
- A new reports route or field fails the build until the spec, and so the generated reference, describe it.
- Consumers have a published shape to code against.
- The spec does not prove value semantics (that a counter counts the right event); the analytics store's integration tests and the handler unit tests keep doing that.
Alternatives considered
- Add the routes to
apis/openapi.yaml. Rejected: that spec describescmd/execution, and Schemathesis would then call/reports/*on a binary that does not serve them. - Schemathesis against
cmd/fulfillment-reportswith a testcontainers Postgres. Rejected for now: it needs the projector's migrations and a container in thecontractjob for three read-only GET operations whose inputs the Go tests already cover.