Skip to main content

EventStorming

Design-level EventStorming, reconstructed from the code rather than from a workshop: every sticky below is a real use case, aggregate, domain event, policy or read model, and every hotspot is a gap already documented in an ADR, a code comment or these docs. Time flows left to right.

Legend​

Process 1 — Inbound: register, classify, receive, stow​

Source: internal/application/usecases/register_bin.go, apply_product_classification.go, receive_stock.go, stow_stock.go, internal/adapters/outbound/facilitycache/consumer.go, internal/adapters/inbound/kafka/product_master_consumer.go, internal/domain/product/segregation.go, internal/adapters/outbound/kafka/publisher.go and analytics_publisher.go. Omitted: the rejection paths (they raise no event) and the HTTP fallback lookup.

Process 2 — Reservation lifecycle​

Source: internal/application/usecases/reserve_stock.go, revoke_reservation.go, confirm_pick.go, confirm_picks_for_order.go, internal/adapters/inbound/kafka/task_completed_consumer.go, reservation_expiry.go, get_usable.go, get_reservations_by_demand_ref.go, internal/domain/reservation/reservation.go, internal/adapters/inbound/mcp/tools.go. Omitted: the analytics copies of the events and the 409 paths.

Process 3 — Cycle count and accuracy​

Source: internal/application/usecases/run_cycle_count.go, internal/adapters/inbound/kafka/analytics_consumer.go, internal/adapters/outbound/analyticsstore/postgres_projection.go, internal/adapters/inbound/http/reports_handler.go. Omitted: the clean-count branch (only CycleCountCompleted with discrepancy=false).

Stickies and their evidence​

StickyKindCode evidence
Inventory control, Picker or simulator, MCP host / agentActorREST callers of PUT /bins/{binId}, POST /stock-receipts, POST /stowages, POST /bins/{binId}/cycle-counts, POST /reservations/{id}/pick-confirmations; MCP revoke_reservation
RegisterBin, ApplyProductClassification (Kafka, ADR 0034), ReceiveStock, StowStock, ReserveStock, RevokeReservation, ConfirmPick, ConfirmPicksForOrder (Kafka, ADR 0035), RunCycleCountCommandinternal/application/usecases/*.go, routed in internal/adapters/inbound/http/server.go
StockUnit, Bin, Reservation, ProductClassificationAggregateinternal/domain/stock, location, reservation, product
StockReceived, ItemStowed, LocationRecorded, StockReserved, ReservationRevoked, ReservationExpired, StockPicked, ItemUnlocated, CycleCountCompleted, DiscrepancyDetectedDomain Eventinternal/domain/shared/events.go
ProductClassifiedDomain Event (external, product-master's)consumed in internal/adapters/inbound/kafka/product_master_consumer.go (ADR 0034); this service no longer raises or publishes one
ZoneRegistered, LocationSlotRegistered, LocationSlotDecommissionedDomain Event (external)consumed in internal/adapters/outbound/facilitycache/consumer.go
TaskCompletedDomain Event (external)consumed in internal/adapters/inbound/kafka/task_completed_consumer.go (ADR 0035)
Placement checkPolicyStowStock.checkPlacement
Same-bin DOT segregationPolicyStowStock.checkSegregation, product.Incompatible
Replay guardPolicyReserveStock.activeReservationFor, isReplayOf
Lazy expiry on every readPolicyexpireIfDue, expireAllIfDue
Shortfall marks whole units UNLOCATEDPolicyRunCycleCount.markShortfallUnlocated
Projector upsertPolicyinbound/kafka.AnalyticsConsumer, analyticsstore.PostgresProjection
Facility location cacheRead Modelfacilitycache.Consumer.GetSlotAttributes
Usable inventory per SKURead Modelusecases.GetUsable
Reservations by demandRefRead Modelusecases.GetReservationsByDemandRef
Flow and Accuracy reportRead Modelinternal/analytics/report, table flow_accuracy_rollup
facility-layout, order-management, wes-work-planning, fulfillment-execution, warehouse-ops-agentExternal Systemsee the Context Map

Hotspots and where they are documented​

#HotspotDocumented in
H1A bin id is never validated against facility-layout's slot catalogueContext Map, "What is still not built"
H2Fragile, Oversized, HighValue carry no placement ruleContext Map; ADR 0009
H3Decided 2026-10-06: kept permissive (ADR 0013/0020) — the binary default LOCATION_LOOKUP_MODE=permissive stayed: a cold facility cache would reject every receipt, and the cluster already injects kafka. Overtaken by ADR 0042: permissive and the unset default were removed, the mode is kafka or httpcmd/inventory/lookup.go, cmd/inventory/config.go; ADR 0013, ADR 0020, ADR 0042
H4ProductClassified is raised but never published Resolved 2026-10-06: published through the outbox on both topics (ADR 0031); LocationRecorded stays in-process (no consumer). Superseded by ADR 0034: product-master owns classification; this service's own ProductClassified and the one-shot backfill were removed at stage E (2026-10-17) and nothing here raises or publishes it any moreADR 0031, ADR 0034, Domain Events
H5Decided 2026-10-06: kept (ADR 0003) — no background sweeper for timed-out reservations; expiry stays lazyDomain Events; ADR 0003
H6The ReserveStock replay guard is best-effort under concurrencycode comment on activeReservationFor in reserve_stock.go
H7Decided 2026-10-07 (audit decision 18; supersedes the counting of 17a for line-aware work): confirm-pick is event-driven and PER LINE (ADR 0036, builds on ADR 0035) — picks are confirmed from fulfillment-execution's TaskCompleted (PICK, order_ref, line_no), never a sync REST/MCP call. order-management sends lineNo on POST /reservations, the Reservation stores it (reservations.line_no) and the event carries the task's line_no, so the consumer confirms exactly the ACTIVE reservation of (order_ref, line_no); the order's other lines stay ACTIVE. This closes ADR 0035's "one pick early" edge for line-aware events. The ADR 0035 counting (order_pick_progress, confirm on the order's LAST pick, never early) remains as the backward-compatible fallback for events without line_no and reservations with a NULL line_no. An expired one is skipped and countedADR 0036, ADR 0035, Context Relationships
H8Cycle-count overage is reported, never reconciledrun_cycle_count.go comment; Use Cases
H9Short picks are not modelled: a Task carries no SKU or quantity, so a confirmed line's whole reserved quantity is picked (per-line identity, ADR 0036, makes partial picks expressible, but they still need per-line quantities in wes-work-planning's WorkUnit and fulfillment-execution's Task, and a business rule no ADR specifies)ADR 0035, ADR 0036