Skip to main content

Events

Hand-authored from apis/asyncapi.yaml (AsyncAPI 2.6.0), which is linted by Spectral in CI on every push. Every Kafka message this service produces or consumes is a CloudEvents 1.0 event — mandatory, with no other envelope (ADR 0026).

Channel / topicwarehouse.workforce.events
ProtocolKafka
Default content typeapplication/cloudevents+json
Events in the catalog10
On the integration topic1 — ShiftPlanCommitted
On the analytics topic (warehouse.workforce.analytics)all 10

The CloudEvents envelope​

Every message is a CloudEvents 1.0 structured-mode event: the Kafka message value is the JSON event format, and every message carries the Kafka header content-type: application/cloudevents+json; charset=UTF-8 alongside the W3C traceparent/tracestate headers. Every attribute below is required.

AttributeTypeMeaning
specversionstring, always "1.0"CloudEvents specification version
idstring (uuid)Unique identifier of this occurrence, a UUID v4 minted once at encode time and persisted with the outbox row, so a redelivery repeats it. The consumer dedupe key
sourcestring (uri-reference)The producing context — always /warehouse/workforce-management
typestringReverse-DNS event type; see the convention below
subjectstringThe aggregate instance the event is about
timestring (date-time)RFC 3339 UTC timestamp of when the event occurred in the domain
datacontenttypestring, always "application/json"Content type of data
dataschemastring (uri)urn:warehouse:workforce-management:<events|analytics>:<EventName>:v1 — names the payload shape per topic
dataobjectThe event-specific payload

The type naming convention​

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

All lowercase except the final PascalCase event name. For this context:

  • <subdomain> = wes
  • <bounded-context> = workforce-management
  • <entity> = the aggregate that raises it: associate, shiftplan or assignment

So a committed shift plan is published as:

com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommitted

PathUnderstaffed uses shiftplan, because the gap is measured against a committed ShiftPlan's planned heads.

Consumers must route on the full type and must ignore unknown type values. The same occurrence keeps the same type on the integration and the analytics topic; dataschema tells the two payload shapes apart. A breaking payload change gets a new .v2 type and a new dataschema version.

Integration topic — warehouse.workforce.events​

ShiftPlanCommitted​

Type: com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommitted · Subject: {site_code}/{shift_id} (= the Kafka key; written {building_id}/{shift_id} before ADR 0035, same value, unchanged) · dataschema: urn:warehouse:workforce-management:events:ShiftPlanCommitted:v1

A human committed the split of headcount across process paths for one site's shift. The commit is validated in the domain: plannedHeads(path) must not exceed installedStations(path), and planned hours must fit the shift's max hours.

This event is fanned out into one message per PathPlan line. A plan committed with three path lines produces three messages, each carrying that one line's path_id, planned_heads, planned_rate and planned_hours alongside the plan's site_code, building_id and shift_id. Consumers must expect N messages per commit and must not assume a message carries the whole plan. Each line message has its own unique id; all of them share the subject/key of the ShiftPlan aggregate, so they land on one partition in order.

data fieldTypeMeaning
site_codestringThe canonical Site code the plan was committed for. Additive on v1 and not required (messages encoded before the change lack it): fall back to building_id when absent
building_idstringDeprecated — same value as site_code; kept, removal needs a later breaking ADR
shift_idstringThe shift the plan was committed for
path_idstringThe process path this message's line covers
planned_headsintegerHeads committed to this path
planned_ratenumberExpected units per head per hour
planned_hoursnumberTotal hours committed to this path
{
"specversion": "1.0",
"id": "9f1c2b7e-4c3a-4a1d-9f0b-6c2b8a7d1e33",
"source": "/warehouse/workforce-management",
"type": "com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommitted",
"subject": "BLD1/SHIFT1",
"time": "2026-08-21T22:00:00Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:workforce-management:events:ShiftPlanCommitted:v1",
"data": {
"site_code": "BLD1",
"building_id": "BLD1",
"shift_id": "SHIFT1",
"path_id": "pack",
"planned_heads": 3,
"planned_rate": 50,
"planned_hours": 24
}
}

Downstream consumer: wes-work-planning, which projects it into its LaborPlanObserved read model keyed by path_id, and explicitly does not feed it into its own ShiftPlan aggregate.

Analytics topic — warehouse.workforce.analytics​

