Labor Performance — Event Contracts 2.0.0

Event contracts for the Labor Performance bounded context, in three directions:

  • Inbound (warehouse.fulfillment.events) — the integration contract this service consumes. Documented below in full; this is what the original v1 of this file covered.
  • Outbound analytics (warehouse.labor-performance.analytics) — the ANALYTICS stream this service publishes its own domain events to, feeding its own analytical data product's projector (ADR 0007). It is consumed today only by this repo's own cmd/labor-projector; no other service subscribes. Publishing is not optional: events are written to a transactional outbox and drained onto Kafka by the relay inside cmd/labor; EVENT_PUBLISHER=log is rejected at boot.
  • Outbound integration (warehouse.labor-performance.events) — this service's Open-Host-Service topic for OTHER bounded contexts (ADR 0013, widened by ADR 0038). Before this topic existed, labor-performance was the fleet's only pure event sink: it consumed TaskCompleted from fulfillment-execution but published nothing any sibling service could subscribe to. TaskPerformanceRecorded is published here so workforce-management (the first consumer) can build an event-fed local cache instead of calling this service synchronously over REST, and LaborStandardDefined / LaborStandardRevised (ADR
    1. so warehouse-planning can keep a local copy of the engineered standards. Published through the same transactional outbox relay as the analytics stream (not opt-in).

The three are deliberately separate topics so the integration contracts (inbound and outbound) and the analytical stream all evolve independently.

Inbound: a pure consumer of fulfillment-execution

Unlike every other apis/asyncapi.yaml in this fleet (which document only what a service PUBLISHES), this section describes what this service SUBSCRIBES TO: it is a pure Kafka consumer of fulfillment-execution's already-published TaskCompleted integration event. This service has no REST or Go-import dependency on fulfillment-execution — everything it needs (associate_id, task_id, duration_seconds) already travels on the Kafka event (see the bounded-context-boundary decision in ADR 0003-kafka-choreography-consumer-of-fulfillment-execution.md).

Message format: CloudEvents 1.0 (mandatory, ADR 0021)

Every message on every channel below — inbound and outbound, integration and analytics — is a CloudEvents 1.0 event in structured content mode (Kafka message value = application/cloudevents+json, Kafka header content-type: application/cloudevents+json; charset=UTF-8). There is no other envelope: the retired flat envelope is rejected by every consumer (dead-lettered on warehouse.fulfillment.events, skipped with a WARN on the analytics topic).

{
  "specversion": "1.0",
  "id": "4f1c2a7e-9d31-4a6b-8f0e-6b2c1d5e7a90",
  "source": "/warehouse/fulfillment-execution",
  "type": "com.warehouse.wes.fulfillment-execution.task.TaskCompleted",
  "subject": "task-10231",
  "time": "2026-08-29T22:00:00Z",
  "datacontenttype": "application/json",
  "dataschema": "urn:warehouse:fulfillment-execution:events:TaskCompleted:v1",
  "data": { ... }
}

All attributes are required. id is the de-duplication key this service uses (the ProcessedEvents idempotency gate) — NOT task_id. Consumers dispatch on the FULL type string and ignore unknown types. dataschema distinguishes the integration (:events:) payload from the analytics (:analytics:) payload of the same occurrence, which share one type.

Shared, fan-out topic

warehouse.fulfillment.events is the SAME topic wes-work-planning already consumes from, under its own consumer group. This service uses its own consumer group id (KAFKA_CONSUMER_GROUP env, REQUIRED: the service refuses to boot without it), so both consumers see every message independently. Only type == "com.warehouse.wes.fulfillment-execution.task.TaskCompleted" is acted on — every other event type on this shared topic (there are none from fulfillment-execution today, but the topic is shared/fan-out by convention) is silently skipped, not an error.

task_type on the inbound wire

fulfillment-execution's TaskCompleted carries task_type (its ADR-0023). An unrecognized or absent value resolves to "" (unclassified) via shared.ParseTaskTypeLenient, never a rejection.

Graceful degradation on an older payload

associate_id and duration_seconds are the two fields added by fulfillment-execution's feature/labor-performance-hooks change. Both are optional on the wire (omitempty on the publisher's own struct): an older payload that predates that enrichment simply omits them, and this service's JSON unmarshaling already degrades those absent fields to their Go zero values ("" / 0) — exactly the "no checked-in occupant" / "unmeasurable duration" business facts this service's own aggregate invariants already model, not an error.

  • #labor-performance
  • #task

