Skip to main content

Bounded context canvas

Synced from pick-face-replenishment

This page is a copy of docs/docs/ddd/bounded-context-canvas.md on develop, derived from that repository's code. Edit it there, then re-sync.

ddd-crew Bounded Context Canvas v5, filled from the code on develop and ADR 0001.

Canvas at a glance​

Source: internal/adapters/inbound/http/server.go, internal/adapters/inbound/kafka/*_consumer.go, internal/adapters/outbound/events/encoder.go, ADR 0001 canvas. Dashed boxes are edges with no consumer or caller yet. A solid box is built on develop; deployment state is on Integration.

Name​

pick-face-replenishment

Purpose​

Keep every forward pick face stocked between its minimum and maximum by requesting a move from the best reserve bin, and close the request when the ledger records the move.

Strategic classification​

Supporting subdomain, WMS tier (reasoning). Business model: cost reduction (no empty forward pick face, fewer short picks). Evolution: custom-built (genesis).

Domain roles​

  • Policy holder: owns the min/max rule per site and SKU.
  • Work generator: raises replenishment requests from levels, from a new forward map, from the sweep, or by hand.
  • Closer: completes a request from the ledger's StockRelocated.

Inbound communication​

MessageTypeSenderChannelCollaborator behaviour
PUT /policies/{siteId}/{sku}commandplanner, consoleRESTdeclare or change a policy (If-Match)
DELETE /policies/{siteId}/{sku}commandplannerRESTremove a policy, cancel its open requests
POST /replenishmentscommandplanner, agentRESTraise a request by hand (Idempotency-Key)
POST /replenishments/{requestId}/cancellationscommandplannerRESTcancel an open request (Idempotency-Key)
POST /sites/{siteId}/evaluationscommandplanner, agentRESTsweep a site (Idempotency-Key)
GET /policies, /policies/{siteId}/{sku}, /pick-faces, /replenishments, /replenishments/{requestId}queryplanner, console, agentRESTread
com.warehouse.wms.inventory-storage.stock.BinStockLevelChangedeventinventory-storageKafka warehouse.inventory.eventsabsolute bin level, versioned (inventory-storage ADR 0040)
com.warehouse.wms.inventory-storage.stock.StockRelocatedeventinventory-storageKafka warehouse.inventory.eventscompletes a request when reason is REPLENISHMENT (produced for a completed REPLENISH task, inventory-storage ADR 0041)
com.warehouse.wms.slotting-optimization.slotplan.SlotPlanApprovedeventslotting-optimizationKafka warehouse.slotting-optimization.eventsfull forward map
com.warehouse.wms.facility-layout.zone.ZoneRegisteredeventfacility-layoutKafka warehouse.facility.eventszone code per zone
com.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredeventfacility-layoutKafka warehouse.facility.eventslocation, its zone and role
com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedeventfacility-layoutKafka warehouse.facility.eventslocation retired

Outbound communication​

MessageTypeReceiverChannel
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentRequestedeventwes-work-planning (plans one REPLENISH work unit per request id; opt-in through REPLENISHMENT_MODE=kafka, its ADR 0042)Kafka warehouse.pick-face-replenishment.events and .analytics
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentCompletedeventanyone (wes-work-planning ignores it)Kafka ...events and ...analytics
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentCancelledeventwes-work-planning (withdraws its unit only while Pending) and anyoneKafka ...events and ...analytics
com.warehouse.wms.pick-face-replenishment.policy.ReplenishmentPolicyDeclaredeventanalyticsKafka ...analytics only
REST responsesquery resultsplanner, console, agentREST
<topic>.dlq dead letterseventoperatorsKafka

Ubiquitous language​

See the glossary. Key terms: pick face, forward bin, reserve bin, policy (min, max, multiple), request, projected level, priority, source bin policy, usable stock.

Business decisions​

  • A face is low when projected <= minQty, with projected = on_hand - reserved + open request quantity.
  • How much: up to maxQty, rounded down to a multiple, capped at the source's usable stock.
  • Which reserve bin: the one with the most usable stock, ties to the smallest bin code (fullest-reserve-bin-v1).
  • URGENT when nothing is available.
  • At most one open request per pick face.
  • When a request is cancelled: operator, a newer slot plan that drops the assignment, or policy removal.
  • A request completes only on a matching REPLENISHMENT relocation.

Assumptions​

  • Reserve bins are Storage locations in zones listed in RESERVE_ZONE_CODES (default RSV); forward faces are in FORWARD_ZONE_CODES (default FWD).
  • One SKU per forward slot; the forward bin of a SKU is its slot in the last approved slot plan.
  • A bin never seen reads as level 0 (ADR 0005).
  • The execution chain is built end to end on develop: wes-work-planning plans one REPLENISH work unit per ReplenishmentRequested (its ADR 0042; started only with REPLENISHMENT_MODE=kafka), process-path-management declares the REPLENISH path (its ADR 0036), fulfillment-execution runs the REPLENISH task (its ADR 0050) and inventory-storage records a relocation with reason REPLENISHMENT (its ADR 0041). In warehouse-infra the service is registered and wes-work-planning has REPLENISHMENT_MODE=kafka; cluster state was not checked.

Verification metrics​

Domain coverage gate 90 %; mutation efficacy and mutant coverage thresholds 90 % (measured 100 %); 57 BDD scenarios; golden bytes per published type; fitness tests (Testing). The service exports no runtime metrics (Observability).

Open questions​

  • Producer changes P1 (BinStockLevelChanged, inventory-storage ADR 0040), P3 and P3b (REPLENISH work in wes-work-planning, its ADR 0042, with the REPLENISH path in process-path-management ADR 0036) and P4 (reason REPLENISHMENT on StockRelocated, inventory-storage ADR 0041) are all built, and fulfillment-execution runs the REPLENISH task (its ADR 0050) (ADR 0001, 0003). What remains is operational: the wes-work-planning consumer is off unless REPLENISHMENT_MODE=kafka with REPLENISHMENT_CONSUMER_GROUP is set (the default permissive consumes nothing), the REPLENISH path has to be seeded with scripts/seed_catalogue.py (until then wes-work-planning dead-letters the requests), and warehouse-infra sets REPLENISHMENT_MODE=kafka (so the consumer is on there) but does not seed the path.
  • slotting-optimization's relocation consumer acts only on reason SLOTTING and counts every other reason, including REPLENISHMENT, as unmatched (internal/application/usecases/record_relocation.go), so the clash ADR 0003 records no longer exists.
  • No data retention exists for outbox_events, processed_events and idempotency_keys (Runbook).