Skip to main content

Domain Events

Twenty-four past-tense events (internal/domain/shared/events*.go). Twenty-three are published to Kafka (apis/asyncapi.yaml); LocationRecorded stays in-process. The catalog below lists the twelve events of the stock, reservation, count and relocation paths; the transfer, container and held-stock events are in Which events flow where and the Events page. Only StockRelocated is built by an aggregate (internal/domain/relocation/relocation.go); every other event is published directly by a use case, and the Raised by column names the aggregate or use case the fact is about. Every event carries an occurredAt taken from the injected Clock port — never wall-clock time at publish — so ordering is a domain fact rather than an infrastructure artefact.

// internal/domain/shared/events.go
type DomainEvent interface {
EventName() string
OccurredAt() time.Time
}

The domain never depends on the publishing mechanism. Use cases hand events to ports.EventPublisher; which adapter is behind it (log, buffered, Postgres table, Kafka) is a composition-root decision.

The catalog​

EventRaised byRaised whenPayload
StockReceivedStockUnit (pre-location)ReceiveStock acknowledges inbound goodssku, quantity
ItemStowedStockUnitStowStock succeeds — item-scan + location-scan both presentsku, binId, quantity
LocationRecordedStockUnitImmediately after ItemStowed; the bin now authoritatively holds this unitstockUnitId, binId
StockReservedReservationReserveStock succeedsreservationId, sku, quantity, demandRef
ReservationExpiredReservationA reservation's timeout elapses and is discovered at the next read (GetReservationsByDemandRef, RevokeReservation, ConfirmPick, or ReserveStock's own idempotency lookup) — lazy, not swept, see belowreservationId
ReservationRevokedReservationRevokeReservation succeedsreservationId
StockPickedReservationConfirmPick consumes a reservation — from the REST route, or, in production, from ConfirmPicksForOrder on fulfillment-execution's TaskCompleted: for exactly the picked line when the event carries line_no (ADR 0036), on the order's last pick otherwise (ADR 0035)reservationId, sku, quantity
ItemUnlocatedStockUnitA cycle-count shortfall cannot account for stockstockUnitId, sku, binId, quantity
CycleCountCompletedRunCycleCount (use case; publishes directly while it changes StockUnits, no Bin is loaded)Any cycle count finishes, clean or notbinId, countedQty, systemQty, discrepancy
DiscrepancyDetectedRunCycleCount (use case; no Bin is loaded)A cycle count finds counted ≠ systembinId, countedQty, systemQty
StockRelocatedRelocationRelocateStock moves a quantity of one SKU between two bins of one site — from POST /relocations or, for a completed RELOCATE task, from ApplyRelocationTask (ADR 0039), and for a completed REPLENISH task (reason REPLENISHMENT, sourceRef = the replenishment request id), from ApplyReplenishTask (ADR 0041)relocationId, siteId, sku, fromBin, toBin, quantity, reason, sourceRef
BinStockLevelChangedStockUnit ledger (per bin and SKU)Any use case that moves a (bin, SKU) level, from the same transaction: stow, pick, relocate (source then destination), cycle-count shortfall, reserve, revoke / expiry (ADR 0040)siteId, binId, sku, onHand, reserved (absolute levels), version (per bin and SKU), reason

Which events flow where​

Nineteen of the twenty-four events go to the integration topic warehouse.inventory.events (isIntegrationEvent in internal/adapters/outbound/kafka/publisher.go): StockReserved and ReservationRevoked on the reservation path; the three transfer replies (TransferStockAllocated, TransferStockAllocationRejected, TransferStockAllocationReleased, ADR 0030, ADR 0051) and the receipt/stow facts TransferReceiptStaged and TransferStockStowed (ADR 0033); StockRelocated (ADR 0039); BinStockLevelChanged, the per-bin absolute level feed (ADR 0040); the promoted exception facts ItemStowed, ItemUnlocated and DiscrepancyDetected (ADR 0043); the four container events ContainerRegistered, ContainerStowed, CaseBroken and ContainerEmptied (ADR 0046); and the held-stock facts StockHeld, StockReleased and StockDispositioned (ADR 0052). The legacy ProductClassified (ADR 0034, product-master ADR 0003) was removed at stage E (2026-10-17), together with its republish command. The integration publisher's Encode returns nothing for the other five (StockReceived, StockPicked, ReservationExpired, CycleCountCompleted, LocationRecorded) — deliberate, not an oversight: those are not part of the published integration contract.

