ADR 0010: Approved slot plans are executed as WES relocation work
Status
Amended by ADR 0011: RELOCATION_MODE accepts only kafka (default kafka) and the consumer always runs.
Accepted (2026-10-14, final-gaps wave decision E1). Supersedes
ADR 0007, whose options and open
questions it decides. ADR 0001
and ADR 0002 stand:
this context still only plans; it never creates floor work and never writes
the stock ledger. Additive only: SlotPlanApproved v1 is unchanged, one new
table (migration 0002), optional response fields on the plan read API and the
MCP plan tool.
Context
ADR 0007 laid out three ways to turn an Approved plan's moves into floor work: (A) wes-work-planning plans the moves as work, (B) inventory-storage creates and tracks relocations itself, (C) a slotting-owned move list worked through the console. It answered none of its seven open questions.
A forward-slot move is physical floor work. The fleet already has ONE conductor
for floor work (wes-work-planning plans, process-path-management routes,
fulfillment-execution executes with operators; labour and capacity planning
and the WES telemetry apply) and ONE stock ledger (inventory-storage), joined
by an existing pattern: fulfillment-execution's TaskCompleted drives
inventory-storage's ledger (confirm-pick, inventory-storage ADR 0035/0036).
Option B makes inventory-storage a second work planner, which ADR 0001 of this
context excluded. Option C duplicates truth between a move list and the
ledger. Option A keeps one planner, one executor and one ledger, and every
option needed inventory-storage's relocation command anyway.
Decision
Option A. wes-work-planning plans and staffs the moves of an Approved plan;
fulfillment-execution executes them with operators; inventory-storage records
them on the ledger; this context learns the outcome from inventory-storage's
StockRelocated and keeps a per-plan execution-progress read model.
Answers to ADR 0007's open questions
- Relocation command. inventory-storage owns an intra-site
RelocateStock command: move a quantity of one SKU from bin A to bin B in
one site, atomically on the ledger (both bins in one transaction, never
negative, optimistic concurrency like its other stock commands), raising
com.warehouse.wms.inventory-storage.stock.StockRelocated(snake_case data:relocation_id,site_code,sku,from_bin,to_bin,quantity,reason,source_ref,occurred_at) through its outbox. It is exposed as RESTPOST /relocations(Idempotency-Key, like its other commands) AND applied from fulfillment-execution'sTaskCompletedwhentask_typeisRELOCATE(an additive consumer branch next to confirm-pick). - Who plans it. Yes: slot moves are floor work planned and staffed by wes-work-planning (a second demand source next to orders).
- Supersession. When a newer plan's
SlotPlanApprovedarrives, wes-work-planning cancels the superseded plan's NOT-YET-RELEASED relocation work and plans the new plan's moves; released and in-progress tasks run to completion. - Ordering. wes-work-planning sequences inside one plan: a move into a
slot that another move vacates is released only after that vacate's task
completes (a dependency on
TaskCompleted). - Quantity and source. v1 moves the whole on-hand quantity of the SKU at
the source bin, counted and confirmed by the operator at execution (the
fulfillment-execution task completion carries the confirmed quantity).
Relocatesource =from_slot;Vacatedestination = a reserve bin chosen at execution (the operator scans it; inventory-storage validates the bin exists in the site);Assignsource = any bin holding the SKU that is not a forward slot, chosen at execution (the operator scans it; inventory-storage validates the SKU is there). No min/max replenishment is introduced (ADR 0002 keeps it out of scope). - Payload.
SlotPlanApprovedv1 is enough (sku,from_slot?,to_slot?,kind); the quantity is resolved at execution. No v2. - Feedback. slotting-optimization consumes
StockRelocatedto record per-move execution progress on the plan (read model: executed moves / total, last executed at), exposed on its plan read API and MCP plan tool; it does NOT gate proposals on it in v1.
Implemented by (one ADR per context)
- inventory-storage ADR 0039: RelocateStock,
POST /relocationsandGET /relocations/{id},StockRelocatedonwarehouse.inventory.events, and theTaskCompletedRELOCATE branch. On the task pathsource_refis the task'srelocation_ref, or the task id when the producer sent none. - fulfillment-execution ADR 0047: the
RELOCATEtask type (sku, from_bin?, to_bin?, kind, plan_id, move_seq); completing it takes the operator-confirmed quantity and the scanned bins;TaskCompletedgains the additive optional fieldssku,from_bin,to_bin,quantityandrelocation_ref=<plan_id>:<move_seq>. - wes-work-planning ADR 0040: consumes
SlotPlanApproved, plans one RELOCATE work unit per move (move_seq= the 0-based position of the move in the event'smoves), sequences (answer 4) and supersedes (answer 3) them, and releases them through the existing release flow via the RELOCATE path. - process-path-management ADR 0033 (the
RELOCATEprocess path, required capabilityrelocate) and ADR 0034 (path intake: RELOCATE's intake isSLOT_RELOCATION, so approved slot plans, and only they, route onto it; customer order lines never do).
This context's part
- Consumer. A new consumer reads
warehouse.inventory.eventsunder a stable group (RELOCATION_MODE=kafka,RELOCATION_CONSUMER_GROUP, no default; modepermissive= no consumer, the default) and acts oncom.warehouse.wms.inventory-storage.stock.StockRelocatedonly; every other type on the topic is ignored. CloudEvents 1.0 viainternal/adapters/kafka/cloudevents, dispatch on the FULLtype, the CloudEventsidclaimed (consumerslotting-relocation) in the SAME transaction as the effect, offset committed afterwards (ADR 0003's pattern). - Matching.
source_refis matched first:<plan_id>:<move_seq>(split at the last:) names the move at that 0-based position of the plan's moves, which is the orderSlotPlanApprovedpublishes them in (sorted by SKU). The move matches when the plan exists, is Approved or Superseded (its released tasks still run to completion, answer 3), is forsite_code, has a move atmove_seq, and that move is forsku. Only whensource_refis not a move reference (empty, a task id, a manual ticket) does the consumer fall back to the site's CURRENT Approved plan: the move forskuwhose bins agree with its kind (Relocate:from_slot=from_binandto_slot=to_bin;Assign:to_slot=to_bin;Vacate:from_slot=from_bin).site_codeis this context's site id (the fleet's site codes). - Unmatched is not poison. A relocation that matches no move (unknown
plan, plan not Approved/Superseded, other site, no move at that position,
another SKU, no current plan, no move with those bins) is claimed, logged
at INFO and counted (
slotting_optimization.relocations.observed,outcome=unmatched,reason=<why>); it is never dead-lettered, because most relocations (manual, consolidation, replenishment) are not slot-plan moves. Amendment (replenishment, inventory-storage ADR 0041): only a relocation whosereasonisSLOTTINGcan execute a move. Any other reason is unmatched withreason=reason-not-slotting, decided before thesource_refor the bins are looked at, so a REPLENISHMENT move between the same SKU and bins as a plan move cannot inflate the plan's progress. - Read model. Table
slot_plan_move_executions, one row per matched relocation (primary keyrelocation_id: a replay of the same relocation under a new CloudEvents id cannot count twice). Per plan: moves total (the plan's moves), moves executed (moves with at least one relocation), last executed at (latestoccurred_at), and per move (move_seq,sku,kind) an executed flag and the executed quantity (sum of its relocations). Computed in the domain (slotplan.Progress), never stored as a counter. - Exposure.
GET /slot-plans/{planId}gains an optionalexecutionobject (OpenAPI additive) and the MCPget_slot_plantool an optionalexecutionfield (omitempty). Proposals (POST /slot-plans) and approvals are NOT gated on progress in v1. - Failure classes. A
StockRelocatedwhose data cannot be decoded or misses a required field (or carries a quantity below 1) is a deterministic poison: dead-lettered at once towarehouse.inventory.events.dlqwith thex-dlq-*headers, no retries. A message that is not a CloudEvent is skipped (WARN) like every other consumer here. A transient failure (database) is retried with capped backoff, then dead-lettered after the bounded attempts. Cancellation is never dead-lettered: the loop returnsctx.Err()before any dead-letter call and the message is redelivered.
Consequences
- An Approved plan now changes the floor: the moves become RELOCATE work in wes-work-planning and stock moves in inventory-storage, and the plan read API shows how far execution has got. The docs (integration, context map, domain message flow) no longer mark execution as "planned, not built".
- The plan read model depends on inventory-storage's
source_refcarrying the move reference; the bins fallback covers producers that send none. - Progress is advisory in v1: a newer plan can be generated and approved while the previous one is half executed (wes-work-planning applies answer 3). Gating proposals on progress would need a new ADR.
- Deployment: the chart renders
RELOCATION_MODE/RELOCATION_CONSUMER_GROUPfrom values (defaultpermissive, no group); turning it on in the cluster is a values change in warehouse-infra.