ADR 0001: warehouse-planning as a new Core bounded context
Status
Amended (2026-11-18): labour standards are consumed from labor-performance by ADR 0022, and the Separate Ways handling of process-path-management in the Addendum is superseded by ADR 0025 once it is implemented.
Accepted (2026-10-03). Amended (2026-10-03) — see Addendum. The Addendum's handling of facility-layout storage/station tallies as capacity constraints is superseded by ADR 0002. The labour consumer's site attribution (building_id) is amended by ADR 0021: it reads site_code first.
Context
The fleet's bounded contexts (inventory-storage, facility-layout,
workforce-management, process-path-management, fulfillment-execution,
wes-work-planning, order-management, network-fulfillment,
labor-performance) each know a piece of what constrains warehouse
throughput — labor, storage, path topology, execution-time flow — but none
of them answers "can this warehouse process the demand assigned to it."
workforce-management explicitly stops at the path boundary. A DDD
reference study of Warehouse Capacity Planning
(/Users/claudioed/.hermes/plans/2026-10-03_185721-warehouse-planning-bc-plan.md
on the maintainer's machine) identified this as a genuine missing
bounded context, not something to bolt onto an existing service.
Decision
Introduce warehouse-planning as a new Core Domain bounded context,
sitting in the wes tier of the fleet's CloudEvents subdomain taxonomy
(wms is reserved for facility-layout/inventory-storage only — see
warehouse-systems-fleet-ops skill's subdomain table).
Context map (Customer/Supplier unless noted)
| Relationship | Direction | Pattern |
|---|---|---|
process-path-management -> warehouse-planning | path_id identity + required_capabilities only (see Addendum — NOT a step sequence) | Conformist on identity, never forks the upstream structure |
workforce-management -> warehouse-planning | available labor-hours per pool/window | Published Language via Kafka |
facility-layout -> warehouse-planning | location/zone structural capacity | Published Language via Kafka |
fulfillment-execution / wes-work-planning -> warehouse-planning | observed/current effective capacity (feedback, later phase) | Published Language via Kafka |
order-management / network-fulfillment -> warehouse-planning | assigned demand for a planning window | Published Language via Kafka (final shape to be confirmed before the demand-ingestion phase) |
warehouse-planning -> order-management | CapacityPlanPublished / CapacityShortageDetected | Published Language, consumed by order-management in a later, separate change |
warehouse-planning -> warehouse-ops-agent, warehouse-console | read-only capacity queries | Open Host Service via REST/MCP |
Explicitly excluded: inventory-storage stock levels are never
consumed directly. Storage capacity comes from facility-layout
structural data, never from inventory quantities (stock is not capacity).
No live cross-context lookup
warehouse-planning never makes a synchronous REST/MCP call to a sibling
bounded context to answer a capacity question. All cross-context facts
used in a capacity computation are ingested as published CloudEvents and
kept as local, declarative read models. This generalizes the rule already
adopted by process-path-management and labor-performance: a capacity
decision must stay available and fast even when an upstream context is
degraded or unreachable.
Consequences
- This context owns
ProcessCapacity,CapacityPlanandProcessPath(the physical process-step sequence — see Addendum, this is now a LOCALLY OWNED declaration, not a Conformist copy) — it does not own labor scheduling, storage slotting, or path capability/eligibility authoring, all of which remain in their existing contexts. order-managementneeds a follow-up change (separate PR, separate repo) to actually consumeCapacityPlanPublished/CapacityShortageDetected— out of scope for this repo's own delivery.
Addendum (2026-10-03): upstream event contract spike (Task 0.4)
Before building Phase 3's event consumers, the exact upstream contracts
were read from each producer's own apis/asyncapi.yaml on
origin/develop rather than guessed. Two findings changed the original
Decision:
1. process-path-management does not publish a process-step sequence
Its ProcessPath aggregate (ProcessPathCreated/Updated/Deactivated
on warehouse.process-path-management.events,
com.warehouse.wes.process-path-management.processpath.<EventName>)
carries path_id, match_prefix, direct, required_capabilities,
destination_location_role, cycle_time_p95, eligibility — routing and
capability-matching metadata, never an ordered list of physical process
steps (Pick -> Rebin -> Pack). There is nowhere else in the fleet that
publishes that sequence either.
Correction: warehouse-planning's ProcessPath (the ordered
[]ProcessType used by ComputeProcessPathCapacity) is a locally
owned, operator-declared concept (via POST /process-paths, already
shipped in Phase 2), not a Conformist copy of
process-path-management's aggregate. The two contexts share the same
path_id string as a loose cross-reference (so a human/operator can line
up "PICK the capability-routing path" with "PICK the physical step" by
eye), but warehouse-planning never consumes
process-path-management's Kafka events to populate its own ProcessPath
steps. Phase 3 therefore does NOT include a process-path-management
consumer.
2. Confirmed consumed-event shapes for Phase 3
- Labor:
workforce-managementpublishescom.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommittedonwarehouse.workforce.events. Fan-out: one message perPathPlanline within a committedShiftPlan.data:building_id,shift_id,path_id,planned_heads,planned_rate,planned_hours. No explicit window start/end is carried — Phase 3 derives theCapacityWindowas[event time, event time + planned_hours], a documented assumption to revisit ifworkforce-managementlater exposes a real shift-start timestamp distinct from the event's owntime. LABOR constraint rate =planned_heads * planned_ratein whatever native unitplanned_rateis in for thatpath_id(units/hour per the fleet's established convention). - Storage/Station:
facility-layouthas no dedicated capacity event.LocationSlotRegistered/LocationSlotDecommissionedonwarehouse.facility.events(com.warehouse.wms.facility-layout.locationslot.<EventName>) carrylocationCode,zoneId,locationType,role(defaultStorage), and — only whenrole=WorkCenter— anactivitiesarray (Pack,Sort,QC,VAS,Deconsolidate,Receive,Kit). Phase 3 tallies these itself, mirroring inventory-storage's existing location-classification cache pattern: a STABLE, SHARED consumer group (StorageCapacityConsumer'sSTORAGE_CAPACITY_CONSUMER_GROUP) with an atomicprocessed_eventsclaim per message — NOT a per-process-unique consumer group withFirstOffsetreplay. (Verified against the shipped code,internal/adapters/inbound/kafka/storage_capacity_consumer.go: the code was already correct; only this paragraph's description of it was stale, corrected 2026-10-05.) This is the same at-least-once, idempotent-claim shapeLaborCapacityConsumerandOrderDemandConsumeruse (docs/adr/0007), not the separate per-process full-replay-cache pattern used elsewhere in the fleet for a different correctness need.role=Storageslots, counted per(zoneId, locationType), feed a LOCATIONCapacityConstraint(position count as a capacity proxy).role=WorkCenterslots whoseactivitiesincludes a given process name, counted per zone, feed a STATIONCapacityConstraintfor that process (the doc's "10 packing stations" concept).LocationSlotDecommissioneddecrements the same tally.
Forward links
- ADR 0004 resolves this
ADR's "final shape to be confirmed before the demand-ingestion phase" open
question (context-map row above): demand is ingested from
order-management'sOrderAllocated/OrderPartiallyAllocatedevents into a local read model, andassigned_demandis now optional onPOST /capacity-plans.
Addendum 2026-11-13: current state
The "later, separate change" in the context map and the last Consequences bullet above has landed: order-management consumes warehouse.warehouse-planning.events in its internal/adapters/inbound/kafka/planned_capacity_consumer.go (order-management ADR 0031), under PLANNED_CAPACITY_CONSUMER_GROUP (cmd/order/planned_capacity.go:29; the consumer is built only when that variable is set, :45).
It acts on CapacityPlanCreated (stored as a draft) and on CapacityPlanPublished and CapacityShortageDetected (stored as published); BottleneckDetected and every other type are ignored (planned_capacity_consumer.go:196-203).