Domain events
Eight past-tense domain events are declared in
internal/domain/shared/events.go. All implement one interface:
type DomainEvent interface {
EventName() string
OccurredAt() time.Time
}
OccurredAt comes from the injected Clock port, never from time.Now()
inside the domain, so every event assertion in the test suite is exact.
Published
All eight go to warehouse.work-planning.events (and a copy of each to
warehouse.wes.analytics for this service's own analytics projector) as
CloudEvents 1.0 structured-mode JSON. The Kafka partition key is the
CloudEvents subject: the work unit id for workunit events, the
path id for every other event
(ADR-0024).
dataschema is urn:warehouse:wes-work-planning:events:<EventName>:v1
(:analytics: on the analytics topic).
| Full CloudEvents type | Key / subject | data fields | Raised by | Known consumers |
|---|---|---|---|---|
com.warehouse.wes.work-planning.workunit.WorkUnitCreated | work unit id | path_id, work_unit_id, optional reference and line_no (ADR-0041) | EnqueueWorkUnit (REST, ApplyOrderAllocated, ApplyWorkDemandReleased) and ApplySlotPlanApproved | order-management's release-confirmation consumer, opt-in (RELEASE_CONFIRMATION_MODE=kafka, off by default); it matches reference and line_no |
com.warehouse.wes.work-planning.workunit.WorkReleased | work unit id | path_id, work_unit_id, cpt, ref, optional required_capabilities, fragile, gift_wrap, line_no (ADR-0036), transfer fields (ADR-0033), relocation on RELOCATE units (ADR-0040), replenishment on REPLENISH units (ADR-0042) | ReleaseNextWork (REST or MCP) | fulfillment-execution — internal/adapters/inbound/kafka/consumer.go turns it into a Task |
com.warehouse.wes.work-planning.workunit.WorkUnitCompleted | work unit id | path_id, work_unit_id | RecordCompletion (REST or ApplyTaskCompleted) | — |
com.warehouse.wes.work-planning.workpool.BacklogThresholdBreached | path id | path_id | SampleBacklog when backlog depth exceeds the alarm threshold | — |
com.warehouse.wes.work-planning.workpool.RateDeviationDetected | path id | path_id | nothing — reserved for a future detection rule, not emitted (decided 2026-10-06: kept) | — |
com.warehouse.wes.work-planning.workpool.PathThrottled | path id | path_id | RebalanceDecision, flow-fed pool over threshold | — |
com.warehouse.wes.work-planning.workpool.LaborReassignmentFlagged | path id | path_id | RebalanceDecision, release-fed pool at WIP limit with backlog | — |
com.warehouse.wes.work-planning.workpool.PathCapacityChanged | path id | path_id, cutoff_at, remaining_units, known | SampleBacklog, only when cutoffAt is supplied (ADR-0018) | order-management — internal/adapters/outbound/kafkapathcapacity/consumer.go; network-fulfillment — internal/adapters/outbound/pathcapacitycache/consumer.go |
com.warehouse.wes.work-planning.charge.ChargeForecastReceived,
com.warehouse.wes.work-planning.plan.ShiftPlanCommitted and
com.warehouse.wes.work-planning.pathplan.PathPlanDriftDetected are retired:
no longer published, still acknowledged by the analytics projector for the
topic's history
(ADR-0049).
warehouse-planning publishes the labour plan and LabourPlanDriftDetected now.
Every event also reaches cmd/wes-projector via warehouse.wes.analytics
(consumer group wes-analytics); five of them move the
release throughput report.
Source of the table: internal/domain/shared/events.go,
internal/adapters/outbound/kafka/publisher.go (eventTypeEntity,
subjectFor, dataFor), apis/asyncapi.yaml, and git grep of each
sibling's origin/develop.
RateDeviationDetected is declared in the domain, in apis/asyncapi.yaml
and in the analytics rollup, but no use case raises it — computing rate
deviation needs a time-windowed actual-rate projection that is not built.
Decided 2026-10-06: kept reserved. It is declared for a future detection
rule (ADR-0020 defers
it), is not emitted today, and is not removed (removing a declared message would
be a contract removal).
Every event above is written to the transactional outbox and published to Kafka
by the always-on relay; EVENT_PUBLISHER accepts only kafka, there is no
log-only publisher (ADR-0044).
Consumed
Consumer group KAFKA_CONSUMER_GROUP (mandatory; the chart renders wes-work-planning),
dispatching on the full type; unknown types are ignored; a non-CloudEvents
message goes straight to <topic>.dlq; a handler error is tried 3 times in
total (exponential backoff) and then dead-lettered. Each handler marks the CloudEvents id in
processed_events atomically with its effect
(ADR-0028).
| Topic | Full CloudEvents type | Producer | Handled by |
|---|---|---|---|
warehouse.workforce.events | com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommitted | workforce-management | ObserveLaborPlan → LaborPlanObserved (pure projection) |
warehouse.inventory.events | com.warehouse.wms.inventory-storage.reservation.StockReserved | inventory-storage | ObserveInventoryChange, delta −quantity |
warehouse.inventory.events | com.warehouse.wms.inventory-storage.reservation.ReservationRevoked | inventory-storage | ObserveInventoryChange, delta +quantity |
warehouse.fulfillment.events | com.warehouse.wes.fulfillment-execution.task.TaskCompleted | fulfillment-execution | ApplyTaskCompleted → RecordCompletion |
warehouse.order-management.events | com.warehouse.wes.order-management.order.OrderAllocated | order-management | ApplyOrderAllocated → EnqueueWorkUnit per line |
warehouse.order-management.events | com.warehouse.wes.order-management.order.OrderPartiallyAllocated | order-management | same |
warehouse.slotting-optimization.events | com.warehouse.wms.slotting-optimization.slotplan.SlotPlanApproved | slotting-optimization | ApplySlotPlanApproved → one RELOCATE unit per move, sequenced, superseding the site's older plan (ADR-0040) |
warehouse.pick-face-replenishment.events | com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentRequested / ReplenishmentCancelled | pick-face-replenishment | ApplyReplenishmentRequested → ONE REPLENISH unit per request id; ApplyReplenishmentCancelled → cancels a still-Pending unit; only with REPLENISHMENT_MODE=kafka (ADR-0042) |
warehouse.product-master.events | com.warehouse.wms.product-master.product.ProductClassified | product-master | ObserveProductClassification → version-guarded upsert into product_classification_copy (ADR-0035); own group PRODUCT_CLASSIFICATION_CONSUMER_GROUP |
warehouse.product-master.events | com.warehouse.wms.product-master.product.ProductPackLevelDeclared | product-master | ObservePackLevel → version-guarded upsert into product_pack_level_copy, keyed by GTIN (ADR-0045); own group PACK_VIEW_CONSUMER_GROUP |
warehouse.product-master.events | com.warehouse.wms.product-master.product.ProductPackLevelRetired | product-master | ObservePackLevel → end-dates the level (effective_to); no-op for an unknown GTIN or an older version |
warehouse.product-master.events | com.warehouse.wms.product-master.product.ProductPackLevelMeasured | product-master | ObservePackLevel → stores the measured dimensions; no-op for an unknown GTIN or an older version |
warehouse.process-path-management.events | com.warehouse.wes.process-path-management.processpath.ProcessPathCreated / ProcessPathUpdated / ProcessPathDeactivated | process-path-management | kafkacatalog.Consumer (process-unique group, replays from earliest), only with PATH_CATALOGUE_SOURCE=kafka |
Event flow through a shift
Source: the use cases in internal/application/usecases/. Omits: MCP entry
points and analytics fan-out. The shift's forecast and labour plan are sent
to warehouse-planning, not here
(ADR-0049).
Workforce's ShiftPlanCommitted is a different event from a different
context from the retired plan.ShiftPlanCommitted that shared its name
(ADR-0006).
Why events carry so little
Most events carry only a path_id: a domain event is a fact that something
happened, and the smallest payload that identifies the subject keeps
consumers from treating the stream as data replication.
The exceptions are deliberate. WorkReleased is enriched in the adapter
with cpt, ref, gift_wrap, line_no and classification hints so fulfillment-execution
can build a Task without calling back. PathCapacityChanged is a
report, so it carries the figures it reports.
Wire format
Envelope, headers and examples: Events and
.claude/rules/cloudevents-envelope.md
(ADR-0027).