Bounded context canvas
A ddd-crew Bounded Context Canvas
(v5). Every message row maps to a real route in
internal/adapters/inbound/http/router.go, a real MCP tool in
internal/adapters/inbound/mcp/, or a real Kafka topic and CloudEvents type
in internal/adapters/kafka/cloudevents/cloudevents.go and
internal/adapters/outbound/kafka/publisher.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
Work Planning & Release — repository wes-work-planning, Go module
github.com/claudioed/wes-work-planning, CloudEvents source
/warehouse/wes-work-planning, type prefix com.warehouse.wes.work-planning.
The core of the WES tier: the conductor.
Purpose
Turn demand and stock reality into continuously released, priority-ordered work on each process path, and keep every path's buffer healthy while the shift runs. In one loop: release (earliest CPT first, WIP-limited) → observe (completions, backlog telemetry) → correct (throttle upstream or reassign labour). Planning the shift (charge forecast, committed labour plan) is warehouse-planning's (ADR-0049).
It does not plan the shift (warehouse-planning), pick, pack or ship (fulfillment-execution), own stock (inventory-storage), staff people (workforce-management) or own the process-path catalogue (process-path-management).
Strategic Classification
| Dimension | Value |
|---|---|
| Domain | Core — see Subdomain classification and the Core domain chart |
| Business model | Cost reduction / throughput — making every CPT with less labour and less WIP; not directly revenue-generating, not compliance |
| Evolution | Custom-built — release policy, WIP backpressure and flow balancing are written and tuned here |
Domain Roles
| Role (ddd-crew archetype) | How it shows up |
|---|---|
| Execution | Admits work one unit at a time (ReleaseNextWork) and tracks it to completion. |
| Enforcer | Enforces the WIP limit on release-fed pools. |
| Analysis | Backlog telemetry, rebalance recommendations, remaining-capacity signals. |
Inbound Communication
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
| Any upstream caller | EnqueueWorkUnit | Command | REST POST /paths/{pathId}/work-units (Idempotency-Key required with Postgres) | OHS |
| Supervisor / agent | ReleaseNextWork | Command | REST POST /paths/{pathId}/work-releases; MCP tool release_next_work | OHS |
| Operator | ConfigurePool | Command | REST PUT /paths/{pathId}/pool (no MCP tool; ADR-0034) | OHS |
| Station / supervisor | RecordCompletion | Command | REST POST /work-units/{id}/completions | OHS |
| Supervisor / warehouse-ops-agent | SampleBacklog | Query (may emit events) | REST GET /paths/{pathId}/telemetry?cutoffAt=; MCP tool get_backlog_telemetry; MCP resource telemetry://{pathId}/backlog | OHS |
| Supervisor / warehouse-ops-agent | RebalanceDecision | Command (computes a decision, emits events) | REST POST /paths/{pathId}/rebalance-decisions (keyed); MCP tool get_rebalance_recommendation | OHS |
| warehouse-ops-agent and UI | GetWorkUnitsByReference, GetWorkUnit | Query | REST GET /work-units?reference=, GET /work-units/{id} | OHS |
| UI | LaborPlanView, InventoryView | Query | REST GET /paths/{pathId}/labor-plan-view, GET /inventory-view/{sku} | OHS |
| warehouse-ops-agent | Release throughput report | Query | REST GET /reports/throughput, GET /reports/throughput/freshness (cmd/wes-reports); MCP tool get_release_throughput_report when REPORTS_BASE_URL is set | OHS |
| workforce-management | ShiftPlanCommitted | Event | Kafka warehouse.workforce.events, com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommitted | Customer/Supplier, we conform behind an ACL |
| inventory-storage | StockReserved, ReservationRevoked | Event | Kafka warehouse.inventory.events, com.warehouse.wms.inventory-storage.reservation.StockReserved / ...ReservationRevoked | Customer/Supplier, ACL |
| fulfillment-execution | TaskCompleted | Event | Kafka warehouse.fulfillment.events, com.warehouse.wes.fulfillment-execution.task.TaskCompleted | Customer/Supplier (feedback edge), ACL |
| order-management | OrderAllocated, OrderPartiallyAllocated | Event | Kafka warehouse.order-management.events, com.warehouse.wes.order-management.order.OrderAllocated / ...OrderPartiallyAllocated | Customer/Supplier, ACL (ADR-0031) |
| process-path-management | ProcessPathCreated, ProcessPathUpdated, ProcessPathDeactivated | Event | Kafka warehouse.process-path-management.events, com.warehouse.wes.process-path-management.processpath.* (only with PATH_CATALOGUE_SOURCE=kafka) | Conformist (ADR-0030) |
| product-master | ProductClassified | Event | Kafka warehouse.product-master.events, com.warehouse.wms.product-master.product.ProductClassified (only with PRODUCT_CLASSIFICATION_MODE=kafka; own group PRODUCT_CLASSIFICATION_CONSUMER_GROUP) | Published Language into a local, version-guarded copy read at release (ADR-0035) |
| product-master | ProductPackLevelDeclared, ProductPackLevelRetired, ProductPackLevelMeasured | Event | Kafka warehouse.product-master.events, com.warehouse.wms.product-master.product.ProductPackLevelDeclared / ...ProductPackLevelRetired / ...ProductPackLevelMeasured (always on; own group PACK_VIEW_CONSUMER_GROUP) | Published Language into a local, version-guarded pack-level copy keyed by GTIN (ADR-0045) |
| network-inventory-planning | WorkDemandReleased (one transfer leg: pick, then dispatch) | Command | Kafka warehouse.network-inventory-planning.events, com.warehouse.wes.network-inventory-planning.workdemand.WorkDemandReleased → ApplyWorkDemandReleased enqueues one transfer-referenced work unit (ADR-0033) | Conformist to NIP's Published Language, ACL |
Outbound Communication
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
| fulfillment-execution | WorkReleased | Event | Kafka warehouse.work-planning.events, com.warehouse.wes.work-planning.workunit.WorkReleased | OHS + Published Language (we supply) |
| order-management | PathCapacityChanged | Event | Kafka warehouse.work-planning.events, com.warehouse.wes.work-planning.workpool.PathCapacityChanged | OHS + PL (ADR-0018) |
| network-fulfillment | PathCapacityChanged | Event | same topic and type | OHS + PL; network-fulfillment is Conformist |
| (no consumer today) | WorkUnitCreated, WorkUnitCompleted, BacklogThresholdBreached, RateDeviationDetected (reserved, not emitted; decided 2026-10-06), PathThrottled, LaborReassignmentFlagged | Event | Kafka warehouse.work-planning.events, com.warehouse.wes.work-planning.<entity>.<Event> | Published for observability |
own analytics projector (cmd/wes-projector) | all 8 domain events | Event | Kafka warehouse.wes.analytics, same CloudEvents types, dataschema urn:warehouse:wes-work-planning:analytics:<Event>:v1 | Internal data product (ADR-0011) |
ChargeForecastReceived, plan.ShiftPlanCommitted and PathPlanDriftDetected
are retired, and the facility-layout travel-distance query is gone
(ADR-0049).
The planner calls warehouse-planning's PUT /workload-forecasts/{site_id}/{path_id}
and PUT /labour-plans/{site_id}/{shift_id}/{path_id} instead; the two old
POSTs here answered 410 for one release and were removed in stage E (a POST answers 404).
Ubiquitous Language
Full glossary: Ubiquitous language. Top terms:
| Term | Code identifier |
|---|---|
| Charge | — (warehouse-planning's workload forecast since ADR-0049) |
| CPT | shared.CPT |
| Process path | shared.PathId, pathcatalog.PathDefinition |
| Work pool | release.WorkPool |
| Feed mode (release-fed / flow-fed) | release.FeedMode (ReleaseFed, FlowFed) |
| Work unit | workunit.WorkUnit |
| Release | usecases.ReleaseNextWork, release.ReleasePolicy |
| WIP limit / alarm threshold | wipLimit, alarmThreshold on WorkPool |
| Flow balancing | usecases.RebalanceDecision |
| Observed labour plan | laborview.LaborPlanObserved |
Business Decisions
- Earliest CPT first is the entire priority function (
nextPendingIndex, ADR-0002). - The WIP limit is enforced only on release-fed pools; flow-fed pools only alarm (ADR-0003).
- The first enqueue on a path whose pool was never configured creates it
release-fed with WIP limit and alarm threshold 1000 (
defaultWIPLimit,defaultAlarmThreshold). An operator sets a path's mode and WIP limit explicitly withPUT /paths/{pathId}/pool(ConfigurePool, ADR-0034); lowering a limit below the current WIP never evicts work, releases pause until WIP < limit. - A flow-fed path reports remaining capacity as
Known=false, always (ADR-0018, ADR-0020). - Workforce's
ShiftPlanCommittedis a read model only: a pure projection intoLaborPlanObserved(ADR-0006; since ADR-0049 nothing here compares it with a plan). - Every
pathIdis validated against process-path-management's catalogue (ADR-0012); anOrderAllocatedwith one unknown path fails as a whole. TaskCompletedfor a work unit this context never planned is a logged, processed skip;OrderAllocatedlines already enqueued are skipped.- Every
POSTrequires anIdempotency-Key(ADR-0022, ADR-0047).
Assumptions
- One work pool per process path, and a path's work fits one aggregate row set (entries are never pruned).
promise_dateonOrderAllocatedis the CPT of every line.- Kafka is at-least-once: every consumer is idempotent on the CloudEvents
id(ADR-0028). - REST and MCP are reached inside the cluster (through Kong locally) and are unauthenticated (ADR-0016).
Verification Metrics
| Metric | Source |
|---|---|
wes.work_units.released counter, attribute path.id | internal/adapters/outbound/telemetry/release_metrics.go (ADR-0013) |
wes.outbox.lag_seconds gauge — age of the oldest unpublished outbox row | internal/adapters/outbound/postgres/outbox_metrics.go |
Hourly work_released, work_unit_completed, backlog_threshold_breached, path_throttled per path | throughput_rollup, GET /reports/throughput (Release throughput report) |
| Backlog depth vs alarm threshold, WIP vs WIP limit | GET /paths/{pathId}/telemetry |
| Dead-lettered messages | <topic>.dlq topics |
Open Questions
RateDeviationDetectedis declared, catalogued and counted by the analytics projector but no use case raises it — it needs a time-windowed actual-rate projection that does not exist. Decided 2026-10-06: kept reserved (declared for a future detection rule, ADR-0020 defers it; not emitted today; not removed).Nothing in production code creates a flow-fed pool or changes a pool's WIP limit.Resolved 2026-10-06:PUT /paths/{pathId}/pool(ADR-0034).UsableInventoryObservedfeeds no decision. Decided 2026-10-06: read-only context by design (ADR-0006); gating release on it would be a new business rule (reservations in inventory-storage already guard availability).- The
eventstable (migration0001) is unused. Decided 2026-10-06: legacy, unused; retained, additive migrations only. WorkPoolentries are never removed, so a long-lived path's pool grows without bound and every save rewrites all entries.order-managementgets no reply event forOrderAllocated; it cannot learn from Kafka whether its lines were enqueued (a deliberate v1 choice, ADR-0031).