Domain Events
Every event this context publishes, with its full CloudEvents 1.0 type,
topic, partition key, payload, producing use case and known consumers.
Part of the DDD artifact pack.
Envelope (all events)
Every message is a CloudEvents 1.0 event in structured content mode
(the Kafka value is the JSON event; ADR 0016), built only by
internal/adapters/kafka/cloudevents.New:
| Attribute | Value |
|---|---|
specversion | 1.0 |
id | UUID minted once per occurrence (uuid.NewString), shared by the integration and analytics copies and stable across outbox redelivery |
source | /warehouse/process-path-management |
type | com.warehouse.wes.process-path-management.<entity>.<EventName> |
subject | aggregate id — path_id, site_id or flow_id; equal to the Kafka key |
time | the domain event's At, UTC |
datacontenttype | application/json |
dataschema | urn:warehouse:process-path-management:events:<EventName>:v1 (integration) or urn:warehouse:process-path-management:analytics:<EventName>:v1 (analytics) |
| Kafka headers | content-type: application/cloudevents+json; charset=UTF-8 on every message; plus traceparent (and tracestate when set) when the event was raised inside a traced operation — captured at enqueue time and stored on the outbox row (ADR 0027). Baggage is never propagated; an untraced event carries neither header. |
Topics: warehouse.process-path-management.events (integration) and
warehouse.process-path-management.analytics (analytics, ADR 0007). Every
event a use case raises through DefinePath, RevisePath, DeactivatePath,
DefineCPTSchedule, DefineProcessFlow or RetireProcessFlow is written to both, in one outbox transaction (Postgres
is mandatory, ADR 0037).
The start-up catalogue republish (usecases.RepublishCatalogue, ADR 0038) is
the exception: it writes to the integration topic only.
Writers use the kafkago.Hash balancer (ADR 0013), so all events with the
same key land on the same partition.
Published events
| Event | Full CloudEvents type | Partition key / subject | Producer use case | Known consumers |
|---|---|---|---|---|
| ProcessPathCreated | com.warehouse.wes.process-path-management.processpath.ProcessPathCreated | path_id | usecases.DefinePath | fulfillment-execution, wes-work-planning, workforce-management, order-management, network-fulfillment; own pathmgmt-projector (analytics) |
| ProcessPathUpdated | com.warehouse.wes.process-path-management.processpath.ProcessPathUpdated | path_id | usecases.RevisePath (only when Revise returns changed=true); also usecases.RepublishCatalogue, one per ACTIVE path at every start, integration topic only | same five; own projector (not for the republished ones) |
| ProcessPathDeactivated | com.warehouse.wes.process-path-management.processpath.ProcessPathDeactivated | path_id | usecases.DeactivatePath (only on an Active path) | same five; own projector |
| CPTScheduleChanged | com.warehouse.wes.process-path-management.cptschedule.CPTScheduleChanged | site_id | usecases.DefineCPTSchedule (first define, or a revise with changed=true); also usecases.RepublishCatalogue, one per site at every start, integration topic only | order-management, network-fulfillment, dock-scheduling, outbound-shipping; own projector skips it |
| ProcessFlowDefined | com.warehouse.wes.process-path-management.processflow.ProcessFlowDefined | flow_id | usecases.DefineProcessFlow (first define, version 1) | warehouse-planning (the consumer named in ADR 0042; its side is owned by that repo); own projector skips it |
| ProcessFlowRevised | com.warehouse.wes.process-path-management.processflow.ProcessFlowRevised | flow_id | usecases.DefineProcessFlow (only when Revise returns changed=true); also usecases.RepublishCatalogue, one per ACTIVE flow at every start with the current state and version, integration topic only | same; own projector skips it |
| ProcessFlowRetired | com.warehouse.wes.process-path-management.processflow.ProcessFlowRetired | flow_id | usecases.RetireProcessFlow (only on the first retirement) | same; own projector skips it |
A ProcessPathUpdated, CPTScheduleChanged or ProcessFlowRevised on the integration topic can
therefore be a republish of an unchanged path, schedule or flow (new CloudEvents
id, same type and data); consumers upsert it, and nothing should count
it as a revision. See Use cases.
ProcessPathCreated / ProcessPathUpdated — data
Go type kafka.ProcessPathData (internal/adapters/outbound/kafka/publisher.go);
schema ProcessPathData in apis/asyncapi.yaml.
| Field | Type | Notes |
|---|---|---|
path_id | string | always present |
match_prefix | string | omitempty |
direct | boolean | omitempty — absent when false; consumers must default it to false |
required_capabilities | string array | omitempty |
destination_location_role | string | Drop / WorkCenter / Shipping; absent when unset (ADR 0009) |
cycle_time_p95 | string | Go duration, e.g. 2h0m0s (ADR 0010) |
eligibility | object | always present on Created/Updated, {} when fully permissive |
eligibility.max_units_per_line | integer | absent = unbounded |
eligibility.required_product_attributes | string array | omitempty |
eligibility.excluded_product_attributes | string array | omitempty |
eligibility.non_sortable | boolean | omitempty |
intake | string array | demand sources allowed to route work onto the path: CUSTOMER_ORDER, STOCK_TRANSFER, SLOT_RELOCATION, INVENTORY_CONTROL, REPLENISHMENT (ADR 0034); always present on Created/Updated, [] when only an explicit path id reaches the path; canonical (sorted) order |
ProcessPathUpdated carries the full current definition (not a diff);
destination_location_role is repeated unchanged because it is never
revisable.
ProcessPathDeactivated — data
Only path_id. Every definition field is omitted, not zeroed.
CPTScheduleChanged — data
Go type kafka.CPTScheduleData; built from cptschedule.ToSnapshot.
| Field | Type | Notes |
|---|---|---|
site_id | string | |
timezone | string | IANA zone |
cutoffs[] | array | full snapshot, never a diff |
cutoffs[].cpt_id | string | unique within the site |
cutoffs[].local_time | string | HH:MM |
cutoffs[].days_of_week | string array | Mon..Sun |
cutoffs[].ship_method | string | |
cutoffs[].eligible_path_ids | string array | Active paths at write time |
ProcessFlowDefined / ProcessFlowRevised / ProcessFlowRetired — data
Go type kafka.ProcessFlowData, the same shape for all three, built from
processflow.State; schema in apis/asyncapi.yaml. Always the full state
of the flow at one version, never a diff.
| Field | Type | Notes |
|---|---|---|
flow_id | string | equals the Kafka key and the CloudEvents subject |
name | string | |
stages[] | array | in flow order; the array order IS the order of the stages |
stages[].path_id | string | an Active path of this catalogue at write time |
stages[].process_type | string | PICK, REBIN, PACK, SLAM, DISPATCH, ARRIVAL, RELOCATE, REPLENISH |
status | string | ACTIVE, or RETIRED on ProcessFlowRetired |
version | integer | 1 on ProcessFlowDefined, +1 per accepted change (a revision that changes something, or the retirement). A consumer applies a message only when its version is greater than the one it holds, so a republish and a redelivery are no-ops for a consumer that is caught up |
Unlike the version column of the other aggregates, which is storage
metadata, this version is part of the published contract
(ADR 0042).
Events NOT raised
- A no-op
PUT /process-paths/{pathId}(identicalmatchPrefix,requiredCapabilities,cycleTimeP95,eligibility,intake) raises nothing. DELETEon an already-deactivated path raises nothing (204).- A
PUT /sites/{siteId}/cpt-scheduleidentical to the stored schedule raises nothing. - A
PUT /process-flows/{flowId}that changes neither the name nor the stages raises nothing and keeps theversion;DELETEon an already retired flow raises nothing (204). - Read operations (REST
GET, every MCP tool and A2A skill) never raise events.
Consumed events
This context consumes no other context's events. Its only consumer,
internal/adapters/inbound/kafka.AnalyticsConsumer (run by
cmd/pathmgmt-projector, group process-path-management-analytics,
StartOffset: FirstOffset), reads its own analytics topic:
| Type | Effect |
|---|---|
...processpath.ProcessPathCreated | catalogue_growth_rollup.paths_defined += 1 for the UTC day bucket |
...processpath.ProcessPathUpdated | paths_revised += 1 |
...processpath.ProcessPathDeactivated | paths_deactivated += 1 |
...cptschedule.CPTScheduleChanged, the three ...processflow.ProcessFlow* types and any unknown type | committed and skipped |
| non-CloudEvents message | dead-lettered to warehouse.process-path-management.analytics.dlq, then committed |
projecting type whose claim+apply step still fails after maxAnalyticsHandlerAttempts (3) | dead-lettered to the same DLQ, then committed (ADR 0012, ADR 0032) |
Dedupe is on the CloudEvents id, twice: analytics_consumed_events
(consumer gate) and analytics_processed_events (claimed inside the
projection transaction). Both claims and the rollup upsert commit in ONE
analytics transaction (ADR 0032), so a projector stop between the claim and
the apply leaves no claim and the redelivery applies the event exactly once.
Delivery guarantees
- Atomic with state (Postgres mode):
OutboxPublisher.Publishinserts oneoutbox_eventsrow per topic inside the use case'sUnitOfWorktransaction (ADR 0003). - At-least-once to Kafka:
OutboxRelaysends rows inidorder withRequiredAcks: RequireAlland marks them published afterwards; a crash between send and mark re-sends with the sameid. - Per-aggregate order: same key → same partition (Hash balancer); the relay stops a pass at the first failed send so later rows never overtake it.
Source: internal/domain/shared/events.go,
internal/domain/cptschedule/events.go,
internal/domain/processflow/events.go,
internal/adapters/outbound/kafka/process_flow_events.go,
internal/adapters/outbound/kafka/publisher.go,
internal/adapters/outbound/kafka/analytics_publisher.go,
internal/adapters/outbound/kafka/writer_config.go,
internal/adapters/kafka/cloudevents/cloudevents.go,
internal/adapters/kafka/cloudevents/types.go,
internal/adapters/outbound/postgres/outbox_publisher.go,
internal/adapters/outbound/postgres/outbox_relay.go,
internal/adapters/inbound/kafka/analytics_consumer.go,
apis/asyncapi.yaml.