Skip to main content

Runbook

warehouse-ops-agent is one stateless Go process (cmd/agent). It owns no database and no Kafka topic. Every answer is computed at request time from the sibling contexts' MCP servers, their REST and *-reports APIs, Prometheus, Loki and, when enabled, the Anthropic Messages API. Most "operations" for this service are therefore about configuration and about the health of its upstreams. Every variable named here is described on Configuration.

What does not exist here​

Several sections of a fleet runbook do not apply to this repo. They are listed so nobody goes looking for them:

Fleet conceptIn this repoEvidence
Postgres, migrations, MIGRATIONS_DATABASE_URLnoneno migrations/ directory; no database/sql or pgx import; chart values.yaml comment: "no database, no Kafka"
Kafka producer or consumer, consumer groupsnoneno Kafka client import; internal/observability/telemetry.go says the agent "never produces or consumes a Kafka message"
CloudEvents types, outbox relay, DLQ topicsnonenothing is published; see Domain events
Sweepers, housekeeping jobs, schedulersnonecmd/agent/main.go starts only the HTTP server
/readyznonethe router registers only /healthz (internal/adapters/inbound/http/router.go)
A second binary (cmd/mcp, *-reports, projector)nonecmd/ holds only agent; the MCP server is mounted at /mcp on the same listener

Deployment​

