task-interleaving Domain Events 1.0.0

Event catalog for the task-interleaving bounded context (WES subdomain): when a station completes a task, which open task nearby could the operator do next with the smallest detour (ADR 0001, ADR 0002). The output is an advisory hint, never an assignment.

Published. The StationTrip aggregate (one per station) raises InterleavingHintIssued when it issues a hint, InterleavingHintConsumed when the hinted station claims one of the candidates, and InterleavingHintExpired when an unclaimed hint reaches its expires_at; the InterleavingPolicy aggregate raises InterleavingPolicyDeclared. Only InterleavingHintIssued is on the integration topic warehouse.task-interleaving.events (fulfillment-execution reads it, ADR 0002). All four types are on the analytics topic warehouse.task-interleaving.analytics. Events are written through a transactional outbox: the aggregate row and its already-encoded events are written in ONE database transaction and a relay drains them to Kafka (at-least-once; the CloudEvents id is stored with the outbox row, so a retry republishes the same id). A superseded hint raises no event of its own: a consumer learns of it from the next InterleavingHintIssued of the same station.

Consumed (ADR 0003). TaskAvailable, TaskClaimed and TaskCompleted from fulfillment-execution (TaskAvailable and TaskClaimed have been published on its integration topic since its ADR 0049; TaskAvailable is announced for RELOCATE and REPLENISH tasks, ADR 0050, and for a PICK task whose plan carries both the site and the pick face, ADR 0062; PACK, SLAM and REBIN are not announced), and ZoneRegistered, LocationSlotRegistered, LocationSlotDecommissioned and LocationGeometryUpdated from facility-layout. Each feeds a durable local copy. Both consumers are always on (FULFILLMENT_MODE and LAYOUT_MODE only accept kafka, ADR 0006); the consumer groups are mandatory env FULFILLMENT_CONSUMER_GROUP and LAYOUT_CONSUMER_GROUP. A transient handler failure is retried up to five times, then the message is dead-lettered to <topic>.dlq with x-dlq-* headers; a payload of a handled type that can never be applied (a missing required field, malformed data) is dead-lettered at once; a message that is not a valid CloudEvents 1.0 event is skipped with a WARN and committed past; an unknown type is ignored. The consumed messages below are the producers' own contracts, decoded independently here and never imported.

Envelope (mandatory). CloudEvents 1.0, structured content mode, Kafka header content-type: application/cloudevents+json; charset=UTF-8. Optional W3C trace-context headers (traceparent, and tracestate / baggage when present) carry the trace of the writing request; consumers may extract them and must not require them. specversion, id, source (/warehouse/task-interleaving), type, subject, time, datacontenttype (application/json) and dataschema (urn:warehouse:task-interleaving:<events|analytics>:<EventName>:v1) are all required. Kafka key and subject = the station id for hint events and the site id for the policy event. Type = com.warehouse.wes.task-interleaving.<entity>.<EventName> where <entity> is the raising aggregate, lowercase, no separators: stationtrip or policy. data is snake_case, optional fields are omitted when unset and timestamps are RFC 3339 UTC. A breaking payload change is a new .v2 type, never a mutation.

  • #task-interleaving
  • #stationtrip
  • #policy
  • #consumed
  • #analytics

Servers

  • {brokers}kafkaproduction

    Fleet-shared Kafka broker (host supplied by the deployment environment).

    object
    string
    required
    Security:
    security.protocol:PLAINTEXT

