openapi: 3.0.3 info: title: WES — Work Planning & Release version: "1.0.0" description: > The core bounded context of a Warehouse Execution System (WES). It releases work continuously in CPT priority order (waveless — no discrete wave batches; CPT is the Critical Pull Time, the last moment a parcel can be manifested and still make its truck) and performs flow balancing off live buffer telemetry using Drum-Buffer-Rope with CPT as the drum. It is the "conductor": downstream of WMS planning/inventory, upstream of WCS equipment control. Aggregates owned by this service: `WorkPool` (the priority queue for one process path — release-fed pools enforce a hard WIP limit, flow-fed pools only alarm) and `WorkUnit` (a releasable unit of work with at-most-once assignment and no double-complete). The charge forecast and the shift plan moved to warehouse-planning (ADR-0049): their two POST routes answered `410 Gone` for one release and were removed in stage E (a POST to either answers `404`). This service does **not** own equipment control (WCS), inventory reservation, or workforce scheduling — it only *observes* projections of those via Kafka integration events (`LaborPlanObserved`, `UsableInventoryObserved`), exposed read-only through this API. It also does not implement HATEOAS; this is a Richardson Maturity Level 2 API (resource nouns, correct verbs, correct status codes) without hypermedia controls. contact: name: WES Work Planning & Release url: https://github.com/IQVO/wes-work-planning servers: - url: http://localhost:8080 description: Local development (needs a real Postgres and a real Kafka, see README) tags: - name: Charge Forecast description: > Retired (ADR-0049): the volume due by CPT on a path is warehouse-planning's workload forecast now (`PUT /workload-forecasts/{site_id}/{path_id}`). `POST /paths/{pathId}/charge` was removed in stage E and answers `404`. - name: Shift Plan description: > Retired (ADR-0049): rate × heads × hours on a path is warehouse-planning's labour plan now (`PUT /labour-plans/{site_id}/{shift_id}/{path_id}`). `POST /paths/{pathId}/plan` was removed in stage E and answers `404`. Distinct from Workforce Management's reported labor plan — see the Labor Plan View tag for that. - name: Work Units description: > A releasable unit of work (e.g. a pick task) enqueued onto a process path's work pool. Carries a CPT and is assigned at most once. - name: Release description: > Continuous, priority-ordered admission of work into a process path's work pool (waveless) — earliest-CPT-first, at-most-once handout. - name: Pool Configuration description: > The explicit operator command that sets a process path's work pool feed mode and WIP limit (ADR-0034). Lowering a limit never evicts work. - name: Telemetry description: > Live buffer telemetry read models (backlog depth, WIP, feed mode) built as projections from work-pool state, not aggregate state. - name: Rebalance description: > Flow-balancing recommendations (throttle upstream release vs. flag labor reassignment) computed from live backlog telemetry — Drum-Buffer-Rope with CPT as the drum. - name: Labor Plan View description: > A read-only projection of the labor plan Workforce Management last reported for a path (via its own `ShiftPlanCommitted` integration event). NOT this service's own Shift Plan aggregate — same term, different bounded context. - name: Inventory View description: > A read-only projection of the usable-quantity Inventory last reported for a SKU (via its `StockReserved`/`ReservationRevoked` integration events). Keyed by SKU, not by process path. - name: Health description: Operational health check. paths: /healthz: get: operationId: healthCheck summary: Health check description: > Liveness probe for the service. Always returns 200 with a static status body if the process is up — does not check downstream dependencies (Postgres, Kafka). tags: [Health] responses: "200": description: Service is up. content: application/json: schema: type: object properties: status: type: string example: ok required: [status] example: status: ok /readyz: get: operationId: readinessCheck summary: Readiness check description: > Readiness probe for the service. Returns 200 `{"status":"ready"}` while the process accepts traffic AND Postgres answers a ping AND a Kafka broker answers a metadata request (reachability only: topics are never required, the service's writers auto-create them). The dependency verdict is cached for a few seconds. Returns 503 `{"status":"not_ready"}` once graceful shutdown has begun (readiness is flipped first so a Kubernetes readinessProbe stops routing new requests during the drain window), and a 503 problem+json of type `dependency-unavailable` (the detail names the failing dependencies) while Postgres or Kafka is not reachable. Separate from `/healthz`, which is liveness and is never flipped by shutdown or by a dependency. tags: [Health] responses: "200": description: Service is ready to receive traffic. content: application/json: schema: type: object properties: status: type: string example: ready required: [status] example: status: ready "503": description: >- The service is draining, or Postgres or Kafka is not reachable, and must not receive new traffic. content: application/json: schema: type: object properties: status: type: string example: not_ready required: [status] example: status: not_ready application/problem+json: schema: $ref: "#/components/schemas/Problem" /paths/{pathId}/work-units: post: operationId: enqueueWorkUnit deprecated: true summary: Enqueue a work unit onto a process path's work pool description: > Adds a releasable unit of work (e.g. a pick task) to a process path's `WorkPool` — the EnqueueWorkUnit use case. `workUnitId` is client-supplied and must be unique within the pool: enqueueing the same `workUnitId` twice returns `409 Conflict` (`work-unit-already-enqueued`) rather than silently creating a duplicate entry — this endpoint is idempotent-by-client-supplied-ID in that sense, though not a pure no-op retry (a second call with the same ID is rejected, not silently accepted). If this is the first unit ever enqueued against the path, a `WorkPool` is auto-provisioned as release-fed with a default WIP limit. Publishes `WorkUnitCreated`. A unit becomes a pack-aware pick (`workKind` `CASE_PICK` / `EACH_PICK`) when the body carries `quantity` (eaches), `pickUnit` or `fromBin`, or a `BREAK_CASE` when it carries `caseBreak` (ADR-0045); both need a `sku` and the two never mix. A `CASE` pick needs an active CASE pack level in the local copy and a whole number of cases. **Idempotency (ADR-0022, replay classes ADR-0050).** This resource-creating POST requires a caller-supplied `Idempotency-Key` header. The first request with a given key is processed and its final response (status, headers, body) is stored in the same database transaction as the write; a retry with the same key and the same body replays that stored response verbatim and does not enqueue again. A refusal is stored only when it is final for the request — a validation of the request's own fields (FINAL). A refusal that depends on state that can change (`work-unit-already-enqueued`, `unknown-path-id`, `no-active-case-level`, `quantity-not-case-multiple`, any 5xx) is not stored: the key is released, so the same key can be retried and executes again (a different body under it is a new request, not `idempotency-key-reused`). A missing key is `400 idempotency-key-required`; the same key with a different body after a stored answer is `409 idempotency-key-reused`. Use a fresh key per logical action. A replay carries `Idempotency-Replayed: true`. Superseded by the K1 choreography (X3): order-management publishes `OrderAllocated` / `OrderPartiallyAllocated` and this service's `ApplyOrderAllocated` consumer enqueues one work unit per line (OM ADR 0005 / WP ADR-0031); removal planned with the next breaking window. tags: [Work Units] parameters: - $ref: "#/components/parameters/PathId" - $ref: "#/components/parameters/IdempotencyKey" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/EnqueueWorkUnitRequest" example: workUnitId: wu-482910 cpt: "2026-08-21T12:00:00Z" reference: order-77213-line-1 responses: "201": description: Work unit enqueued in `Pending` state. headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" Location: schema: type: string description: Canonical URI of the created work unit. example: /work-units/wu-482910 content: application/json: schema: $ref: "#/components/schemas/WorkUnitResponse" example: id: wu-482910 pathId: pick-a cpt: "2026-08-21T12:00:00Z" reference: order-77213-line-1 state: Pending giftWrap: false "400": description: > Either the `Idempotency-Key` header is missing (`idempotency-key-required`) or malformed (`idempotency-key-invalid`), or the body is malformed / fails validation (including a missing `cpt`) / names an unknown `pathId` (`unknown-path-id`), or fails the `lineNo` (`invalid-line-no`) or pack-aware checks (`unknown-pick-unit`, `invalid-pick-plan`, `invalid-case-break`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/idempotency-key-required title: Idempotency-Key header is required status: 400 detail: "idempotency key required: this endpoint creates a new resource on every call and requires a caller-supplied Idempotency-Key header so a retried request is never applied twice" instance: /paths/pick-a/work-units "422": description: > A `CASE` pick cannot be planned: the SKU has no active CASE pack level in this service's local copy (`no-active-case-level`) or `quantity` is not a whole number of cases (`quantity-not-case-multiple`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/quantity-not-case-multiple title: Quantity is not a whole number of cases status: 422 detail: "pick load: quantity is not a whole number of cases: 35 eaches with 12 per case" instance: /paths/pick-a/work-units "409": description: > A work unit with this `workUnitId` is already enqueued in this pool (`work-unit-already-enqueued`), the pool was modified concurrently (`concurrent-modification`), or the `Idempotency-Key` was already used with a different request (`idempotency-key-reused`; fingerprint = method + path + body hash). Distinguish by the problem `type`. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/work-unit-already-enqueued title: Work unit already enqueued in this pool status: 409 detail: "work unit already enqueued in this pool" instance: /paths/pick-a/work-units "500": $ref: "#/components/responses/InternalError" /paths/{pathId}/work-releases: post: operationId: releaseNextWork summary: Release the next highest-priority work unit on a process path description: > Applies the release policy to a process path's `WorkPool` — the ReleaseNextWork use case. Admits the pending work unit with the earliest (most urgent) CPT, transitioning it Pending → Released. This is continuous, priority-ordered admission (waveless), not a batch/wave release. A release-fed pool enforces its WIP limit as a hard invariant: releasing past the limit fails with `409`. Publishes `WorkReleased`, which downstream fulfillment-execution consumes to create a Task. This is a collection-level command on the path's work pool (not scoped to a single work unit id, since the caller does not choose which unit is released — the priority policy does), analogous in REST terms to a resource-scoped bulk action. tags: [Release] parameters: - $ref: "#/components/parameters/IdempotencyKey" - $ref: "#/components/parameters/PathId" responses: "200": headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" description: The released work unit, now in `Released` state. content: application/json: schema: $ref: "#/components/schemas/WorkUnitResponse" example: id: wu-482910 pathId: pick-a cpt: "2026-08-21T12:00:00Z" reference: order-77213-line-1 state: Released giftWrap: false "400": description: > The `Idempotency-Key` header is missing (`idempotency-key-required`) or malformed (`idempotency-key-invalid`), or the `pathId` is invalid (`invalid-path-id`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" "404": description: No work pool has been provisioned for this path yet (no work unit has ever been enqueued). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/not-found title: Resource not found status: 404 detail: "resource not found" instance: /paths/pick-a/work-releases "409": description: > The pool is empty (`work-pool-empty`), a release-fed pool is already at its WIP limit (`wip-limit-reached`), the pool was modified concurrently (`concurrent-modification`), or the `Idempotency-Key` was already used with a different request (`idempotency-key-reused`). Distinguish by the problem `type`. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/wip-limit-reached title: Release-fed pool WIP limit reached status: 409 detail: "WIP limit reached" instance: /paths/pick-a/work-releases "500": $ref: "#/components/responses/InternalError" /paths/{pathId}/pool: put: operationId: configurePool summary: Configure a process path's work pool (feed mode and WIP limit) description: > The ConfigurePool command (ADR-0034): sets the pool's feed mode (`ReleaseFed` or `FlowFed`) and its WIP limit, creating the pool when none exists yet. This is the only way to obtain a flow-fed pool; a path nobody configured keeps the fallback `EnqueueWorkUnit` seeds on first enqueue (`ReleaseFed`, WIP limit 1000). **Idempotent.** `PUT` fully describes the desired configuration: the same body always yields the same result, and an identical repeat writes nothing. The alarm threshold and the pool's entries are not part of this command and are never touched. **Lowering a limit never evicts work.** If the new `wipLimit` is below the current `wip`, nothing is cancelled or taken back: the pool is simply saturated and `POST /paths/{pathId}/work-releases` answers `409 wip-limit-reached` until completions bring `wip` strictly below the new limit. Raising the limit takes effect on the next release. The response reports the live `wip` so the caller can see the overshoot. On a `FlowFed` pool the limit is stored but not enforced (flow-fed pools only alarm, see ADR-0003). Raises no event. REST only: no MCP tool exposes this command. tags: [Pool Configuration] parameters: - $ref: "#/components/parameters/PathId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ConfigurePoolRequest" example: mode: ReleaseFed wipLimit: 200 responses: "200": description: The pool as configured, with its live occupancy. content: application/json: schema: $ref: "#/components/schemas/PoolConfigResponse" example: pathId: pick-a mode: ReleaseFed wipLimit: 200 wip: 4 backlogDepth: 12 "400": description: > Malformed body, a missing `wipLimit`, a `wipLimit` that is not a positive integer (`invalid-wip-limit`), a `mode` other than `ReleaseFed`/`FlowFed` (`unknown-feed-mode`), or a `pathId` outside the deployment's declared process-path families (`unknown-path-id`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/invalid-wip-limit title: Invalid WIP limit status: 400 detail: "work pool WIP limit must be a positive integer" instance: /paths/pick-a/pool "409": description: > The pool was modified concurrently and the retry budget was exhausted; retry the request (`concurrent-modification`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/concurrent-modification title: The work pool was modified concurrently; retry the request status: 409 detail: "concurrent modification" instance: /paths/pick-a/pool "500": $ref: "#/components/responses/InternalError" /paths/{pathId}/telemetry: get: operationId: sampleBacklog summary: Sample live backlog telemetry for a process path description: > Returns the current backlog depth/WIP read model for a process path's work pool — the SampleBacklog use case. This is a projection built from live `WorkPool` state, not persisted aggregate state. Side effect: if the pool is over its alarm threshold, publishes `BacklogThresholdBreached` (an existing, documented telemetry side effect of sampling — it does not mutate the `WorkPool` or `WorkUnit` aggregates themselves, so this remains a safe GET). When the optional `cutoffAt` query parameter is supplied, this same read additionally reports — and publishes — the path's current remaining admission capacity for that CPT cutoff window (`PathCapacityChanged`, see ADR-0018). `remainingCapacityKnown` is `false` for a FlowFed path (no hard admission ceiling) or a ReleaseFed path with no WIP limit provisioned; `remainingCapacityUnits` is present only when `remainingCapacityKnown` is `true`. Omitting `cutoffAt` entirely skips capacity reporting and publishing, keeping every existing caller's behavior unchanged. tags: [Telemetry] parameters: - $ref: "#/components/parameters/PathId" - name: cutoffAt in: query required: false description: > Optional RFC3339 CPT cutoff timestamp. When supplied, the response additionally reports remaining admission capacity for this path correlated against this cutoff, and a `PathCapacityChanged` event is published (ADR-0018). Must be non-empty when present — `?cutoffAt=` (present but empty) is a `400`, not "omitted". schema: type: string format: date-time minLength: 1 example: "2026-08-21T18:00:00Z" responses: "200": description: Current backlog snapshot. content: application/json: schema: $ref: "#/components/schemas/BacklogSnapshotResponse" example: pathId: pick-a backlogDepth: 12 wip: 4 mode: ReleaseFed overAlarmThreshold: false "400": $ref: "#/components/responses/BadRequest" "404": $ref: "#/components/responses/NotFound" "500": $ref: "#/components/responses/InternalError" /paths/{pathId}/rebalance-decisions: post: operationId: rebalanceDecision summary: Decide the flow-balancing recommendation for a process path description: > Inspects a process path's live buffer telemetry (backlog vs. plan) and recommends `ThrottleUpstream` (a flow-fed path over its alarm threshold — slow admission upstream, Drum-Buffer-Rope with CPT as the drum), `ReassignLabor` (a release-fed path saturated at its WIP limit with backlog remaining — flag for headcount reassignment), or `NoActionNeeded` — the RebalanceDecision use case. This is a keyed POST because the decision has an effect: the first execution publishes `PathThrottled` or `LaborReassignmentFlagged` when a non-default action is recommended. The request has no body. The decision is computed, not stored as a resource, so there is no `Location` and no GET for it. A replay of the same `Idempotency-Key` returns the stored decision with `Idempotency-Replayed: true` and publishes nothing again; every new decision (for example each poll of a dashboard) must send a new key. When a labor plan has been observed for this path (see Labor Plan View), the response additionally includes it as extra context under `laborPlan` — this is additive and does not change the throttle/reassign decision logic itself. tags: [Rebalance] parameters: - $ref: "#/components/parameters/IdempotencyKey" - $ref: "#/components/parameters/PathId" responses: "201": description: The computed rebalance decision (not a stored resource; no `Location`). headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" content: application/json: schema: $ref: "#/components/schemas/RebalanceResponse" example: pathId: pick-a action: ThrottleUpstream backlogDepth: 340 wip: 0 laborPlan: pathId: pick-a plannedHeads: 6 plannedRate: 95.5 plannedHours: 8 observedAt: "2026-08-21T09:00:00Z" "400": $ref: "#/components/responses/BadRequest" "404": $ref: "#/components/responses/NotFound" "409": description: > The `Idempotency-Key` was already used with a different request (`idempotency-key-reused`; fingerprint = method + path + body hash). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/idempotency-key-reused title: Idempotency-Key was already used with a different request status: 409 detail: "idempotency key reused: the Idempotency-Key header on this request was already used with a different request; use a new Idempotency-Key for a genuinely different request" instance: /paths/pick-a/rebalance-decisions "500": $ref: "#/components/responses/InternalError" /paths/{pathId}/labor-plan-view: get: operationId: getLaborPlanView summary: Get the latest labor plan Workforce Management reported for a path description: > Returns the `LaborPlanObserved` read model — the latest `planned_heads`/`planned_rate`/`planned_hours` Workforce Management published on its `ShiftPlanCommitted` integration event for this path, projected via the Kafka consumer (Task 7). This is a read-only projection from a DIFFERENT bounded context's `ShiftPlan` concept. `404` until at least one `ShiftPlanCommitted` event has been observed for the path. tags: [Labor Plan View] parameters: - $ref: "#/components/parameters/PathId" responses: "200": description: Latest observed labor plan for this path. content: application/json: schema: $ref: "#/components/schemas/LaborPlanViewResponse" example: pathId: pick-a plannedHeads: 6 plannedRate: 95.5 plannedHours: 8 observedAt: "2026-08-21T09:00:00Z" "400": $ref: "#/components/responses/BadRequest" "404": description: No `ShiftPlanCommitted` event has been observed for this path yet. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/not-found title: Resource not found status: 404 detail: "resource not found" instance: /paths/pick-a/labor-plan-view "500": $ref: "#/components/responses/InternalError" /work-units: get: operationId: getWorkUnitsByReference summary: Look up work units by their external order-line reference description: > Returns every `WorkUnit` ever enqueued for the given `reference` — the GetWorkUnitsByReference use case. `reference` is the external reference threaded through `POST /paths/{pathId}/work-units` (typically an order line), NOT this service's internal client-supplied `workUnitId`. A reference can plausibly correspond to more than one `WorkUnit` across retries/history (e.g. re-enqueued after an abandoned attempt) — the response is always an array, even when a caller expects at most one live unit, and is empty (not `404`) when the reference has never been seen. This is the cross-service lookup a console screen uses to answer "what work did this service release for order X, line N". tags: [Work Units] parameters: - name: reference in: query required: true description: > The external order-line reference to look up (as supplied on `EnqueueWorkUnitRequest.reference`). Missing or empty returns `400`. schema: type: string minLength: 1 example: order-77213-line-1 - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Cursor" responses: "200": description: > One keyset page (ordered by cpt, id) of the work units found for this reference: `{items, nextCursor}`; `items` is empty (not 404) when nothing matches and `nextCursor` is absent on the last page. content: application/json: schema: $ref: "#/components/schemas/WorkUnitPage" example: items: - id: wu-482910 pathId: pick-a cpt: "2026-08-21T12:00:00Z" reference: order-77213-line-1 state: Completed giftWrap: false sku: sku-482910 releasedAt: "2026-08-21T09:00:00Z" completedAt: "2026-08-21T10:00:00Z" "400": description: > The `reference` query parameter was missing or empty, `limit` is out of range (`invalid-limit`), `cursor` does not decode (`invalid-cursor`), or an undeclared query parameter was sent (`unknown-query-parameter`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/reference-required title: Reference query parameter is required status: 400 detail: "reference query parameter is required" instance: /work-units "500": $ref: "#/components/responses/InternalError" /work-units/{id}: get: operationId: getWorkUnit summary: Get one work unit by its own identity description: > Returns a single `WorkUnit` resolved by its own `workUnitId` — the GetWorkUnit use case. This is the identity lookup, distinct from `GET /work-units?reference=` (which looks units up by their UPSTREAM order-line reference and always returns an array). A client holding only a work unit id — e.g. an associate's RF gun that claimed a PICK task from fulfillment-execution, whose `orderRef` is this service's `workUnitId` — reads the unit's `sku`, upstream `reference`, `pathId`, `cpt` and `state` here instead of parsing the id string (ids are opaque to clients). Read-only and side-effect-free; the response shape is the same `WorkUnitResponse` the other work-unit endpoints return. An unknown id returns `404` (`not-found`). tags: [Work Units] parameters: - $ref: "#/components/parameters/WorkUnitId" responses: "200": description: The work unit with this id, in its current state. content: application/json: schema: $ref: "#/components/schemas/WorkUnitResponse" example: id: order-77213-line-1 pathId: pick-a cpt: "2026-08-21T12:00:00Z" reference: order-77213 state: Released giftWrap: false sku: sku-482910 releasedAt: "2026-08-21T09:00:00Z" "404": description: No work unit exists with this id. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/not-found title: Resource not found status: 404 detail: "resource not found" instance: /work-units/order-77213-line-1 "500": $ref: "#/components/responses/InternalError" /work-units/{id}/completions: post: operationId: recordCompletion deprecated: true summary: Record completion of a released work unit description: > Finishes a released work unit — the RecordCompletion use case. Transitions Released → Completed and publishes `WorkUnitCompleted`, which updates backlog telemetry projections. Enforces the `WorkUnit` aggregate's at-most-once-completion invariant: completing an already completed unit, or one that was never released, returns `409`. This endpoint is also the target of the additive `TaskCompleted` Kafka consumer (Task 8) — fulfillment-execution's task completion drives the exact same use case as this HTTP call. Superseded by the `TaskCompleted` consumer (K14): fulfillment-execution publishes task completion on Kafka and this service consumes it to drive the same use case; removal planned with the next breaking window. tags: [Work Units] parameters: - $ref: "#/components/parameters/IdempotencyKey" - $ref: "#/components/parameters/WorkUnitId" responses: "200": headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" description: The completed work unit, now in `Completed` state. content: application/json: schema: $ref: "#/components/schemas/WorkUnitResponse" example: id: wu-482910 pathId: pick-a cpt: "2026-08-21T12:00:00Z" reference: order-77213-line-1 state: Completed giftWrap: false "404": description: No work unit exists with this id. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/not-found title: Resource not found status: 404 detail: "resource not found" instance: /work-units/wu-482910/completions "409": description: > The work unit was never released (`work-unit-not-released`), was already completed (`work-unit-already-completed`), was cancelled (`work-unit-cancelled`), the pool was modified concurrently (`concurrent-modification`), or the `Idempotency-Key` was already used with a different request (`idempotency-key-reused`). Distinguish by the problem `type`. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/work-unit-already-completed title: Work unit already completed status: 409 detail: "work unit is already completed" instance: /work-units/wu-482910/completions "400": description: > The `Idempotency-Key` header is missing (`idempotency-key-required`) or malformed (`idempotency-key-invalid`). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" "500": $ref: "#/components/responses/InternalError" /inventory-view/{sku}: get: operationId: getInventoryView summary: Get the latest observed usable inventory for a SKU description: > Returns the `UsableInventoryObserved` read model — the latest usable-quantity projection for a SKU, built from Inventory's `StockReserved` (decrements) and `ReservationRevoked` (increments) integration events, projected via the Kafka consumer (Task 7). Keyed by SKU, not by process path — Inventory reservations are SKU-scoped, with no natural path mapping. `404` until at least one event has been observed for the SKU. tags: [Inventory View] parameters: - $ref: "#/components/parameters/Sku" responses: "200": description: Latest observed usable quantity for this SKU. content: application/json: schema: $ref: "#/components/schemas/InventoryViewResponse" example: sku: sku-88213 usableQuantity: 245 observedAt: "2026-08-21T09:00:00Z" "404": description: No inventory event has been observed for this SKU yet. content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/not-found title: Resource not found status: 404 detail: "resource not found" instance: /inventory-view/sku-88213 "500": $ref: "#/components/responses/InternalError" components: headers: IdempotencyReplayed: description: Present, with value `true`, only when this answer is a replay of a stored earlier answer for the same `Idempotency-Key`. schema: type: string enum: ["true"] parameters: PathId: name: pathId in: path required: true description: > The process path's identifier — a named station that owns a queue (unit-in → unit-out), e.g. a pick zone or pack line. Must belong to a process-path family declared in this deployment's process-path catalogue (ADR-0012; today the fleet's sortable-fc topology declares the pick/pack/rebin/slam families, each optionally carrying a "-"-delimited station/zone suffix, e.g. pick-a or pack-station-1). The write endpoints (enqueueWorkUnit, configurePool) reject ids outside the declared families with `400 unknown-path-id`; read endpoints surface a missing pool/projection as `404` instead. schema: type: string minLength: 1 pattern: '^(pick|pack|rebin|slam)(-.*)?$' example: pick-a IdempotencyKey: name: Idempotency-Key in: header required: true description: > Caller-supplied key that makes a retried POST safe (ADR-0022, ADR-0047). 1-128 printable ASCII characters; **clients must always send one** (missing: `400 idempotency-key-required`; malformed: `400 idempotency-key-invalid`). Generate a fresh UUID per logical submit and reuse it only to retry that same request. The key is global: reusing it with a different method, path or body is `409 idempotency-key-reused`. A replayed answer carries `Idempotency-Replayed: true`. schema: type: string minLength: 1 maxLength: 128 example: 6f1c9a52-8f6e-4a0b-9d44-2c1b0f7a3e55 Limit: name: limit in: query required: false description: Page size (1-500, default 100). Out of range is `400 invalid-limit`. schema: type: integer minimum: 1 maximum: 500 default: 100 Cursor: name: cursor in: query required: false description: > Opaque keyset cursor taken from a previous page's `nextCursor`; repeat the filters on every page. Undecodable is `400 invalid-cursor`. Any other query parameter is `400 unknown-query-parameter`. schema: type: string WorkUnitId: name: id in: path required: true description: The work unit's client-supplied identifier. schema: type: string minLength: 1 example: wu-482910 Sku: name: sku in: path required: true description: The stock-keeping unit identifier this inventory view is projected for. schema: type: string minLength: 1 example: sku-88213 responses: BadRequest: description: > Malformed request body (invalid JSON), a missing required field (silently-defaulted zero values are never accepted), an invalid field value (e.g. negative quantity, empty path id), a `pathId` outside the deployment's declared process-path families (`unknown-path-id`), or a malformed query parameter (e.g. empty or non-RFC3339 `cutoffAt`), or a NUL character (U+0000) in the body or the query string (`malformed-request-body`: Postgres text cannot hold it, ADR-0044). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/invalid-quantity title: Invalid quantity status: 400 detail: "quantity must be non-negative" instance: /paths/pick-a/work-units NotFound: description: >- No resource exists at this path/id (a NUL character, U+0000, in the path never names a resource and answers the same 404). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/not-found title: Resource not found status: 404 detail: "resource not found" instance: /paths/unknown-path/telemetry InternalError: description: An unexpected server-side failure (e.g. a repository or event-publisher error). content: application/problem+json: schema: $ref: "#/components/schemas/Problem" example: type: https://errors.wes-work-planning.warehouse-systems.dev/internal-error title: Internal server error status: 500 detail: "event store unavailable" instance: /paths/pick-a/work-releases schemas: Problem: type: object description: > RFC 7807 (https://www.rfc-editor.org/rfc/rfc7807) Problem Details for HTTP APIs. Every error response in this service uses this shape with Content-Type application/problem+json. properties: type: type: string format: uri description: > A URI identifying the error category (does not need to resolve to a real page). Stable per distinct error category in this service. example: https://errors.wes-work-planning.warehouse-systems.dev/work-unit-already-completed title: type: string description: Fixed, category-level human-readable summary. example: Work unit already completed status: type: integer format: int32 description: Duplicates the HTTP status code (RFC 7807 requirement). example: 409 detail: type: string description: The specific error message for this occurrence. example: work unit is already completed instance: type: string description: The request path that produced the error, omitted if there is no natural resource path. example: /work-units/wu-482910/completions required: [type, title, status, detail] CaseBreak: type: object description: The sealed-case break of a `BREAK_CASE` work unit (ADR-0045). properties: lpn: type: string minLength: 1 maxLength: 64 pattern: '^[A-Za-z0-9._-]+$' description: The sealed case's licence plate. example: LPN-0001 looseBin: type: string minLength: 1 description: The bin the loose eaches go to. example: LOOSE-A1 pickTaskId: type: string minLength: 1 description: The pick task the break serves. example: task-482910 required: [lpn, looseBin, pickTaskId] PickPlan: type: object description: The pick plan of a `CASE_PICK` / `EACH_PICK` work unit; read-only. properties: quantity: type: integer format: int32 minimum: 1 description: Quantity in eaches. example: 36 unit: type: string enum: [EACH, CASE] example: CASE fromBin: type: string description: Omitted when no source bin was given. example: BIN-A1 required: [quantity, unit] EnqueueWorkUnitRequest: type: object properties: workUnitId: type: string minLength: 1 description: Client-supplied unique identifier for this work unit. example: wu-482910 cpt: type: string format: date-time description: This work unit's Critical Pull Time — drives release priority (earliest CPT first). example: "2026-08-21T12:00:00Z" reference: type: string minLength: 1 description: An external reference this work unit corresponds to (e.g. an order line). example: order-77213-line-1 sku: type: string nullable: true description: >- OPTIONAL inventory SKU this order line corresponds to, if known. When set, ReleaseNextWork's outbound WorkReleased event carries derived hazmat-capability/fragile hints looked up once from inventory-storage's product classification at release time (see ADR-0009). Omit — or send null, which is treated exactly like omitted — when the SKU is not known to the caller. example: sku-482910 giftWrap: type: boolean nullable: true description: >- OPTIONAL. Whether the requester asked the warehouse to produce a gift package for this work unit, stated at enqueue time. This is a caller-stated WorkReleased characteristic, not a product attribute — unlike `sku`, it is never looked up from another service (see ADR-0010). Omit — or send null, which is treated as not requested — when gift wrap was not asked for. example: true lineNo: type: integer format: int32 minimum: 1 maximum: 2147483647 nullable: true description: >- OPTIONAL. The 1-based order line this work unit is for, stored on the work unit and carried as `line_no` on its `WorkReleased` event (ADR-0036). It never changes `workUnitId` — the order-allocation consumer's `-line-` ids stay as they are. Omit — or send null, which is treated exactly like omitted — when the line is not known; `0`, negative values and values above `2147483647` (the 32-bit column limit) are rejected with `400` (`invalid-line-no`). example: 3 quantity: type: integer format: int32 minimum: 1 nullable: true description: >- OPTIONAL (ADR-0045). Quantity in EACHES; with `pickUnit` or `fromBin` it is required and makes the unit a pack-aware pick (`CASE_PICK` / `EACH_PICK`). Needs `sku`; below 1 is `400 invalid-pick-plan`. example: 36 pickUnit: type: string nullable: true enum: [EACH, CASE, null] description: >- OPTIONAL (ADR-0045), default `EACH` for a pick. `CASE` needs an active CASE pack level and a whole number of cases (otherwise `422`). Any other value is `400 unknown-pick-unit`. example: CASE fromBin: type: string nullable: true description: OPTIONAL (ADR-0045). Source bin of the pick. example: BIN-A1 caseBreak: allOf: - $ref: "#/components/schemas/CaseBreak" description: >- OPTIONAL (ADR-0045). Makes the unit a `BREAK_CASE`; needs `sku` and excludes `quantity`, `pickUnit` and `fromBin` (otherwise `400 invalid-case-break`). allOf: # The pack-aware rules of the handler (packAwareOf), which OpenAPI 3.0 # can only state as negations. A body that breaks one is 400 # invalid-pick-plan / invalid-case-break. - description: A sealed-case break (`caseBreak`) excludes the pick fields. not: anyOf: - required: [caseBreak, quantity] - required: [caseBreak, pickUnit] - required: [caseBreak, fromBin] - description: '`pickUnit` or `fromBin` needs `quantity` (eaches).' not: allOf: - anyOf: - required: [pickUnit] - required: [fromBin] - not: required: [quantity] - description: A pick plan or a case break needs a non-blank `sku` (null counts as absent). not: allOf: - anyOf: - required: [caseBreak] - required: [quantity] - required: [pickUnit] - required: [fromBin] - not: required: [sku] properties: sku: type: string pattern: '\S' required: [workUnitId, cpt, reference] WorkUnitPage: type: object required: [items] properties: items: type: array items: $ref: "#/components/schemas/WorkUnitResponse" nextCursor: type: string description: Opaque cursor for the next page; absent on the last page. WorkUnitState: type: string description: > Pending (enqueued, not yet released) → Released (admitted into active work) → Completed. At most one active assignment; cannot complete twice or before release. Cancelled (ADR-0040) is terminal and reached only from Pending: a RELOCATE unit of a slot plan that a newer approved plan for the same site superseded before it was released. enum: [Pending, Released, Completed, Cancelled] example: Pending WorkUnitResponse: type: object properties: id: type: string example: wu-482910 pathId: type: string example: pick-a cpt: type: string format: date-time example: "2026-08-21T12:00:00Z" reference: type: string example: order-77213-line-1 state: $ref: "#/components/schemas/WorkUnitState" giftWrap: type: boolean description: >- Whether the requester asked the warehouse to produce a gift package for this work unit (see ADR-0010). False when not requested. example: false sku: type: string description: >- OPTIONAL inventory SKU this work unit's order line corresponds to. Omitted when not known — not every caller supplies one (see EnqueueWorkUnitRequest.sku). example: sku-482910 lineNo: type: integer format: int32 minimum: 1 maximum: 2147483647 description: >- OPTIONAL order line number this work unit is for (ADR-0036). Omitted when not known — a unit created before this field existed, or one enqueued without `lineNo`. example: 3 releasedAt: type: string format: date-time description: >- When this work unit was released (Pending → Released). Omitted while still Pending. example: "2026-08-21T09:00:00Z" completedAt: type: string format: date-time description: >- When this work unit was completed (Released → Completed). Omitted until completed. example: "2026-08-21T10:00:00Z" cancelledAt: type: string format: date-time description: >- When this work unit was cancelled (Pending → Cancelled, ADR-0040). Omitted unless the state is Cancelled. example: "2026-10-15T09:00:00Z" relocation: $ref: "#/components/schemas/RelocationMove" workKind: type: string enum: [CASE_PICK, EACH_PICK, BREAK_CASE] description: >- Pack-aware kind (ADR-0045). Omitted on every other unit (order, transfer, relocation). example: CASE_PICK pick: $ref: "#/components/schemas/PickPlan" caseBreak: $ref: "#/components/schemas/CaseBreak" required: [id, pathId, cpt, reference, state, giftWrap] RelocationMove: type: object description: >- The slot-plan move a RELOCATE work unit executes (ADR-0040). Present only on RELOCATE units (pathId RELOCATE, reference = the plan id); absent on order and transfer work. properties: planId: type: string description: The approved slot plan (slotting-optimization) this move belongs to. example: plan-3b0e8d2a-7c41-4f6a-9d15-2a8b6c4e1f07 moveSeq: type: integer minimum: 0 description: 0-based position of the move in the plan's published moves. example: 1 kind: type: string enum: [Relocate, Assign, Vacate] example: Relocate siteId: type: string example: SITE-1 fromSlot: type: string description: Slot vacated; omitted for Assign. example: WH1-FWD-A02-03-01-A toSlot: type: string description: Slot filled; omitted for Vacate. example: WH1-FWD-A01-01-02-A blockedBy: type: string description: >- The work unit (same plan) that vacates this move's toSlot; this unit is not releasable until that one completes. Omitted when it waits on nothing. example: plan-3b0e8d2a-7c41-4f6a-9d15-2a8b6c4e1f07-move-2 required: [planId, moveSeq, kind, siteId] PoolMode: type: string description: > ReleaseFed pools are volume-controlled by this service (WIP limit is a hard invariant); FlowFed pools admit on priority only (WIP limit is an alarm threshold, not enforced). enum: [ReleaseFed, FlowFed] example: ReleaseFed ConfigurePoolRequest: type: object properties: mode: $ref: "#/components/schemas/PoolMode" wipLimit: type: integer format: int64 minimum: 1 maximum: 2147483647 description: > The pool's WIP limit: a positive integer no greater than 2147483647 (it is stored in a Postgres INTEGER; a larger value is `400 invalid-wip-limit`). Enforced as a hard invariant on `ReleaseFed` pools, stored but only informative on `FlowFed` pools. May be set below the current WIP: nothing is evicted, releases pause until WIP drops below it. example: 200 required: [mode, wipLimit] PoolConfigResponse: type: object properties: pathId: type: string example: pick-a mode: $ref: "#/components/schemas/PoolMode" wipLimit: type: integer format: int64 example: 200 wip: type: integer format: int64 description: > Released-but-not-completed entries right now. May exceed `wipLimit` after a limit was lowered below it. example: 4 backlogDepth: type: integer format: int64 description: Entries still pending release. example: 12 required: [pathId, mode, wipLimit, wip, backlogDepth] BacklogSnapshotResponse: type: object properties: pathId: type: string example: pick-a backlogDepth: type: integer format: int32 description: Count of work units still pending release. example: 12 wip: type: integer format: int32 description: Count of work units currently released and in progress. example: 4 mode: $ref: "#/components/schemas/PoolMode" overAlarmThreshold: type: boolean description: Whether backlogDepth has crossed this pool's alarm threshold. example: false remainingCapacityKnown: type: boolean description: > Present only when the request supplied a `cutoffAt` query parameter (ADR-0018). `false` for a FlowFed path (no hard admission ceiling) or a ReleaseFed path with no WIP limit provisioned. example: true remainingCapacityUnits: type: integer format: int32 description: > Present only when `remainingCapacityKnown` is `true` — the path's WIP limit minus its current WIP (always non-negative, since the aggregate never admits past its own WIP limit). example: 3 required: [pathId, backlogDepth, wip, mode, overAlarmThreshold] RebalanceAction: type: string description: > ThrottleUpstream (flow-fed path over alarm threshold — slow upstream admission), ReassignLabor (release-fed path saturated at its WIP limit with backlog remaining — flag for headcount reassignment), or NoActionNeeded. enum: [NoActionNeeded, ThrottleUpstream, ReassignLabor] example: ThrottleUpstream LaborPlanViewResponse: type: object description: > The latest labor plan Workforce Management reported for a path — a read-only projection of Workforce Management's plan. properties: pathId: type: string example: pick-a plannedHeads: type: integer format: int32 example: 6 plannedRate: type: number format: double example: 95.5 plannedHours: type: number format: double example: 8 observedAt: type: string format: date-time description: When this service last observed a ShiftPlanCommitted event for this path. example: "2026-08-21T09:00:00Z" driftHeads: type: integer format: int32 deprecated: true description: > No longer computed (ADR-0049: the drift reconciliation of ADR-0019 moved to warehouse-planning with the shift plan). Present only on a path whose last observed plan was reconciled before that, until the path's next observed plan; removed in stage E. Signed: `plannedHeads` here minus the planned heads of this service's old committed PathPlan, `0` when they agreed. example: 1 driftDetectedAt: type: string format: date-time deprecated: true description: > No longer computed (ADR-0049); see `driftHeads`. When the drift was detected, present only when `driftHeads` is non-zero. example: "2026-08-21T09:05:00Z" required: [pathId, plannedHeads, plannedRate, plannedHours, observedAt] RebalanceResponse: type: object properties: pathId: type: string example: pick-a action: $ref: "#/components/schemas/RebalanceAction" backlogDepth: type: integer format: int32 example: 340 wip: type: integer format: int32 example: 0 laborPlan: allOf: - $ref: "#/components/schemas/LaborPlanViewResponse" description: > Present only if a labor plan has been observed for this path; omitted entirely (not present as null) otherwise. Additive context, does not affect `action`. required: [pathId, action, backlogDepth, wip] InventoryViewResponse: type: object properties: sku: type: string example: sku-88213 usableQuantity: type: integer format: int32 description: > Latest observed usable quantity for this SKU. Can be negative in this projection if reservations were observed before the corresponding stock-receipt event — that is expected of an eventually-consistent read model and not itself an error. example: 245 observedAt: type: string format: date-time example: "2026-08-21T09:00:00Z" required: [sku, usableQuantity, observedAt]