52. Postgres and Kafka are the only runtime of every binary
Status
Accepted (2026-10-19). Fleet decision of the same date: every bounded context
runs only on a real database and a real broker; the in-memory adapters are
test doubles. Amends ADR-0001 (the
publisher swap is no longer a runtime choice), ADR-0004
(EVENT_PUBLISHER=log|kafka, default log, and the localhost:9092 default),
ADR-0020 (the "no DATABASE_URL" rows of the
wiring table), ADR-0029
(what /readyz checks), ADR-0039
and ADR-0051 (permissive and
off are gone; kafka is the only mode). The bodies of those records are not
edited. No public event shape, topic name or REST route changes.
Context
Until now cmd/execution could start with no DATABASE_URL (in-memory
repositories, lost on restart), with EVENT_PUBLISHER unset (a log sink that
sends nothing), with KAFKA_BROKERS unset (a localhost:9092 default that is
never right in a cluster), and with the two local-copy consumers in
permissive. Every one of those starts, answers /healthz and /readyz with
200, and silently does less than the deployment believes: a pod without Kafka
accepted work and published nothing. cmd/mcp and cmd/fulfillment-projector
had the same shape (the projector defaulted its broker to localhost:9092).
The Schemathesis contract job ran against the in-memory boot, so it never
exercised a Postgres text column. PostgreSQL text cannot hold U+0000: a
statement that carries one aborts the surrounding transaction (SQLSTATE 22021,
then 25P02 for the next statement), which on the real runtime is a 500 after the
Idempotency-Key was recorded, and the schema has no way to say "no U+0000".
Decision
- No degraded mode in any binary under
cmd/.cmd/execution,cmd/mcp,cmd/fulfillment-projector,cmd/fulfillment-reportsandcmd/sweeprun on Postgres and Kafka only. The in-memory repositories andeventslog/buffered/multi publishers stay in the tree as test doubles; the wall clock moved tointernal/adapters/outbound/systemso no binary needs the memory package.TestRuntimeBinaryHasNoInMemoryAdapters(internal/architecture) fails the build when a non-test file undercmd/imports the memory package, the log/buffered/multi publishers or the permissive/in-memory copies of the two local-copy adapters, andTestRuntimeBinarySensorBitesproves the detector fires. - Misconfiguration is a boot error that names the variable, raised before
the listener binds or anything dials. Required:
DATABASE_URL,KAFKA_BROKERS(no default),WORK_RELEASED_CONSUMER_GROUP,PRODUCT_CLASSIFICATION_CONSUMER_GROUP,TASK_INTERLEAVING_CONSUMER_GROUPforcmd/execution;DATABASE_URLandKAFKA_BROKERSforcmd/mcp;ANALYTICS_DATABASE_URLandKAFKA_BROKERSfor the projector.EVENT_PUBLISHER,PRODUCT_CLASSIFICATION_MODEandTASK_INTERLEAVING_MODEremain accepted but only with the valuekafka(or unset);log,permissive,off, and the earlier-removedhttpfail the boot, so a stale deployment fails loudly instead of degrading.MIGRATIONS_DATABASE_URLstill falls back toDATABASE_URL(ADR-0031). - Kafka consumers and the outbox relay always run in
cmd/execution. The relay and theWorkReleaseddead-letter writer no longer depend on a mode.cmd/mcpwritesoutbox_eventsin the use case's transaction and does not run a relay (unchanged: onlycmd/executiondrains).run()returns a non-zero error when a consumer or the relay stops on its own. /readyzis a dependency check,/healthzstays liveness./readyzis 200 only while the process is not draining, a Postgres ping succeeds and a Kafka broker answers a metadata request (and, withPATH_CATALOGUE_SOURCE=kafka, after the catalogue replay, ADR-0044). The verdict is cached for 3 s and each probe is bounded at 2 s. Otherwise it is 503application/problem+jsonof typedependency-unavailablenaming the failing dependency. It never checks a topic: the metadata request names none, so it cannot auto-create one, and the relay and DLQ writers createwarehouse.fulfillment.events,warehouse.fulfillment.analyticsand the.dlqtopic on first write (AllowAutoTopicCreation, as before). A pod that required its output topics to be ready would never receive the traffic that creates them.- The Idempotency-Key is required in every deployment.
apis/openapi.yamldeclares the headerrequired: trueonPOST /tasks;400 idempotency-key-requiredwas already the answer on Postgres and is now the only one. - A NUL (U+0000) is a client error.
rejectNULruns before routing: 404 for a NUL in the path (it names no resource), 400invalid-requestin the query, 400malformed-request-bodyin a body (raw byte or the\u0000escape; an escaped backslash followed byu0000is not a NUL). Nothing is recorded, so the Idempotency-Key stays free for the clean retry. - The contract job runs on the real runtime.
contractin CI usespostgres:16andconfluentinc/confluent-local:7.6.1service containers, waits on/readyz, passes--generation-allow-x00 false(the schema cannot say "no U+0000") and abefore_callhook that gives each request a fresh Idempotency-Key. - Helm. The chart refuses to render without
database.urlordatabase.existingSecretand withoutkafka.brokers;config.eventPublisherdefaults tokafka; the three consumer groups are chart values (the oldfulfillment-executiondefault forWORK_RELEASED_CONSUMER_GROUPis kept so committed offsets survive) andextraEnvwins when it names a group, so warehouse-infra never receives a duplicate env entry.kafka.enabledandmcp.eventPublisherare removed.
Consequences
- A broken Postgres or Kafka now takes the pod out of the Service endpoints instead of letting it accept work it cannot persist or publish. The cost is that a broker outage removes every replica from rotation, including read-only REST traffic; a flapping broker can flap readiness (the 3 s cache damps it).
- The topic convention is untouched: topics are auto-created on first write and
/readyzdoes not require them, so a fresh cluster still comes up. Consumers still need their topics to exist when they start (a kafka-go group consumer that starts before its topic exists does not pick it up later); the integration test pre-creates the three consumed topics, as the cluster does. - Local development needs Postgres and Kafka (
docker compose up, or the commands inscripts/contract-test.sh). Unit, httptest and BDD tests keep using the in-memory doubles and need nothing. - Existing deployments must provide
WORK_RELEASED_CONSUMER_GROUP,PRODUCT_CLASSIFICATION_CONSUMER_GROUPandTASK_INTERLEAVING_CONSUMER_GROUP(the chart now does by default) and must not setEVENT_PUBLISHER=log. - Out of scope and unchanged: the synchronous-edge
*_MODEvariables toward sibling contexts (LOCATION_ROLE_MODE, andFACILITY_LAYOUT_BASE_URL), the circuit-breaker behaviour, and every event schema and topic name.