Skip to main content

Bounded context canvas

Synced from warehouse-planning

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​

AxisVerdictEvidence
DomainCoreADR 0001; see the core domain chart
Business modelRisk reduction / engagement creator: it does not earn revenue itself; it protects promised delivery by detecting a capacity shortage before the window startsCapacityShortageDetected is consumed by order-management
EvolutionCustom-built (recently out of genesis)Created 2026-10-03, core rules changed by ADRs 0002, 0003 and 0004

Domain Roles​

RoleApplies?Notes
Analysis contextYes (primary)Composes upstream facts into capacity, shortage and bottleneck; never executes work.
Specification contextYesOperators declare process paths, station standards and constraints that the computation uses.
Gateway / Open Host ServiceYesREST, MCP and the warehouse.warehouse-planning.events Published Language.
Execution contextNoIt never dispatches, routes or assigns work.
Analytics / reportingYes, inside the contextcmd/planning-projector and cmd/planning-reports over a separate analytical database (ADR 0005).

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
workforce-managementShiftPlanCommitted (one message per PathPlan line)EventKafka warehouse.workforce.events, com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommittedUpstream 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-performanceLaborStandardDefined, LaborStandardRevisedEventKafka warehouse.labor-performance.events, com.warehouse.wes.labor-performance.standard.*Upstream OHS + PL; ACL (labor_standard_consumer.go, always on, ADR 0022)
facility-layoutLocationSlotRegisteredEventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredUpstream OHS + PL; ACL (storage_capacity_consumer.go)
facility-layoutLocationSlotDecommissionedEventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedUpstream OHS + PL; ACL
order-managementOrderAllocatedEventKafka warehouse.order-management.events, com.warehouse.wes.order-management.order.OrderAllocatedUpstream OHS + PL; ACL (order_demand_consumer.go, always on)
order-managementOrderPartiallyAllocatedEventKafka warehouse.order-management.events, com.warehouse.wes.order-management.order.OrderPartiallyAllocatedUpstream OHS + PL; ACL (always on)
Operator / warehouse-console remoteRegister process capacity constraintCommandREST POST /process-capacities; MCP register_process_capacity_constraintThis context is the OHS
Operator / remoteGet effective process capacityQueryREST GET /process-capacities; MCP get_effective_process_capacityOHS
OperatorDeclare a process flowCommandprocess-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-managementRecord process flowCommand (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 remoteList process pathsQueryREST GET /process-paths (each item source: flow|local) and GET /process-paths/{id}OHS
Operator / remote / warehouse-ops-agentGet process path capacityQueryREST GET /process-paths/{id}/capacity; MCP get_process_path_capacityOHS (the agent is a Customer of the MCP tool)
Operator / remoteCreate capacity planCommandREST POST /capacity-plans; MCP create_capacity_planOHS
Operator / remotePublish capacity planCommandREST POST /capacity-plans/{id}/publications; MCP publish_capacity_planOHS
Operator / remote / warehouse-ops-agentGet capacity planQueryREST GET /capacity-plans/{id}; MCP get_capacity_planOHS
warehouse-console remoteList capacity plansQueryREST GET /capacity-plansOHS
Operator / remoteCompare plan scenariosQueryREST GET /capacity-plans/comparisons?ids= (ADR 0024)OHS
Operator / remoteDeclare station standardCommandREST PUT /station-standards/{location}/{process_type}; MCP declare_station_standardOHS
Operator / remote / warehouse-ops-agentList station standardsQueryREST GET /station-standards; MCP list_station_standardsOHS
Operator / remote / warehouse-ops-agentGet storage capacityQueryREST GET /storage-capacity; MCP get_storage_capacityOHS
Operator / remoteGet expected demandQueryREST GET /demand; MCP get_expected_demandOHS
Planner / e2e-tests warehouse-day simulationReceive workload forecastCommandREST PUT /workload-forecasts/{site_id}/{path_id} (no MCP tool, ADR 0023 decision 7)OHS
Planner / simulationGet workload forecastQueryREST GET /workload-forecasts/{site_id}/{path_id}OHS
Planner / simulationCommit labour planCommandREST PUT /labour-plans/{site_id}/{shift_id}/{path_id}OHS
Planner / simulationGet / list labour plansQueryREST GET /labour-plans/{site_id}/{shift_id}/{path_id}, GET /labour-plans?site_id=&shift_id=OHS
Analyst / dashboardBottleneck frequency, shortage trend, plan throughput, freshnessQueryREST GET /reports/bottleneck-frequency, /reports/shortage-trend, /reports/plan-throughput, /reports/freshness on cmd/planning-reportsOHS (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.

CollaboratorMessageTypeChannelRelationship
order-managementCapacityPlanCreatedEventKafka warehouse.warehouse-planning.events, com.warehouse.wes.warehouse-planning.capacityplan.CapacityPlanCreatedThis 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)CapacityPlanPublishedEventsame topic, com.warehouse.wes.warehouse-planning.capacityplan.CapacityPlanPublishedOHS + PL
order-managementCapacityShortageDetectedEventsame topic, com.warehouse.wes.warehouse-planning.capacityplan.CapacityShortageDetectedOHS + PL
none today (order-management ignores it)BottleneckDetectedEventsame topic, com.warehouse.wes.warehouse-planning.capacityplan.BottleneckDetectedOHS + PL
workforce-management (its labour_requirements copy, ADR 0043)LabourPlanCommittedEventsame topic, com.warehouse.wes.warehouse-planning.labourplan.LabourPlanCommittedOHS + PL; workforce-management downstream with an ACL
none todayWorkloadForecastReceivedEventsame topic, com.warehouse.wes.warehouse-planning.workloadforecast.WorkloadForecastReceivedOHS + PL
none today (surfaced to planners)LabourPlanDriftDetectedEventsame topic, com.warehouse.wes.warehouse-planning.labourplan.LabourPlanDriftDetectedOHS + PL
own cmd/planning-projectorthe four plan types (projected) and the three requirement types (acknowledged, not projected)EventKafka warehouse.warehouse-planning.analytics (dataschema ...:analytics:<EventName>:v1)Internal to this context (ADR 0005)
operators (dead-letter triage)a message that failed 5 timesEvent (copy)Kafka warehouse.workforce.events.dlq, warehouse.facility.events.dlq, warehouse.order-management.events.dlq, warehouse.labor-performance.events.dlq, warehouse.warehouse-planning.analytics.dlqInternal 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​

  1. 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).
  2. 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).
  3. Every candidate rate is normalized to ORDER per hour through the WorkloadProfile before it is compared; LINE cannot be normalized and is rejected (ErrUnsupportedNormalizationUnit).
  4. A ProcessCapacity holds one native unit (ErrUnitMismatch).
  5. shortage = max(0, demand - capacity over window); demand equal to capacity is not a shortage, and the plan keeps the requested window.
  6. A plan is published at most once (ErrAlreadyPublished, 409); shortage and bottleneck events are raised only at publish and only when shortage > 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).
  7. An omitted assigned_demand defaults to the expected orders; zero orders is no data and rejects the plan (ErrMissingAssignedDemand), never a zero-demand plan (ADR 0004).
  8. No live cross-context lookup, ever; stock from inventory-storage is never read (ADR 0001).
  9. 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).
  10. planned_heads <= installed_stations; omitted heads are ceil(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).
  11. A PUT that 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_rate is 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 site DEMAND_SITE_ID when 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 on processcapacity, capacityplan and processpath; 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.created with an outcome attribute (ADR 0011); the GET /reports/freshness lag of the analytical projection.

Open Questions​

  • When will workforce-management publish a real shift start and an explicit unit for planned_rate?
  • Should the WorkloadProfile be 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-planning and demand from network-fulfillment are anticipated by ADR 0001 but have no code yet.