Twelve go to the internal analytics topic warehouse.inventory.analytics (analyticsEventFor in internal/adapters/outbound/kafka/analytics_publisher.go and heldAnalyticsEvent in held_events.go): the nine types the projector folds (StockReceived, ItemStowed, ItemUnlocated, StockReserved, StockPicked, ReservationExpired, ReservationRevoked, CycleCountCompleted, DiscrepancyDetected) and the three held-stock facts, which the projector acknowledges without folding. Counted over the twenty-three published types: eight reach both topics (StockReserved, ReservationRevoked, ItemStowed, ItemUnlocated, DiscrepancyDetected and the three held-stock facts), four are analytics-only (StockReceived, StockPicked, ReservationExpired, CycleCountCompleted) and eleven are integration-only (the three transfer replies, TransferReceiptStaged, TransferStockStowed, StockRelocated, BinStockLevelChanged and the four container events). LocationRecorded goes nowhere (no outbox row, no Kafka message — it has no consumer, so it stays in-process by decision). apis/asyncapi.yaml documents both channels, so a downstream team cannot mistake a documented analytics event for a wired integration one.

Wire catalogue​

The published events of the stock, reservation, count, relocation and bin-level paths, from the publishers' Encode methods (internal/adapters/outbound/kafka/publisher.go, analytics_publisher.go). The transfer replies, the container events and the held-stock facts follow the same envelope and are documented per message in apis/asyncapi.yaml; the held-stock facts also appear under Consumed events below. All messages are CloudEvents 1.0 structured mode, source=/warehouse/inventory-storage, routed with the Hash balancer on the Kafka key (ADR 0021), and — always, since Postgres is the only runtime — enqueued in outbox_events by the producing use case's transaction and relayed by cmd/inventory.