Every event below (and ShiftPlanCommitted, as one message per commit carrying only site_code/building_id/shift_id) is published to the internal analytics topic with dataschema urn:warehouse:workforce-management:analytics:<EventName>:v1, for this service's own analytics projector. None of them is on the integration topic.

ShiftPlanProposed​

Type: ...shiftplan.ShiftPlanProposed · Subject: {path_id} (= the Kafka key)

Heads for a path were computed as a pure computation — heads = ceil(charge ÷ plannedRate) — before a human committed anything. A proposal is advisory: the software proposes, a human commits.

data fieldType
site_codestring (canonical, additive, not required; same value as building_id)
building_idstring (deprecated, same value as site_code)
path_idstring
planned_headsinteger
planned_ratenumber

PathUnderstaffed​

Type: ...shiftplan.PathUnderstaffed · Subject: {path_id}

A path's active LaborAssignment count is below the plannedHeads committed for it on the current ShiftPlan. A flag, not a decision: this context surfaces the gap and never moves anyone in response. Rebalancing is a human call, recorded back here as a new assignment.

data fieldType
path_idstring
planned_headsinteger
active_headsinteger

AssociateShiftStarted​

Type: ...associate.AssociateShiftStarted · Subject: {associate_id}

An associate's roster entry was created for the shift.

data fieldTypeMeaning
associate_idstringThe associate starting the shift

AssociateCertified​

Type: ...associate.AssociateCertified · Subject: {associate_id}

A certification was added to an associate's roster entry.

data fieldType
associate_idstring
certificationstring

AssociateBreakStarted​

Type: ...associate.AssociateBreakStarted · Subject: {associate_id}

An associate began a logged break and is no longer assignable.

data fieldType
associate_idstring

AssociateBreakEnded​

Type: ...associate.AssociateBreakEnded · Subject: {associate_id}

An associate ended a logged break and is assignable again.

data fieldType
associate_idstring

AssociateShiftEnded​

Type: ...associate.AssociateShiftEnded · Subject: {associate_id}

An associate's shift closed, ending all of their active assignments.

data fieldType
associate_idstring

LaborAssigned​

Type: ...assignment.LaborAssigned · Subject: {associate_id}

An associate was placed on a process path for an interval.

data fieldTypeMeaning
associate_idstringThe assigned associate
path_idstringProcess path the associate now works, e.g. pack. Never a task id.

LaborReassigned​

Type: ...assignment.LaborReassigned · Subject: {associate_id}

An associate's active assignment was ended in favour of another path.

data fieldTypeMeaning
associate_idstringThe reassigned associate
from_path_idstringProcess path whose active assignment was ended
to_path_idstringProcess path the associate was moved onto

Consuming this channel​

  • Route on the full type. Never a short name or suffix match; do not switch on subject or on payload shape.
  • Ignore unknown types. The catalog will grow.
  • Expect N messages per commit for ShiftPlanCommitted, one per path line.
  • Assume at-least-once delivery. Kafka redelivers; consumers must be idempotent on the CloudEvents id — wes-work-planning does exactly this, backed by a processed_events table with the event id as primary key.
  • Reject anything that is not a valid CloudEvents 1.0 event (DLQ or WARN-and-skip). Never fall back to parsing another shape.

What this service consumes​

From siblings, two opt-in topics. Each is replayed from the earliest offset into an in-memory cache under a per-process consumer group. Neither is written to Postgres.

TopicProducerEvent types usedEnabled byAdapter
warehouse.process-path-management.eventsprocess-path-managementcom.warehouse.wes.process-path-management.processpath.ProcessPathCreated, …ProcessPathUpdated, …ProcessPathDeactivatedPATH_CATALOGUE_SOURCE=kafkainternal/adapters/outbound/kafkacatalog
warehouse.labor-performance.eventslabor-performancecom.warehouse.wes.labor-performance.performance.TaskPerformanceRecordedLABOR_PERFORMANCE_MODE=kafka-cacheinternal/adapters/outbound/laborperformancecache

Both cache consumers decode with the SDK, dispatch on the full type, and log at WARN and skip any message that is not a valid CloudEvents 1.0 event. The labor-performance cache also dedupes on id, because its running mean is a sum.

Internally, the analytics projector (cmd/workforce-projector) consumes this service's own warehouse.workforce.analytics topic under the group workforce-analytics. It dedupes on the CloudEvents id via the analytics_processed_events table in the analytical database. See Integration.