Skip to main content

Bounded context canvas

Synced from warehouse-ops-agent

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 real route in internal/adapters/inbound/http/router.go, a real tool in internal/adapters/inbound/mcp/tools.go, or a real callTool / HTTP path in internal/adapters/outbound/.

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,mcp} and internal/adapters/outbound/{mcpclient,restclient,llm,logs}. 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-ops-agent — the fleet's read-side decision-support agent and warehouse-console Backend-for-Frontend (console-bff). One Go binary, cmd/agent, listening on AGENT_ADDR (default :8095) for REST at / and its own MCP server at /mcp.

Purpose​

Correlate read-only facts fanned out from the fleet's bounded contexts into ranked, evidence-carrying, human-gated recommendations, so that no upstream context has to own cross-context correlation that would blur its boundary. Concretely it produces:

  • the E3 daily brief (per-site, per-path facts plus open exceptions when two or more independent signals correlate), with an optional warehouse-planning capacity outlook (ADR 0013);
  • the E1 flow-balance exception (assign_labor / release_next_work / hold), optionally arbitrated by an LLM (ADR 0004) and enriched by a labor-utilization overlay (ADR 0008);
  • the E2 stranded-reservation exception (revoke_reservation with a mandatory blast radius, or hold);
  • the travel-factor advisory (ADR 0009);
  • the runtime-signals report (Istio error rate / p99 from Prometheus, error-log counts from Loki);
  • and, for warehouse-console, the order lifecycle read model and the WMS / WES report dashboards (ADR 0002 / 0003).

It recommends; it never acts. There is no write path (zero write tools, CI-enforced).

Strategic Classification​

AspectClassification
DomainSupporting on the fleet map, with the caveat in Subdomain classification: it owns no aggregate, so it is not a bounded context in the aggregate-and-invariant sense. See the core domain chart.
Business ModelCost reduction / operator productivity: internal tooling that shortens time-to-diagnosis. No revenue capability.
EvolutionCustom-built (correlation policy); product (console-bff BFF shape); commodity inputs (Prometheus, Loki, LLM API).

Domain Roles​

  • Analysis context — observes facts other contexts own and synthesizes a diagnosis plus a recommendation (E1, E2, E3, ADR 0008 / 0009, runtime signals). No invariant of its own.
  • Gateway / BFF — the console-bff routes are pure read-model projections stitched from other contexts' REST APIs, with no policy on top.

Inbound Communication​

All inbound traffic is synchronous and unauthenticated (ADR 0006). There is no Kafka consumer.

CollaboratorMessageTypeChannelRelationship
Platform probeshealth checkQueryREST GET /healthzPlatform
warehouse-console, HTTP clientsdaily briefQueryREST GET /daily-briefCustomer of this OHS
HTTP clientsflow-balance exceptionQueryREST GET /flow-balance/{pathId}?buildingId=&shiftId=Customer of this OHS
HTTP clientsexplain travel factorQueryREST GET /explain-travel-factor?pathId=&fromLocationCode=&toLocationCode=Customer of this OHS
warehouse-consoleorder lifecycleQueryREST GET /console/orders/{id}/lifecycleBFF for its one frontend
warehouse-consoleWMS dashboardQueryREST GET /console/reports/wms?from=&to=BFF for its one frontend
warehouse-consoleWES dashboardQueryREST GET /console/reports/wes?from=&to=BFF for its one frontend
HTTP clientsruntime signalsQueryREST GET /runtime-signalsCustomer of this OHS
Agentic / LLM hostdaily briefQueryMCP get_daily_briefCustomer of this OHS
Agentic / LLM hostopen exceptions by min severityQueryMCP list_open_exceptionsCustomer of this OHS
Agentic / LLM hostflow-balance exceptionQueryMCP get_flow_balance_exception (registered when wired)Customer of this OHS
Agentic / LLM hosttravel factorQueryMCP explain_travel_factor (registered when wired)Customer of this OHS
Agentic / LLM hoststranded reservationQueryMCP detect_stranded_reservation (registered when wired)Customer of this OHS