EventFull CloudEvents typeTopicKafka key / subjectdata fieldsProducer use caseKnown consumers
StockReservedcom.warehouse.wms.inventory-storage.reservation.StockReservedwarehouse.inventory.eventsreservation id / reservation idsku, quantity, demand_refReserveStockwes-work-planning (decrements its observed usable)
StockReservedsame typewarehouse.inventory.analyticsreservation id / reservation idsku, reservation_id, quantityReserveStockcmd/inventory-projector
ReservationRevokedcom.warehouse.wms.inventory-storage.reservation.ReservationRevokedwarehouse.inventory.eventsreservation id / reservation idsku, quantity, demand_ref (enriched by repo lookup)RevokeReservation (REST and MCP)wes-work-planning (increments its observed usable)
ReservationRevokedsame typewarehouse.inventory.analyticsreservation id / reservation idreservation_id, sku (enriched)RevokeReservationcmd/inventory-projector
ReservationExpiredcom.warehouse.wms.inventory-storage.reservation.ReservationExpiredwarehouse.inventory.analyticsreservation id / reservation idreservation_id, sku (enriched)lazy expiry in GetReservationsByDemandRef, ReserveStock, RevokeReservation, ConfirmPickcmd/inventory-projector
StockPickedcom.warehouse.wms.inventory-storage.reservation.StockPickedwarehouse.inventory.analyticsreservation id / reservation idsku, reservation_id, quantityConfirmPick (REST, and per reservation from ConfirmPicksForOrder, ADR 0035)cmd/inventory-projector
StockReceivedcom.warehouse.wms.inventory-storage.stock.StockReceivedwarehouse.inventory.analyticsSKU / SKUsku, quantityReceiveStockcmd/inventory-projector
ItemStowedcom.warehouse.wms.inventory-storage.stock.ItemStowedwarehouse.inventory.analyticsSKU / SKUsku, bin_id, quantityStowStockcmd/inventory-projector
ItemStowedsame typewarehouse.inventory.eventsSKU / SKUsku, bin_id, quantity (byte-identical to the analytics copy, ADR 0043)StowStocknone today: returns-processing does not consume it (its Kafka consumers in internal/adapters/inbound/kafka/ are allocated_lines, manifests and product_classes; its ADR 0003 defers closing the restock loop)
ItemUnlocatedcom.warehouse.wms.inventory-storage.stock.ItemUnlocatedwarehouse.inventory.analyticsSKU / stock unit idsku, bin_id, stock_unit_id, quantityRunCycleCountcmd/inventory-projector
ItemUnlocatedsame typewarehouse.inventory.eventsSKU / stock unit idsku, bin_id, stock_unit_id, quantity (byte-identical to the analytics copy, ADR 0043)RunCycleCountexception-management (opens cases from short counts)
CycleCountCompletedcom.warehouse.wms.inventory-storage.bin.CycleCountCompletedwarehouse.inventory.analyticsbin id / bin idbin_id, counted, system, discrepancyRunCycleCountcmd/inventory-projector
DiscrepancyDetectedcom.warehouse.wms.inventory-storage.bin.DiscrepancyDetectedwarehouse.inventory.analyticsbin id / bin idbin_id, counted, systemRunCycleCountcmd/inventory-projector
DiscrepancyDetectedsame typewarehouse.inventory.eventsbin id / bin idbin_id, counted, system (byte-identical to the analytics copy, ADR 0043)RunCycleCountexception-management (opens cases from short counts)
TransferReceiptStagedcom.warehouse.wms.inventory-storage.stock.TransferReceiptStagedwarehouse.inventory.eventstransfer line id / transfer line idtransfer_id, transfer_line_id, destination_site_id, sku, expected_quantity, received_quantity, variance (signed, ADR 0033)StageTransferReceiptplanning reconciliation (over/short is explicit, never absorbed)
TransferStockStowedcom.warehouse.wms.inventory-storage.stock.TransferStockStowedwarehouse.inventory.eventstransfer line id / transfer line idtransfer_id, transfer_line_id, destination_site_id, sku, received_quantity, stowed_quantity, allocations[] (ADR 0033)StowTransferStockthe only event that raises destination usable; wes-work-planning may project it
StockRelocatedcom.warehouse.wms.inventory-storage.stock.StockRelocatedwarehouse.inventory.eventsrelocation id / relocation idrelocation_id, site_code, sku, from_bin, to_bin, quantity, reason (SLOTTING/CONSOLIDATION/MANUAL/REPLENISHMENT), source_ref (always present, "" when none), occurred_at (ADR 0039, REPLENISHMENT by ADR 0041)RelocateStock (POST /relocations, and ApplyRelocationTask on a RELOCATE TaskCompleted, and ApplyReplenishTask on a REPLENISH one)slotting-optimization (slot-plan execution progress, its ADR 0010; must act only on SLOTTING), pick-face-replenishment (closes a request when reason=REPLENISHMENT and source_ref = the request id)
BinStockLevelChangedcom.warehouse.wms.inventory-storage.stock.BinStockLevelChangedwarehouse.inventory.events<bin>:<sku> / <bin>:<sku>site_code, bin, sku, on_hand, reserved (absolute levels after the change), version (per bin and SKU, strictly increasing), reason (STOW/PICK/RELOCATE/REPLENISHMENT/COUNT/RESERVE/REVOKE/UNLOCATED), occurred_at (ADR 0040)every stock-moving use case, from its own transaction: StowStock, StowTransferStock, ConfirmPick/ConfirmPicksForOrder, RelocateStock, RunCycleCount (shortfall), ReserveStock, AllocateTransferStock, RevokeReservation and lazy expirypick-face-replenishment (forward-slot minimum detection)
LocationRecorded— (not published; decided 2026-10-06: stays in-process, no consumer)———StowStocknone

