Business Context
Written here from the context's own
introduction,
its integration page
and its ADRs under docs/adr/ in
IQVO/pick-face-replenishment
(0001 to 0005, all Accepted 2026-10-17), checked against the code on
develop. Where the code has moved past an ADR's wording, the code is
authoritative.
The gap
slotting-optimization decides which SKU holds which forward pick slot and
inventory-storage owns the stock ledger and can relocate stock between bins.
Nothing in the fleet watched whether a forward pick face still held enough of
its SKU, and nothing asked for stock to be moved from a reserve bin when it ran
low. Slotting's own pages listed REPLENISH (min/max) work as planned, not
built. Without that, a picker finds an empty face and the problem is solved by
hand.
Replenishment is a stock-level-driven work generator: it reacts to levels,
holds a policy per pick face, and ends when the ledger records the move. That
lifecycle differs from slotting (which plans slots and never watches levels)
and from fulfillment-execution (which owns task state and must stay the
single writer of it), so it is a context of its own (ADR 0001).
What it owns
| Fact | Value |
|---|---|
| Subdomain class | Supporting (ADR 0001) |
| Tier | WMS (CloudEvents subdomain segment wms, the sixth wms context) |
| Aggregates | ReplenishmentPolicy (package internal/domain/policy) and ReplenishmentRequest (package internal/domain/replenishment), ADR 0002 |
| Detector | the pure function Detect in internal/domain/detection, with the SourceBinPolicy port (v1: fullest-reserve-bin-v1) |
| Binaries | four: cmd/api (REST on HTTP_ADDR, default :8080, plus four Kafka consumers and the outbox relay as goroutines), cmd/mcp (read-only MCP server, ADR 0007), cmd/pfr-projector and cmd/pfr-reports (the analytics read side, ADR 0008) |
| Data store | one Postgres database (embedded migrations). DATABASE_URL and KAFKA_BROKERS are mandatory (a boot error naming the variable); the in-memory adapters are test doubles only (its ADR 0006) |
| Kafka | publishes warehouse.pick-face-replenishment.events and warehouse.pick-face-replenishment.analytics; consumes warehouse.inventory.events, warehouse.slotting-optimization.events, warehouse.facility.events and warehouse.product-master.events (pack levels, ADR 0009) (ADR 0003, ADR 0004) |
| Auth | none (fleet-wide decision) |
- The policy. The explicit
MIN_MAXrule of one (site, SKU):minQty,maxQty,multipleand aversion. Invariants:0 <= minQty < maxQty,multiple >= 1. Declared withPUT /policies/{siteId}/{sku}underIf-Matchoptimistic concurrency and removed withDELETE. Declaring publishes the analytics-only factReplenishmentPolicyDeclared. - The request. One decision to move
quantityunits of a SKU from one reserve bin to one forward bin:Requested, thenCompletedorCancelled(both terminal). At most one is open per (site, forward bin, SKU). Its priority isURGENTwhen the face had nothing available at detection (on_hand - reserved <= 0), elseNORMAL. - The detection. From a pick face, its policy, its open request and the
candidate reserve bins, one of five verdicts:
NoPolicy,AlreadyOpen,Healthy(projected level above the minimum),NoSource(no reserve bin with usable stock, or a quantity below one multiple) andRaise. - The completion. Only
inventory-storage'sStockRelocatedwith reasonREPLENISHMENTandsource_refequal to the request id closes a request; the quantity actually moved is recorded and can be less than requested.
The v1 policy
Deterministic and explainable (ADR 0002; see the Ubiquitous Language):
- Available =
on_hand - reserved. Projected = available plus the quantity of the face's open request, if any. - Healthy while projected is above
minQty. At or below it, the need ismaxQty - projected, rounded down to amultipleso a request never overfills the face. A need below one multiple raises nothing. - Source bin (
fullest-reserve-bin-v1): among the reserve bins of the site other than the forward bin, with usable stock of at least 1, the one with the largest usable stock; ties go to the lexically smallest bin code. A reserve bin is aStoragelocation in a zone listed inRESERVE_ZONE_CODES(defaultRSV). A forward assignment whose bin is in a known zone outsideFORWARD_ZONE_CODES(defaultFWD) is not a pick face. - Quantity is capped at the source's usable stock and rounded down again, so a partial fill is possible. The next detection raises another request once the first closes.
A demand-cover policy (days of cover from SiteSkuDemandChanged) is a planned
later version behind the same port. It does not exist today.
Main capabilities
| Capability | Interface | Use case |
|---|---|---|
| Declare, read, list and remove a min/max policy | PUT/GET/DELETE /policies/{siteId}/{sku}, GET /policies | see Use Cases |
See every pick face with its status (BELOW_MIN, OK, NO_SOURCE, NO_POLICY) | GET /pick-faces | ListPickFaces |
| Raise requests by sweep | POST /sites/{siteId}/evaluations | EvaluateSite |
| Raise a request by hand | POST /replenishments | RaiseManualRequest |
| Read requests | GET /replenishments, GET /replenishments/{requestId} | GetRequest, ListRequests |
| Cancel a request | POST /replenishments/{requestId}/cancellations | CancelRequest |
| Raise requests as bin levels or the forward map change | Kafka consumers (always on; INVENTORY_MODE, SLOTTING_MODE and LAYOUT_MODE default to kafka) | ApplyBinLevel, ApplyRelocation, ApplyForwardAssignmentMap, ApplyZone, ApplyLocationRegistered, ApplyLocationDecommissioned |
| Publish requests and their outcome | transactional outbox + relay (always on; both are mandatory) | every write use case |
The write endpoints require an Idempotency-Key in every deployment (enforced with Postgres).
The full catalogue is on Use Cases.
What it deliberately does not do
- Own stock levels, slot assignments or locations. It keeps event-fed local
copies (
bin_stock_levels,forward_assignments,zones,locations) and never calls a sibling at request time. It makes no outbound HTTP or MCP call at all. - Create floor work. It publishes
ReplenishmentRequested;wes-work-planningandfulfillment-executionown work and task state. A cancel withdraws the planned unit only whilewes-work-planningstill holds it Pending (its ADR 0042); a request already released as floor work is not recalled. - Write the stock ledger. It requests a move;
inventory-storagerecords it. - Guess. With no level, no assignment, no reserve location copy or no
policy, the detector reports
NO_SOURCEorNO_POLICYinstead of raising. - Schedule. Nothing re-evaluates a site periodically; requests are raised when a bin level or a new forward map is applied, by the sweep, or by hand.
- Out of scope for v1: velocity-derived min/max, multi-SKU faces, reserve-to-reserve consolidation, travel-aware source choice.
It has no edge to inbound-receiving, order-management or product-master
(ADR 0001).
Honest scope today
- The service is built on
IQVO/pick-face-replenishmentdevelop: REST API, outbox and relay, the four consumers, the read-only MCP server, the analytics projector and reports, the console remote and the BDD and architecture fitness suites. This site holds itsapis/pick-face-replenishment/specs, the generated references and the synced artifact pack and operations pages. - It is wired in
warehouse-infradevelop:terraform/apps.yamlregisters it (database, analytics database, web remotereplenishment_mfe) andhelm-values/pick-face-replenishment.yamlsets every consumer group. Its Kong URL ishttp://localhost:8000/api/pick-face-replenishment. The kind cluster was not checked for this page. - The execution chain is complete on
developand wired. The inputs fromslotting-optimization,facility-layout,inventory-storageandproduct-masterare published by producers ondevelop(inventory-storagepublishesBinStockLevelChangedand records a completedREPLENISHtask as aStockRelocatedwith reasonREPLENISHMENT, its ADR 0040 and ADR 0041). The output side exists as well:wes-work-planningconsumesReplenishmentRequestedandReplenishmentCancelledand plans oneREPLENISHwork unit per request (its ADR 0042),process-path-managementdeclares theREPLENISHpath (its ADR 0036) andfulfillment-executionrunsREPLENISHtasks (its ADR 0050). Both consumed contracts were pinned consumer-first (ADR 0003) and the producers now match them (field names equal, key<bin>:<sku>).warehouse-infrasetsREPLENISHMENT_MODE=kafkafor the planner. TheREPLENISHpath exists on a cluster only after the catalogue seed (an operator step), and no request has been traced through every hop on a cluster. - The analytics topic is read only by this context's own projector. A
demand-cover policy behind the
MIN_MAXport is a later phase.