EventStorming
Design-level EventStorming in the notation of the ddd-crew EventStorming glossary and cheat sheet, reconstructed from the code rather than from a workshop. Three processes: observe the labour plan, run the release loop, and observe and correct. The release loop is fed by four work sources, not only by order lines: allocated orders, released transfer demands, approved slot plans and replenishment requests. Planning the shift (the charge forecast and the shift plan) moved to warehouse-planning (ADR-0049).
Legend
Process 1 — Observe the labour plan
Source: internal/application/usecases/observe_labor_plan.go,
internal/domain/laborview/*.go. The planner sends the shift's forecast and
labour plan to warehouse-planning
(PUT /workload-forecasts/{site_id}/{path_id},
PUT /labour-plans/{site_id}/{shift_id}/{path_id}), which also checks the
plan against labour and publishes LabourPlanDriftDetected. This context's
old planning routes are removed (stage E, after one release of 410):
POST /paths/{pathId}/charge and POST /paths/{pathId}/plan were removed and answer 404.
Process 2 — The release loop
Four upstream facts put work into a WorkPool. Each has its own use case, its
own idempotency and its own deterministic work unit id
(ADR-0031,
ADR-0033,
ADR-0040,
ADR-0042):
| Source | Policy | Work kind | Reaches the pool through |
|---|---|---|---|
order-management OrderAllocated | one work unit per order line | none (plain unit) | ApplyOrderAllocated, then EnqueueWorkUnit |
network-inventory-planning WorkDemandReleased | one transfer work unit per demand, id = demand_id | TRANSFER_PICK, TRANSFER_DISPATCH, TRANSFER_ARRIVAL | ApplyWorkDemandReleased, then EnqueueWorkUnit |
slotting-optimization SlotPlanApproved | one RELOCATE unit per move, on path RELOCATE; a move into a slot another move vacates waits for it | RELOCATE | ApplySlotPlanApproved (builds the units and the pool entries itself) |
pick-face-replenishment ReplenishmentRequested / ReplenishmentCancelled | one REPLENISH unit per request id, on path REPLENISH; a cancellation withdraws it while it is still Pending | REPLENISH | ApplyReplenishmentRequested, ApplyReplenishmentCancelled (build and withdraw the units themselves) |
Pack-aware work (CASE_PICK, EACH_PICK, BREAK_CASE) is not a fifth event
source: it arrives through REST EnqueueWorkUnit requests that carry a pick
plan or a case break. A CASE_PICK is checked at enqueue time against a local
copy of product-master's pack levels (an active CASE level and a whole number of
cases), kept by ObservePackLevel
(ADR-0045). The same copy supplies the
pack facts for the charge and travel estimates of Process 1.
Source: internal/application/usecases/apply_order_allocated.go,
apply_work_demand_released.go, apply_slot_plan_approved.go,
apply_replenishment_requested.go, apply_replenishment_cancelled.go,
observe_pack_level.go, enqueue_work_unit.go, release_next_work.go,
record_completion.go, apply_task_completed.go, pool_retry.go,
internal/domain/release/*.go, internal/domain/workunit/*.go,
internal/domain/relocation/*.go,
internal/adapters/outbound/postgres/work_pool_repo.go. Omits: the
idempotency layers (Idempotency-Key, processed-event mark), the
stale-entry reconciliation inside release, the stale and already-applied slot
plan outcomes, and the unknown-request and not-cancellable replenishment
cancellations.
Process 3 — Observe and correct
Source: internal/application/usecases/sample_backlog.go,
rebalance_decision.go, configure_pool.go, observe_inventory_change.go,
internal/domain/shared/events.go. Omits: PathCapacityChanged is raised only
when cutoffAt is supplied, and BacklogThresholdBreached only over the
alarm threshold. Configure pool raises no event
(ADR-0034).
Stickies and their evidence
| Sticky | Kind | Evidence |
|---|---|---|
| Planner, Supervisor or ops agent, Upstream caller | Actor | REST callers of internal/adapters/inbound/http/router.go; MCP host of internal/adapters/inbound/mcp/tools.go |
| Enqueue work unit | Command | usecases.EnqueueWorkUnit, POST /paths/{pathId}/work-units |
| Plan relocation work | Command (Kafka only) | usecases.ApplySlotPlanApproved (ADR-0040) |
| Plan replenishment, Cancel replenishment | Command (Kafka only) | usecases.ApplyReplenishmentRequested, usecases.ApplyReplenishmentCancelled (ADR-0042) |
| Release next work | Command | usecases.ReleaseNextWork, POST /paths/{pathId}/work-releases, MCP release_next_work |
| Record completion | Command | usecases.RecordCompletion, POST /work-units/{id}/completions |
| Sample backlog | Command (query that can emit events) | usecases.SampleBacklog, GET /paths/{pathId}/telemetry |
| Decide rebalance | Command (computes a decision, emits events) | usecases.RebalanceDecision, POST /paths/{pathId}/rebalance-decisions |
| Configure pool | Command | usecases.ConfigurePool, PUT /paths/{pathId}/pool (ADR-0034); raises no event |
| WorkPool, WorkUnit | Aggregate | internal/domain/{release,workunit} |
| Work unit created … Path capacity changed (8) | Domain event | internal/domain/shared/events.go |
| Workforce shift plan committed, Order allocated, Work demand released, Slot plan approved, Replenishment requested, Replenishment cancelled, Task completed, Stock reserved, Pack level declared, retired or measured | Domain event (external) | type constants in internal/adapters/kafka/cloudevents/cloudevents.go |
| Project the labor plan | Policy | usecases.ObserveLaborPlan |
| Enqueue one work unit per line | Policy | usecases.ApplyOrderAllocated |
| Enqueue one transfer work unit per demand | Policy | usecases.ApplyWorkDemandReleased (ADR-0033) |
| Plan one RELOCATE unit per move, cancel older plans' unreleased moves | Policy | usecases.ApplySlotPlanApproved |
| Plan one REPLENISH unit per request, cancel it while Pending | Policy | usecases.ApplyReplenishmentRequested, usecases.ApplyReplenishmentCancelled |
| Update the pack level copy | Policy | usecases.ObservePackLevel (ADR-0045) |
| Admit the units blocked on a completed RELOCATE unit | Policy | RecordCompletion.admitWaiting |
| Earliest CPT first, WIP limit | Policy | release.ReleasePolicy, WorkPool.nextPendingIndex, ErrWIPLimitReached |
| Record completion of its work unit | Policy | usecases.ApplyTaskCompleted |
| Throttle upstream, reassign labor | Policy | usecases.RebalanceDecision switch on pool.Mode() |
| LaborPlanObserved, UsableInventoryObserved | Read model | internal/domain/laborview, internal/domain/inventoryview |
| Pack level copy | Read model | productclassificationview.PackLevelRecord, ports.PackLevelCopyRepo, written by usecases.ObservePackLevel |
| Backlog telemetry, Rebalance recommendation | Read model | usecases.BacklogSnapshot, usecases.RebalanceRecommendation |
| Product classification view | Read model | internal/domain/productclassificationview |
| workforce-management, order-management, network-inventory-planning, slotting-optimization, pick-face-replenishment, inventory-storage, product-master, fulfillment-execution, network-fulfillment, warehouse-planning | External system | topics and REST clients listed on the Bounded context canvas; warehouse-planning only as the planner's destination (ADR-0049) |
Hotspots
Each hotspot is a known gap visible in code or ADRs, not a guess. Rows marked Decided or Resolved record the 2026-10-06 decision so the question does not resurface.
| Hotspot | Evidence |
|---|---|
WorkPool entries are never pruned and every save rewrites them | WorkPoolRepo.Save deletes and re-inserts all work_pool_entries for the path |
Hot WorkPool row under concurrent writes | ADR-0029; maxPoolSaveAttempts = 12, then 409 concurrent-modification |
RateDeviationDetected is declared but never raised | Decided 2026-10-06: kept reserved. Declared for a future detection rule (ADR-0020 defers it); not emitted today. Detection needs a business rule nobody has specified, and removing the declaration would be a contract removal |
Resolved 2026-10-06 (ADR-0034): PUT /paths/{pathId}/pool (usecases.ConfigurePool) sets a path's mode and WIP limit, creating the pool if absent; lowering below the current WIP never evicts, releases pause until WIP < limit. An unconfigured path keeps the ReleaseFed / 1000 fallback of EnqueueWorkUnit | |
UsableInventoryObserved feeds no decision | Decided 2026-10-06: read-only context by design (ADR-0006); gating release on it would be a new business rule. Reservations in inventory-storage already guard availability. Only ObserveInventoryChange writes it and only InventoryView (GET /inventory-view/{sku}) reads it |
events table is unused | Decided 2026-10-06: legacy, unused; retained, additive migrations only. Dropping it is destructive and needs explicit approval |