Skip to main content

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​

DimensionValue
DomainCore — see Subdomain classification and the Core domain chart
Business modelCost reduction / throughput — making every CPT with less labour and less WIP; not directly revenue-generating, not compliance
EvolutionCustom-built — release policy, WIP backpressure and flow balancing are written and tuned here

Domain Roles​

Role (ddd-crew archetype)How it shows up
ExecutionAdmits work one unit at a time (ReleaseNextWork) and tracks it to completion.
EnforcerEnforces the WIP limit on release-fed pools.
AnalysisBacklog telemetry, rebalance recommendations, remaining-capacity signals.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
Any upstream callerEnqueueWorkUnitCommandREST POST /paths/{pathId}/work-units (Idempotency-Key required with Postgres)OHS
Supervisor / agentReleaseNextWorkCommandREST POST /paths/{pathId}/work-releases; MCP tool release_next_workOHS
OperatorConfigurePoolCommandREST PUT /paths/{pathId}/pool (no MCP tool; ADR-0034)OHS
Station / supervisorRecordCompletionCommandREST POST /work-units/{id}/completionsOHS
Supervisor / warehouse-ops-agentSampleBacklogQuery (may emit events)REST GET /paths/{pathId}/telemetry?cutoffAt=; MCP tool get_backlog_telemetry; MCP resource telemetry://{pathId}/backlogOHS
Supervisor / warehouse-ops-agentRebalanceDecisionCommand (computes a decision, emits events)REST POST /paths/{pathId}/rebalance-decisions (keyed); MCP tool get_rebalance_recommendationOHS
warehouse-ops-agent and UIGetWorkUnitsByReference, GetWorkUnitQueryREST GET /work-units?reference=, GET /work-units/{id}OHS
UILaborPlanView, InventoryViewQueryREST GET /paths/{pathId}/labor-plan-view, GET /inventory-view/{sku}OHS
warehouse-ops-agentRelease throughput reportQueryREST GET /reports/throughput, GET /reports/throughput/freshness (cmd/wes-reports); MCP tool get_release_throughput_report when REPORTS_BASE_URL is setOHS
workforce-managementShiftPlanCommittedEventKafka warehouse.workforce.events, com.warehouse.wes.workforce-management.shiftplan.ShiftPlanCommittedCustomer/Supplier, we conform behind an ACL
inventory-storageStockReserved, ReservationRevokedEventKafka warehouse.inventory.events, com.warehouse.wms.inventory-storage.reservation.StockReserved / ...ReservationRevokedCustomer/Supplier, ACL
fulfillment-executionTaskCompletedEventKafka warehouse.fulfillment.events, com.warehouse.wes.fulfillment-execution.task.TaskCompletedCustomer/Supplier (feedback edge), ACL
order-managementOrderAllocated, OrderPartiallyAllocatedEventKafka warehouse.order-management.events, com.warehouse.wes.order-management.order.OrderAllocated / ...OrderPartiallyAllocatedCustomer/Supplier, ACL (ADR-0031)
process-path-managementProcessPathCreated, ProcessPathUpdated, ProcessPathDeactivatedEventKafka warehouse.process-path-management.events, com.warehouse.wes.process-path-management.processpath.* (only with PATH_CATALOGUE_SOURCE=kafka)Conformist (ADR-0030)
product-masterProductClassifiedEventKafka 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-masterProductPackLevelDeclared, ProductPackLevelRetired, ProductPackLevelMeasuredEventKafka 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-planningWorkDemandReleased (one transfer leg: pick, then dispatch)CommandKafka 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​

CollaboratorMessageTypeChannelRelationship
fulfillment-executionWorkReleasedEventKafka warehouse.work-planning.events, com.warehouse.wes.work-planning.workunit.WorkReleasedOHS + Published Language (we supply)
order-managementPathCapacityChangedEventKafka warehouse.work-planning.events, com.warehouse.wes.work-planning.workpool.PathCapacityChangedOHS + PL (ADR-0018)
network-fulfillmentPathCapacityChangedEventsame topic and typeOHS + PL; network-fulfillment is Conformist
(no consumer today)WorkUnitCreated, WorkUnitCompleted, BacklogThresholdBreached, RateDeviationDetected (reserved, not emitted; decided 2026-10-06), PathThrottled, LaborReassignmentFlaggedEventKafka warehouse.work-planning.events, com.warehouse.wes.work-planning.<entity>.<Event>Published for observability
own analytics projector (cmd/wes-projector)all 8 domain eventsEventKafka warehouse.wes.analytics, same CloudEvents types, dataschema urn:warehouse:wes-work-planning:analytics:<Event>:v1Internal 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:

TermCode identifier
Charge— (warehouse-planning's workload forecast since ADR-0049)
CPTshared.CPT
Process pathshared.PathId, pathcatalog.PathDefinition
Work poolrelease.WorkPool
Feed mode (release-fed / flow-fed)release.FeedMode (ReleaseFed, FlowFed)
Work unitworkunit.WorkUnit
Releaseusecases.ReleaseNextWork, release.ReleasePolicy
WIP limit / alarm thresholdwipLimit, alarmThreshold on WorkPool
Flow balancingusecases.RebalanceDecision
Observed labour planlaborview.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 with PUT /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 ShiftPlanCommitted is a read model only: a pure projection into LaborPlanObserved (ADR-0006; since ADR-0049 nothing here compares it with a plan).
  • Every pathId is validated against process-path-management's catalogue (ADR-0012); an OrderAllocated with one unknown path fails as a whole.
  • TaskCompleted for a work unit this context never planned is a logged, processed skip; OrderAllocated lines already enqueued are skipped.
  • Every POST requires an Idempotency-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_date on OrderAllocated is 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​

MetricSource
wes.work_units.released counter, attribute path.idinternal/adapters/outbound/telemetry/release_metrics.go (ADR-0013)
wes.outbox.lag_seconds gauge — age of the oldest unpublished outbox rowinternal/adapters/outbound/postgres/outbox_metrics.go
Hourly work_released, work_unit_completed, backlog_threshold_breached, path_throttled per paththroughput_rollup, GET /reports/throughput (Release throughput report)
Backlog depth vs alarm threshold, WIP vs WIP limitGET /paths/{pathId}/telemetry
Dead-lettered messages<topic>.dlq topics

Open Questions​

  • RateDeviationDetected is 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).
  • UsableInventoryObserved feeds 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 events table (migration 0001) is unused. Decided 2026-10-06: legacy, unused; retained, additive migrations only.
  • WorkPool entries are never removed, so a long-lived path's pool grows without bound and every save rewrites all entries.
  • order-management gets no reply event for OrderAllocated; it cannot learn from Kafka whether its lines were enqueued (a deliberate v1 choice, ADR-0031).