Bounded context canvas
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.
Following the ddd-crew Bounded Context Canvas v5.
Every message row below maps to a route in NewRouter
(internal/adapters/inbound/http/process_capacity_handler.go), a tool in
internal/adapters/inbound/mcp/tools.go, or a topic and CloudEvents type in
internal/adapters/inbound/kafka/*_consumer.go /
internal/adapters/outbound/kafka/encoder.go.
Canvas at a glance
Two pictures of the sections below, laid out like the ddd-crew canvas:
first the inbound collaborators feeding this context (purpose, domain roles
and the business decisions it enforces), then the outbound collaborators it
calls or notifies. Arrows follow the message type: solid blue
commands (cmd), dotted green queries (qry), thick orange events
(evt); each arrow names its channel and the messages it carries. Box shapes
mark the collaborator kind: rounded = people, UI or any client; blue =
sibling bounded context; double border = external system or platform;
grey = this context's own projector, reports or dead-letter path; dashed =
published today with no consumer. Channel names on the arrows are
abbreviated (REST, MCP, Kafka, HTTP, port); the Inbound and Outbound
Communication tables carry the exact route, tool, topic and CloudEvents
type for every message.
Inbound
Outbound
Source: the Inbound Communication and Outbound Communication tables of this
page, which map to internal/adapters/inbound/{http,kafka,mcp} and internal/adapters/outbound/. The diagram omits assumptions, verification metrics, open
questions and the ubiquitous language (sections below), the relationship
pattern per message (OHS, ACL, Conformist, Customer/Supplier - see the
tables) and anything the tables mark as deprecated or platform-only
(health probes).
Name
Warehouse Planning (warehouse-planning, Go module
github.com/claudioed/warehouse-planning, GitHub IQVO/warehouse-planning).
Purpose
Answer can this warehouse process the demand assigned to it, given its
labor, location, equipment, station, conveyor and buffer constraints? It
holds the usable throughput of each process at each site and window
(ProcessCapacity), composes it at read time into a normalized end-to-end
path capacity, compares it with the demand assigned to a window in a
CapacityPlan, and announces shortages and bottlenecks as events. Since ADR
0022 and ADR 0023 it also owns the labour requirement: a copy of
labor-performance's engineered standards prices the labour each plan step
needs, and the WorkloadForecast and the shift LabourPlan (moved here from
wes-work-planning) state the heads a path needs per shift, published as
LabourPlanCommitted for workforce-management, which owns the supply. It does not
own labor scheduling or supply, the engineered standards, storage slotting,
stock, execution, or path capability and eligibility authoring (ADR 0001,
Consequences; ADR 0023).
Strategic Classification
| Axis | Verdict | Evidence |
|---|---|---|
| Domain | Core | ADR 0001; see the core domain chart |
| Business model | Risk reduction / engagement creator: it does not earn revenue itself; it protects promised delivery by detecting a capacity shortage before the window starts | CapacityShortageDetected is consumed by order-management |
| Evolution | Custom-built (recently out of genesis) | Created 2026-10-03, core rules changed by ADRs 0002, 0003 and 0004 |
Domain Roles
| Role | Applies? | Notes |
|---|---|---|
| Analysis context | Yes (primary) | Composes upstream facts into capacity, shortage and bottleneck; never executes work. |
| Specification context | Yes | Operators declare process paths, station standards and constraints that the computation uses. |
| Gateway / Open Host Service | Yes | REST, MCP and the warehouse.warehouse-planning.events Published Language. |
| Execution context | No | It never dispatches, routes or assigns work. |
| Analytics / reporting | Yes, inside the context | cmd/planning-projector and cmd/planning-reports over a separate analytical database (ADR 0005). |
Inbound Communication
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
workforce-management | ShiftPlanCommitted (one message per PathPlan line) | Event | Kafka warehouse.workforce.events, com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommitted | Upstream OHS + PL; this side is an ACL (labor_capacity_consumer.go): a LABOR constraint, and for a line with a shift_id the committed heads of the labour plan drift (ADR 0023) |
labor-performance | LaborStandardDefined, LaborStandardRevised | Event | Kafka warehouse.labor-performance.events, com.warehouse.wes.labor-performance.standard.* | Upstream OHS + PL; ACL (labor_standard_consumer.go, always on, ADR 0022) |
facility-layout | LocationSlotRegistered | Event | Kafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotRegistered | Upstream OHS + PL; ACL (storage_capacity_consumer.go) |
facility-layout | LocationSlotDecommissioned | Event | Kafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissioned | Upstream OHS + PL; ACL |
order-management | OrderAllocated | Event | Kafka warehouse.order-management.events, com.warehouse.wes.order-management.order.OrderAllocated | Upstream OHS + PL; ACL (order_demand_consumer.go, always on) |
order-management | OrderPartiallyAllocated | Event | Kafka warehouse.order-management.events, com.warehouse.wes.order-management.order.OrderPartiallyAllocated | Upstream OHS + PL; ACL (always on) |
Operator / warehouse-console remote | Register process capacity constraint | Command | REST POST /process-capacities; MCP register_process_capacity_constraint | This context is the OHS |
| Operator / remote | Get effective process capacity | Query | REST GET /process-capacities; MCP get_effective_process_capacity | OHS |
| Operator | Declare a process flow | Command | process-path-management PUT /process-flows/{flowId}; consumed here as the process_flows copy (ADR 0025; the local POST /process-paths answers 410 process-path-moved since stage 2) | ACL |
process-path-management | Record process flow | Command (event-fed) | Kafka ProcessFlowDefined/Revised/Retired on warehouse.process-path-management.events -> the process_flows copy, applied only when its version is greater (ADR 0025) | ACL |
warehouse-console remote | List process paths | Query | REST GET /process-paths (each item source: flow|local) and GET /process-paths/{id} | OHS |
Operator / remote / warehouse-ops-agent | Get process path capacity | Query | REST GET /process-paths/{id}/capacity; MCP get_process_path_capacity | OHS (the agent is a Customer of the MCP tool) |
| Operator / remote | Create capacity plan | Command | REST POST /capacity-plans; MCP create_capacity_plan | OHS |
| Operator / remote | Publish capacity plan | Command | REST POST /capacity-plans/{id}/publications; MCP publish_capacity_plan | OHS |
Operator / remote / warehouse-ops-agent | Get capacity plan | Query | REST GET /capacity-plans/{id}; MCP get_capacity_plan | OHS |
warehouse-console remote | List capacity plans | Query | REST GET /capacity-plans | OHS |
| Operator / remote | Compare plan scenarios | Query | REST GET /capacity-plans/comparisons?ids= (ADR 0024) | OHS |
| Operator / remote | Declare station standard | Command | REST PUT /station-standards/{location}/{process_type}; MCP declare_station_standard | OHS |
Operator / remote / warehouse-ops-agent | List station standards | Query | REST GET /station-standards; MCP list_station_standards | OHS |
Operator / remote / warehouse-ops-agent | Get storage capacity | Query | REST GET /storage-capacity; MCP get_storage_capacity | OHS |
| Operator / remote | Get expected demand | Query | REST GET /demand; MCP get_expected_demand | OHS |
Planner / e2e-tests warehouse-day simulation | Receive workload forecast | Command | REST PUT /workload-forecasts/{site_id}/{path_id} (no MCP tool, ADR 0023 decision 7) | OHS |
| Planner / simulation | Get workload forecast | Query | REST GET /workload-forecasts/{site_id}/{path_id} | OHS |
| Planner / simulation | Commit labour plan | Command | REST PUT /labour-plans/{site_id}/{shift_id}/{path_id} | OHS |
| Planner / simulation | Get / list labour plans | Query | REST GET /labour-plans/{site_id}/{shift_id}/{path_id}, GET /labour-plans?site_id=&shift_id= | OHS |
| Analyst / dashboard | Bottleneck frequency, shortage trend, plan throughput, freshness | Query | REST GET /reports/bottleneck-frequency, /reports/shortage-trend, /reports/plan-throughput, /reports/freshness on cmd/planning-reports | OHS (read-only) |
No REST or MCP endpoint is authenticated (fleet-wide revert of 2026-09-11).
Outbound Communication
The context makes no synchronous call to any sibling (ADR 0001). Everything
outbound leaves through the transactional outbox and the relay in cmd/api.
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
order-management | CapacityPlanCreated | Event | Kafka warehouse.warehouse-planning.events, com.warehouse.wes.warehouse-planning.capacityplan.CapacityPlanCreated | This context upstream, OHS + PL; order-management downstream with an ACL (its planned_capacity_consumer.go, opt-in) |
order-management, network-inventory-planning (its published_capacity_plan read model) | CapacityPlanPublished | Event | same topic, com.warehouse.wes.warehouse-planning.capacityplan.CapacityPlanPublished | OHS + PL |
order-management | CapacityShortageDetected | Event | same topic, com.warehouse.wes.warehouse-planning.capacityplan.CapacityShortageDetected | OHS + PL |
none today (order-management ignores it) | BottleneckDetected | Event | same topic, com.warehouse.wes.warehouse-planning.capacityplan.BottleneckDetected | OHS + PL |
workforce-management (its labour_requirements copy, ADR 0043) | LabourPlanCommitted | Event | same topic, com.warehouse.wes.warehouse-planning.labourplan.LabourPlanCommitted | OHS + PL; workforce-management downstream with an ACL |
| none today | WorkloadForecastReceived | Event | same topic, com.warehouse.wes.warehouse-planning.workloadforecast.WorkloadForecastReceived | OHS + PL |
| none today (surfaced to planners) | LabourPlanDriftDetected | Event | same topic, com.warehouse.wes.warehouse-planning.labourplan.LabourPlanDriftDetected | OHS + PL |
own cmd/planning-projector | the four plan types (projected) and the three requirement types (acknowledged, not projected) | Event | Kafka warehouse.warehouse-planning.analytics (dataschema ...:analytics:<EventName>:v1) | Internal to this context (ADR 0005) |
| operators (dead-letter triage) | a message that failed 5 times | Event (copy) | Kafka warehouse.workforce.events.dlq, warehouse.facility.events.dlq, warehouse.order-management.events.dlq, warehouse.labor-performance.events.dlq, warehouse.warehouse-planning.analytics.dlq | Internal operational channel |
Ubiquitous Language
Full glossary with code identifiers: Ubiquitous language. Top terms: ProcessCapacity, CapacityConstraint, CapacityRate, CapacityWindow (and covers), WorkloadProfile, ProcessPath, ProcessPathCapacity, StationStandard, Station count, Site / location, CapacityPlan, Shortage, Bottleneck, Expected demand, DemandSource, and on the requirement side Labour standard, Labour requirement, Workload forecast, Labour plan, Planned heads, Heads source, Committed heads, Labour plan drift.
Business Decisions
- A capacity number always carries a window, and a registered window applies to a planning window only when it covers it; per constraint type the newest window start wins (ADR 0003).
- Station capacity is
count x StationStandard, composed at read time and never stored; stations without a standard give a warning, never an invented throughput (ADR 0002). - Every candidate rate is normalized to ORDER per hour through the
WorkloadProfilebefore it is compared;LINEcannot be normalized and is rejected (ErrUnsupportedNormalizationUnit). - A
ProcessCapacityholds one native unit (ErrUnitMismatch). shortage = max(0, demand - capacity over window); demand equal to capacity is not a shortage, and the plan keeps the requested window.- A plan is published at most once (
ErrAlreadyPublished,409); shortage and bottleneck events are raised only at publish and only whenshortage > 0. Publishing supersedes the plan published before it for the same site, location, path and window (SUPERSEDED, terminal,CapacityPlanSuperseded, ADR 0024); a superseded plan cannot be published again (ErrSuperseded,409 capacity-plan-superseded). - An omitted
assigned_demanddefaults to the expected orders; zero orders is no data and rejects the plan (ErrMissingAssignedDemand), never a zero-demand plan (ADR 0004). - No live cross-context lookup, ever; stock from
inventory-storageis never read (ADR 0001). - A step's labour requirement is
tasks x standard seconds, from the labor-performance copy resolved at the window start; no standard or no task factor is unknown, never a guessed number (ADR 0022). planned_heads <= installed_stations; omitted heads areceil(forecast units due in the shift / (rate x hours)), and zero forecast buckets in the shift is no data (422 missing-planned-heads), never zero heads (ADR 0023).- A
PUTthat changes nothing raises nothing; the labour plan drift is raised only when non-zero and new, and never corrects the plan or the commitment (ADR 0023 decision 3).
Assumptions
- The labor window is
[event time, event time + planned_hours): no upstream field carries a shift start (ADR 0001 Addendum). planned_rateis in units per hour (laborRateUnit = UnitUnit), a documented default.- Site = building id = the first dash-separated segment of a facility zone id.
- An order is attributed to the site its event names (
site_id, order-management ADR 0050), or to the fallback siteDEMAND_SITE_IDwhen it names none (ADR 0021). Task completions carry no site and always use it. - The WorkloadProfile factors are supplied on each request (no persistence).
- The labour plan drift matches site and shift exactly as sent on both sides (the path code is canonical, trimmed and upper case), and relies on the per-key order of workforce-management's topic (no stale-event guard on the event time).
Verification Metrics
- Golden exact-JSON tests per published type on both topics
(
encoder_test.go,analytics_encoder_test.go). make mutation-fast(gremlins) is blocking in CI onprocesscapacity,capacityplanandprocesspath; coverage gate 90% on domain + application.- Outbox atomicity and redelivery proven with testcontainers Postgres and
Kafka (
capacity_plan_outbox_integration_test.go,relay_integration_test.go,atomic_consumers_integration_test.go). - Business: the Tier-2 counter
warehouse_planning.capacity_plans.createdwith an outcome attribute (ADR 0011); theGET /reports/freshnesslag of the analytical projection.
Open Questions
- When will
workforce-managementpublish a real shift start and an explicit unit forplanned_rate? - Should the
WorkloadProfilebe persisted per warehouse instead of travelling on every request? - How should demand be attributed to sites once order-management events carry a fulfillment site, and should cancellations be netted?
- Observed-capacity feedback from
fulfillment-execution/wes-work-planningand demand fromnetwork-fulfillmentare anticipated by ADR 0001 but have no code yet.