0031. The reports API has its own OpenAPI contract
Status
Accepted.
Context
cmd/pathmgmt-reports (ADR 0007) serves three routes:
GET /reports/catalogue-growth, GET /reports/catalogue-growth/freshness
and GET /healthz. warehouse-console's context-reports screen and this
service's own MCP tool get_catalogue_growth_report call them. They were
described only in prose on the runbook page: no machine-readable contract,
no lint, no generated reference, and no test that would fail when the
handlers and the description drift apart. apis/openapi.yaml describes the
OLTP cmd/pathmgmt API, which is a different binary on a different port
against a different database, so adding the reports routes to it would
describe a server that does not exist.
The fleet's 2026-10-12 gap review (D18) decided that every *-reports
binary's routes go into apis/openapi-reports.yaml, the convention
labor-performance started.
Decision
apis/openapi-reports.yaml(OpenAPI 3.0.3) specifies the three routes, their query parameters (from,torequired RFC 3339;granularityoptional,dayonly), theCatalogueGrowthReport,CatalogueGrowthRow,FreshnessandHealthbodies, and the RFC 7807Problembody of the 400invalid-report-queryand 500report-store-erroranswers. The window is half-open[from, to)on the day bucket, as the Postgres query implements it. This is a description of existing behaviour: no route, parameter or body changed.- The
api-lintCI job andmake api-lintrun Spectral on it with the same ruleset asapis/openapi.yaml. - The docs site generates a second API reference from it
(
docs/docs/api-reference/rest-reports/, plugin configpathmgmtReports); thedocs-api-driftjob regenerates both references withnpm run clean-api-docs:all && npm run gen-api-docs:alland fails on any diff or untracked page. internal/adapters/inbound/http/reports_contract_test.gokeeps the spec honest:TestReportsContract_RoutesMatchSpecwalks the real chi router and fails when a served route is not specified or a specified route is not served;TestReportsContract_ResponsesMatchSpecdrives every documented status (200, 400, 500) of every operation and fails on an undeclared status or media type, a missing required property or an undocumented one (including the first report row).- Schemathesis (ADR 0025) stays on
apis/openapi.yamlonly: the reports binary needs a Postgres read model to answer, and the Go contract test covers its small surface without one.
Consequences
Easier
- Consumers of the reports API (the console, the MCP tool, other agents) have a generated reference and a spec they can generate clients from.
- A change to a reports handler or DTO that is not reflected in the spec
fails
go testin CI.
Harder
- Two specs to keep in step with two routers; the contract test and the drift job make forgetting one visible.
- The contract test checks property presence, not value types or formats; Schemathesis-level property-based coverage of the reports API is not part of this decision.