Consumed (not produced): com.warehouse.wms.product-master.product.ProductClassified on warehouse.product-master.events feeds the local classification copy via ApplyProductClassification (ADR 0034); on the same topic com.warehouse.wms.product-master.product.ProductPackLevelDeclared and ProductPackLevelRetired feed the local packaging view pack_levels via ApplyPackLevel (ADR 0046); com.warehouse.wms.slotting-optimization.slotplan.SlotPlanApproved on warehouse.slotting-optimization.events replaces a site's forward-slot map (forward_pick_face_plans, forward_pick_faces) via ApplySlotPlan (ADR 0050); and com.warehouse.wes.fulfillment-execution.task.TaskCompleted on warehouse.fulfillment.events confirms the order's picked reservations via ConfirmPicksForOrder: exactly the picked line's reservation when the event carries line_no (ADR 0036), the order's on its last pick otherwise (ADR 0035) — and, for task_type=RELOCATE, applies the move via ApplyRelocationTask → RelocateStock (ADR 0039), and for task_type=REPLENISH via ApplyReplenishTask (ADR 0041) — and com.warehouse.wms.inbound-receiving.receipt.ReceiptLineReceived on warehouse.inbound-receiving.events books a received Good line as staged stock via BookInboundReceiptLine → ReceiveStock (the same StockReceived as POST /stock-receipts; a Damaged line is booked as held stock, ADR 0037, ADR 0052); on the same topic ReceiptCartonReceived creates or links Containers via LinkReceiptCarton (ADR 0045, ADR 0046); com.warehouse.wms.returns-processing.disposition.ReturnLineStaged on warehouse.returns-processing.events books a RESTOCK handover as staged stock through the same ReceiveStock seam via BookReturnLine (ADR 0044); and, on warehouse.network-inventory-planning.events, TransferAllocationRequested and TransferAllocationReleaseRequested drive AllocateTransferStock and ReleaseTransferAllocation (ADR 0030, ADR 0051). The table below lists each consumed type.

dataschema is urn:warehouse:inventory-storage:events:<EventName>:v1 on the integration topic and urn:warehouse:inventory-storage:analytics:<EventName>:v1 on the analytics topic.

Consumed events​

