Skip to main content

Domain events

Every event this context publishes or consumes. All are CloudEvents 1.0 in structured content mode (content-type: application/cloudevents+json; charset=UTF-8) with source=/warehouse/network-inventory-planning on what it publishes. The published catalogue is pinned by ADR 0004 and an architecture fitness test (internal/architecture/catalogue_fitness_test.go): adding, renaming or versioning a published type is one change across apis/asyncapi.yaml, the emitting code and that ADR.

Published on warehouse.network-inventory-planning.events​

All through the transactional outbox, in the same transaction as the state change that justifies them.

TypeKafka keyRaised whenConsumer
com.warehouse.wes.network-inventory-planning.transfer.TransferPlanApprovedtransfer_idan operator approved a proposal (APPROVED)none in the fleet today
com.warehouse.wes.network-inventory-planning.transfer.TransferAllocationRequestedtransfer_line_id (<transfer_id>:1)the saga asks for origin stock (ALLOCATING, same transaction)inventory-storage
com.warehouse.wes.network-inventory-planning.transfer.TransferAllocationReleaseRequestedtransfer_line_id (<transfer_id>:1)an operator cancelled an ALLOCATED transfer (ALLOCATED → RELEASING, same transaction, ADR 0022)inventory-storage
com.warehouse.wes.network-inventory-planning.workdemand.WorkDemandReleaseddemand_id (<transfer_id>:pick / :dispatch)pick leg with ALLOCATED, dispatch leg with PICKEDwes-work-planning

dataschema is urn:warehouse:network-inventory-planning:events:<EventName>:v1. The workdemand entity segment is the one WES's consumed contract names.

Payloads (apis/asyncapi.yaml, internal/adapters/outbound/kafka/publisher.go):

  • TransferPlanApproved: transfer_id, origin_site_id, destination_site_id, sku, quantity, policy_version, operator_reason (may be empty), proposal_as_of.
  • TransferAllocationRequested: exactly inventory-storage's five fields, transfer_id, transfer_line_id, origin_site_id, sku, quantity.
  • TransferAllocationReleaseRequested: transfer_id, transfer_line_id, reservation_id (the hold being resolved), origin_site_id, sku, quantity, reason (the operator's cancellation reason).
  • WorkDemandReleased: exactly WES's eight fields, demand_id, work_kind (TRANSFER_PICK or TRANSFER_DISPATCH), transfer_ref, path_id, site_id (the origin), cpt (triggering fact time + the leg's offset), sku, quantity (allocated for pick, picked for dispatch).

Published on warehouse.network-inventory-planning.analytics (ADR 0007)​

Saga-health occurrences for this context's own projector, not an integration contract. dataschema is urn:warehouse:network-inventory-planning:analytics:<EventName>:v1.

TypeKeyDataRaised when
...saga.TransferStateAdvancedtransfer_idtransfer_id, from (empty for the creation entry), to, age_seconds (since creation)each transition of the saga, in the transition's own transaction: ApproveTransfer (→DRAFT, →PROPOSED, →APPROVED, →ALLOCATING), ApplyTransferAllocation (→ALLOCATED), ApplyTransferRejection (→UNFULFILLABLE), ApplyTransferPick (→PICKED), ApplyTransferDispatched (→IN_TRANSIT), ApplyTransferArrival / ApplyTransferReceiptStaged (→ARRIVED), ApplyTransferStow (→RECEIVED), CancelTransfer (→CANCELLED, or →RELEASING for an ALLOCATED transfer) and ApplyTransferAllocationReleased (RELEASING→CANCELLED)
...saga.TransferStuckDetectedtransfer_idtransfer_id, state, age_seconds (since updated_at), threshold_secondseach health tick, for each non-terminal transfer past its threshold
...saga.RebalanceRunCompletedrun_idrun_id, proposal_count, rejected_count, stale_factsa scheduled rebalance completed (a FAILED run publishes nothing)

