Skip to main content

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):

SourcePolicyWork kindReaches the pool through
order-management OrderAllocatedone work unit per order linenone (plain unit)ApplyOrderAllocated, then EnqueueWorkUnit
network-inventory-planning WorkDemandReleasedone transfer work unit per demand, id = demand_idTRANSFER_PICK, TRANSFER_DISPATCH, TRANSFER_ARRIVALApplyWorkDemandReleased, then EnqueueWorkUnit
slotting-optimization SlotPlanApprovedone RELOCATE unit per move, on path RELOCATE; a move into a slot another move vacates waits for itRELOCATEApplySlotPlanApproved (builds the units and the pool entries itself)
pick-face-replenishment ReplenishmentRequested / ReplenishmentCancelledone REPLENISH unit per request id, on path REPLENISH; a cancellation withdraws it while it is still PendingREPLENISHApplyReplenishmentRequested, 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​

StickyKindEvidence
Planner, Supervisor or ops agent, Upstream callerActorREST callers of internal/adapters/inbound/http/router.go; MCP host of internal/adapters/inbound/mcp/tools.go
Enqueue work unitCommandusecases.EnqueueWorkUnit, POST /paths/{pathId}/work-units
Plan relocation workCommand (Kafka only)usecases.ApplySlotPlanApproved (ADR-0040)
Plan replenishment, Cancel replenishmentCommand (Kafka only)usecases.ApplyReplenishmentRequested, usecases.ApplyReplenishmentCancelled (ADR-0042)
Release next workCommandusecases.ReleaseNextWork, POST /paths/{pathId}/work-releases, MCP release_next_work
Record completionCommandusecases.RecordCompletion, POST /work-units/{id}/completions
Sample backlogCommand (query that can emit events)usecases.SampleBacklog, GET /paths/{pathId}/telemetry
Decide rebalanceCommand (computes a decision, emits events)usecases.RebalanceDecision, POST /paths/{pathId}/rebalance-decisions
Configure poolCommandusecases.ConfigurePool, PUT /paths/{pathId}/pool (ADR-0034); raises no event
WorkPool, WorkUnitAggregateinternal/domain/{release,workunit}
Work unit created … Path capacity changed (8)Domain eventinternal/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 measuredDomain event (external)type constants in internal/adapters/kafka/cloudevents/cloudevents.go
Project the labor planPolicyusecases.ObserveLaborPlan
Enqueue one work unit per linePolicyusecases.ApplyOrderAllocated
Enqueue one transfer work unit per demandPolicyusecases.ApplyWorkDemandReleased (ADR-0033)
Plan one RELOCATE unit per move, cancel older plans' unreleased movesPolicyusecases.ApplySlotPlanApproved
Plan one REPLENISH unit per request, cancel it while PendingPolicyusecases.ApplyReplenishmentRequested, usecases.ApplyReplenishmentCancelled
Update the pack level copyPolicyusecases.ObservePackLevel (ADR-0045)
Admit the units blocked on a completed RELOCATE unitPolicyRecordCompletion.admitWaiting
Earliest CPT first, WIP limitPolicyrelease.ReleasePolicy, WorkPool.nextPendingIndex, ErrWIPLimitReached
Record completion of its work unitPolicyusecases.ApplyTaskCompleted
Throttle upstream, reassign laborPolicyusecases.RebalanceDecision switch on pool.Mode()
LaborPlanObserved, UsableInventoryObservedRead modelinternal/domain/laborview, internal/domain/inventoryview
Pack level copyRead modelproductclassificationview.PackLevelRecord, ports.PackLevelCopyRepo, written by usecases.ObservePackLevel
Backlog telemetry, Rebalance recommendationRead modelusecases.BacklogSnapshot, usecases.RebalanceRecommendation
Product classification viewRead modelinternal/domain/productclassificationview
workforce-management, order-management, network-inventory-planning, slotting-optimization, pick-face-replenishment, inventory-storage, product-master, fulfillment-execution, network-fulfillment, warehouse-planningExternal systemtopics 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.

HotspotEvidence
WorkPool entries are never pruned and every save rewrites themWorkPoolRepo.Save deletes and re-inserts all work_pool_entries for the path
Hot WorkPool row under concurrent writesADR-0029; maxPoolSaveAttempts = 12, then 409 concurrent-modification
RateDeviationDetected is declared but never raisedDecided 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
No code path creates a flow-fed pool or changes WIP limitsResolved 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 decisionDecided 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 unusedDecided 2026-10-06: legacy, unused; retained, additive migrations only. Dropping it is destructive and needs explicit approval