openapi: 3.0.3 info: title: Workforce Management Reports API version: "1.0.0" contact: name: claudioed email: claudioed.oliveira@gmail.com description: > The READ-ONLY analytical surface of workforce-management's "Labor Utilization & Staffing" data product (ADR 0010), served by the separate `cmd/workforce-reports` binary over a read-only Postgres pool against the analytical database. It is NOT the OLTP `cmd/workforce` API documented in apis/openapi.yaml: a different binary, port and database (ADR 0037). The report is a projection over this service's own domain events, delivered as CloudEvents 1.0 on the `warehouse.workforce.analytics` topic and applied by `cmd/workforce-projector`, the single writer. It is EVENTUALLY CONSISTENT, to a freshness target of p95 event-to-report lag under 30 seconds: read GET /reports/labor/freshness to see how far the read model trails the event stream. Rows are keyed by process path (`pathId`) and UTC hour bucket. Associate-scoped events carry no path (this context stops at the path boundary, ADR 0002), so their counters land on the row whose `pathId` is the empty string. No route requires authentication (ADR 0018). Errors use RFC 7807 problem details (`application/problem+json`, ADR 0005). servers: - url: http://localhost:8092 description: Local development (cmd/workforce-reports, HTTP_ADDR default :8092) tags: - name: Reports description: The Labor Utilization & Staffing analytical read model. - name: Health description: Liveness of the reports process. paths: /healthz: get: tags: [Health] operationId: getReportsHealthz summary: Liveness probe description: > Reports that the reports process is up. It does not touch the analytical database: the pool is opened once at boot, under the bootretry budget, and the process exits when that fails. responses: "200": description: The process is up. content: application/json: schema: $ref: "#/components/schemas/Health" /reports/labor: get: tags: [Reports] operationId: getLaborReport summary: Labor utilization and staffing per process path and UTC hour description: > Returns one row per (pathId, hour bucket) in the half-open window [from, to) compared against `hourBucket`, ordered by hour bucket then path. An empty window is a 200 with an empty `rows` array, not a 404. Path-scoped counters (`laborAssigned`, `laborReassigned`, `understaffingEvents`) land on the row of their path. Associate-scoped counters (`shiftsStarted`, `shiftsEnded`, `breaks`, `avgBreakSeconds`, `certifications`) land on the row whose `pathId` is the empty string. parameters: - name: from in: query required: true description: Inclusive window start, RFC 3339. schema: type: string format: date-time example: "2026-06-01T00:00:00Z" - name: to in: query required: true description: Exclusive window end, RFC 3339. schema: type: string format: date-time example: "2026-06-02T00:00:00Z" - name: pathId in: query required: false description: > Optional exact-match process-path filter. Omit (or send it empty) for every path, including the building-wide empty-path row. schema: type: string example: pack - name: granularity in: query required: false description: Bucket resolution. Only hourly buckets exist. schema: type: string enum: [hour] default: hour responses: "200": description: The report rows for the window. content: application/json: schema: $ref: "#/components/schemas/LaborReport" "400": description: > `from` or `to` is missing or not RFC 3339, or `granularity` is not `hour` (`invalid-report-query`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" "500": description: The analytical database could not be read (`report-store-error`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" /reports/labor/freshness: get: tags: [Reports] operationId: getLaborReportFreshness summary: How far the read model trails the event stream description: > Returns the age of the most recently projected event, the data product's freshness signal. A growing lag means the projector is behind or stopped. A lag of 0 on an empty read model looks the same as a perfectly fresh one, so read it together with the report rows. responses: "200": description: The current projection lag. content: application/json: schema: $ref: "#/components/schemas/Freshness" "500": description: The freshness signal could not be read (`report-store-error`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" components: schemas: Health: type: object required: [status] properties: status: type: string description: Always `ok` when the process answers. example: ok LaborReport: type: object required: [rows] properties: rows: type: array description: One row per (pathId, hour bucket). Always present; empty for a window with no data. items: $ref: "#/components/schemas/LaborRow" LaborRow: type: object required: - pathId - hourBucket - shiftsStarted - shiftsEnded - breaks - avgBreakSeconds - certifications - laborAssigned - laborReassigned - understaffingEvents properties: pathId: type: string description: > Process path of the row. The empty string is the building-wide bucket that holds the associate-scoped counters. example: pack hourBucket: type: string format: date-time description: Start of the UTC hour this row aggregates. example: "2026-06-01T14:00:00Z" shiftsStarted: type: integer format: int32 description: AssociateShiftStarted events (empty pathId only). example: 3 shiftsEnded: type: integer format: int32 description: AssociateShiftEnded events (empty pathId only). example: 0 breaks: type: integer format: int32 description: AssociateBreakStarted events (empty pathId only). example: 2 avgBreakSeconds: type: number format: double description: > Mean seconds from a break's start to its end, over breaks whose paired end was observed; 0 when none was. example: 300 certifications: type: integer format: int32 description: AssociateCertified events (empty pathId only). example: 1 laborAssigned: type: integer format: int32 description: LaborAssigned events to this path. example: 12 laborReassigned: type: integer format: int32 description: LaborReassigned events into this path. example: 3 understaffingEvents: type: integer format: int32 description: PathUnderstaffed events for this path. example: 1 Freshness: type: object required: [lagSeconds] properties: lagSeconds: type: number format: double description: > Seconds between now and the time of the most recently projected event. 0 when the read model is empty. example: 4.2 Problem: type: object description: RFC 7807 problem details, the same shape as the OLTP API's. required: [type, title, status, detail] properties: type: type: string format: uri description: Identifier of the error category. example: https://errors.workforce-management.warehouse-systems.dev/invalid-report-query title: type: string description: Fixed summary of the error category. example: The report query is malformed or missing a required parameter status: type: integer format: int32 description: The HTTP status code, repeated in the body. example: 400 detail: type: string description: What went wrong in this request. example: "query parameter 'from' is required (RFC3339)" instance: type: string description: The request path. example: /reports/labor