Work Units
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.
Enqueue a work unit onto a process path's work pool
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`.
Look up work units by their external order-line reference
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'.
Get one work unit by its own identity
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`).
Record completion of a released work unit
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.