Operations

  • SUB warehouse.task-interleaving.events

    This service's integration topic. Written by the outbox relay; key = station id; every message carries the CloudEvents content-type header (plus the optional W3C traceparent of the writing request). Only InterleavingHintIssued is published here: the hint table of fulfillment-execution is its consumer. Dispatch on the full type, ignore unknown types, dedupe on id.

    Receive interleaving hints.

    Subscribe to the hints. Route on the full type (com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintIssued). A hint is advisory: use it only as a tie-break inside one priority band, ignore it once expires_at has passed, and fail open when it is absent.

    Operation IDreceiveInterleavingHints

    Available only on servers:

    • #stationtrip

    Accepts the following message:

    Interleaving hint issued

    A station completed a task and nearby open tasks were recommended.

    type = com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintIssued, dataschema = urn:warehouse:task-interleaving:events:InterleavingHintIssued:v1; subject and Kafka key = the station id. The CloudEvents time is when the hint was issued. candidates is non-empty (an empty candidate set issues NO hint), ranked from 1 by detour_m ascending then task_id, at most the policy's max_candidates. The hint is valid until expires_at.

    allOf
    • #stationtrip

    Examples

  • SUB warehouse.task-interleaving.analytics

    This service's analytics topic. Written by the SAME outbox relay, from rows inserted in the same transaction as the integration row, with the SAME type and id per occurrence and dataschema = urn:warehouse:task-interleaving:analytics:<EventName>:v1; key = station id (hint events) or site id (policy event). InterleavingHintConsumed, InterleavingHintExpired and InterleavingPolicyDeclared exist ONLY here. Not an integration contract: other contexts consume the integration topic. The only consumer is this service's own cmd/ti-projector (ADR 0008), under a fixed consumer group read from env ANALYTICS_CONSUMER_GROUP (default task-interleaving-analytics), which folds the events into the separate analytical database that cmd/ti-reports serves (GET /reports/hint-adoption, GET /reports/freshness). A message the projector can never apply (a known type whose payload contradicts its envelope or fails validation) is dead-lettered at once, byte for byte, to warehouse.task-interleaving.analytics.dlq; a transient failure retries the same message and never dead-letters it.

    Receive the interleaving analytics events.

    Route on the full type; the payloads are the integration payloads for InterleavingHintIssued and the documented analytics-only payloads for the other three types. The projector keeps, per hint, the earliest CloudEvents time of each of InterleavingHintIssued, InterleavingHintConsumed and InterleavingHintExpired (arrival order never matters) and records InterleavingPolicyDeclared only as an applied id (freshness). A redelivered id is applied once.

    Operation IDreceiveInterleavingAnalyticsEvents

    Available only on servers:

    • #analytics

    Accepts one of the following messages:

    • #0Interleaving hint issued (analytics stream)

      The analytics copy of InterleavingHintIssued.

      Same type, same id, same payload as the integration InterleavingHintIssued; only dataschema differs (urn:warehouse:task-interleaving:analytics:InterleavingHintIssued:v1).

      allOf
      • #analytics

      Examples

    • #1Interleaving hint consumed (analytics only)

      The hinted station claimed one of the hint's candidates before it expired.

      type = com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintConsumed, dataschema = urn:warehouse:task-interleaving:analytics:InterleavingHintConsumed:v1; analytics topic only. Subject and Kafka key = the station id. The CloudEvents time is when the claim was recorded. rank and detour_m are those of the claimed candidate in the hint.

      allOf
      • #stationtrip
      • #analytics

      Examples

    • #2Interleaving hint expired (analytics only)

      A hint reached its expires_at without a candidate being claimed.

      type = com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintExpired, dataschema = urn:warehouse:task-interleaving:analytics:InterleavingHintExpired:v1; analytics topic only. Subject and Kafka key = the station id. The CloudEvents time is the moment the expiry was recorded, at or after expires_at.

      allOf
      • #stationtrip
      • #analytics

      Examples

    • #3Interleaving policy declared (analytics only)

      An operator declared or replaced a site's interleaving policy.

      type = com.warehouse.wes.task-interleaving.policy.InterleavingPolicyDeclared, dataschema = urn:warehouse:task-interleaving:analytics:InterleavingPolicyDeclared:v1; analytics topic only. Subject and Kafka key = the site id. version starts at 1 and increases by one per declaration.

      allOf
      • #policy
      • #analytics

      Examples

  • PUB warehouse.fulfillment.events

    fulfillment-execution's integration topic (key and subject = the task id). This service consumes TaskAvailable, TaskClaimed and TaskCompleted under a stable consumer group read from the mandatory env FULFILLMENT_CONSUMER_GROUP; dead letters go to warehouse.fulfillment.events.dlq. Every other type on the topic is ignored.

    Consume task availability, claims and completions.

    TaskAvailable upserts a task into the local open-task pool and TaskClaimed removes it (both are published on the integration topic since fulfillment-execution's ADR 0049; TaskAvailable for RELOCATE and REPLENISH tasks, ADR 0050, and for a PICK task whose plan carries both the site and the pick face, ADR 0062). TaskCompleted (verified on fulfillment-execution's origin/develop) records the completion at the station: the position is the completed task's to_location read from the local pool copy, so a completion of a task this context never saw as available is ignored. The CloudEvents id claim and the effect commit in one transaction; the offset is committed afterwards (ADR 0003).

    Operation IDconsumeFulfillmentTaskEvents

    Available only on servers:

    • #consumed

    Accepts one of the following messages:

    • #0TaskAvailable (consumed, fulfillment-execution)

      A task entered or re-entered the open-task pool.

      Published by fulfillment-execution since its ADR 0049, for the tasks whose location it knows: RELOCATE and REPLENISH tasks carry bins (ADR 0050) and a PICK task whose plan carries both the site and the pick face is announced too (ADR 0062); a pick missing either, and PACK, SLAM and REBIN tasks, are not announced, so the PACK, SLAM and REBIN location rules below describe what this consumer accepts, not what is sent today). This contract was pinned here consumer-first. type = com.warehouse.wes.fulfillment-execution.task.TaskAvailable, source /warehouse/fulfillment-execution, dataschema urn:warehouse:fulfillment-execution:events:TaskAvailable:v1. Subject and Kafka key = the task id. Raised whenever a task ENTERS or RE-ENTERS the pool (release, lease expiry); upsert it into the pool copy. from_location is where the operator must go first, to_location is where the operator ends (PICK: both the pick bin; RELOCATE and REPLENISH: source and destination bin; PACK, SLAM and REBIN: the station code). priority_band is an opaque string equal across tasks that fulfillment-execution orders as peers; this context stores it and never interprets it. A message with an unknown task_type is stored but is never a candidate.

      allOf
      • #consumed

      Examples

    • #1TaskClaimed (consumed, fulfillment-execution)

      A station claimed a task; it left the pool.

      Published by fulfillment-execution on its integration topic since its ADR 0049 (with claimed_at, for every task type); it was previously only an analytics occurrence ({task_id, task_type, station_id}). type = com.warehouse.wes.fulfillment-execution.task.TaskClaimed, dataschema urn:warehouse:fulfillment-execution:events:TaskClaimed:v1. Subject and Kafka key = the task id. Removes the task from the open pool (the row is kept so a later TaskCompleted can read its end location) and, when the claimed task is a candidate of the Active hint of station_id, marks that hint Consumed; any other claim leaves the hint Active until it expires or is superseded.

      allOf
      • #consumed

      Examples

    • #2TaskCompleted (consumed, fulfillment-execution)

      A station finished a claimed task.

      type = com.warehouse.wes.fulfillment-execution.task.TaskCompleted, source /warehouse/fulfillment-execution, dataschema urn:warehouse:fulfillment-execution:events:TaskCompleted:v1. Subject and Kafka key = the task id; the CloudEvents time is the completion time. Verified on fulfillment-execution's origin/develop: task_id, station_id and work_unit_id are required by the producer. This context reads task_id (required) and station_id and ignores every other field (task_type, order_ref, line_no, the RELOCATE sku, from_bin, to_bin, quantity, relocation_ref, ...). The station's new position is the completed task's to_location from the local pool copy, with its site; a completion of a task absent from the copy (or without a to_location) is recorded as completed and otherwise ignored (no position, no hint; never dead-lettered). station_id is optional here: when blank, the claimer recorded in the pool copy is the completing station.

      allOf
      • #consumed

      Examples

  • PUB warehouse.facility.events

    facility-layout's integration topic. This service consumes ZoneRegistered (key zoneId), LocationSlotRegistered, LocationSlotDecommissioned and LocationGeometryUpdated (key locationCode) under a stable consumer group read from the mandatory env LAYOUT_CONSUMER_GROUP; dead letters go to warehouse.facility.events.dlq. Every other type is ignored.

    Consume zones, location slots and location geometry.

    The geometry copy is keyed by locationCode (LocationGeometryUpdated upserts a point); a location's site is found through its zoneId (LocationSlotRegistered) and that zone's siteCode (ZoneRegistered), joined at read time, so the events may arrive in any order. Decommissioning removes the location and is irreversible. A location without known geometry is never a candidate and never an origin: its distance is unknown, not zero.

    Operation IDconsumeFacilityLayoutEvents

    Available only on servers:

    • #consumed

    Accepts one of the following messages:

    • #0ZoneRegistered (consumed, facility-layout)

      A behavioural zone was added inside a site's area.

      type = com.warehouse.wms.facility-layout.zone.ZoneRegistered, source /warehouse/facility-layout, dataschema urn:warehouse:facility-layout:events:ZoneRegistered:v1. Subject and Kafka key = zoneId. Only zoneId, siteCode (both required) and zoneCode (stored) are used: they give the site of a location. data also carries eventName, eventType and occurredAt, which are ignored.

      allOf
      • #consumed

      Examples

    • #1LocationSlotRegistered (consumed, facility-layout)

      A coded leaf slot now exists on the warehouse map.

      type = com.warehouse.wms.facility-layout.locationslot.LocationSlotRegistered, dataschema urn:warehouse:facility-layout:events:LocationSlotRegistered:v1. Subject and Kafka key = locationCode. Only locationCode and zoneId are used (they give the location's zone, hence its site). data also carries eventName, eventType and occurredAt, which are ignored.

      allOf
      • #consumed

      Examples

    • #2LocationSlotDecommissioned (consumed, facility-layout)

      A coded slot was permanently retired.

      type = com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissioned, dataschema urn:warehouse:facility-layout:events:LocationSlotDecommissioned:v1. Subject and Kafka key = locationCode. Irreversible: the location and its geometry are removed from the local copy.

      allOf
      • #consumed

      Examples

    • #3LocationGeometryUpdated (consumed, facility-layout)

      A coded slot's physical position and footprint was set or changed.

      type = com.warehouse.wms.facility-layout.locationslot.LocationGeometryUpdated, dataschema urn:warehouse:facility-layout:events:LocationGeometryUpdated:v1. Subject and Kafka key = locationCode. The position (xM, yM, zM) in the site's local coordinate frame, in metres, feeds the rectilinear-v1 travel model; the footprint and pickSequence are ignored. Last writer wins per locationCode (one location's stream is totally ordered on its key).

      allOf
      • #consumed

      Examples

