Skip to main content

Events

The asynchronous contract is apis/asyncapi.yaml (AsyncAPI 2.6.0), linted in CI by Spectral alongside the OpenAPI spec. This page is hand-authored from that file and the adapter code; the two describe the same wire format.

The CloudEvents envelope (mandatory)​

Every Kafka message this service produces or consumes — on the integration topics and on the internal analytics topic — is a CloudEvents 1.0 event in the Kafka protocol binding's structured content mode: the whole event (context attributes plus data) is the JSON message value. There is no other envelope and no envelope toggle (ADR-0032).

  • Kafka header on every produced message: content-type: application/cloudevents+json; charset=UTF-8, alongside the W3C traceparent/tracestate headers.
  • Kafka key: the aggregate id (task id or package id) — unchanged, with the Hash balancer, so all events for one aggregate share a partition.
  • Built and validated with the official github.com/cloudevents/sdk-go/v2/event package, through the single helper internal/adapters/kafka/cloudevents.

Context attributes (all required)​

AttributeValue
specversion"1.0"
idUUID v4, minted once per occurrence and persisted with the outbox row, so a redelivery carries the same id. The consumer deduplication key.
source/warehouse/fulfillment-execution
typecom.warehouse.wes.fulfillment-execution.<entity>.<EventName>
subjectThe aggregate instance id — equal to the Kafka key
timeThe domain occurred-at instant, UTC, RFC 3339
datacontenttypeapplication/json
dataschemaurn:warehouse:fulfillment-execution:<events|analytics>:<EventName>:v1
dataThe event payload, snake_case keys

The type naming convention​

com.warehouse.<subdomain>.<bounded-context>.<entity>.<EventName>

For this service <subdomain> is wes, <bounded-context> is fulfillment-execution, and <entity> is the raising aggregate — task or package. The same type names an occurrence on both the integration and the analytics topic; dataschema names the payload shape. A breaking payload change ships as a new .v2 type with a new dataschema version, never by mutating the old one.

Example​

{
"specversion": "1.0",
"id": "6f1c2a3b-4d5e-4f60-8a7b-9c0d1e2f3a4b",
"source": "/warehouse/fulfillment-execution",
"type": "com.warehouse.wes.fulfillment-execution.task.TaskCompleted",
"subject": "task-8a1f",
"time": "2026-09-30T15:00:00Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:fulfillment-execution:events:TaskCompleted:v1",
"data": {
"task_id": "task-8a1f",
"station_id": "station-03",
"work_unit_id": "wu-8a1f",
"associate_id": "worker-42",
"duration_seconds": 245,
"task_type": "PICK",
"order_ref": "order-8a1f",
"line_no": 2
}
}

order_ref is optional (omitted when empty) and additive — the event stays v1 (ADR-0040). It is the upstream order id (WorkReleased.ref, kept on the task), the key inventory-storage uses to confirm picks; it is not work_unit_id, which for order work is the per-line work unit id. The analytics-topic TaskCompleted carries the same optional field.

line_no is likewise optional (omitted when unknown, never 0) and additive (ADR-0041): the 1-based order line the task's work was released for, copied from the optional WorkReleased.line_no and stored on the task as source_line_no. It is set for order work only (never transfer work) and is never parsed from work_unit_id. With order_ref it lets inventory-storage confirm the reservation of exactly that line. The analytics-topic TaskCompleted carries it too. The valid range is 1..2147483647 (32-bit); on the consumed WorkReleased a larger value is ignored (the task's line stays unknown), not rejected.

On the consumed WorkReleased, site_id of order work (no transfer_ref) is the fulfillment site the order named: it is kept on the task as its order site (tasks.order_site_id), the rebin PACK task inherits it from the order's PICK tasks, and PackageManifested publishes it as site_id (ADR-0065). Like line_no, an absent or malformed value (anything but ^[A-Z0-9]+$) is ignored, not rejected: the task is created without a site. On transfer work site_id stays the transfer fact's site and nothing else.

Channels​

