Skip to main content

EventStorming (design level)

Synced from labor-performance

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 follows the ddd-crew EventStorming glossary & cheat sheet. Each board reads left to right. Every sticky is backed by code in the table under it; hotspots are known gaps recorded in ADRs or visible in the code, not invented ones.

Legend​

Source: ddd-crew cheat-sheet colours as specified for this fleet. Omitted: nothing — this is the key only.

Board 1 — Score a completed task​

Source: internal/adapters/inbound/kafka/consumer.go, internal/application/usecases/record_task_performance.go, internal/domain/performance/performance.go, internal/domain/idleness/idleness.go, internal/domain/shared/events.go, internal/application/ports/ports.go. Omitted: the retry/backoff loop and the outbox relay (infrastructure, not domain).

StickyKindCode evidence
fulfillment-executionExternal Systemcloudevents.TypeFulfillmentTaskCompleted, topic cloudevents.TopicFulfillmentEvents
TaskCompletedDomain Event (upstream)consumer.handleFulfillmentEvent, taskCompletedData
Record once per event idPolicyports.ProcessedEvents.MarkProcessed inside RecordTaskPerformance.Execute
RecordTaskPerformanceCommandusecases.RecordTaskPerformanceRequest / RecordTaskPerformance.Execute
LaborStandard active as of completionRead ModelStandardRepo.FindActiveAsOf in standardSecondsAtCompletion
TaskPerformanceAggregateperformance.New
IdlePeriodAggregateidleness.New in recordIdleGap
TaskPerformanceRecordedDomain Eventshared.NewTaskPerformanceRecorded; CE type com.warehouse.wes.labor-performance.performance.TaskPerformanceRecorded
workforce-managementExternal Systemintegration topic warehouse.labor-performance.events (integration_publisher.go)
labor-performance projectorExternal System (own process)analytics topic warehouse.labor-performance.analytics (analytics_publisher.go)
ScorecardRead Modelports.Scorecard, GetAssociateScorecard
TaskTypePerformanceRead Modelports.TaskTypePerformance, GetTaskTypePerformance
UtilizationRead Modelusecases.UtilizationResult, GetUtilization. Decided 2026-10-06: open gap stays per associate (ADR 0014); at task-type scope openGapSeconds is always 0 by design — not a hotspot
Unknown task types never scoredHotspotshared.ParseTaskTypeLenient doc comment (REBIN)
Idle cap is a judgment callHotspotADR 0014 "Negative / accepted"; defaultIdleGapCapSeconds = 3600
DLQ has no consumerHotspotdlqTopicSuffix = ".dlq" in consumer.go; no reader of that topic exists in the repo

Board 2 — Define or revise a labor standard​

Source: internal/adapters/inbound/http/server.go, internal/application/usecases/define_standard.go, internal/domain/standard/standard.go, internal/domain/shared/events.go. Omitted: the idempotency-key replay and the 409 concurrency branch (see Sequence diagrams).

StickyKindCode evidence
Industrial engineerActorweb/src/screens/LaborPerformanceScreen.tsx (apiPost("/standards"))
Current standardRead ModelGET /standards/{taskType} → GetStandard → StandardRepo.FindCurrentlyActive
DefineStandardCommandPOST /standards → usecases.DefineStandard.Execute
Close the open standardPolicynext.Supersede(prior) in DefineStandard.ExecuteSpec (same standard.Scope only)
LaborStandardAggregatestandard.NewForScope, LaborStandard.Supersede
LaborStandardDefinedDomain Eventshared.NewLaborStandardDefined; CE type com.warehouse.wes.labor-performance.standard.LaborStandardDefined
LaborStandardRevisedDomain Eventshared.NewLaborStandardRevised; CE type com.warehouse.wes.labor-performance.standard.LaborStandardRevised
labor-performance projectorExternal System (own process)analytics_consumer.go (isProjecting)
warehouse-planningExternal Systemintegration topic warehouse.labor-performance.events (integration_publisher.go, ADR 0038)
No auth on POST /standardsHotspotADR 0012; NewRouter has no auth middleware

Board 3 — Build the Labor Performance Report​

Source: internal/adapters/inbound/kafka/analytics_consumer.go, internal/adapters/outbound/analyticsstore/postgres_projection.go, internal/analytics/report/labor_performance.go, internal/adapters/inbound/http/reports_handler.go. Omitted: there is no command and no aggregate on this board — the analytical side is a pure projection (ADR 0007).

StickyKindCode evidence
TaskPerformanceRecorded, LaborStandardDefined/RevisedDomain EventisProjecting in analytics_consumer.go
Fold once per eventPolicyanalytics_consumed_events gate (ConsumedEventsRepo) + claim into analytics_processed_events, applied in ONE analyticsstore.UnitOfWork transaction; offset committed only after it succeeds (FetchMessage + CommitMessages), a failed fold is retried with capped backoff
labor_performance_rollupRead Modelmigrations/analytics/0001_report.up.sql
Supervisor or ops agentActorconsole laborPerformance.config.tsx; agent restclient/reports_clients.go
Labor Performance ReportRead Modelreport.Build, GET /reports/performance
Report freshnessRead ModelReportStore.FreshnessLag, GET /reports/performance/freshness