0038. The reports API has its own OpenAPI contract
Status
Accepted (2026-10-12, fleet gap fix D18). Adds a contract to
ADR-0011 (the data product) without
changing its behaviour. Follows the fleet convention labor-performance
started (a *-reports binary's routes live in apis/openapi-reports.yaml).
Context
cmd/wes-reports is the reader of the "Release Throughput & Backlog Health"
data product: a separate binary, on its own port (:8092), over a read-only
pool against the analytical database. It serves three routes:
GET /reports/throughput, GET /reports/throughput/freshness and
GET /healthz. The MCP report tool and warehouse-console call them.
None of the three was in a machine-readable contract. apis/openapi.yaml
describes cmd/wes only, so the reports routes were described by hand in the
runbook and the analytics page, were not linted, were not rendered in the API
reference, and were not contract-tested: a renamed field or a new status code
would reach a consumer unnoticed.
Adding the routes to apis/openapi.yaml would be wrong: that spec's server is
cmd/wes on :8080, the Schemathesis contract job boots cmd/wes in memory
against it, and a client generated from it would call routes that service
does not have.
Decision
- A separate spec,
apis/openapi-reports.yaml(OpenAPI 3.0.3), with the reports binary as its server (http://localhost:8092). It documents the three routes, their parameters (from/torequired RFC 3339, the half-open window[from, to);pathIdandgranularity=houroptional), the200shapes and the RFC 7807400 invalid-report-queryand500 report-store-errorproblems. Field names and types are what the handlers serialise today; nothing in the API changes. - Linted like the OLTP spec. The
api-lintCI job runs Spectral with the same.spectral.yamlon both specs. - Rendered like the OLTP spec. A second
docusaurus-plugin-openapi-docsconfig (wesReports) generatesdocs/docs/api/rest-reports/;prebuildand thedocs-api-driftCI job regenerate both (clean-api-docs all,gen-api-docs all) and fail on any diff or uncommitted page. - Contract-tested in Go, in
internal/adapters/inbound/http/reports_contract_test.go, without a database:TestReportsContract_RoutesMatchSpecfails when the router serves a route the spec lacks or the spec lists a route the router does not serve;TestReportsContract_ResponsesMatchSpecdrives every documented status of every operation through the real router with a fake store and checks each body against the declared schema (required properties present, no undocumented property). Schemathesis is not used here: it would need the analytical database and a projector to produce data, and the Go test already covers the same drift.
Consequences
- Easier: a consumer (the MCP report tool, warehouse-console, the ops agent) has a spec to read and generate from, and a change to a report field fails a test in this repository before it reaches them.
- Harder: a new reports route or field must be added to the spec and the generated pages must be regenerated in the same change, or CI fails. That is the point.
rateDeviationDetectedis documented as reserved (always0), the same rule as the AsyncAPI contract: no ADR defines when RateDeviationDetected is raised.- No behaviour change, no new route, no auth (the reports API stays unauthenticated, ADR-0016).