Servers

  • kafka.warehouse-systems.internal:9092kafkaproduction

    Shared Kafka broker for warehouse-systems integration events. Locally, docker compose up -d --wait kafka in this repository provides one at localhost:9092.

    Security:
    security.protocol:PLAINTEXT

Operations

  • SUB warehouse.fulfillment.events

    The shared, fan-out topic owned by fulfillment-execution (its kafka.Topic constant). This service subscribes to it under its own consumer group and acts only on TaskCompleted messages.

    Consume TaskCompleted events from fulfillment-execution.

    Feeds each TaskCompleted message into the RecordTaskPerformance use case, which is idempotent on the CloudEvents id and resolves whichever LaborStandard was active for the task's type AS OF the CloudEvents time attribute (not "active right now"), so a possibly out-of-order or replayed message is scored against the standard genuinely in force when the task completed. Every other event type on this topic is silently skipped. A message that is not a valid CloudEvent, or whose handling still fails after 3 attempts (exponential backoff), is copied to warehouse.fulfillment.events.dlq (headers x-dlq-source-topic, x-dlq-error, x-dlq-failed-at added) and committed past. The consumer group is KAFKA_CONSUMER_GROUP (required, no default).

    Operation IDconsumeTaskCompleted

    Available only on servers:

    • #task

    Accepts the following message:

    Task Completed

    A station finished a claimed task; fulfillment-execution's fact.

    Raised by fulfillment-execution's Task aggregate when a station completes a claimed task. This service consumes it to record a TaskPerformance row scored against whatever LaborStandard was active for the task's type at completion time.

    allOf
    • #task

    Examples

  • PUB warehouse.labor-performance.analytics

    The dedicated ANALYTICS topic this service owns and publishes to, feeding its own analytical data product's projector (cmd/labor-projector). Separate from any integration topic so the analytical stream and the integration contract evolve independently (ADR 0007). Published through the transactional outbox relay; the log publisher is rejected at boot (EVENT_PUBLISHER=log).

    Publish this service's own domain events for its analytical read model.

    Emits LaborStandardDefined, LaborStandardRevised and TaskPerformanceRecorded onto the analytics topic as CloudEvents 1.0 events whose dataschema is urn:warehouse:labor-performance:analytics:<EventName>:v1. The message key is the TaskType, so every event folding into one report dimension lands on a single partition and is applied in publish order. The CloudEvents id is the projector's de-duplication key. This topic is consumed only by this repo's own projector; the standard events and TaskPerformanceRecorded are ALSO published on the integration topic warehouse.labor-performance.events for other contexts (ADR 0013, ADR 0038).

    Operation IDpublishLaborAnalyticsEvents

    Available only on servers:

    • #labor-performance

    Accepts one of the following messages:

    • #0Labor Standard Defined

      A TaskType had no active standard, and one was just defined.

      Raised when DefineStandard creates the first engineered standard for a TaskType. The projector counts it into the (task_type, hour-of- effective_from) rollup row. The same occurrence is also published on the integration topic with the same data (LaborStandardDefinedIntegration, ADR 0038), under its own CloudEvents id.

      allOf
      • #labor-performance

      Examples

    • #1Labor Standard Revised

      An active standard was closed and a new one started in its place.

      Raised when DefineStandard is called for a TaskType that already has an active standard. History is append-only — the prior standard is closed, never overwritten (ADR 0004). A bucket with a non-zero revision count is one whose efficiency figures span two different yardsticks and are not directly comparable across the boundary. The same occurrence is also published on the integration topic with the same data (LaborStandardRevisedIntegration, ADR 0038).

      allOf
      • #labor-performance

      Examples

    • #2Task Performance Recorded

      One completed task was scored against the standard active at completion time.

      Raised by RecordTaskPerformance for every consumed TaskCompleted. efficiency_pct is NULLABLE and null is a real, expected value, not a missing field: it is null whenever the task could not be scored — no active standard for its TaskType at completion time, or a non-positive duration. Consumers MUST NOT coerce null to 0; doing so would report an unmeasurable task as a 0%-efficient one. The projector counts such an event toward its bucket's task count while excluding it from the mean. completed_at is the BUSINESS time and is what the projector buckets on — distinct from the CloudEvents time attribute, which is the domain occurred-at and feeds only the freshness watermark. The two differ for any replayed or late-ingested event.

      allOf
      • #task

      Examples

  • SUB warehouse.labor-performance.analytics

    The dedicated ANALYTICS topic this service owns and publishes to, feeding its own analytical data product's projector (cmd/labor-projector). Separate from any integration topic so the analytical stream and the integration contract evolve independently (ADR 0007). Published through the transactional outbox relay; the log publisher is rejected at boot (EVENT_PUBLISHER=log).

    Consumed by this repo's own cmd/labor-projector (the only subscriber).

    Consumer group labor-performance-analytics, starting from the first offset. Dispatches on the full CloudEvents type and ignores unknown types. A message that is not a valid CloudEvent, or whose data cannot be decoded, is skipped with a WARN (no DLQ). Each event is de-duplicated on the CloudEvents id and applied in one unit of work with the de-duplication mark; any other failure is retried with exponential backoff (200ms up to 5s) without committing past the message.

    Operation IDconsumeLaborAnalyticsEvents

    Available only on servers:

    • #labor-performance

    Accepts one of the following messages:

    • #0Labor Standard Defined

      A TaskType had no active standard, and one was just defined.

      Raised when DefineStandard creates the first engineered standard for a TaskType. The projector counts it into the (task_type, hour-of- effective_from) rollup row. The same occurrence is also published on the integration topic with the same data (LaborStandardDefinedIntegration, ADR 0038), under its own CloudEvents id.

      allOf
      • #labor-performance

      Examples

    • #1Labor Standard Revised

      An active standard was closed and a new one started in its place.

      Raised when DefineStandard is called for a TaskType that already has an active standard. History is append-only — the prior standard is closed, never overwritten (ADR 0004). A bucket with a non-zero revision count is one whose efficiency figures span two different yardsticks and are not directly comparable across the boundary. The same occurrence is also published on the integration topic with the same data (LaborStandardRevisedIntegration, ADR 0038).

      allOf
      • #labor-performance

      Examples

    • #2Task Performance Recorded

      One completed task was scored against the standard active at completion time.

      Raised by RecordTaskPerformance for every consumed TaskCompleted. efficiency_pct is NULLABLE and null is a real, expected value, not a missing field: it is null whenever the task could not be scored — no active standard for its TaskType at completion time, or a non-positive duration. Consumers MUST NOT coerce null to 0; doing so would report an unmeasurable task as a 0%-efficient one. The projector counts such an event toward its bucket's task count while excluding it from the mean. completed_at is the BUSINESS time and is what the projector buckets on — distinct from the CloudEvents time attribute, which is the domain occurred-at and feeds only the freshness watermark. The two differ for any replayed or late-ingested event.

      allOf
      • #task

      Examples

  • PUB warehouse.labor-performance.events

    The dedicated INTEGRATION topic this service owns and publishes to (ADR 0013) — its first Open-Host-Service Published Language for OTHER bounded contexts to consume. Separate from the analytics topic above (which feeds only this repo's own projector) so the two streams evolve independently. Before this topic existed, labor-performance was the fleet's only pure event sink: it consumed TaskCompleted from fulfillment-execution but published nothing any sibling service could subscribe to. Published through the transactional outbox relay; the log publisher is rejected at boot. The first consumer is workforce-management, whose event-fed local cache (laborperformancecache) already consumes this topic in place of a synchronous HTTP call; warehouse-planning (its ADR 0022) keeps a local copy of the standards from the two standard events (ADR 0038).

    Publish TaskPerformanceRecorded and the standard events for other bounded contexts to consume.

    Emits three types onto the integration topic as CloudEvents 1.0 events whose dataschema is urn:warehouse:labor-performance:events:<EventName>:v1. The CloudEvents id is the consumer's de-duplication key; consumers dispatch on the full type and ignore unknown types.

    TaskPerformanceRecorded (ADR 0013): type com.warehouse.wes.labor-performance.performance.TaskPerformanceRecorded, subject = the associate id (the task id when there is no associate, since subject is never empty). The message key is the AssociateId — NOT the TaskType the analytics topic keys on — so every event for one associate lands on a single partition and is applied in publish order, which is what a per-associate read-cache consumer needs. A task with no checked-in associate (e.g. a robot station) is keyed on the empty string.

    LaborStandardDefined / LaborStandardRevised (ADR 0038): the same type as on the analytics topic and the SAME data (field names and types unchanged), subject = the standard id, message key = the TaskType, so every revision of one task type stays in order. A consumer keeping a local copy applies them in publish order per task type.

    Operation IDpublishLaborIntegrationEvents

    Available only on servers:

    • #labor-performance

    Accepts one of the following messages:

    • #0Task Performance Recorded (integration)

      One completed task was scored against the standard active at completion time — published for other bounded contexts (ADR 0013).

      Raised by RecordTaskPerformance for every consumed TaskCompleted, the SAME domain event as the analytics stream's TaskPerformanceRecorded message, on a different topic and with the :events: dataschema. Partition key is AssociateId, not TaskType. efficiency_pct is NULLABLE and null is a real, expected value: null whenever the task could not be scored — no active standard for its TaskType at completion time, or a non-positive duration. Consumers MUST NOT coerce null to 0. completed_at is the BUSINESS time; the CloudEvents time attribute is the domain occurred-at (scoring) instant. The two differ for any replayed or late-ingested event.

      allOf
      • #task
      • #labor-performance

      Examples

    • #1Labor Standard Defined (integration)

      A standard was defined where none was open for its scope — published for other bounded contexts (ADR 0038).

      The SAME domain event as the analytics stream's LaborStandardDefined message, with the SAME data (field names and types unchanged), on the integration topic and with the :events: dataschema. Subject is the standard id; the partition key is the TaskType, so every revision of one task type stays in order. A consumer (e.g. warehouse-planning, which keeps a local copy of the standards) treats the optional fields as optional: messages produced before an additive field existed simply do not carry it.

      allOf

      ADR 0038. Same type and same data schema as the analytics stream's LaborStandardDefinedCloudEvent; only the dataschema stream segment differs.

      • #labor-performance

      Examples

    • #2Labor Standard Revised (integration)

      An open standard was closed and a new one started in its place — published for other bounded contexts (ADR 0038).

      The SAME domain event as the analytics stream's LaborStandardRevised message, with the SAME data, on the integration topic and with the :events: dataschema. standard_id is the NEW record; the closed one is never overwritten (append-only history, ADR 0004). Subject is the new standard id; the partition key is the TaskType.

      allOf

      ADR 0038. Same type and same data schema as the analytics stream's LaborStandardRevisedCloudEvent; only the dataschema stream segment differs.

      • #labor-performance

      Examples

Messages

  • #1Labor Standard Defined

    A TaskType had no active standard, and one was just defined.

    Message IDLaborStandardDefined

    Raised when DefineStandard creates the first engineered standard for a TaskType. The projector counts it into the (task_type, hour-of- effective_from) rollup row. The same occurrence is also published on the integration topic with the same data (LaborStandardDefinedIntegration, ADR 0038), under its own CloudEvents id.

    allOf
    • #labor-performance
  • #2Labor Standard Revised

    An active standard was closed and a new one started in its place.

    Message IDLaborStandardRevised

    Raised when DefineStandard is called for a TaskType that already has an active standard. History is append-only — the prior standard is closed, never overwritten (ADR 0004). A bucket with a non-zero revision count is one whose efficiency figures span two different yardsticks and are not directly comparable across the boundary. The same occurrence is also published on the integration topic with the same data (LaborStandardRevisedIntegration, ADR 0038).

    allOf
    • #labor-performance
  • #3Task Performance Recorded

    One completed task was scored against the standard active at completion time.

    Message IDTaskPerformanceRecorded

    Raised by RecordTaskPerformance for every consumed TaskCompleted. efficiency_pct is NULLABLE and null is a real, expected value, not a missing field: it is null whenever the task could not be scored — no active standard for its TaskType at completion time, or a non-positive duration. Consumers MUST NOT coerce null to 0; doing so would report an unmeasurable task as a 0%-efficient one. The projector counts such an event toward its bucket's task count while excluding it from the mean. completed_at is the BUSINESS time and is what the projector buckets on — distinct from the CloudEvents time attribute, which is the domain occurred-at and feeds only the freshness watermark. The two differ for any replayed or late-ingested event.

    allOf
    • #task
  • #4Task Performance Recorded (integration)

    One completed task was scored against the standard active at completion time — published for other bounded contexts (ADR 0013).

    Message IDTaskPerformanceRecordedIntegration

    Raised by RecordTaskPerformance for every consumed TaskCompleted, the SAME domain event as the analytics stream's TaskPerformanceRecorded message, on a different topic and with the :events: dataschema. Partition key is AssociateId, not TaskType. efficiency_pct is NULLABLE and null is a real, expected value: null whenever the task could not be scored — no active standard for its TaskType at completion time, or a non-positive duration. Consumers MUST NOT coerce null to 0. completed_at is the BUSINESS time; the CloudEvents time attribute is the domain occurred-at (scoring) instant. The two differ for any replayed or late-ingested event.

    allOf
    • #task
    • #labor-performance
  • #5Labor Standard Defined (integration)

    A standard was defined where none was open for its scope — published for other bounded contexts (ADR 0038).

    Message IDLaborStandardDefinedIntegration

    The SAME domain event as the analytics stream's LaborStandardDefined message, with the SAME data (field names and types unchanged), on the integration topic and with the :events: dataschema. Subject is the standard id; the partition key is the TaskType, so every revision of one task type stays in order. A consumer (e.g. warehouse-planning, which keeps a local copy of the standards) treats the optional fields as optional: messages produced before an additive field existed simply do not carry it.

    allOf

    ADR 0038. Same type and same data schema as the analytics stream's LaborStandardDefinedCloudEvent; only the dataschema stream segment differs.

    • #labor-performance
  • #6Labor Standard Revised (integration)

    An open standard was closed and a new one started in its place — published for other bounded contexts (ADR 0038).

    Message IDLaborStandardRevisedIntegration

    The SAME domain event as the analytics stream's LaborStandardRevised message, with the SAME data, on the integration topic and with the :events: dataschema. standard_id is the NEW record; the closed one is never overwritten (append-only history, ADR 0004). Subject is the new standard id; the partition key is the TaskType.

    allOf

    ADR 0038. Same type and same data schema as the analytics stream's LaborStandardRevisedCloudEvent; only the dataschema stream segment differs.

    • #labor-performance
  • #7Task Completed

    A station finished a claimed task; fulfillment-execution's fact.

    Message IDTaskCompleted

    Raised by fulfillment-execution's Task aggregate when a station completes a claimed task. This service consumes it to record a TaskPerformance row scored against whatever LaborStandard was active for the task's type at completion time.

    allOf
    • #task

Schemas

  • object [CloudEvents 1.0 envelope (structured mode, ADR 0021)]

    The ONLY envelope on every topic this service produces or consumes. Every attribute is REQUIRED in this fleet. Kafka header content-type: application/cloudevents+json; charset=UTF-8. W3C trace context travels in the traceparent/tracestate Kafka headers, never as extension attributes.

  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf

    ADR 0038. Same type and same data schema as the analytics stream's LaborStandardDefinedCloudEvent; only the dataschema stream segment differs.

  • allOf

    ADR 0038. Same type and same data schema as the analytics stream's LaborStandardRevisedCloudEvent; only the dataschema stream segment differs.

  • object

    Only task_id is required by this consumer (an empty one fails handling and is dead-lettered); station_id and work_unit_id are published by fulfillment-execution but never read here. Unknown fields are ignored.

  • object
  • object
  • object
  • object