Integration
Every edge between slotting-optimization and the rest of the fleet, as the
code on develop builds it. The service has no outbound HTTP or MCP
client: it never calls a sibling. Everything it knows about demand,
products, slots and executed moves arrives on Kafka and is kept in local
copies (ADR 0003, ADR 0010); everything it decides leaves on Kafka through
the transactional outbox (ADR 0004).
Topics: warehouse.order-management.events, warehouse.product-master.events,
warehouse.facility.events, warehouse.inventory.events (in),
warehouse.slotting-optimization.events (out, integration) and
warehouse.slotting-optimization.analytics (out, read only by this
repository's projector, ADR 0006). The dashed edge is wired in the console
but does not reach the reports binary in the kind cluster (see below).
Source: internal/adapters/inbound/kafka/{demand,product,packlevel,layout,stock}_consumer.go,
internal/adapters/outbound/kafka/encoder.go,
internal/adapters/inbound/http/server.go, ADR 0001 (context map),
ADR 0010
(execution).
Upstream
All four are Conformist edges over the producer's Published Language:
the payloads are restated in Go structs (never imported) and in
apis/asyncapi.yaml, and the full CloudEvents type string is the dispatch
key. Each producer was checked on its own origin/develop on 2026-10-09:
the topic constant and the type strings below exist in its code.
| Producer | Topic | Type consumed | Fields read | Effect here |
|---|---|---|---|---|
order-management | warehouse.order-management.events | com.warehouse.wes.order-management.siteskudemand.SiteSkuDemandChanged | source_order_id, line_no, site_id, sku, demanded_units, due_at, state (ACTIVE or REMOVED) | upsert of demand_lines by (source_order_id, line_no), last writer wins; dropped when DEMAND_SITE_ID names another site |
product-master | warehouse.product-master.events | com.warehouse.wms.product-master.product.ProductClassified | sku, handling_tags, temperature_class, version | replaces the classification in product_profiles if version is newer |
product-master | same | com.warehouse.wms.product-master.product.ProductDimensionsDeclared, com.warehouse.wms.product-master.product.ProductMeasured | sku, effective.volume_mm3, effective.weight_g, effective_source, version | replaces the effective unit size if version is newer; effective_source = none clears it |
product-master | same | com.warehouse.wms.product-master.product.ProductPackLevelDeclared, ...ProductPackLevelRetired, ...ProductPackLevelMeasured | sku, level, gtin, and per type units_per_pack, dims{length_mm,width_mm,height_mm,weight_g}, effective_from (Declared); effective_to (Retired); dims (Measured); version | upsert of pack_levels, one row per (sku, level), guarded by version (ADR 0012); read by the case-pick faces. An undecodable payload is dead-lettered at once |
facility-layout | warehouse.facility.events | com.warehouse.wms.facility-layout.zone.ZoneRegistered | zoneId, siteCode, areaCode, zoneCode, temperatureClass, hazmat | upsert of zones |
facility-layout | same | com.warehouse.wms.facility-layout.locationslot.LocationSlotRegistered | locationCode, zoneId, role (empty means Storage), maxWeightKg, maxVolumeM3 | upsert of slots unless the slot was decommissioned |
facility-layout | same | com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissioned | locationCode | slots.active = false, for good |
inventory-storage (its ADR 0039) | warehouse.inventory.events | com.warehouse.wms.inventory-storage.stock.StockRelocated | relocation_id, site_code, sku, from_bin, to_bin, quantity, source_ref, occurred_at | matched to a plan's move (source_ref = <plan_id>:<move_seq> first, else site_code + sku + bins on the site's Approved plan) and recorded in slot_plan_move_executions once per relocation_id; unmatched relocations are counted, not stored (ADR 0010) |
Every other type on those topics (for example FacilityLayoutImported or
LocationGeometryUpdated on the facility topic, StockReserved on the
inventory topic) is ignored.
On the slot-plan path source_ref is fulfillment-execution's
relocation_ref (<plan_id>:<move_seq>, its ADR 0047), which
inventory-storage's RELOCATE branch stores as the relocation's source_ref
(it falls back to the task id when the producer sent none). move_seq is
the 0-based position of the move in SlotPlanApproved.moves, the order
wes-work-planning numbers the moves in (its ADR 0040).
Failure behaviour (inbound)
| Situation | Behaviour |
|---|---|
| Producer down or silent | nothing breaks; the copy goes stale and the next plan is computed from what it holds. Plans list unplaceable SKUs with a reason instead of guessing. |
| Broker down | the readers retry inside kafka-go; boot is not blocked. |
| Message is not CloudEvents 1.0, payload malformed, values invalid (demand, product, layout) | logged at WARN and committed past (never retried, never dead-lettered) |
StockRelocated whose data cannot be decoded or misses a required field | dead-lettered at once to warehouse.inventory.events.dlq (no retry) and committed past |
StockRelocated that matches no move (unknown plan or move, other site, or any relocation whose reason is not SLOTTING: manual, consolidation, replenishment) | claimed, logged at INFO and counted (slotting_optimization.relocations.observed{outcome="unmatched"}), never dead-lettered |
| Shutdown (context cancelled) mid-message | never dead-lettered: the offset stays uncommitted and the message is redelivered |
| Transient failure (Postgres) | same message retried with backoff, 5 attempts, then <topic>.dlq |
| Redelivery | processed_events claim makes it a no-op (outcome=duplicate) |
| Out-of-order product events | the version guard keeps the newest (outcome=stale) |
| Consumer behind or its broker down | the copy is whatever the database already holds; the consumers always run (*_MODE accepts only kafka, ADR 0011) and the process exits non-zero when one dies on its own |
Downstream
| Consumer | Protocol | Contract | State on develop |
|---|---|---|---|
any subscriber of warehouse.slotting-optimization.events | Kafka, CloudEvents 1.0 structured mode, key = plan id, optional W3C traceparent header of the writing request (ADR 0009) | com.warehouse.wms.slotting-optimization.slotplan.SlotPlanGenerated, ...SlotPlanApproved (full {sku, slot} map, the moves, supersedes_plan_id), ...SlotPlanRejected; dataschema urn:warehouse:slotting-optimization:events:<EventName>:v1 (Domain events) | wes-work-planning (below), inventory-storage (below) and pick-face-replenishment consume SlotPlanApproved; no sibling consumes SlotPlanGenerated or SlotPlanRejected |
inventory-storage | Kafka, Published Language / Conformist | SlotPlanApproved v1: the full assignments map replaces the site's forward-face read model, which ReserveStock reads to draw a SKU's forward pick face before its reserve bins (SlotPlanConsumer, internal/adapters/inbound/kafka/slot_plan_consumer.go on its origin/develop, its ADR 0050; its apis/asyncapi.yaml says the consumer always runs) | built there; this context's moves are ignored by it (RELOCATE work goes through wes-work-planning, above) |
pick-face-replenishment | Kafka, Published Language / Conformist | SlotPlanApproved v1: its forward-assignment map (ApplyForwardAssignmentMap, internal/adapters/inbound/kafka/slotting_consumer.go on its origin/develop) | live: built there and wired by warehouse-infra (helm-values/pick-face-replenishment.yaml, group pick-face-replenishment-slotting) |
cmd/slotting-projector (this repository) | Kafka warehouse.slotting-optimization.analytics, same CloudEvents ids as the integration topic | the three event types with byte-identical payloads, dataschema urn:warehouse:slotting-optimization:analytics:<EventName>:v1 (ADR 0006) | live: analytics.enabled: true in warehouse-infra's values; not an integration contract, no sibling reads it |
planners, web remote slotting_mfe | REST (Open Host Service), unauthenticated | apis/openapi.yaml: POST /slot-plans, GET /slot-plans, GET /slot-plans/{planId}, POST /slot-plans/{planId}/approvals, POST /slot-plans/{planId}/rejections, GET /forward-slots, GET /sku-velocity | API live behind Kong /api/slotting-optimization. The remote (web/) is built and registered by warehouse-console (route /slotting/*, container slotting_mfe, /mfes/slotting-optimization/), but warehouse-infra does not deploy it (no frontend_remote in terraform/apps.yaml, no frontend.enabled): wired-but-unused. CORS_ALLOWED_ORIGINS defaults to the console's dev origin http://localhost:5173. |
warehouse-console reports screen | REST GET /reports/slot-plan-funnel, GET /reports/freshness (snake_case) | apis/openapi.yaml (getSlotPlanFunnel, getReportsFreshness), served by cmd/slotting-reports | the console's "Slotting: Slot Plan Funnel" screen calls ${apiOrigin}/api/slotting-optimization/reports/...; this chart renders no Kong route to the reports Service, so in the kind cluster the call reaches cmd/api and is a 404. The reports binary itself is deployed (in-cluster Service slotting-optimization-reports:80). |
wes-work-planning -> fulfillment-execution -> inventory-storage | Kafka | SlotPlanApproved: one RELOCATE work unit per move, sequenced inside the plan (a move into a slot another move vacates waits for that vacate) and superseded by a newer plan's approval (not-yet-released work is cancelled); released on the RELOCATE process path (process-path-management ADR 0033, intake SLOT_RELOCATION, ADR 0034); executed as a fulfillment-execution RELOCATE task (its ADR 0047) whose TaskCompleted inventory-storage applies as RelocateStock (its ADR 0039) | built in those contexts (wes-work-planning ADR 0040); decided by ADR 0010, which supersedes ADR 0007. The resulting StockRelocated comes back upstream (above) as execution progress. |
warehouse-ops-agent and other MCP clients | MCP (Streamable HTTP) | read tools get_slot_plan (with execution, ADR 0010), list_slot_plans, get_forward_slots, get_sku_velocity | live: cmd/mcp (ADR 0005), unauthenticated, read-only, deployed by warehouse-infra (mcp.enabled: true, Kong /api/mcp/slotting-optimization). warehouse-ops-agent (its ADR 0024, internal/adapters/outbound/mcpclient/slotting_optimization.go) calls list_slot_plans and get_slot_plan for its slot-plan watch, at http://slotting-optimization-mcp.warehouse-systems.svc.cluster.local:8090/mcp (helm-values/warehouse-ops-agent.yaml); it does not call get_forward_slots or get_sku_velocity |
Failure behaviour (outbound)
The plan row and its outbox rows commit in one transaction, so a decision is
never lost and never published without being stored. A broker outage only
delays publication: the relay retries every OUTBOX_RELAY_INTERVAL, in id
order, with the original CloudEvents ids, and stops at the first failing
row so per-plan order holds. A row that fails OUTBOX_MAX_ATTEMPTS times
(default 20) is excluded and logged at ERROR so the rows behind it move on;
later events of the same plan then overtake it until an operator re-arms it
(ADR 0008). The relay always publishes to Kafka
(EVENT_PUBLISHER accepts only kafka): there is no log sink.
Explicit non-edges
- No command edge to
inventory-storage: this context never moves stock itself and does not change stow behaviour (ADR 0001). The stock moves of an approved plan are planned by wes-work-planning, executed by fulfillment-execution and recorded by inventory-storage; this context only reads the resultingStockRelocated(ADR 0010). The edge that does exist is an event edge: inventory-storage consumesSlotPlanApprovedfor its forward-face read model (row above). - Proposals are not gated on execution in v1: a new plan can be generated and approved while the previous one is half executed.
- No edge to
inbound-receivingorwarehouse-planning. - No request-time calls from this service: it calls no sibling. The only request-time callers are people (REST, the web remote), warehouse-ops-agent (MCP) and the console's reports screen.
Edge and infrastructure
warehouse-infra (origin/develop) deploys the chart with the api, the MCP
server and the analytics pair on. Kong :8000 routes
/api/slotting-optimization to the api and /api/mcp/slotting-optimization
to the MCP server; there is no route to the reports Service and the web
remote is not deployed. Details:
Runbook.