EventFull CloudEvents typeTopicConsumer (group)Effect
ZoneRegisteredcom.warehouse.wms.facility-layout.zone.ZoneRegisteredwarehouse.facility.eventsfacilitycache.Consumer (per-process group inventory-storage-facility-location-cache-<host>-<pid>-<ns>, FirstOffset replay)caches zone hazmat + temperatureClass by zoneId
LocationSlotRegisteredcom.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredwarehouse.facility.eventssamemaps locationCode → zoneId (derived from the code when absent)
LocationSlotHandlingUnitDeclaredcom.warehouse.wms.facility-layout.locationslot.LocationSlotHandlingUnitDeclaredwarehouse.facility.eventssamesets the bin handling unit (EACH/CASE/PALLET) in the event-fed copy, last write wins per locationCode (ADR 0047); LocationSlotRegistered carries the same optional handlingUnit
LocationSlotDecommissionedcom.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedwarehouse.facility.eventssamedrops the slot, so it answers Known=false
TaskCompletedcom.warehouse.wes.fulfillment-execution.task.TaskCompletedwarehouse.fulfillment.eventsTaskCompletedConsumer (stable group from the mandatory TASK_COMPLETED_CONSUMER_GROUP, chart default inventory-storage-confirm-pick, FirstOffset, always on)for task_type=PICK with order_ref: with the additive optional line_no (ADR 0036) confirms exactly the ACTIVE reservation of (order_ref, line_no) (StockPicked), skipping CONFIRMED/REVOKED/EXPIRED (expired counted) and leaving the order's other lines ACTIVE; nothing is counted. Without line_no, or for reservations with no line_no, the ADR 0035 fallback counts the pick for the order (order_pick_progress, one PICK task per order line) and, only on the LAST pick (count reaches the ACTIVE + CONFIRMED reservations), confirms every ACTIVE one. Claim, counter (fallback only) and confirmations in one transaction; no order_ref or no reservations is a no-op; a line_no outside 1..2147483647 is dead-lettered (ADR 0036). For task_type=RELOCATE (ADR 0039): ApplyRelocationTask reads the additive sku, from_bin, to_bin, quantity, relocation_ref, claims the CloudEvents id (consumer task-completed-relocate) and runs RelocateStock in one transaction (StockRelocated); a completion that can never apply (missing field, unknown bin, other site, same bin, insufficient usable, destination full) is dead-lettered at once. For task_type=REPLENISH (ADR 0041): ApplyReplenishTask reads the same additive fields plus the required request_ref (the replenishment request id), claims the id under consumer task-completed-replenish and runs RelocateStock with reason REPLENISHMENT and source_ref = request_ref in one transaction (StockRelocated, two BinStockLevelChanged); a missing request_ref is dead-lettered at once
ReceiptLineReceivedcom.warehouse.wms.inbound-receiving.receipt.ReceiptLineReceivedwarehouse.inbound-receiving.eventsInboundReceiptConsumer (stable group from the mandatory INBOUND_RECEIPT_CONSUMER_GROUP, always on, FirstOffset)for condition=Good: BookInboundReceiptLine claims the CloudEvents id (processed_events) and runs ReceiveStock in one transaction, so one StockReceived (analytics topic) per id, staged and not yet usable (ADR 0037); for condition=Damaged: BookInboundReceiptLine claims the id and runs HoldStock in one transaction, so one StockHeld per id, never usable (ADR 0052); an empty sku, a non-positive quantity or an unknown condition is logged and committed past
ReceiptCartonReceivedcom.warehouse.wms.inbound-receiving.receipt.ReceiptCartonReceivedwarehouse.inbound-receiving.eventsInboundReceiptConsumer (same group as ReceiptLineReceived)LinkReceiptCarton claims the CloudEvents id and creates or links the Containers of the carton (ADR 0045, ADR 0046); it never books a quantity
ReturnLineStagedcom.warehouse.wms.returns-processing.disposition.ReturnLineStagedwarehouse.returns-processing.eventsReturnLineConsumer (stable group from the mandatory RETURN_LINE_CONSUMER_GROUP, always on)BookReturnLine claims the id (consumer return-line-staged) and runs ReceiveStock in one transaction, so one StockReceived (analytics topic) per id, staged and not yet usable (ADR 0044); an empty sku, a non-positive quantity, an empty disposition_id or a condition other than Good is logged (WARN) and committed past
TransferAllocationRequestedcom.warehouse.wes.network-inventory-planning.transfer.TransferAllocationRequestedwarehouse.network-inventory-planning.eventsConsumer in transfer_consumer.go (stable group from the mandatory TRANSFER_ALLOCATION_CONSUMER_GROUP, chart default inventory-storage-transfer-allocation)AllocateTransferStock decides the allocation and replies TransferStockAllocated or TransferStockAllocationRejected on this service's own integration topic through the outbox (ADR 0030); a payload that can never apply is logged (WARN) and committed past, there is no DLQ on this topic
TransferAllocationReleaseRequestedcom.warehouse.wes.network-inventory-planning.transfer.TransferAllocationReleaseRequestedwarehouse.network-inventory-planning.eventssameReleaseTransferAllocation resolves the origin reservation of a transfer cancelled after allocation, idempotent by transfer_line_id, and replies TransferStockAllocationReleased through the outbox (ADR 0051)
SlotPlanApprovedcom.warehouse.wms.slotting-optimization.slotplan.SlotPlanApprovedwarehouse.slotting-optimization.eventsSlotPlanConsumer (group SLOT_PLAN_CONSUMER_GROUP, default inventory-storage-slot-plan, replays from the first offset for a new group)ApplySlotPlan replaces the site's forward-slot map (forward_pick_face_plans, forward_pick_faces) in one transaction with the id claim, only when approved_at is later than the held plan's; SlotPlanGenerated and SlotPlanRejected are committed past (ADR 0050)
ProductClassified, ProductPackLevelDeclared, ProductPackLevelRetiredcom.warehouse.wms.product-master.product.<Event>warehouse.product-master.eventsProductMasterConsumer (stable group from the mandatory PRODUCT_MASTER_CONSUMER_GROUP, always on)ProductClassified: ApplyProductClassification upserts the local classification copy when its version is greater than the stored one (ADR 0034); the two pack-level events feed the local packaging view pack_levels via ApplyPackLevel (ADR 0046); the other product-master types are committed past
StockHeld, StockReleased, StockDispositionedcom.warehouse.wms.inventory-storage.stock.<Event>warehouse.inventory.events and warehouse.inventory.analyticsnone yet (x-no-consumer-reason in apis/asyncapi.yaml); the projector acknowledges the types it does not foldheld-stock facts (ADR 0052): key = subject = held unit id; StockHeld on a Damaged line, StockReleased + StockDispositioned (+ the StockReceived of the release) on RELEASE, StockDispositioned on every other decision
all nine analytics types abovecom.warehouse.wms.inventory-storage.*warehouse.inventory.analyticscmd/inventory-projector (group inventory-analytics, FirstOffset)upserts flow_accuracy_rollup, dedupes on the CloudEvents id; a ProductClassified on the same topic would be acknowledged and ignored (none is published there since ADR 0034)