All five MCP tools carry ReadOnlyHint: true. The MCP server is mounted on the same chi router as REST (ADR 0010) and runs stateless (ADR 0012).

Outbound Communication​

Every outbound call is a read. "Live" means a use case calls it today; "wired" means the client method exists but no use case calls it.

CollaboratorMessageTypeChannelRelationship
wes-work-planning (Core)backlog telemetryQueryMCP get_backlog_telemetry — live (daily brief)Customer / Conformist of OHS
wes-work-planning (Core)rebalance recommendationQueryMCP get_rebalance_recommendation — live (E1)Customer / Conformist of OHS
fulfillment-execution (Core)queue statusQueryMCP get_queue_status — live (daily brief)Customer / Conformist of OHS
fulfillment-execution (Core)stuck tasksQueryMCP diagnose_stuck_tasks — live (daily brief, E1, E2)Customer / Conformist of OHS
workforce-management (Supporting)staffing gapQueryMCP get_staffing_gap — live (daily brief, E1)Customer / Conformist of OHS
inventory-storage (Core)availabilityQueryMCP check_availability — live (E2)Customer / Conformist of OHS
inventory-storage (Core)bin occupancyQueryMCP get_bin_occupancy — live (E2 blast radius)Customer / Conformist of OHS
facility-layout (Generic)sitesQueryMCP list_sites — live (daily brief)Customer / Conformist of OHS
facility-layout (Generic)travel distanceQueryMCP estimate_travel_distance — live (ADR 0009)Customer / Conformist of OHS
labor-performance (Supporting)task-type utilizationQueryMCP get_task_type_utilization — live (ADR 0008)Customer / Conformist of OHS
warehouse-planning (Core)path capacityQueryMCP get_process_path_capacity — live (capacity outlook, only when WAREHOUSE_PLANNING_MCP_ENDPOINT is set)Customer / Conformist of OHS (read tools only)
order-management (Generic/Supporting)promise KPIsQueryMCP get_promise_health — live (daily brief promiseHealth section, ADR 0024; get_order published but unwired)Customer / Conformist of OHS
slotting-optimization (Supporting)slot plansQueryMCP list_slot_plans, get_slot_plan — live (daily brief slotPlanWatch section, ADR 0024; get_forward_slots and get_sku_velocity unwired)Customer / Conformist of OHS
order-management (Generic/Supporting)order headerQueryREST GET /orders/{id} — live (order lifecycle)Conformist
inventory-storage (Core)reservations by demand refQueryREST GET /reservations?demandRef= — live (order lifecycle)Conformist
wes-work-planning (Core)work units by referenceQueryREST GET /work-units?reference= — live (order lifecycle)Conformist
fulfillment-execution (Core)tasks by order refQueryREST GET /tasks?orderRef= — live (order lifecycle, one call per work unit)Conformist
order-management reports readerorder funnel + freshnessQueryREST GET /reports/funnel, /reports/funnel/freshness — live (WMS dashboard)Conformist
inventory-storage reports readerflow accuracy + freshnessQueryREST GET /reports/flow-accuracy, /freshness — live (WMS)Conformist
facility-layout reports readercatalog growth + freshnessQueryREST GET /reports/catalog-growth, /freshness — live (WMS)Conformist
wes-work-planning reports readerplanning throughput + freshnessQueryREST GET /reports/throughput, /freshness — live (WES)Conformist
fulfillment-execution reports readerfulfillment throughput + freshnessQueryREST GET /reports/throughput, /freshness — live (WES)Conformist
workforce-management reports readerlabor + freshnessQueryREST GET /reports/labor, /freshness — live (WES)Conformist
labor-performance reports readerperformance + freshnessQueryREST GET /reports/performance, /freshness — live (WES)Conformist
Prometheus (observability, not a context)Istio error rate, p99QueryHTTP GET /api/v1/query — live (runtime signals)Read-only telemetry source
Loki (observability, not a context)error log linesQueryHTTP GET /loki/api/v1/query_range — live (runtime signals)Read-only telemetry source
Anthropic Messages API (external)plan via tool useQueryHTTP POST /v1/messages — only when LLM_MODE is shadow or onExternal service behind the policy gate

