0038. Postgres and Kafka are the only runtime
Status
Accepted (2026-10-19). Supersedes the in-memory fallback of cmd/mcp, the log
publisher, the direct (non-outbox) publisher, the file process-path catalogue,
the permissive labor-performance mode and the "relay only with
EVENT_PUBLISHER=kafka" rule that
ADR 0008,
ADR 0013,
ADR 0016,
ADR 0019 and
ADR 0030 allowed. Fleet
decision "everything must use real database and broker"; workforce-management
follows pick-face-replenishment, task-interleaving and product-master
(their ADR 0010). No migration and no contract change: REST, MCP and the
CloudEvents envelope (ADR 0026)
are unchanged; only the readiness of /readyz grows.
Context
The four binaries could start in states that cannot serve the cluster, and did so silently:
cmd/mcpwithoutDATABASE_URLserved its tools from its own empty in-memory repositories: anassign_laborcall succeeded and vanished on restart, and nothing it wrote was visible over REST.cmd/workforcedefaultedEVENT_PUBLISHERtolog: the outbox relay was not even started and events only reached the JSON log, sowarehouse.workforce.eventsandwarehouse.workforce.analyticsstayed empty while/readyzsaid ready.KAFKA_BROKERSwas optional (the publisher fell back tolocalhost:9092).PATH_CATALOGUE_SOURCEdefaulted tofile, a boot-time YAML that the cluster replaced by the Kafka replay (ADR 0030) and that nobody kept in sync.LABOR_PERFORMANCE_MODEdefaulted topermissive: no measured rate and no idle-share signal, silently.- The projector hard-coded its consumer group.
/readyzwas only a drain gate: it said "ready" while Postgres or Kafka was unreachable.
The chart and the troubleshooting guide documented these as normal states ("events logged, not sent"). A fallback that works makes a mis-set environment look like a healthy deployment.
Decision
- One runtime.
cmd/workforceandcmd/mcprun on real Postgres;cmd/workforce,cmd/mcpandcmd/workforce-projectorrun on real Kafka. There is no in-memory mode, no log sink, no file catalogue and no optional relay; the outbox relay and both consumers start with the service.cmd/workforce-reportsalready read only the analytical Postgres and is unchanged. - Missing configuration is a boot error that names the variable, raised
before telemetry, any connection and the listener, with every problem
reported at once:
DATABASE_URL is required: this context runs on real Postgres,KAFKA_BROKERS is required: this context runs on real Kafka,ANALYTICS_CONSUMER_GROUP is required(projector, no default in the binary).EVENT_PUBLISHERstays only because the chart and warehouse-infra set it: unset andkafkaare accepted,logand anything else stop the boot.PATH_CATALOGUE_SOURCEiskafka(unset meanskafka;fileisPATH_CATALOGUE_SOURCE=file is not supported), andLABOR_PERFORMANCE_MODEdefaults tokafka-cache(permissiveisLABOR_PERFORMANCE_MODE=permissive is not supported). - The composition roots build real adapters only.
cmd/workforce/config.goturns the environment into a validatedbootConfig;internal/compositionholds the shared validation and the publisher/catalogue builders. Thefilecatalogadapter and the direct/log publisher paths are deleted. Thememoryadapters stay ininternal/adapters/outbound/memoryas test doubles for unit and BDD tests and are never imported by a binary. /readyztells the truth. It is200only while the drain gate is open AND Postgres answers a ping AND a Kafka broker answers. Otherwise503({"status":"not_ready"}while draining; aproblem+jsonof typedependency-unavailablenamingpostgresand/orkafkawhen a dependency fails). The verdict is cached 3 s and one round is bounded to 2 s, so probes cannot hammer the database or the broker, and a cancelled caller does not poison the cached verdict./healthzstays a pure liveness check.- Readiness checks the broker, not the topics. The broker auto-creates
topics on the first write (fleet convention) and this service never creates
topics through an admin API. A not-ready pod receives no traffic and so
could never make the first write: requiring the topics would deadlock a
cold cluster. The check dials a fresh connection per call and asks for the
broker list with an empty, non-nil topic list; kafka-go's
Client.Metadatais served from a cached layout after the first answer and would not notice a broker going away. A missing output topic therefore shows as oneoutbox relay pass failed ... Unknown Topic Or PartitionERROR on the first publish of a cold broker (the retry succeeds once the broker has auto-created it) and a missing input topic asconnect ... kafka consumerretries at boot, never as a crash loop that outlives the topic. - Sensors keep it true.
TestRuntimeBinaryHasNoInMemoryAdapters(internal/architecture, withTestRuntimeBinarySensorBites) fails when a non-test file undercmd/**importsinternal/adapters/outbound/memory, andTestNoGoFilesAtRepoRootkeeps the repository root free of Go files: the godog runner moved from the root tofeatures/. - The deployment mirrors it. The chart fails the render, naming the value,
without
database.url/database.existingSecretorkafka.brokers(no default), withconfig.eventPublisherother thankafka, withkafka.enabled=false, withpathCatalogue.enabled=true, with a*_MODE/EVENT_PUBLISHER/PATH_CATALOGUE_*entry inextraEnvthat selects a retired mode, with a grace period under 25 s, and with analytics enabled but no analytical DSN source oranalytics.projector.consumerGroup(defaultworkforce-analytics, the group the projector has always used, so its committed offsets survive the rollout).KAFKA_BROKERSis always rendered.kafka.enabledis still accepted (warehouse-infra sets it totrue) but is no longer a switch. The CIcontractjob (Schemathesis) boots the real binary on a Postgres and a Kafka service container instead of a Postgres and a seeded catalogue file.
Consequences
- A mis-set environment fails at boot with a message that names the missing variable; it no longer degrades into a pod that is up, empty and silent.
- Local
go run ./cmd/workforceneeds a Postgres and a Kafka broker:docker compose up -d --waitprovides both. Fast feedback stays in unit and BDD tests over the memory doubles. - A broker outage takes the api pods out of the Service (readiness
503) where the chart's readiness probe is/readyz, not out of the node: liveness is unaffected, so nothing restarts. Writes that were accepted stay in the transactional outbox and are relayed when the broker returns (ADR 0016, ADR 0036). - The local process-path catalogue of a fresh broker is empty until
process-path-managementpublishes; path ids are rejected with400 unknown-path-iduntil then (the quickstart shows the seed event). - Tests:
TestRunOnRealPostgresAndKafka(cmd/workforce/e2e_integration_test.go, testcontainers) boots the realrun()with nothing but the deployment's environment, drives REST and Kafka, asserts the Postgres rows, the CloudEvents envelope on both output topics, replay idempotency, an in-process restart (no loss, no duplicate) and/readyzfollowing the dependencies (green with no output topic,503naming the dependency when it goes away). The broker check also has unit tests over a fake broker (answers, lists no broker, dead address, asks the live broker every time), and every boot error is a table test (cmd/workforce/bootconfig_test.go,cmd/mcp/bootconfig_test.go,cmd/workforce-projector/config_test.go).
Out of scope
The REST sync edges are unchanged and tracked as a follow-up:
INSTALLED_CAPACITY_MODE=permissive|http (fulfillment-execution,
ADR 0014) and the
LABOR_PERFORMANCE_MODE=http rollback of the labor-performance edge
(ADR 0012); neither is a
database or a broker. warehouse-infra's readiness probe still points at
/healthz; switching it to /readyz is an infra follow-up.