Any other type on warehouse.facility.events is ignored; a message that is not a valid CloudEvent is dead-lettered to warehouse.facility.events.dlq. The projector WARN-logs and skips invalid messages instead. On warehouse.fulfillment.events every type other than TaskCompleted is committed past; a TaskCompleted with an undecodable payload, or whose handling keeps failing after 5 attempts, is dead-lettered to warehouse.fulfillment.events.dlq, and a message that is not a CloudEvent is skipped with a sampled WARN. A completed pick on the counting fallback before the order's last one only advances the internal order_pick_progress counter; it raises no event and changes no contract, and a per-line pick (ADR 0036) writes no counter at all. Short picks are not modelled: the Task carries no SKU or quantity (ADR 0035).

Lazy expiry: no sweeper, resolved at the next read​

ReservationExpired and Reservation.Expire() exist in the domain and are unit-tested, and are now genuinely raised — but not by a background sweeper. The decision (2026-09-26, see ADR 0003) is lazy expiry: a timed-out reservation is discovered and resolved the next time it is read, not on a schedule. Every read path that can return a Reservation runs the same check first — GetReservationsByDemandRef, RevokeReservation, ConfirmPick, and ReserveStock's own idempotency lookup — so there is no window where a stale ACTIVE reservation can be returned to a caller:

  • if the reservation is ACTIVE and past expiresAt, the read transitions it to EXPIRED, returns its allocated quantity to the owning StockUnit's usable pool, persists both changes, and publishes ReservationExpired through the same ports.EventPublisher every other domain event uses — all before the read returns;
  • if it is already EXPIRED, CONFIRMED, or REVOKED, the read is a no-op: the event is never raised twice for the same reservation;
  • Reservation.Confirm(now) still independently returns ErrExpired past expiresAt as a second line of defence — but by the time ConfirmPick reaches that call, the lazy-expiry check on its own read has usually already resolved the reservation to EXPIRED, so the caller sees ErrAlreadyResolved instead.

