Skip to main content

EventStorming (design level)

Synced from warehouse-planning

This page is a copy of docs/docs/ddd/eventstorming.md on develop, derived from that repository's code. Edit it there, then re-sync.

Notation from the ddd-crew EventStorming glossary and cheat sheet. Six processes, each read left to right. Hotspots are real, documented gaps (ADRs, code comments), not invented ones.

Legend​

Source: ddd-crew cheat-sheet colours as specified for the fleet. Omits: nothing; this is the key for the six diagrams below.

1. Capacity facts arrive from upstream​

Source: internal/adapters/inbound/kafka/labor_capacity_consumer.go, storage_capacity_consumer.go, internal/application/usecases/register_process_capacity_constraint.go, declare_station_standard.go, internal/domain/processcapacity/*.go (events.go). Omits: the processed-event claim and DLQ mechanics (see the sequence diagrams) and RegisterProcessPath, which the operator also issues before planning. ProcessCapacity raises ProcessCapacityRegistered when its first constraint is registered and ProcessCapacityChanged when a registration moves the effective rate; a registration that leaves the rate untouched raises nothing. Neither event has a consumer yet (see Domain events), and the analytics fanout carries plan facts only (apis/asyncapi.yaml, ADR 0005).

2. Plan, publish, announce the shortage​

Source: internal/application/usecases/create_capacity_plan.go, publish_capacity_plan.go, inbound_demand.go, internal/domain/capacityplan/*.go, internal/adapters/outbound/kafka/analytics_encoder.go (FanoutEncoder), internal/adapters/outbound/analyticsstore/postgres_projection.go, internal/adapters/inbound/http/reports_handler.go. Omits: the rejection paths (ErrAlreadyPublished, ErrSuperseded, ErrMissingAssignedDemand, ErrMissingStepCapacity). CapacityPlanSuperseded (the older plan of the same site, location, path and window) is queued before CapacityPlanPublished; CapacityShortageDetected and BottleneckDetected are raised only when shortage > 0.

3. Expected demand from order-management​

Source: internal/adapters/inbound/kafka/order_demand_consumer.go, internal/application/usecases/expected_demand.go, internal/domain/demand/order.go, ADR 0004, ADR 0021. Omits: OrderRepromised (deliberately ignored: no new cutoff instant) and the required DEMAND_CONSUMER_GROUP / DEMAND_SITE_ID configuration.

4. Inbound demand from dock-scheduling​

Source: internal/adapters/inbound/kafka/dock_appointment_consumer.go, internal/application/usecases/inbound_demand.go (RecordInboundAppointment, DeclareInboundLabourStandard, GetInboundDemand), create_capacity_plan.go (resolveInbound), ADR 0017 and ADR 0020. Omits: the processed-event claim and DLQ mechanics, and the retired source (inbound-receiving's appointment events are no longer consumed, ADR 0020).

5. Observed capacity from fulfillment-execution​

Source: internal/adapters/inbound/kafka/observed_capacity_consumer.go, internal/application/usecases/observed_capacity.go (RecordObservedCompletion, GetCapacityPlanVariance), ADR 0017. Omits: the processed-event claim and DLQ mechanics and the required OBSERVED_CAPACITY_CONSUMER_GROUP / DEMAND_SITE_ID configuration. The variance never changes a planned capacity.

6. The labour requirement: standards, forecast, labour plan, drift​

ADR 0022 and ADR 0023.

Source: internal/adapters/inbound/kafka/labor_standard_consumer.go, labor_capacity_consumer.go, internal/domain/laborstandard/standard.go, internal/domain/capacityplan/labour_requirement.go, internal/application/usecases/workload_forecast.go, labour_plan.go, labour_plan_drift.go, internal/domain/labourplan/*.go, internal/domain/workloadforecast/*.go. Omits: the processed-event claims, the DLQ mechanics and the reads (GET /workload-forecasts/..., GET /labour-plans...). WorkloadForecastReceived and LabourPlanDriftDetected have no consumer yet; all three requirement events are also written to the analytics topic, where the projector acknowledges them without projecting them.

Sticky inventory​

StickyKindCode evidence
Operator, PlannerActorREST callers (warehouse-console remote web/src/api.ts) and MCP clients
RegisterProcessCapacityConstraintCommandinternal/application/usecases/register_process_capacity_constraint.go
DeclareStationStandardCommandinternal/application/usecases/declare_station_standard.go
CreateCapacityPlanCommandinternal/application/usecases/create_capacity_plan.go
PublishCapacityPlanCommandinternal/application/usecases/publish_capacity_plan.go
RecordOrderDemandCommandinternal/application/usecases/expected_demand.go
RecordInboundAppointment, DeclareInboundLabourStandardCommandinternal/application/usecases/inbound_demand.go
RecordObservedCompletionCommandinternal/application/usecases/observed_capacity.go
ReceiveWorkloadForecastCommandinternal/application/usecases/workload_forecast.go
CommitLabourPlanCommandinternal/application/usecases/labour_plan.go
RecordShiftCommitmentCommandinternal/application/usecases/labour_plan_drift.go
ProcessCapacityAggregateinternal/domain/processcapacity/process_capacity.go
CapacityPlanAggregateinternal/domain/capacityplan/capacity_plan.go
WorkloadForecastAggregateinternal/domain/workloadforecast/forecast.go
LabourPlanAggregateinternal/domain/labourplan/plan.go
CapacityPlanCreated, CapacityPlanPublished, CapacityShortageDetected, BottleneckDetectedDomain event (published)internal/domain/capacityplan/events.go, internal/adapters/outbound/kafka/encoder.go
ProcessCapacityRegistered, ProcessCapacityChangedDomain event (published, integration topic only)internal/domain/processcapacity/events.go, register_process_capacity_constraint.go
WorkloadForecastReceived, LabourPlanCommitted, LabourPlanDriftDetectedDomain event (published, both topics)internal/domain/workloadforecast/events.go, internal/domain/labourplan/events.go
ShiftPlanCommittedDomain event (consumed)typeShiftPlanCommitted in labor_capacity_consumer.go
LaborStandardDefined, LaborStandardRevisedDomain event (consumed)labor_standard_consumer.go
LocationSlotRegistered, LocationSlotDecommissionedDomain event (consumed)typeLocationSlotRegistered, typeLocationSlotDecommissioned in storage_capacity_consumer.go
OrderAllocated, OrderPartiallyAllocatedDomain event (consumed)typeOrderAllocated, typeOrderPartiallyAllocated in order_demand_consumer.go
DockAppointmentBooked, DockAppointmentRescheduled, DockAppointmentCancelled, DockAppointmentNoShowDomain event (consumed)typeDockAppointment* in dock_appointment_consumer.go
TaskCompletedDomain event (consumed)typeTaskCompleted in observed_capacity_consumer.go
Register LABOR on shift commitPolicyLaborCapacityConsumer.HandleMessage
Adjust the tally on slot changePolicyStorageCapacityConsumer.handleRegistered / handleDecommissioned
Record order demandPolicyOrderDemandConsumer.HandleMessage
Apply a dock appointment event, version guardedPolicyDockAppointmentConsumer.HandleMessage
Count a completed task in its minute bucketPolicyObservedCapacityConsumer.HandleMessage
Keep each labour standard as a factPolicyLaborStandardConsumer.HandleMessage
Record the committed heads of a shift linePolicyLaborCapacityConsumer.recordCommitment
Compare planned and committed heads, raise only a new driftPolicydriftRecorder.record, labourplan.Drift.ShouldRaise
Fan out to both topics through the outboxPolicyFanoutEncoder.Encode, enqueue in create_capacity_plan.go
Path capacity, facility tally, StationStandard, expected demand, inbound demand, observed capacity and variance, plan_facts, reportsRead modelGetProcessPathCapacity, location_slot_tally, station_standards, order_demand, inbound_appointments, inbound_labour_standards, observed_capacity, plan_facts, internal/analytics/report
workforce-management, facility-layout, order-management, dock-scheduling, fulfillment-execution, labor-performanceExternal systemthe six consumer files above (labor_capacity_consumer.go, storage_capacity_consumer.go, order_demand_consumer.go, dock_appointment_consumer.go, observed_capacity_consumer.go, labor_standard_consumer.go) and order-management's planned_capacity_consumer.go
Derived labor window, assumed UNIT/HOURHotspotADR 0001 Addendum; laborRateUnit comment in labor_capacity_consumer.go
Stations without a standard only warnHotspotComposeStepCapacity warning, ADR 0002
WorkloadProfile not storedHotspotGetProcessPathCapacityCommand doc comment ("PHASE 2 SIMPLIFICATION")
BottleneckDetected without a consumerHotspotorder-management's planned_capacity_consumer.go ignores it
Unsited orders on one site, no cancellation nettingHotspotADR 0004 §3, ADR 0021, cmd/api/runtime.go
No inbound standard declared, appointments price at zeroHotspotresolveInbound in create_capacity_plan.go
Observed capacity is advisory and single-siteHotspotobserved_capacity_consumer.go, ADR 0017
Labour requirement unknown outside PICK, PACK, SLAMHotspotcapacityplan.ReasonNoLaborStandard, ADR 0022 decision 4
Zero forecast buckets in the shift is no dataHotspotusecases.ErrMissingPlannedHeads, ADR 0023 decision 2
Drift site and shift keys match as sent (the path code is canonical); no stale-event guard; a simultaneous first commitment and first plan can leave one drift unraisedHotspotlabour_plan_drift.go, labor_capacity_consumer.go (recordCommitment)