ChannelDirectionContent
warehouse.fulfillment.eventspublishedIntegration events (below)
warehouse.fulfillment.analyticspublished, consumed by this service's own projectorAnalytics events (ADR-0012)
warehouse.work-planning.eventsconsumedWorkReleased from wes-work-planning
warehouse.process-path-management.eventsconsumed (when PATH_CATALOGUE_SOURCE=kafka)ProcessPath* catalogue events
warehouse.product-master.eventsconsumedProductPackLevelDeclared / ProductPackLevelRetired (always on, group PACK_VIEW_CONSUMER_GROUP, ADR-0054) and ProductClassified (when PRODUCT_CLASSIFICATION_MODE=kafka, group PRODUCT_CLASSIFICATION_CONSUMER_GROUP, ADR-0039) from product-master
warehouse.task-interleaving.eventsconsumed (when TASK_INTERLEAVING_MODE=kafka)InterleavingHintIssued from task-interleaving (ADR-0051)

Server: kafka.warehouse-systems.internal:9092, protocol kafka, configured per service via KAFKA_BROKERS.

Events published — integration (warehouse.fulfillment.events)​

typedata fieldsConsumed by
com.warehouse.wes.fulfillment-execution.task.TaskAvailabletask_id, task_type, site_id, from_location, to_location, required_capabilities, cpt?, priority_band, available_at (ADR-0049; a PICK with a sited plan is announced too, a pick missing site or pick face is not — ADR-0062)task-interleaving
com.warehouse.wes.fulfillment-execution.task.TaskClaimedtask_id, task_type, station_id, claimed_at (ADR-0049)task-interleaving
com.warehouse.wes.fulfillment-execution.task.TaskCompletedtask_id, station_id, work_unit_id, associate_id, duration_seconds, task_type, order_ref? (ADR-0040), line_no? (ADR-0041), batch_id?, batch_size? (ADR-0063, omitted on every non-batched completion)wes-work-planning, labor-performance, inventory-storage (pick confirmation)
com.warehouse.wes.fulfillment-execution.task.TaskCPTMissedtask_id, order_ref, task_type, cptorder-management
com.warehouse.wes.fulfillment-execution.package.PackageManifestedpackage_id, order_ref, source_order_id?, cpt? (the SLAM task's CPT, else the PACK task's), weight_g?, site_id? (the order's fulfillment site, omitted when the order named none) (ADR-0061, ADR-0065)order-management, outbound-shipping
com.warehouse.wes.fulfillment-execution.package.PackageDivertedpackage_idexception-management (planned) (ADR-0053)
com.warehouse.wes.fulfillment-execution.package.WeightDiscrepancyDetectedpackage_id, expected_g, actual_gexception-management (planned) (ADR-0053)
com.warehouse.wes.fulfillment-execution.transfer.TransferPicked / TransferDispatched / TransferArrivedtransfer_ref, demand_id?, work_unit_id, task_id, work_kind, site_id?, sku?, quantity? (key and subject = the completing task id)network-inventory-planning's transfer saga
com.warehouse.wes.fulfillment-execution.workbatch.WorkBatchFormedbatch_id, station_id, cpt, formed_at, version, members[] (task_id, stop_seq, compartment) — key and subject = batch id; published only with PICK_BATCH_MODE on (ADR-0063)labor-performance, warehouse-console (planned)
com.warehouse.wes.fulfillment-execution.workbatch.WorkBatchCompletedbatch_id, station_id, member_count, walk_seconds, completed_at, version — the last open stop completed; walk_seconds is completion minus formation (ADR-0063)labor-performance, warehouse-console (planned)
com.warehouse.wes.fulfillment-execution.workbatch.WorkBatchAbandonedbatch_id, station_id, member_count, abandoned_at, version — every member left without completing; the tasks themselves stay claimable through the ordinary sweep (ADR-0063)labor-performance, warehouse-console (planned)

TaskCompleted and the work_unit_id enrichment​

work_unit_id is the field that makes the feedback loop work. The domain event carries only TaskId and StationId; the publisher looks the task back up through ports.TaskRepo and reads OrderRef() — which was populated from WorkReleased.data.work_unit_id when the task was created. So the value Work Planning gets back is exactly the one it sent, and it can call RecordCompletion(workUnitId) directly. associate_id, duration_seconds and task_type are soft enrichments for labor-performance (ADR-0014, ADR-0023), omitted when unavailable.

TaskCPTMissed and PackageManifested — the promise feedback loop (ADR-0025)​

These two events are the fulfillment-execution half of order-management ADR 0014 §5's promise feedback loop: order-management's RepromiseOrder consumer reacts to them to recompute — and, if it moved, re-promise — the affected shipment group's delivery date. TaskCPTMissed needs no repo-lookup enrichment: every field comes straight off the domain event. Since ADR-0061 PackageManifested gains a best-effort, fail-soft one: the payload's optional ship-correlation fields (source_order_id, cpt) are resolved from the order's tasks at encode time.

TaskCPTMissed is raised by the Clock-driven CPT-missed sweep (POST /tasks/sweep-cpt-misses) for a task still open (Pending or Claimed) at or past its CPT, and re-fires on every sweep pass for as long as the task stays overdue — each pass is a new occurrence with a new id, so a consumer must dedupe on its own business key.

PackageManifested is raised alongside LabelApplied — additively, never in its place — when a package passes its SLAM weigh-check. A diverted package (weight outside tolerance) was not manifested and does not raise this event.

PackageDiverted and WeightDiscrepancyDetected — the promoted SLAM exception facts (ADR-0053)​

When SLAM finds the weight outside tolerance it raises WeightDiscrepancyDetected (the measurement) and PackageDiverted (the divert to the problem-solve area). Both were analytics-only until ADR-0053 promoted them to warehouse.fulfillment.events so the exception-management context can open a problem-solve case on the divert: same type, same subject/key (the package id) and byte-identical data to the analytics occurrence — a wire test pins the bytes, not just the fields. LabelApplied, PackageSealed and LeaseExpired stay analytics-only.

Events published — analytics (warehouse.fulfillment.analytics)​

Same type strings, dataschema urn:warehouse:fulfillment-execution:analytics:<EventName>:v1:

typedata fields
...task.TaskCreatedtask_id, task_type
...task.TaskClaimedtask_id, task_type, station_id
...task.LeaseExpiredtask_id, task_type
...task.TaskCompletedtask_id, task_type, station_id, order_ref?, line_no?
...task.ItemPickedtask_id, task_type
...package.PackageSealedpackage_id
...package.WeightDiscrepancyDetectedpackage_id, expected_g, actual_g — also published on the integration topic (ADR-0053)
...package.LabelAppliedpackage_id
...package.PackageDivertedpackage_id — also published on the integration topic (ADR-0053)
...package.PackageManifestedpackage_id, order_ref, task_type, station_id, on_time, resolved
...workbatch.WorkBatchFormedbatch_id, station_id, cpt, formed_at, version, members[] — byte-identical data to the integration occurrence (ADR-0063); not projected yet (wave 4's batch-effectiveness report reads them)
...workbatch.WorkBatchCompletedbatch_id, station_id, member_count, walk_seconds, completed_at, version (ADR-0063)
...workbatch.WorkBatchAbandonedbatch_id, station_id, member_count, abandoned_at, version (ADR-0063)

ItemArrivedAtRebin and OrderConsolidated (ADR-0016) are in-process only and are not published on either topic.

Events consumed​

Source contextTopicFull typeEffect here
wes-work-planningwarehouse.work-planning.eventscom.warehouse.wes.work-planning.workunit.WorkReleasedCreates a Task via the CreateTask use case
process-path-managementwarehouse.process-path-management.eventscom.warehouse.wes.process-path-management.processpath.ProcessPathCreated / ProcessPathUpdated / ProcessPathDeactivatedMaintains the in-memory process-path catalogue
product-masterwarehouse.product-master.eventscom.warehouse.wms.product-master.product.ProductPackLevelDeclared / ProductPackLevelRetiredVersion-guarded upsert of the local PackView that resolves a scanned GTIN (ADR-0054); always on
product-masterwarehouse.product-master.eventscom.warehouse.wms.product-master.product.ProductClassifiedVersion-guarded upsert of the local classification copy read by SealPackage (ADR-0039); only with PRODUCT_CLASSIFICATION_MODE=kafka
task-interleavingwarehouse.task-interleaving.eventscom.warehouse.wes.task-interleaving.stationtrip.InterleavingHintIssuedSupersedes the station's row of interleaving_hints; ClaimNext reads it as an advisory tie-break inside one priority band (ADR-0051)

Consumers dispatch on the full type string — never a short name, never a suffix match — and silently ignore unknown types, so new event types upstream cannot break them. A WorkReleased looks like:

{
"specversion": "1.0",
"id": "11111111-1111-4111-8111-111111111111",
"source": "/warehouse/wes-work-planning",
"type": "com.warehouse.wes.work-planning.workunit.WorkReleased",
"subject": "wu-8a1f",
"time": "2026-08-23T09:00:00Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:wes-work-planning:events:WorkReleased:v1",
"data": {
"path_id": "pick-zone-a",
"work_unit_id": "wu-8a1f",
"cpt": "2026-08-23T18:00:00Z",
"ref": "order-4471"
}
}

Mapping into this context's model (the Anti-Corruption Layer):

FromToHow
data.path_idtask.Typeprocess-path catalogue lookup, longest matchPrefix wins (pick-zone-a→PICK); no match is a hard error, never a default (ADR-0017)
data.work_unit_idshared.OrderRefdirect
data.cptshared.CPTRFC 3339 → time.Time
(from the matched path)shared.CapabilitySetthe path definition's requiredCapabilities
data.refTask.SourceOrderIdorder work only, never transfer work (its ref is a demand id); published as TaskCompleted.order_ref (ADR-0040)
data.line_noTask.SourceLineNooptional; valid range 1..2147483647 (32-bit, the source_line_no column width); a larger value is ignored (line unknown, WARN with the event id) and the task is still created, so it never fails the insert or dead-letters the message; order work only, never transfer work; never parsed from work_unit_id; published as TaskCompleted.line_no (ADR-0041)

Invalid and legacy messages​

A message that is not a valid CloudEvents 1.0 event — bad JSON, a missing required attribute, a wrong specversion, or the retired flat event_id/event_type/occurred_at envelope — is a deterministic poison message. It is never parsed any other way and never retried:

  • the WorkReleased consumer dead-letters it to warehouse.work-planning.events.dlq (ADR-0029);
  • the process-path catalogue consumer and the analytics projector log it at WARN (topic/partition/offset) and commit past it.

Idempotency​

Kafka delivers at least once, so every consumer is idempotent by construction. Before creating a task the WorkReleased consumer calls ProcessedEvents.MarkProcessed(ctx, id) with the CloudEvents id, which returns true only if this call newly recorded it:

  • New id → create the Task.
  • Already present → skip and acknowledge anyway.

Postgres backs this with processed_events (event_id TEXT PRIMARY KEY, processed_at TIMESTAMPTZ) — the column keeps its name and now stores the CloudEvents id; the primary-key constraint is the deduplication. The in-memory adapter uses a mutex-guarded map. A unit test feeds the same id twice and asserts exactly one task exists.

Consumer group: WORK_RELEASED_CONSUMER_GROUP, default fulfillment-execution.

Smoke-testing the real thing​

With the shared broker from the warehouse-infra kind cluster reachable at localhost:9092:

# Consume: publish a WorkReleased CloudEvent and watch a Task appear
kafka-console-producer.sh --broker-list localhost:9092 \
--topic warehouse.work-planning.events <<'EOF'
{"specversion":"1.0","id":"11111111-1111-4111-8111-111111111111","source":"/warehouse/wes-work-planning","type":"com.warehouse.wes.work-planning.workunit.WorkReleased","subject":"wu-8a1f","time":"2026-08-23T09:00:00Z","datacontenttype":"application/json","dataschema":"urn:warehouse:wes-work-planning:events:WorkReleased:v1","data":{"path_id":"pick-zone-a","work_unit_id":"wu-8a1f","cpt":"2026-08-23T18:00:00Z","ref":"order-4471"}}
EOF
curl -sS localhost:8080/queues/PICK/depth

# Publish: complete a task with EVENT_PUBLISHER=kafka and watch it land
kafka-console-consumer.sh --bootstrap-server localhost:9092 \
--topic warehouse.fulfillment.events --from-beginning

Sending the same id twice must still produce exactly one task — that is the idempotency guarantee, and it is worth verifying by hand at least once.