0037. The reports binary's routes are specified in apis/openapi-reports.yaml
Status
Accepted. Implemented by the change that introduces this record (fleet gap-fix wave 2026-10-12, decision D18). Complements ADR 0010, which introduced the reports reader, without editing it.
Context
cmd/workforce-reports serves the read side of the Labor Utilization &
Staffing data product: GET /healthz, GET /reports/labor and
GET /reports/labor/freshness (NewReportsRouter in
internal/adapters/inbound/http/reports_handler.go). Those routes were
described only in prose (the labor-report page). They appeared in no OpenAPI
file, so Spectral never linted them, the generated API reference never showed
them, and nothing failed when the router and the documentation diverged.
apis/openapi.yaml is the contract of a different binary (cmd/workforce,
port 8080, the OLTP database). Mixing the reports routes into it would make
the Schemathesis contract job fuzz routes that binary does not serve.
Decision
- A separate spec.
apis/openapi-reports.yaml(OpenAPI 3.0.3) specifies exactly the routesNewReportsRouterserves, with the RFC 7807400(invalid-report-query) and500(report-store-error) responses, theLaborReport/LaborRow/Freshness/Healthschemas and the serverhttp://localhost:8092. This follows the fleet convention of one spec per binary for*-reportsbinaries (labor-performance first). - Linted. The
api-lintCI job runs Spectral on it with the same ruleset asapis/openapi.yaml. - Rendered.
docusaurus-plugin-openapi-docsgenerates it intodocs/docs/api-reference/rest-reports/(config idworkforceReports);npm run clean-api-docs && npm run gen-api-docsregenerates both specs and thedocs-api-driftjob fails on any diff, untracked pages included. - Contract-tested.
TestReportsContract_RoutesMatchSpecwalks the chi router and fails when a served route is not in the spec or a specified route is not served.TestReportsContract_ResponsesMatchSpecdrives every documented status of every operation through the real router and checks the status, the media type, every required property and that no response property is undocumented. Both live ininternal/adapters/inbound/http/reports_contract_test.goand run in thetestjob.
Consequences
- A new reports route, field or status must be added to the spec in the same change, or the contract tests fail.
- The contract is additive only: a breaking change to a row's shape is a new endpoint version, as the labor-report page's versioning section says.
- The Schemathesis
contractjob keeps fuzzingapis/openapi.yamlonly; the reports spec is covered by the Go contract tests, which need no database.