Skip to content

The Helm chart runs Loom with an external Postgres as the memory authority, and an overlay sets up ClickHouse Cloud plus Managed Postgres - #467

Merged
zlareb1 merged 14 commits into
mainfrom
feat/clickhouse-cloud-profile
Nov 10, 2026
Merged

zlareb1 merged 14 commits into
mainfrom
feat/clickhouse-cloud-profile

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #450
Related: #461

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The Helm chart takes a postgres block that runs Loom with an external Postgres as the memory authority over verify-full TLS, and values-clickhouse-cloud.yaml with a guide sets up ClickHouse Cloud plus ClickHouse Managed Postgres.

Why

The chart had no Postgres values. An operator could pass LOOM_PG_DSN only through env or secrets.extra. Those routes did three things wrong:

  • the password sat inside the DSN;
  • nothing mounted the CA that sslmode=verify-full needs;
  • hook Jobs and the analytics export got whatever the operator remembered to repeat.

There was also no documented, tested way to run Loom on the two managed services. This PR adds one postgres: block to the chart and an overlay and guide for ClickHouse Cloud plus Managed Postgres with two HA standbys.

Design

  • Values.
    • postgres: {host, port, database, user, passwordSecret {name, key}, caSecret {name, key}, durability, poolMaxSize}.
    • host: "" keeps the ClickHouse authority, and the default render is byte-identical to main's.
    • A release upgraded with --reuse-values from a chart without the block renders as before.
  • What postgres.host renders. These go into every pod that gets loom.config: web, workers, the three hook Jobs and the analytics export. They come through shared helpers (loom.postgres, loom.pgEnv, loom.pgVolume, loom.pgVolumeMount), so no pod kind can miss one.
    • LOOM_STORAGE_AUTHORITY=postgres, LOOM_PG_DURABILITY and LOOM_PG_POOL_MAX_SIZE, in loom.config.
    • LOOM_PG_DSN=postgres://<user>@<host>:<port>/<db>?sslmode=verify-full&sslrootcert=/etc/loom/pg-ca/<key>. It holds no password.
    • PGPASSWORD from secretKeyRef. asyncpg reads it when the DSN has none, so the password never appears in the pod spec and needs no URL encoding.
    • The CA Secret's one key, mounted read-only at /etc/loom/pg-ca.
    • With networkPolicy.enabled, egress to postgres.port.
  • Refusals.
    • The chart refuses to render without postgres.passwordSecret.name or postgres.caSecret.name. verify-full cannot run without a CA.
    • It refuses a host, database or user outside letters, digits, ., _ and -, since those go into the DSN as written. It also refuses a port that is not 1 to 65535, and a password or CA Secret key outside the characters Kubernetes allows in one. A poolMaxSize below LOOM_PG_POOL_MIN_SIZE is left to the boot, which fails closed; values.yaml states the rule.
    • It also refuses when env, extraEnv, secrets.extra or settingsFile sets a name it renders: LOOM_STORAGE_AUTHORITY, LOOM_PG_DSN, LOOM_PG_DURABILITY, LOOM_PG_POOL_MAX_SIZE or PGPASSWORD. Set twice, one value would silently win.
    • The rendered env wins over existingSecret and envFrom, as Kubernetes orders them. The guide says so.
  • Overlay. values-clickhouse-cloud.yaml layers on values-eks.yaml (-f values-eks.yaml -f values-clickhouse-cloud.yaml).
    • It adds the postgres block, with durability: synchronous (the service's two HA standbys) and Secrets loom-postgres and loom-postgres-ca.
    • It sets poolMaxSize: 5 and webWorkers: 2. Two is what the image picks for the chart's 2-CPU limit. It is stated so the documented connection count (70) is explicit.
  • Guide. docs/operations/clickhouse-cloud.md links the pages that own each part instead of repeating them: postgres.md, kubernetes.md, deployment.md and sql-surface.md. It states:
    • the services, including the pg_read_all_stats grant for the standby check;
    • what goes into the CA bundle: every published root, as PEM, with the DER conversion and an openssl verify -no-CApath -no-CAstore … -verify_hostname pre-check;
    • the install, and what the chart renders and refuses;
    • the connection budget, given as guidance and not enforced by the chart;
    • the checks after the install;
    • password and CA rotation, and what the rotation window answers;
    • the SQL surface user, made with kubectl exec -i and the admin password on stdin from a file.
  • Cut from the design on purpose. A Postgres owner-role scheme, an ownership boot check, a chart-enforced connection budget and a SQL-user hook Job were each designed and then removed. Every one added state that review rounds kept finding holes in, and the brief asks for none of them.

Scope and risk

  • Touches:
    • deploy/helm/loom: values.yaml, _helpers.tpl, hooks.yaml, analytics-export.yaml, networkpolicy.yaml and the new overlay;
    • scripts/gates/helm_postgres.py with tests/unit/test_helm_postgres.py;
    • the CI helm job (it now lints and kubeconforms the EKS plus Cloud overlay and runs the gate);
    • the guide and its links (index, kubernetes.md, postgres.md, llms.txt);
    • .claude/rules/helm.md.
  • No server code changes.
  • Risk: with postgres.host unset, nothing changes. The renders of both existing overlays, with and without every optional object, are identical to main's.
  • Coordination: the bundled postgres:16 another change is building for the chart fills this same block.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none for an existing release. A Postgres deployment sets postgres.* at install, on an empty ClickHouse.
  • Rollback: revert. A release installed with postgres.host cannot drop the block: its deployment recorded the Postgres authority.

Tests

  • scripts/gates/helm_postgres.py, run by tests/unit/test_helm_postgres.py and the CI helm job, renders the chart.
    • With the Cloud overlay and every optional object on, every configured pod has:
      • the password-less verify-full DSN;
      • PGPASSWORD from the Secret;
      • the CA mounted read-only at the path sslrootcert names, from the caSecret key.
    • The NetworkPolicy allows 5432, and postgres.port=6432 reaches the DSN and the policy as the same number.
    • With the defaults and with the EKS overlay, no pod carries any of it and 5432 is not opened.
    • Every refusal, by its message.
    • With networkPolicy.enabled=false, the egress-only policy is the same with and without the block.
    • The gate fails against main's chart (KeyError: 'LOOM_STORAGE_AUTHORITY') and passes here.
  • helm lint --strict and kubeconform -strict pass on the EKS, kind, and EKS plus Cloud overlays, with and without every optional object.
  • A live boot with the chart's env. The setup: local postgres:16 with a synchronous standby (dev/ci_start_postgres.sh), the primary serving TLS from a throwaway CA, and an empty ClickHouse 26.10. The server ran with the exact env the chart renders: password-less sslmode=verify-full DSN, PGPASSWORD, LOOM_STORAGE_AUTHORITY=postgres.
    • Boot migrated Postgres, and GET /v1/health?include=postgres answered storage_authority: postgres, pg_ok: true, standby: synchronous. pg_stat_ssl showed TLS on every Loom connection.
    • A memory.set landed in loom.memory_current and read back.
    • Wrong CA bundle: the boot failed with SSLCertVerificationError and exited.
    • Rotation window. I ran ALTER ROLE … PASSWORD and dropped the server's connections. memory.set answered 500 and the log showed InvalidPasswordError. With the password restored, the next call succeeded.
    • The guide's kubectl exec grant form, run as the same sh -c 'read -r LOOM_CH_PASSWORD; …' with the password on stdin, created and then revoked an SQL user. Only the inner sh -c ran here, not kubectl exec against a cluster.
  • Unit: the new test, test_helm_metadata_egress.py, test_doc_links.py, test_public_copy.py, test_agent_instructions.py and test_docs_reference.py pass.
  • Not tested against the real services:
    • ClickHouse Cloud and Managed Postgres themselves;
    • the pg_read_all_stats grant on Managed Postgres;
    • the service's certificate chain and published roots;
    • the direct host's name;
    • an install on a real EKS cluster, including a boot as the pod's non-root user on its read-only root filesystem (the live boot ran the chart's env, not its security context).

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. The design was reviewed to zero findings by an architect subagent before coding. The render gate, the overlay renders and the live boot above were run here.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 14 commits November 10, 2026 04:10
…ority, and an overlay sets up ClickHouse Cloud plus Managed Postgres

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The overlay states the web process count the image picks for the chart's limits, and
the budget follows; the chart refuses DSN fields it would pass through unescaped and a
pool smaller than its minimum; the docs say what the boot refuses and warns about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The chart refuses the block's settings in settingsFile too, a port that is not a port
number, and a pool smaller than the minimum the server will read; the NetworkPolicy
always lists the Postgres port; the docs grant pg_read_all_stats and name namespaces in
the SQL user example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The pool's minimum is left to the boot, which fails closed, and values.yaml states the
rule; the Postgres page says the chart sets the settings, not the service; the helm rule
names the list the block's refusals share.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The NetworkPolicy comment lists the Postgres port; the gate renders the env route that
works without the block; the CA check names OpenSSL 3; the exec example names the
Deployment it holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The port is refused with a leading zero and rendered as a number in the DSN and the
NetworkPolicy; the guide says the pods refuse to start on a ClickHouse that holds memory;
the gate's default render has the policy on, so its port check can fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The port check caps the digits, so an overflowing number is refused, and the gate
renders another port into the DSN and the policy; each Secret gets its own
ExternalSecret; the guide lists every refusal; values.yaml names the third overlay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The guide says what a commit answers while standbys are missing; the Secret names and
keys render quoted; the durability comment names local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The chart refuses an empty or malformed Secret key for the password and the CA, and
the NetworkPolicy comment reads as one paragraph.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The Secret key check refuses '.' and keys starting '..', as Kubernetes does; the guide
points to the block's comments for the refusal rules instead of listing them; the gate
renders every route the refusals cover without the block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The gate renders a release with no postgres key; a host, database or user that is not a
string is refused rather than printed into the DSN; the block's comments name the names
the chart refuses; the guide says what a busy pool answers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The guide says when the old CA Secret can go, and states the pool bound once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The CA steps name ca.crt as the file the check reads and the Secret holds, and where
leaf.pem and chain.pem come from.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The gate's refusal renders take the same required values as its other renders, so the
refusal under test is the only reason one can fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit a3e6f4a into main Nov 10, 2026
32 of 34 checks passed
@zlareb1
zlareb1 deleted the feat/clickhouse-cloud-profile branch November 10, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant