What this service does
The bounded context is built around five control-loop use cases. They
form a single closed control loop: release → observe → correct. The shift's
plan (its charge forecast and its labour plan) is warehouse-planning's since
ADR-0049:
POST /paths/{pathId}/charge and /plan answer 410 naming
PUT /workload-forecasts/{site_id}/{path_id} and
PUT /labour-plans/{site_id}/{shift_id}/{path_id} there.
Alongside them sit ConfigurePool, read-only queries (GetWorkUnitsByReference,
GetWorkUnit, LaborPlanView, InventoryView) and the ten inbound-event
use cases that apply other contexts' events (ObserveLaborPlan,
ObserveInventoryChange, ApplyTaskCompleted, ObserveProductClassification,
ObservePackLevel, and the five that plan or cancel work from upstream facts:
ApplyOrderAllocated, ApplyWorkDemandReleased, ApplySlotPlanApproved,
ApplyReplenishmentRequested, ApplyReplenishmentCancelled), each
idempotent via one atomic processed-event mark
(ADR-0028).
RebalanceDecision's "reassign labour" is a flag for people to act on; the
labour plan itself is warehouse-planning's.
The five use cases
1. EnqueueWorkUnit(path, cpt, ref)
Creates a WorkUnit in state Pending carrying its CPT and an external
reference (e.g. the source order line), and enqueues it in that path's
WorkPool. Optional sku and giftWrap ride along for the WorkReleased
payload (ADR-0009,
ADR-0010).
The first enqueue on a path whose pool was never configured creates it as
release-fed with a WIP limit and alarm threshold of 1000
(defaultWIPLimit/defaultAlarmThreshold); an operator sets a path's mode and
WIP limit explicitly with PUT /paths/{pathId}/pool
(ADR-0034).
Over REST with Postgres the call requires an Idempotency-Key header
(ADR-0022); order-management
reaches the same use case by event choreography
(ADR-0031).
2. ReleaseNextWork(path)
Applies the ReleasePolicy domain service to the path's WorkPool. The
pool hands out the pending entry with the earliest CPT — at most once —
and, on a release-fed pool, refuses when WIP is already at the pool's WIP
limit (ErrWIPLimitReached).
This is the waveless heart of the service: there is no wave, no batch window, no schedule. Admission is a policy applied continuously on demand. See ADR-0002.
Emits WorkReleased, the event fulfillment-execution consumes to create a
Task.
3. RecordCompletion(workUnitId)
Transitions a Released work unit to Completed. The aggregate rejects
double-completion (ErrAlreadyCompleted) and completion of a unit that was
never released (ErrNotReleased).
Reachable two ways: POST /work-units/{id}/completions, or a TaskCompleted
event consumed from fulfillment-execution through ApplyTaskCompleted —
the same use case, called from a different inbound adapter. Completion also
frees the unit's WIP slot on its WorkPool (the pool entry is reconciled to
completed), which is what lets the next release on a saturated
release-fed path proceed. Over Kafka, a TaskCompleted with a new event
id for a unit that is already completed is a logged, processed skip
(TaskCompletedAlreadyCompleted), not a dead letter
(ADR-0043); over REST
the same double completion still answers 409.
4. SampleBacklog(path)
Returns the live telemetry read model: backlog depth (pending entries),
WIP (released-but-not-complete entries), feed mode, and whether the pool is
over its alarm threshold. Raises BacklogThresholdBreached when it is.
When the caller also supplies a CPT cutoffAt, it reports the pool's
remaining admission capacity and raises PathCapacityChanged for that
(path, cutoff) pair — the event order-management consumes
(ADR-0018).
This is a projection computed from pool state, not a field stored on an aggregate — see Read models.
5. RebalanceDecision(path)
The flow-balancing recommendation, computed from the same live telemetry:
| Pool feed mode | Condition | Recommendation | Event raised |
|---|---|---|---|
| Flow-fed | backlog depth > alarm threshold | ThrottleUpstream | PathThrottled |
| Release-fed | WIP ≥ WIP limit and backlog > 0 | ReassignLabor | LaborReassignmentFlagged |
| either | otherwise | NoActionNeeded | — |
Two different pool types get two different corrective levers, because they have two different controllable inputs. See Flow balancing and ADR-0003.
What this service deliberately does not do
- Inventory truth — owned by
inventory-storage. This service only keeps a read-only SKU-keyed projection of what Inventory last reported. - Product master data (handling classification) — owned by
product-master. This service only keeps a version-guarded local copy of itsProductClassifiedevents to stamp thehazmat/fragilehints onWorkReleased(ADR-0035). - Workforce scheduling / individual labor assignment — owned by
workforce-management. This service only keeps a read-only path-keyed projection of the labor plan Workforce last committed. - Task dispatch to a station or associate — owned by
fulfillment-execution. This service releases a work unit; turning that into a claimableTaskhappens downstream. - Equipment control — the WCS tier; out of scope for the whole platform as built today.
- HATEOAS — the REST API is deliberately Richardson Maturity Level 2 (resource nouns, correct verbs, correct status codes) with no hypermedia controls.