Every one of those use cases calls publishStateAdvanced (internal/application/usecases/analytics_hook.go), and cmd/network-inventory-planning/wire_sagas.go wires the outbox publisher into all of them, so the analytics stream has one occurrence for every step of every transfer. Without a broker (KAFKA_BROKERS unset) the publisher is nil and the occurrence is skipped, never an error.

Not published​

TransferProposed, OriginReservationRequested and any transfer-completed integration event are not in the AsyncAPI document. A proposal is advisory and never published. A cancel publishes an integration event only for an ALLOCATED transfer (the TransferAllocationReleaseRequested command above); a cancel before allocation publishes only its TransferStateAdvanced.

Consumed​

Thirteen types from six producers (every receive* operation in apis/asyncapi.yaml except the three saga.* ones below). Decoded as CloudEvents structured mode only, dispatched on the full type, deduplicated on the CloudEvents id in processed_events in the same unit of work, and committed only after that transaction settles.

TypeTopicProducerEffect
com.warehouse.wms.facility-layout.site.SiteCapabilityChangedwarehouse.facility.eventsfacility-layoutupsert site_capability; a greater capability_revision wins
com.warehouse.wes.order-management.siteskudemand.SiteSkuDemandChangedwarehouse.order-management.eventsorder-managementupsert site_sku_demand per (source_order_id, line_no), newest CloudEvents time wins (an older event is a no-op, ADR 0014); REMOVED contributes no units
com.warehouse.wes.warehouse-planning.capacityplan.CapacityPlanPublishedwarehouse.warehouse-planning.eventswarehouse-planningupsert published_capacity_plan per plan_id, newer published_at wins; no site_id → excluded
com.warehouse.wms.inventory-storage.reservation.TransferStockAllocatedwarehouse.inventory.eventsinventory-storageALLOCATING → ALLOCATED; reservation, allocations, expiry; releases the pick demand
com.warehouse.wms.inventory-storage.reservation.TransferStockAllocationRejectedwarehouse.inventory.eventsinventory-storageALLOCATING → UNFULFILLABLE with a closed reason; an unknown reason is logged and skipped
com.warehouse.wms.inventory-storage.reservation.TransferStockAllocationReleasedwarehouse.inventory.eventsinventory-storageRELEASING → CANCELLED; outcome RELEASED or ALREADY_RESOLVED settles it either way; clears reservation id, allocations and expiry (ADR 0022, 0023)
com.warehouse.wes.fulfillment-execution.transfer.TransferPickedwarehouse.fulfillment.eventsfulfillment-executionALLOCATED → PICKED; picked quantity (short allowed); releases the dispatch demand
com.warehouse.wes.fulfillment-execution.transfer.TransferDispatchedwarehouse.fulfillment.eventsfulfillment-executionPICKED → IN_TRANSIT
com.warehouse.wes.fulfillment-execution.transfer.TransferArrivedwarehouse.fulfillment.eventsfulfillment-executionIN_TRANSIT → ARRIVED; reserved, may never fire
com.warehouse.wms.inventory-storage.stock.TransferReceiptStagedwarehouse.inventory.eventsinventory-storageIN_TRANSIT → ARRIVED
com.warehouse.wms.inventory-storage.stock.TransferStockStowedwarehouse.inventory.eventsinventory-storageARRIVED → RECEIVED; stow allocations persisted
com.warehouse.wms.product-master.product.ProductPackLevelDeclaredwarehouse.product-master.eventsproduct-masterupsert the local pack_levels copy used to round case SKUs to whole cases (ADR 0017); a version not greater than the stored one is a no-op
com.warehouse.wms.product-master.product.ProductPackLevelRetiredwarehouse.product-master.eventsproduct-masterend-date that level in the local copy at effective_to; a level never seen or a GTIN that is no longer the stored one is ignored, a version not greater is a no-op

Whichever of TransferArrived and TransferReceiptStaged arrives first drives the arrival; the other is skipped as out of order. nip-projector consumes the three saga.* types from the analytics topic. Failure handling per consumer is in Ecosystem integration.