Architecture / Decision records / ADR-HIS-043
ADR-HIS-043 Local integration environment per session¶
| Status | Accepted |
| Decided | 2026-11-24 by session FN-S02 |
| Record | Drafted 2026-11-24; approved 2026-11-24 by the product owner |
| Where the rule lives | platform/dev-environment/ (its README.md, compose.yaml and his-env); the agent instruction file CLAUDE.md, section 3 |
Context¶
The session plan runs several agent sessions on one server, each in its own git worktree (session rule 10). Build sessions need a PostgreSQL to run their unit and contract tests against. Integrate and gate sessions need every backing service a slice uses: the event backbone with its schema registry, the identity provider, the secrets store and the telemetry stack. Card FN-S02 sets three requirements. Each session's environment is separate, named after the session (HIS_SESSION, COMPOSE_PROJECT_NAME). No environment publishes a fixed host port. Resetting one environment leaves the others untouched.
Production runs on Kubernetes (RKE2, ADR-HIS-004), with the products the technology stack selects. The local environment is development and integration (architecture section 10.2): synthetic data only, with credentials of its own.
Options considered¶
- Runtime: Docker Compose, one project per session; or a local Kubernetes cluster per session (kind or k3d); or one shared set of backing services with a database and a topic prefix for each session.
- Telemetry: the separate OpenTelemetry collector, Prometheus, Loki, Tempo and Grafana containers; or Grafana's
grafana/otel-lgtmimage, which runs the same products in one container. - Host ports: fixed ports offset per session; ports Docker assigns at publish time; or ports picked from free ones at start.
Decision¶
- Docker Compose, one project per session. The environment is
platform/dev-environment/compose.yamland is always run throughplatform/dev-environment/his-env(start,smoke,env,status,stop,reset,psql,compose). The project name isCOMPOSE_PROJECT_NAME, which must equalhis-followed byHIS_SESSIONin lowercase: the value the launcher sets. A value that differs is refused, so a variable left over from another session cannot act on that session's environment. Every container, volume and network is prefixed with that name and labelledcare.cema.his.session=<HIS_SESSION>. - Two profiles.
lightis PostgreSQL alone, for unit and contract tests against stubs.fulladds Kafka in KRaft mode (Apache'sapache/kafkaimage) with Apicurio Registry 3, which stores its data in the session's PostgreSQL. It also adds Keycloak with the synthetic realmhis, OpenBao in development mode, andgrafana/otel-lgtm.startdefaults tolight. - Images pinned by version and digest in
compose.yaml: PostgreSQL 18.7, Kafka 4.3.2, Apicurio Registry 3.3.4, Keycloak 26.8.1, OpenBao 2.6.6, otel-lgtm 0.41.0. A version is changed in that file and checked with the smoke check and the isolation check. - No fixed host port, loopback only. Every port is published on
127.0.0.1. Docker assigns the host port at publish time, except for Kafka's host listener and Keycloak. Those two must know their own address (the advertised listener, the token issuer), sohis-envpicks a free port for each when the session first starts and keeps it in.state/<project>.env.his-env envprints every address asHIS_*lines, for tests and services to read. Containers on the session network use the service names (postgres:5432,kafka:9092,schema-registry:8080,keycloak:8080,secrets:8200,telemetry:4317). - One database per unit. On every start,
his-envcreates one database for each folder underservices/(except_template). The database takes the folder name in snake case, asCLAUDE.mdsection 4 requires, and is owned by a login role of the same name and password. Every other role is refused access to it. - Kafka topics are not created on first write (
auto.create.topics.enable=false), as in production: whoever owns a topic creates it. - Reset removes the session's containers, networks and volumes, then anything else that carries its project label, and its state file. It checks that nothing with that label is left. It never touches another project.
- Checks.
his-env smokechecks every service of the profile from the host, the way a test reaches it, and also checks the naming, the labels and the loopback-only ports.test/isolation-check.shruns the session's environment and a twin (<HIS_SESSION>-twin) side by side, smoke-checks both, resets the twin, and verifies that the session's environment is unchanged.
Rationale¶
Compose gives each session its own containers, network and volumes under one name, with one command to start and one to remove. It starts the full profile in about a minute and uses about 2 GB of memory (its limits add up to 5 GB), so several sessions fit on one server. A Kubernetes cluster per session would match production more closely but would cost several times the memory and start-up time. It would also add little to the unit, contract and integration tests the sessions run, since the Kubernetes deployment is the work of the platform sessions (platform/deployment-topology/). A shared set of services cannot be reset for one session without touching the others.
grafana/otel-lgtm runs the same products as technology stack row 15 (the OpenTelemetry collector, Prometheus, Loki, Tempo and Grafana). It takes one container instead of five and starts with Grafana already connected to the three stores. The services send the same OTLP that production receives. Only the arrangement of the stack differs, and that is the observability unit's concern.
Ports chosen by Docker cannot collide between sessions. The two services that must advertise their own address need a port known before they start. A free port chosen at start, retried if it is taken, is the least that works.
Consequences¶
- Build sessions set
HIS_SESSIONandCOMPOSE_PROJECT_NAME(the launcher does) and runplatform/dev-environment/his-env startin their checkout. Their tests read theHIS_*variables ofhis-env env, never a fixed address. - A new unit folder under
services/gets its database on the nextstart, without a change here. - The environment is not production-like for security. Credentials are known development values. OpenBao runs unsealed and in memory. Keycloak has no MFA and no directory federation, and the realm holds only synthetic users with no roles: access decisions come from the policy decision point, which is not part of this environment. All of this is for local development with synthetic data only (architecture section 10.2).
- The policy decision service (Open Policy Agent), the API gateway (APISIX), the integration engine and the object store are not in the environment. A later card that needs one adds it to
compose.yamlas a further profile or service, under the same naming rules. - Image versions are pinned by digest. Upgrading one is a change to
compose.yamlthat passes the smoke check and the isolation check. The pipeline of FN-S05 enters the images in the software bill of materials and scans them (DEP-004).