ItemValueSource
Imageghcr.io/iqvo/warehouse-ops-agent, tags latest and the short SHA on every push to main, plus vX.Y.Z from the release job.github/workflows/ci.yml (docker-publish, release)
Helm chartcharts/warehouse-ops-agent (chart version and appVersion 0.1.0 in the repo; the release job packages it with the release version and pushes it to oci://ghcr.io/iqvo)charts/warehouse-ops-agent/Chart.yaml, ci.yml
Workloadone Deployment named after the release fullname, one container, replicaCount: 1 unless the HPA is ontemplates/deployment.yaml, ADR 0012
Container porthttp, 8095 (service.targetPort). Every REST route and /mcp share it.values.yaml, templates/deployment.yaml
ServiceClusterIP, port 80 to target port 8095values.yaml (service)
EdgeIngress (ingress.enabled) or Gateway API HTTPRoute (gatewayApi.enabled); both off by default in the charttemplates/ingress.yaml, templates/httproute.yaml
Configurationa ConfigMap loaded with envFrom, plus explicit env: entries for the listener, the MCP endpoints, PROMETHEUS_URL, the OTel variables and the API keytemplates/configmap.yaml, templates/deployment.yaml
Secret<fullname>-credentials with key ANTHROPIC_API_KEY, created only when credentials.anthropicApiKey is set and credentials.existingSecret is emptytemplates/secret.yaml, _helpers.tpl (credentialsSecretName)
Restarts on config changethe pod template carries checksum/config and checksum/secret annotations, so a changed value rolls the podstemplates/deployment.yaml
Resourcesrequests 100m / 128Mi, limits 500m / 256Mivalues.yaml
Security contextnon-root user 1000, all capabilities dropped, no privilege escalationvalues.yaml

In the kind cluster (warehouse-infra)​

warehouse-infra's terraform/ops-agent.tf computes the Helm values and ArgoCD owns the release (terraform/argocd-apps.tf); there is no helm_release for it any more. That overlay:

  • pulls ghcr.io/iqvo/warehouse-ops-agent:latest with pullPolicy: Always;
  • sets every MCP endpoint from terraform/mcp.tf when deploy_mcp_servers is true, and every restUrls.* and reportsUrls.* to the in-cluster Services;
  • runs llm.mode = "shadow" with credentials.existingSecret = "warehouse-ops-agent-anthropic", a Terraform-managed Secret filled from var.anthropic_api_key;
  • routes /api/warehouse-ops-agent through Kong with the prefix stripped, so http://localhost:8000/api/warehouse-ops-agent/daily-brief reaches the router as /daily-brief.

It sets neither prometheus.url nor runtimeSignals.lokiUrl, so GET /runtime-signals reports zeros there (see Troubleshooting).

Probes and startup​

Both probes call GET /healthz on the http port (values.yaml):

ProbeInitial delayPeriod
liveness5 s10 s
readiness3 s5 s

/healthz returns 200 {"status":"ok"} as soon as the listener is up. It checks no upstream, so readiness flips immediately after the process starts and stays green even when every sibling context is down. That is deliberate: each use case degrades on its own (an unavailable entry, a null stage, a hold) instead of failing the pod.

Startup order in cmd/agent/main.go (run):

  1. Build the JSON logger at LOG_LEVEL.
  2. Install the OTel tracer and meter providers. An unreachable Collector does not block startup; the exporters dial lazily.
  3. config.Load(). A malformed or empty DAILY_BRIEF_PATH_TARGETS returns an error and the process exits with status 1.
  4. Build every outbound client. Nothing is dialled yet: each MCP call opens its own session later.
  5. wireReasoner. An unknown LLM_MODE, a non-off mode without ANTHROPIC_API_KEY, or a malformed LLM_TOOL_ALLOWLIST entry exits with status 1. In shadow or on mode it then calls tools/list on the allow-listed upstreams, bounded by 15 s. A failed discovery is logged (llm reasoner: tool discovery failed for an upstream) and is not fatal.
  6. Log warehouse-ops-agent listening with one *_endpoint_configured boolean per MCP upstream and the number of path targets, then serve.

On SIGINT or SIGTERM the server stops accepting connections and gives in-flight requests 10 s to finish (serveAgent), then flushes the OTel providers with a 5 s timeout.

Scaling​

The agent keeps no state between requests, and the MCP server runs in stateless Streamable HTTP mode, so any replica can answer any request (ADR 0012).

SettingDefaultNotes
autoscaling.enabledfalsewhen true, templates/hpa.yaml renders an autoscaling/v2 HPA and replicas is omitted from the Deployment
autoscaling.minReplicas / maxReplicas1 / 3
autoscaling.targetCPUUtilizationPercentage70the only metric wired by default; targetMemoryUtilizationPercentage is commented out

There is no connection pool to size. What a new replica adds is load on the upstreams: each daily brief makes one list_sites call plus four MCP calls per path target (five when warehouse-planning is configured), each over a fresh MCP session with a 10 s timeout. In shadow or on mode each flow-balance request also makes up to six Anthropic calls, and the circuit breaker is per process, so every replica trips independently.

Upstream dependencies at a glance​

DependencyNeeded forIf it is down
wes-work-planning, fulfillment-execution, workforce-management MCPdaily brief, flow balancebrief entries marked unavailable; flow balance partial or hold
facility-layout MCPexplain-travel-factor; site names in the briefexplain-travel-factor 502; brief keeps working without siteName
inventory-storage MCPdetect_stranded_reservationthe missing reading is left out and the policy cannot recommend revoke_reservation, so the tool returns hold
labor-performance MCPthe flow-balance utilization overlaythe overlay is omitted
warehouse-planning, product-master, inbound-receiving, network-inventory-planning MCPoptional featuressee Integration
four OLTP REST APIsorder lifecyclethat stage is null (order-management 404 gives a 404)
seven *-reports REST readersWMS and WES dashboardsthat section is available: false
Prometheus, Lokiruntime signalsunavailableSources lists the source
Anthropic Messages APILLM_MODE shadow or ondeterministic decision returned; breaker opens after repeated failures

The full per-edge contract is on Integration.

Routine procedures​

Deploy a new version​

Merging to main publishes :latest and a short-SHA tag and, through the release job, a vX.Y.Z image tag and chart. With pullPolicy: Always on :latest, a rollout restart picks up the new image:

kubectl -n warehouse-systems rollout restart deployment/warehouse-ops-agent
kubectl -n warehouse-systems rollout status deployment/warehouse-ops-agent

The Deployment name is the chart fullname; with release name warehouse-ops-agent it is warehouse-ops-agent. Check it with kubectl -n warehouse-systems get deploy.

Turn an optional feature on or off​

Set or clear the matching chart value (for example upstreams.productMaster.endpoint). The checksum annotation rolls the pod. Confirm in the startup log line: product_master_endpoint_configured should read true, and GET /master-data-gaps should stop answering 503.

Change the LLM mode​

  1. For shadow or on, make sure the Secret has a real ANTHROPIC_API_KEY first; otherwise the pod crash-loops with LLM_MODE=shadow requires ANTHROPIC_API_KEY.
  2. Set llm.mode. Watch the llm reasoner configured log line: its tools list shows which allow-listed tools were discovered.
  3. In shadow, compare ops_agent_llm_agreement_total{agree="true"} with the total for use_case="flow_balance_advisory" before moving to on (Observability).
  4. To stop calling the model immediately, set llm.mode back to off. The deterministic policy is unchanged by the mode.

Rotate the Anthropic API key​

Update the key in the Secret the chart reads: credentials.anthropicApiKey (chart-managed Secret) or the external Secret named by credentials.existingSecret (in the kind cluster, TF_VAR_anthropic_api_key then terraform apply rewrites warehouse-ops-agent-anthropic). The key is read once at startup, so restart the Deployment afterwards. A chart-managed Secret change rolls the pod by itself through checksum/secret; an external Secret does not.

Replay, re-publish, rebuild​

Not applicable. The agent stores nothing, so there is nothing to replay or rebuild. Re-asking the same question (GET /daily-brief again) recomputes the answer from the upstreams' current state.