Skip to main content

Configuration

Synced from warehouse-planning

This page is a copy of docs/docs/operations/configuration.md on develop, derived from that repository's code. Edit it there, then re-sync.

Every binary is configured only through environment variables. There are no config files and no command-line flags. This page lists each variable each binary reads, taken from its composition root (cmd/<binary>/main.go) and the few adapters that read the environment themselves. An empty value counts as unset: every lookup goes through a getenv(key, fallback) helper or an explicit == "" check.

Postgres and Kafka are the only runtime (ADR 0016). A variable marked yes under Required is a boot error that names it when it is unset, raised before the listener binds; there is no in-memory fallback, no log sink and no consumer that is off. The chart refuses to render without the matching values (helm template names the value).

The Helm chart (charts/warehouse-planning) renders most variables from dedicated values. The Chart value column names the key. "not rendered" means the chart never sets the variable, so the binary's default applies unless you add it through extraEnv (the api component), mcp.extraEnv, or a values override in warehouse-infra.

Every config.* value is also rendered into the chart ConfigMap (<release>-warehouse-planning), and the api Deployment mounts that ConfigMap with envFrom (gap fix D14), so a key that only lives in the ConfigMap still reaches cmd/api; an explicit env entry wins over it. The mcp, analytics-projector and analytics-reports Deployments do not mount it: they read only their own explicit env (the reports binary would otherwise bind the api's HTTP_ADDR). charts/warehouse-planning/tests/render_test.sh asserts both, in CI (chart-tests job).

The OTel environment is rendered on all four backend Deployments (ADR 0015): ENVIRONMENT from environment (default local), SERVICE_VERSION from image.tag (falling back to the chart appVersion) and OTEL_EXPORTER_OTLP_ENDPOINT from otel.endpoint (default otel-collector.observability.svc.cluster.local:4317, the in-cluster Collector) while otel.enabled (default true). warehouse-infra sets none of them for this service, so the chart defaults apply in the kind cluster.

cmd/api (REST, Kafka consumers, outbox relay)​

VariableDefaultRequiredMeaningChart valueSource
HTTP_ADDR:8080noListen address of the REST server.config.httpAddrcmd/api/main.go
LOG_LEVELinfonodebug, info, warn (or warning) or error, case-insensitive. Any other value means info. Logs are JSON on stdout.config.logLevelcmd/api/main.go
DATABASE_URLnoneyesPostgres DSN of the OLTP database (pgxpool). Unset is a boot error (DATABASE_URL is required: ...); there is no in-memory mode (ADR 0016). The chart refuses to render without database.url or database.existingSecret.database.url / database.existingSecret + database.existingSecretKeycmd/api/runtime.go
MIGRATIONS_DATABASE_URLthe value of DATABASE_URLnoDSN used only by the golang-migrate step at boot. In the kind cluster DATABASE_URL goes through PgBouncer (transaction pooling), which cannot hold golang-migrate's session-scoped pg_advisory_lock, so this one is a direct Postgres DSN (ADR 0010). The runtime pool never uses it.database.migrationsExistingSecretKey (rendered with optional: true)cmd/api/main.go
MIGRATIONS_PATHinternal/adapters/outbound/postgres/migrationsnoDirectory of the OLTP *.up.sql files, relative to the working directory. The image copies them to /app/migrations.config.migrationsPath (migrations)cmd/api/main.go
KAFKA_BROKERSnoneyesComma-separated broker list (each entry trimmed, empty entries dropped). Unset or blank is a boot error (KAFKA_BROKERS is required: ...). It feeds the seven consumers, the outbox relay and the /readyz broker check.kafka.brokers (required; a legacy kafka.enabled: true still renders, false is refused)cmd/api/runtime.go
LABOR_CAPACITY_CONSUMER_GROUPnoneyesConsumer group of the labor consumer on warehouse.workforce.events. The same consumer registers the LABOR constraint and, for a line with a shift_id, records the committed heads that the labour plan drift compares (ADR 0023 decision 3); there is no separate drift consumer or group. No default on purpose, so that a local process never joins the live group; unset is a boot error.config.laborCapacityConsumerGroup (required)cmd/api/runtime.go
STORAGE_CAPACITY_CONSUMER_GROUPnoneyesConsumer group of the facility consumer on warehouse.facility.events. No default; unset is a boot error.config.storageCapacityConsumerGroup (required)cmd/api/runtime.go
DEMAND_CONSUMER_GROUPnoneyesConsumer group of the order-demand consumer on warehouse.order-management.events. The consumer is always on (ADR 0004 made it opt-in; ADR 0016 removed the off switch). No default; unset is a boot error.demand.consumerGroup (required)cmd/api/runtime.go
DEMAND_SITE_IDnoneyesThe site every task completion is attributed to (those events carry no site) and the fallback site for an order whose event carries no site_id (ADR 0021); dock appointments carry their own site_id (ADR 0020). Unset is a boot error.demand.siteId (required)cmd/api/runtime.go
DOCK_APPOINTMENT_CONSUMER_GROUPnoneyesConsumer group of the dock-appointment consumer on warehouse.dock-scheduling.events (DockAppointmentBooked, Rescheduled, Cancelled, NoShow; ADR 0017, source switched by ADR 0020). Always on (ADR 0016); no default; unset is a boot error.dockAppointments.consumerGroup (required; warehouse-infra pins warehouse-planning-dock-appointments)cmd/api/runtime.go
INBOUND_DEMAND_CONSUMER_GROUPnonerefusedRETIRED: the group of the old inbound-receiving appointment source. Setting it is a boot error naming DOCK_APPOINTMENT_CONSUMER_GROUP (a stale deployment fails loudly instead of reading a topic nobody feeds); the chart refuses inbound.consumerGroup and an extraEnv entry of this name.none (inbound.consumerGroup is refused)cmd/api/runtime.go
OBSERVED_CAPACITY_CONSUMER_GROUPnoneyesConsumer group of the task-completion consumer on warehouse.fulfillment.events (TaskCompleted; ADR 0017). Always on; no default; unset is a boot error.observed.consumerGroup (required; warehouse-infra pins warehouse-planning-observed-capacity)cmd/api/runtime.go
LABOR_STANDARD_CONSUMER_GROUPnoneyesConsumer group of the labour-standard consumer on warehouse.labor-performance.events (LaborStandardDefined, LaborStandardRevised; ADR 0022). Always on; no default in the binary; unset is a boot error.laborStandard.consumerGroup (chart default and warehouse-infra pin warehouse-planning-labor-standards)cmd/api/runtime.go
PROCESS_FLOW_CONSUMER_GROUPnoneyesConsumer group of the process-flow consumer on warehouse.process-path-management.events (ProcessFlowDefined, ProcessFlowRevised, ProcessFlowRetired; each is the FULL flow state with a version, applied only when greater than the stored one; ADR 0025). Always on; no default in the binary; unset is a boot error. A deterministic failure (unknown process_type, no stages, bad status or version) goes to warehouse.process-path-management.events.dlq.processFlow.consumerGroup (chart default and warehouse-infra pin warehouse-planning-process-flows)cmd/api/runtime.go
EVENT_PUBLISHERkafkanoOutbox relay sink. Only kafka (also the default) is accepted: log is a boot error (EVENT_PUBLISHER=log is not supported: ...), as is any other value. The variable stays because the chart and warehouse-infra set it.config.eventPublisher (kafka)cmd/api/runtime.go
OUTBOX_RELAY_INTERVAL1snoPause between relay passes that did not fill a batch of 100. A Go duration (500ms, 2s) or plain seconds (0.5). A malformed or non-positive value logs a WARN and uses 1s.config.outboxRelayInterval (rendered only when set)cmd/api/main.go
OUTBOX_MAX_ATTEMPTS20noHow many times one outbox row may fail before the relay excludes it from claims (ADR 0013). The row stays in outbox_events with attempts and last_error until an operator re-arms it (UPDATE outbox_events SET attempts = 0 WHERE id = ..., see the Runbook). 0 means unlimited (one poison row then blocks the relay forever). A negative or unparsable value logs a WARN and uses 20.config.outboxMaxAttempts (20)cmd/api/main.go
SHUTDOWN_DRAIN_DELAY5snoHow long shutdown waits after flipping /readyz to 503 and before closing the listener. 0 disables the wait. A negative or unparsable value logs a WARN and uses 5s. Only cmd/api reads it.config.shutdownDrainDelay (rendered only when set)cmd/api/main.go
CORS_ALLOWED_ORIGINShttp://localhost:5173noComma-separated, trimmed list of browser origins for the CORS middleware (methods GET, POST, PUT). Standalone web/ dev on port 5190 needs http://localhost:5190. In the cluster, Kong's CORS plugin answers browsers.config.corsAllowedOrigins (rendered only when set)internal/adapters/inbound/http/process_capacity_handler.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noOTLP/gRPC endpoint (host:port, insecure) for traces and metrics. Export never blocks boot: a missing Collector only drops telemetry.otel.endpoint, rendered while otel.enabledcmd/api/main.go, internal/adapters/outbound/telemetry/telemetry.go
SERVICE_VERSIONdevnoOTel service.version resource attribute.image.tag (else the chart appVersion)cmd/api/main.go
ENVIRONMENTlocalnoOTel deployment.environment.name resource attribute.environmentinternal/adapters/outbound/telemetry/telemetry.go

cmd/mcp (MCP server)​

cmd/mcp reads no Kafka variable: it never dials Kafka and never starts the relay. Its plan tools write outbox rows that the cmd/api relay drains.

VariableDefaultRequiredMeaningChart valueSource
MCP_ADDR:8090noListen address of the Streamable HTTP server (/, /mcp and GET /healthz).mcp.httpAddrcmd/mcp/main.go
LOG_LEVELinfonoAs for cmd/api, and also accepts warning.config.logLevelcmd/mcp/main.go
DATABASE_URLnoneyesThe same OLTP database as cmd/api. Unset is a boot error (DATABASE_URL is required: ...); there is no in-memory mode.as for cmd/apicmd/mcp/main.go
MIGRATIONS_DATABASE_URLthe value of DATABASE_URLnoDirect DSN for the migration step. cmd/mcp also migrates on boot, and the advisory lock makes concurrent starts with cmd/api safe.database.migrationsExistingSecretKeycmd/mcp/main.go
MIGRATIONS_PATHinternal/adapters/outbound/postgres/migrationsnoAs for cmd/api.config.migrationsPathcmd/mcp/main.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noAs for cmd/api. The service name is warehouse-planning-mcp.otel.endpoint, rendered while otel.enabledcmd/mcp/main.go
SERVICE_VERSIONdevnoAs for cmd/api.image.tagcmd/mcp/main.go
ENVIRONMENTlocalnoAs for cmd/api.environmentinternal/adapters/outbound/telemetry/telemetry.go

cmd/a2a (A2A agent)​

cmd/a2a (ADR 0018) reads no Kafka variable: it never dials Kafka and never starts the relay. evaluate_capacity_plan writes outbox rows that the cmd/api relay drains. A missing DATABASE_URL or A2A_AGENT_URL, or an A2A_AGENT_URL that is not an absolute http(s) URL, is a boot error naming the variable, raised before telemetry, any connection and the listener.

VariableDefaultRequiredMeaningChart valueSource
A2A_ADDR:8093noListen address of the JSON-RPC server (/, /a2a, the Agent Card at /.well-known/agent-card.json and GET /healthz).a2a.httpAddrcmd/a2a/main.go
A2A_AGENT_URLnoneyesAbsolute http(s) URL of this agent's JSON-RPC endpoint, advertised on the Agent Card.a2a.agentUrl; empty renders http://<fullname>-a2a.<namespace>.svc.cluster.local:8093/cmd/a2a/main.go
LOG_LEVELinfonoAs for cmd/mcp.config.logLevelcmd/a2a/main.go
DATABASE_URLnoneyesThe same OLTP database as cmd/api. Unset is a boot error (DATABASE_URL is required: ...); there is no in-memory mode.as for cmd/apicmd/a2a/main.go
MIGRATIONS_DATABASE_URLthe value of DATABASE_URLnoDirect DSN for the migration step. cmd/a2a also migrates on boot, and the advisory lock makes concurrent starts with cmd/api safe.database.migrationsExistingSecretKeycmd/a2a/main.go
MIGRATIONS_PATHinternal/adapters/outbound/postgres/migrationsnoAs for cmd/api.config.migrationsPathcmd/a2a/main.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noAs for cmd/api. The service name is warehouse-planning-a2a.otel.endpoint, rendered while otel.enabledcmd/a2a/main.go
SERVICE_VERSIONdevnoAs for cmd/api.image.tagcmd/a2a/main.go
ENVIRONMENTlocalnoAs for cmd/api.environmentinternal/adapters/outbound/telemetry/telemetry.go

cmd/planning-projector (analytics writer)​

The projector validates its configuration before it does anything else and exits non-zero when a required variable is missing. It then calls telemetry.Setup like the other three binaries (ADR 0015).

VariableDefaultRequiredMeaningChart valueSource
ANALYTICS_DATABASE_URLnoneyesRead-write DSN of the separate analytical database (warehouse_planning_analytics). It is also used for the analytical migrations, so make it a direct DSN, not PgBouncer.secret key ANALYTICS_DATABASE_URL (analytics.database.projectorUrl or analytics.database.existingSecret)cmd/planning-projector/main.go
KAFKA_BROKERSnoneyesComma-separated broker list. Each entry is trimmed and empty entries are dropped.kafka.brokerscmd/planning-projector/main.go
ANALYTICS_CONSUMER_GROUPnoneyesFixed consumer group on warehouse.warehouse-planning.analytics. No default; unset is a boot error. A new group id starts from the earliest offset and rebuilds the model from history.analytics.projector.consumerGroup (required while analytics.enabled)cmd/planning-projector/main.go
ANALYTICS_MIGRATIONS_PATHanalytics/migrationsnoDirectory of the analytical *.up.sql files (/app/analytics/migrations in the image).analytics.migrationsPathcmd/planning-projector/main.go
ADMIN_ADDR:8091noAdmin listener for /healthz (liveness) and /readyz (drain gate, analytical Postgres ping and Kafka metadata). The chart's container port is fixed at 8091, so change both together.analytics.projector.adminAddrcmd/planning-projector/main.go
LOG_LEVELinfonoAs for cmd/mcp.config.logLevelcmd/planning-projector/main.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noAs for cmd/api. The service name is warehouse-planning-projector.otel.endpoint, rendered while otel.enabledcmd/planning-projector/main.go
SERVICE_VERSIONdevnoAs for cmd/api.image.tagcmd/planning-projector/main.go
ENVIRONMENTlocalnoAs for cmd/api.environmentinternal/adapters/outbound/telemetry/telemetry.go

cmd/planning-reports (analytics reader)​

VariableDefaultRequiredMeaningChart valueSource
ANALYTICS_DATABASE_URLnoneyesDSN of the analytical database. The pool forces default_transaction_read_only=on. The chart feeds it the reader DSN (secret key ANALYTICS_READER_DATABASE_URL, from analytics.database.reportsUrl, falling back to projectorUrl).analytics.database.reportsUrl / analytics.database.existingSecretcmd/planning-reports/main.go
HTTP_ADDR:8092noListen address of the reports server (/healthz, /readyz with an analytical Postgres ping, and the reports).analytics.reports.httpAddrcmd/planning-reports/main.go
LOG_LEVELinfonoAs for cmd/mcp.config.logLevelcmd/planning-reports/main.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noAs for cmd/api. The service name is warehouse-planning-reports.otel.endpoint, rendered while otel.enabledcmd/planning-reports/main.go
SERVICE_VERSIONdevnoAs for cmd/api.image.tagcmd/planning-reports/main.go
ENVIRONMENTlocalnoAs for cmd/api.environmentinternal/adapters/outbound/telemetry/telemetry.go

Fixed in code (no variable)​

These limits are constants. Changing one needs a code change, and for the pool sizes ADR 0009 asks you to review the HPA ceiling at the same time.

SettingValueWhere
OLTP pool MaxConns and statement_timeout (cmd/api, cmd/mcp)10 connections, 5s. A pool_max_conns in the DSN is overwritten.internal/adapters/outbound/postgres/pool.go
Projector pool5 connections, 10sinternal/adapters/outbound/analyticsstore/pool.go
Reports pool5 connections, 15s, read-only transactionsinternal/adapters/outbound/analyticsstore/pool.go
Boot retry of migrations and the first ping5 attempts, backoff 1, 2, 4 and 8 s between them (15 s in total); the last error is returnedinternal/bootretry/bootretry.go
Outbox relay batch size100 rows per passinternal/adapters/outbound/outbox/relay.go
Consumer retry backoff200 ms doubling to a 5 s capinternal/adapters/inbound/kafka/kafka.go
Domain-consumer attempts before dead-lettering5internal/adapters/inbound/kafka/deadletter.go
HTTP graceful drain, consumer drain, relay drain10 s eachcmd/api/main.go
OTel metric export interval30 sinternal/adapters/outbound/telemetry/telemetry.go
Report rangedefault the 30 days ending now, at most 366 daysinternal/analytics/report/range.go
Version-conflict retry of the requirement-side PUTsone re-run of the whole unit of work; a second conflict is 409 version-conflictinternal/application/usecases/workload_forecast.go (retryOnVersionConflict)
Labour plan count boundplanned_heads, installed_stations and committed heads from 0 to 2147483647internal/domain/labourplan/plan.go (MaxCount)

Requirement side (ADR 0022, ADR 0023)​

The workload forecast, the labour plan and the drift add no environment variable and no chart value: they run inside cmd/api on the same database, outbox and relay, and the drift's commitment side rides on the labor consumer above. The labour-standard copy needs LABOR_STANDARD_CONSUMER_GROUP. The routes are REST only (no MCP tool, no A2A skill, ADR 0023 decision 7), so cmd/mcp and cmd/a2a need nothing new; both read the labour-standard copy for a capacity plan's labour requirement (postgres.NewLaborStandardRepo) but never start its consumer.