Messages

  • #1Interleaving hint issued

    A station completed a task and nearby open tasks were recommended.

    Message IDInterleavingHintIssued

    type = com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintIssued, dataschema = urn:warehouse:task-interleaving:events:InterleavingHintIssued:v1; subject and Kafka key = the station id. The CloudEvents time is when the hint was issued. candidates is non-empty (an empty candidate set issues NO hint), ranked from 1 by detour_m ascending then task_id, at most the policy's max_candidates. The hint is valid until expires_at.

    allOf
    • #stationtrip
  • #2Interleaving hint issued (analytics stream)

    The analytics copy of InterleavingHintIssued.

    Message IDInterleavingHintIssuedAnalytics

    Same type, same id, same payload as the integration InterleavingHintIssued; only dataschema differs (urn:warehouse:task-interleaving:analytics:InterleavingHintIssued:v1).

    allOf
    • #analytics
  • #3Interleaving hint consumed (analytics only)

    The hinted station claimed one of the hint's candidates before it expired.

    Message IDInterleavingHintConsumed

    type = com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintConsumed, dataschema = urn:warehouse:task-interleaving:analytics:InterleavingHintConsumed:v1; analytics topic only. Subject and Kafka key = the station id. The CloudEvents time is when the claim was recorded. rank and detour_m are those of the claimed candidate in the hint.

    allOf
    • #stationtrip
    • #analytics
  • #4Interleaving hint expired (analytics only)

    A hint reached its expires_at without a candidate being claimed.

    Message IDInterleavingHintExpired

    type = com.warehouse.wes.task-interleaving.stationtrip.InterleavingHintExpired, dataschema = urn:warehouse:task-interleaving:analytics:InterleavingHintExpired:v1; analytics topic only. Subject and Kafka key = the station id. The CloudEvents time is the moment the expiry was recorded, at or after expires_at.

    allOf
    • #stationtrip
    • #analytics
  • #5Interleaving policy declared (analytics only)

    An operator declared or replaced a site's interleaving policy.

    Message IDInterleavingPolicyDeclared

    type = com.warehouse.wes.task-interleaving.policy.InterleavingPolicyDeclared, dataschema = urn:warehouse:task-interleaving:analytics:InterleavingPolicyDeclared:v1; analytics topic only. Subject and Kafka key = the site id. version starts at 1 and increases by one per declaration.

    allOf
    • #policy
    • #analytics
  • #6TaskAvailable (consumed, fulfillment-execution)

    A task entered or re-entered the open-task pool.

    Message IDTaskAvailable

    Published by fulfillment-execution since its ADR 0049, for the tasks whose location it knows: RELOCATE and REPLENISH tasks carry bins (ADR 0050) and a PICK task whose plan carries both the site and the pick face is announced too (ADR 0062); a pick missing either, and PACK, SLAM and REBIN tasks, are not announced, so the PACK, SLAM and REBIN location rules below describe what this consumer accepts, not what is sent today). This contract was pinned here consumer-first. type = com.warehouse.wes.fulfillment-execution.task.TaskAvailable, source /warehouse/fulfillment-execution, dataschema urn:warehouse:fulfillment-execution:events:TaskAvailable:v1. Subject and Kafka key = the task id. Raised whenever a task ENTERS or RE-ENTERS the pool (release, lease expiry); upsert it into the pool copy. from_location is where the operator must go first, to_location is where the operator ends (PICK: both the pick bin; RELOCATE and REPLENISH: source and destination bin; PACK, SLAM and REBIN: the station code). priority_band is an opaque string equal across tasks that fulfillment-execution orders as peers; this context stores it and never interprets it. A message with an unknown task_type is stored but is never a candidate.

    allOf
    • #consumed
  • #7TaskClaimed (consumed, fulfillment-execution)

    A station claimed a task; it left the pool.

    Message IDTaskClaimed

    Published by fulfillment-execution on its integration topic since its ADR 0049 (with claimed_at, for every task type); it was previously only an analytics occurrence ({task_id, task_type, station_id}). type = com.warehouse.wes.fulfillment-execution.task.TaskClaimed, dataschema urn:warehouse:fulfillment-execution:events:TaskClaimed:v1. Subject and Kafka key = the task id. Removes the task from the open pool (the row is kept so a later TaskCompleted can read its end location) and, when the claimed task is a candidate of the Active hint of station_id, marks that hint Consumed; any other claim leaves the hint Active until it expires or is superseded.

    allOf
    • #consumed
  • #8TaskCompleted (consumed, fulfillment-execution)

    A station finished a claimed task.

    Message IDTaskCompleted

    type = com.warehouse.wes.fulfillment-execution.task.TaskCompleted, source /warehouse/fulfillment-execution, dataschema urn:warehouse:fulfillment-execution:events:TaskCompleted:v1. Subject and Kafka key = the task id; the CloudEvents time is the completion time. Verified on fulfillment-execution's origin/develop: task_id, station_id and work_unit_id are required by the producer. This context reads task_id (required) and station_id and ignores every other field (task_type, order_ref, line_no, the RELOCATE sku, from_bin, to_bin, quantity, relocation_ref, ...). The station's new position is the completed task's to_location from the local pool copy, with its site; a completion of a task absent from the copy (or without a to_location) is recorded as completed and otherwise ignored (no position, no hint; never dead-lettered). station_id is optional here: when blank, the claimer recorded in the pool copy is the completing station.

    allOf
    • #consumed
  • #9ZoneRegistered (consumed, facility-layout)

    A behavioural zone was added inside a site's area.

    Message IDZoneRegistered

    type = com.warehouse.wms.facility-layout.zone.ZoneRegistered, source /warehouse/facility-layout, dataschema urn:warehouse:facility-layout:events:ZoneRegistered:v1. Subject and Kafka key = zoneId. Only zoneId, siteCode (both required) and zoneCode (stored) are used: they give the site of a location. data also carries eventName, eventType and occurredAt, which are ignored.

    allOf
    • #consumed
  • #10LocationSlotRegistered (consumed, facility-layout)

    A coded leaf slot now exists on the warehouse map.

    Message IDLocationSlotRegistered

    type = com.warehouse.wms.facility-layout.locationslot.LocationSlotRegistered, dataschema urn:warehouse:facility-layout:events:LocationSlotRegistered:v1. Subject and Kafka key = locationCode. Only locationCode and zoneId are used (they give the location's zone, hence its site). data also carries eventName, eventType and occurredAt, which are ignored.

    allOf
    • #consumed
  • #11LocationSlotDecommissioned (consumed, facility-layout)

    A coded slot was permanently retired.

    Message IDLocationSlotDecommissioned

    type = com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissioned, dataschema urn:warehouse:facility-layout:events:LocationSlotDecommissioned:v1. Subject and Kafka key = locationCode. Irreversible: the location and its geometry are removed from the local copy.

    allOf
    • #consumed
  • #12LocationGeometryUpdated (consumed, facility-layout)

    A coded slot's physical position and footprint was set or changed.

    Message IDLocationGeometryUpdated

    type = com.warehouse.wms.facility-layout.locationslot.LocationGeometryUpdated, dataschema urn:warehouse:facility-layout:events:LocationGeometryUpdated:v1. Subject and Kafka key = locationCode. The position (xM, yM, zM) in the site's local coordinate frame, in metres, feeds the rectilinear-v1 travel model; the footprint and pickSequence are ignored. Last writer wins per locationCode (one location's stream is totally ordered on its key).

    allOf
    • #consumed

Schemas

  • object
  • string

    The task types a hint may point at.

  • object
  • object
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf
  • allOf