network-fulfillment (Supporting) is deliberately absent: this agent has no client for it. No outbound message is a Command or an Event.

Ubiquitous Language​

See Ubiquitous language. Top terms: DailyBrief, PathBrief, OpenException, FlowBalanceException (policy.Decision), StrandedReservationException, Evidence trail, Blast radius, PathTarget, UtilizationCorrelation, TravelFactorCorrelation, CapacityOutlook, ServiceSignal, LLMMode / DecisionSource.

Business Decisions​

  • Correlate, don't alert on one metric: deriveExceptions flags a path only when at least two of backlog-over-alarm, understaffed and stuck tasks fire; three is critical, two is warning.
  • Degrade to hold, never guess: a missing anchor signal yields a Partial hold (E1) or a typed hold with an evidence line (E2).
  • No revoke without a blast radius: Evaluate cannot return revoke_reservation unless get_bin_occupancy answered and a reservationId was supplied.
  • Reject, never default, untrusted enums: ParseRebalanceAction, TaskType.Valid, severityRank, ParseLLMMode, ValidatePlan.
  • Model output never bypasses policy: Arbitrate is the only place a plan meets the deterministic decision; off is the default.
  • Capacity outlook is informational and fail-open: it never feeds deriveExceptions and failures become omittedReason.
  • Each console-bff stage / section degrades independently; an order not found in order-management is the only 404. Decided 2026-10-06 (kept, ADR 0002): an unreachable order-management leaves its stage null in a 200 — the agent is an advisory read-side aggregator and one dependency outage must not fail the whole view.

Assumptions​

  • Upstream MCP tool schemas and REST shapes stay stable; the agent mirrors them by hand (no shared Go types).
  • DAILY_BRIEF_PATH_TARGETS correctly binds each context's own name for the same process path; the agent never infers it. Decided 2026-10-06 (ADR 0017): unset selects the default target; unparseable JSON or an empty array [] fails startup with a config error naming the variable.
  • The console is the only consumer of /console/**.
  • Per-request re-reading is cheap enough that no cache or store is needed.

Verification Metrics​

  • TestNoDirectDependencyOnBoundedContexts, TestHexagonalDependencyRules, TestMCPAdapterDependencyRule, TestNoAuthMiddlewareReintroduced (internal/architecture).
  • TestNoMutatingHTTPMethodInOutboundClients, TestNoMutatingToolAnnotationInMCPServer, TestMCPClientsCallOnlyReadTools (internal/architecture/zerowrite).
  • 90% coverage gate (make coverage), gremlins mutation job over ./internal/domain (make mutation-fast).
  • Runtime: ops_agent_llm_agreement_total{agree} (shadow agreement rate) and circuit_breaker_state{dependency="anthropic-llm"}.

Open Questions​

  • No MCP client method is wired-but-unconsumed any more: the 18 that no use case called (warehouse-planning, labor-performance, facility-layout, fulfillment-execution, workforce-management, network-inventory-planning, product-master, inbound-receiving) were removed in Phase 5.4. The order-management client is consumed (get_promise_health) and the process-path-management client was removed (ADR 0024).
  • E2 has an MCP tool but no REST route.
  • DailyBrief (E3) LLM-reasoner coverage is a documented next phase of ADR 0004, not implemented.
  • explain_travel_factor cannot resolve location codes itself (ADR 0009).
  • What would an act slice's authorization gate be, now that ADR 0006 removed fleet auth? (Governance note.)