Skip to main content

Architecture

warehouse-ops-agent is a read-only decision-support aggregator, not a bounded context: it owns no aggregate and persists nothing (ADR 0001). Its code still follows the fleet's hexagonal layout, with one difference: the "domain" is decision policy (pure correlation rules over facts read from other contexts) instead of aggregates.

Binaries and ports​

BinaryRoleListens onSource
agentthe only binary. Serves every REST route and the agent's own MCP server (/mcp, Streamable HTTP, stateless) from one chi routerAGENT_ADDR, default :8095cmd/agent/main.go, cmd/agent/reasoner.go

There is no separate cmd/mcp, no *-reports reader and no projector. In the Helm chart one Deployment runs the binary behind a Service on port 80 (Runbook).

Package layout​

PackageLayerContents
internal/domain/policydomainpure functions and value types: Decide (flow balance, E1), Evaluate (stranded reservation, E2), daily-brief exception derivation (E3), travel-factor classification, utilization correlation, capacity outlook, master-data gaps, inbound outlook, transfer triage and imbalance, runtime-signal thresholds, ValidatePlan and Arbitrate for the LLM plan. No I/O, no struct tags.
internal/application/usecasesapplicationone struct per use case (see Use cases); each gathers facts through ports, degrades on a missing signal, and calls the policy
internal/portsportsthe interfaces the use cases depend on: one client interface per upstream context (clients.go, clients_phase2.go, clients_planning.go, clients_product_master.go, clients_inbound_receiving.go, clients_nip.go, clients_slotting.go, clients_returns_processing.go, clients_exception_management.go), the console REST clients (order_lifecycle_clients.go, console_reports_clients.go), TelemetryReader, LogReader, Reasoner, ToolInvoker, ArbitrationMetrics, and the sentinel errors ErrNotFound, ErrUpstreamInvalidInput, ErrUpstreamNotFound
internal/adapters/inbound/httpdriving adapterchi router, middleware chain, handlers and JSON DTOs for the 13 GET routes; mounts /mcp
internal/adapters/inbound/mcpdriving adapterthe agent's MCP server (warehouse-ops-agent-mcp 1.0.0) and its up to ten read-only tools
internal/adapters/outbound/mcpclientdriven adapterone typed client per upstream MCP server (twenty-six), the shared Session (fresh Streamable HTTP session per call, 10 s timeout), the ADR 0018 tool-error slug classifier, and the ToolInvoker the LLM uses
internal/adapters/outbound/restclientdriven adapterplain REST clients for the four OLTP APIs and the seven *-reports readers (5 s timeout)
internal/adapters/outbound/telemetrydriven adapterthe Prometheus reader (or a no-op stub), and the OTel ArbitrationMetrics and CircuitBreakerMetrics
internal/adapters/outbound/logsdriven adapterthe Loki reader
internal/adapters/outbound/llm/anthropicdriven adapterthe Anthropic Messages API Reasoner: tool-use loop, submit_plan, tool-argument validation, breaker, retry
internal/resiliencesharedbreaker trip condition (ReadyToTrip), state recorder contract, call-timeout helper
internal/observabilitysharedOTel setup and the trace-id slog handler
internal/configcompositionconfig.Load() from environment variables
cmd/agentcomposition rootbuilds every adapter and use case, wires the reasoner by LLM_MODE, serves

Component diagram​

Source: cmd/agent/main.go, cmd/agent/reasoner.go, internal/adapters/inbound/http/router.go, internal/adapters/inbound/mcp/server.go, internal/ports/*.go. The LLM --> MCPC edge is the ToolInvoker: the model's only actuators are read tools on the allow-list, called through the same MCP sessions.

Dependency rules​

internal/architecture/architecture_test.go (arch-go) and fitness_test.go enforce:

RuleTest
domain depends on nothing internal except itselfTestHexagonalDependencyRules
application depends only on domain and portsTestHexagonalDependencyRules
ports depend on nothing internalTestHexagonalDependencyRules
inbound adapters never import outbound adapters, and the reverseTestHexagonalDependencyRules
only cmd wires every layer togetherTestHexagonalDependencyRules
the MCP inbound adapter depends only on application, domain and ports, and nothing else imports itTestMCPAdapterDependencyRule
no module of a sibling context is ever a Go dependency (fulfillment-execution, wes-work-planning, workforce-management, inventory-storage, facility-layout, warehouse-planning, product-master, inbound-receiving)TestNoDirectDependencyOnBoundedContexts
no auth middleware comes back (ADR 0006)TestNoAuthMiddlewareReintroduced
no json: or db: struct tags in the domainTestNoStructTagsInDomain
no write: no mutating HTTP method in outbound clients, only read MCP tools called, every served tool ReadOnlyHintinternal/architecture/zerowrite

The config-to-use-case mapping (toUseCaseTargets, toPathTaskTypes in cmd/agent/main.go) exists so that internal/application never imports internal/config.

Data stores​

None. The agent has no database, no cache, no queue and no file it writes. Everything it returns is recomputed per request from:

  • the sibling contexts' MCP servers (synchronous tools/call),
  • the OLTP REST APIs and *-reports readers (synchronous GET),
  • Prometheus (/api/v1/query) and Loki (/loki/api/v1/query_range),
  • optionally the Anthropic Messages API (POST /v1/messages).

The only in-process state is the circuit breaker's counters and the reasoner's list of discovered tool schemas, both rebuilt on restart.

Request flow: flow-balance exception​

Source: internal/application/usecases/flow_balance_advisory.go, internal/domain/policy/arbitrate.go.