The practical consequence: a reservation nobody revokes still holds quantity out of usable until it is read — there remains no proactive reclaim of quantity for a reservation that both times out and is never looked up again. Decided 2026-10-06: kept — lazy expiry stays, with no sweeper (ADR 0003; pick confirmation from fulfillment-execution's TaskCompleted, ADR 0035, ADR 0036, resolves a picked line's reservation (the order's, on the counting fallback) when its pick completes, which narrows the gap further — a pick that completes after the timeout is skipped and counted, not recovered). That is judged an acceptable trade-off for this service's read volume; if it stops being one, the fix is a scheduled read (e.g. a periodic call to GetReservationsByDemandRef or a dedicated sweep use case), not a change to the lazy check itself. apis/asyncapi.yaml documents ReservationExpired's payload; it reaches the analytics topic (warehouse.inventory.analytics) the same way ReservationRevoked does, via kafka/analytics_publisher.go.

Naming conventions​

Two conventions coexist, and the difference is worth understanding.

In-process: bare past-tense names​

shared.DomainEvent.EventName() returns the bare name — "StockReserved", "ItemStowed". That is the domain's own vocabulary and it deliberately carries no transport or platform naming.

On the wire: reverse-DNS CloudEvents type​

The platform-wide convention, shared across the fleet's services:

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

All lowercase except the final PascalCase event name. For this context the subdomain segment is wms and the bounded context is inventory-storage:

com.warehouse.wms.inventory-storage.stock.ItemStowed
com.warehouse.wms.inventory-storage.reservation.ReservationRevoked
com.warehouse.wms.inventory-storage.bin.CycleCountCompleted

Entity segments group by the aggregate that raises the event: stock, reservation, bin.

StockPicked is grouped under reservation rather than stock, because it is emitted by ConfirmPick when a reservation is consumed and the reservation id is the only identity it carries.

What the Kafka adapters emit​

Every message is a CloudEvents 1.0 event in structured mode — the only envelope (ADR-0024). The integration publisher (warehouse.inventory.events) and the analytics publisher (warehouse.inventory.analytics) both build it through internal/adapters/kafka/cloudevents:

{
"specversion": "1.0",
"id": "9f1c2d3e-4b5a-4c6d-8e7f-0a1b2c3d4e5f",
"source": "/warehouse/inventory-storage",
"type": "com.warehouse.wms.inventory-storage.reservation.StockReserved",
"subject": "res-1",
"time": "2026-08-21T22:00:00Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:inventory-storage:events:StockReserved:v1",
"data": { "sku": "SKU-1", "quantity": 6, "demand_ref": "order-42" }
}

The id is minted once when the event is encoded and stored inside the outbox row, so a relay redelivery carries the same id. See the Events page for every type and payload.

A detail worth knowing: ReservationRevoked enrichment​

The domain event ReservationRevoked carries only a reservationId — the aggregate has no reason to repeat data the reservation already holds. But the integration contract promises {sku, quantity, demand_ref}, because the downstream projection is keyed by SKU and cannot do a lookup.

The Kafka adapter bridges that gap by re-reading the reservation through ReservationRepo at publish time:

case shared.ReservationRevoked:
res, err := p.reservations.FindByID(ctx, e.ReservationID)
if err != nil { return err }
if res == nil { return ErrReservationNotFound }
data = reservationData{SKU: res.SKU().String(), Quantity: res.Quantity().Int(), DemandRef: res.DemandRef()}

This is the right place for it: enrichment for a downstream consumer's convenience is an adapter concern, and putting the extra fields on the domain event to save a lookup would let an integration requirement leak into the domain model. The use case saves the reservation before publishing, so the lookup always succeeds; ErrReservationNotFound exists as a guard, not as an expected path.

Read models are projections​

CLAUDE.md states it as a rule: read models (usable-by-SKU, bin occupancy) are projections from events, not separately-maintained aggregates. Inside this service, GetUsable projects from StockUnits at read time. Across the boundary, wes-work-planning projects StockReserved / ReservationRevoked into its own UsableInventoryObserved read model keyed by SKU. Same discipline, two scopes.