Repository navigation
Run Loom on its bundled ClickHouse, a self-managed server or ClickHouse Cloud - #35
Merged
Merged
Conversation
…ckHouse Cloud The installer could only start the bundled ClickHouse, nothing created the `loom` database on any other server, and the read-only reader user existed only in the bundled server's XML, so outside it caller-shaped reads ran as the read-write user. compose.yaml becomes the one shipped stack, with ClickHouse behind the `bundled` profile; install.sh --clickhouse points it elsewhere and runs the new `loom ch-setup`, which creates the database and the reader with SQL or prints the SQL for an admin, and never replaces a user it did not make. Boot, migrate and doctor share a preflight that stops before any DDL with the fix named, checking the grants the process needs (from 26.9 the ALTER group holds the global-only ALTER HANDLER, so the migration grants name ALTER TABLE and ALTER VIEW). Table settings that came from a server-wide config file now live on the tables, and every session on a pre-26.8 server turns the query condition cache off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Loom user scoped to loom.* may not write ClickStack's default.otel_* tables, and the exporters logged a traceback on every batch; access denied now disables them with one warning, as a missing table does. The doctor no longer creates the loom database it checks for: it warns that boot will. The admin SQL grants READ ON REMOTE, since plain REMOTE on Cloud also allows writes to any host. Migration 028 also sets the dedup window on the `_`-prefixed tables the schema dump leaves out, and a test reads them from the migrations. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zlareb1
force-pushed
the
feat/clickhouse-targets
branch
from
October 15, 2026 07:28
b0894d0 to
bf9096c
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The doctor warned that boot would create a missing database even where the user may not; it now checks CREATE DATABASE and fails with the admin hint. The printed admin SQL says that it replaces any existing reader account, and the docs say the query-log grant shows every user's queries, with a row policy that keeps it to Loom's own where the server allows one. The needs-an-admin messages no longer send ch-setup's own output back to ch-setup, and name the command an installed stack runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ch-setup printed "run ch-setup --print-sql" right above the SQL it printed; the pointer now rides only the boot, migrate and doctor messages. A cap set to 0 is written as no cap and checked like the others, so lifting one rebuilds the reader instead of leaving the old ceiling. The installer takes an empty password from `user:@host` or LOOM_CH_PASSWORD= without a terminal, and the missing-database branches of the preflight are nested. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A login that may create users but not list them read "no such user" when it could not see who owned the reader, and replaced an unrelated account; ch-setup now refuses then and prints the SQL for an admin. A rerun of the installer for the same user and server keeps the password .env holds instead of asking again, so a scripted upgrade needs no terminal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The installer reused a saved password silently, for any port, even with a terminal, so a mistyped one could not be fixed by running it again; it now keeps one only without a terminal and for the same host, port and user, and says so. The docs say a worker-running process needs everything on loom.*, that a self-managed server still refuses writes through remote(), and that changing LOOM_CH_PASSWORD means running ch-setup again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a server without Keeper, any upgrade that brought a migration failed to boot: the provider fence waited for a lock that is a KeeperMap key, which cannot exist there, so no provider configuration was ever published and there was nothing to fence. Boot now migrates without it when the KeeperMap lock table is absent. Enter at the installer's rerun prompt keeps the saved password instead of replacing it with an empty one, and the prompt says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Under docker compose run the two streams are relayed apart and the reason could land between the heading and the SQL. --print-sql still writes to stdout, for piping. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The installer cut the URL at its first `/` before splitting off the user, so a raw `/` in a password put part of it in the host and in an error message; the user and password now go first, up to the last `@`. Workers booting together on a fresh Cloud service raced on CREATE DATABASE and the losers (code 341) crashed the start; a create that fails while the database now exists is not a failure. A serving process that cannot see the database says it may lack the grant, not only that it is missing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An install from before profiles had its LOOM_CH_* lines in .env ignored, because the old compose file pinned the connection; an upgrade now comments them out, so it keeps reaching the bundled server. Boot no longer runs the preflight a second time inside the migration runner. A query string after the port is ignored, and the printed stop command also stops a bundled ClickHouse left from before a switch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The upgrade commented out every LOOM_CH_* line in an old install's .env, but the old compose file pinned only the seven connection settings; tuned timeouts, pool sizes and caller-shaped caps reached Loom and now stay. The reader profile takes its caps from the client's own caller-shaped ceilings, so a new one is pinned too. A bracketed IPv6 host parses without a port, and the migration runner's flag no longer shadows the preflight module. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A refused or failed clusterAllReplicas read was taken for a single server, so a user without REMOTE on a mixed-version cluster passed as the newest version and kept the pre-26.8 condition cache on; only a missing cluster now falls back, the preflight stops otherwise, and the sessions keep the cache off. The preflight probed one system table of the many the runner reads, so a migration could fail halfway; it now names every refused one before any DDL. A password ending in a backslash broke .env's single quotes; it is written double-quoted with \, " and $ escaped, and a test reads it back through Compose. ch-setup compared the reader's values but not its MIN/MAX and CONST constraints; both are checked now, and the PTY test's child is bounded, reaped and its exit checked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since the replica check became strict, one replica that was down, or a user without REMOTE, kept even a serve-only process and `migrate --status` from starting, with a hint that blamed the host settings. The version query now skips unavailable shards, only a process about to migrate insists on every replica's version (the others fall back with a warning, and the sessions keep the condition cache off), the system-table probe runs only when migrating, and server-side errors no longer carry the connection hint. A reconnecting client gets its cache setting before other tasks can use it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A migrating boot refused to start unless every system table Loom ever reads was readable, though only the migration runner's need to be; an admin who withholds system.query_log (it shows every user's queries) got a server that would not start. The runner's tables still stop it; a refused telemetry table is a warning, and a doctor WARN. A restart with nothing pending is no longer held to the migrate-level replica check, so removing REMOTE from an up-to-date deployment does not stop it restarting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… what the server proves A reader of Loom's name is taken as Loom's only when it logs in with LOOM_CH_PASSWORD, so ch-setup never replaces another team's user or profile that happens to share the name. Replica versions must come from every configured replica: a skipped shard is unverified, not absent. Pending migrations are counted from the directory the command will apply, and an unreadable ledger or an image that ships no migration files counts as pending, so ch-setup and doctor inside the image check what the migrating boot enforces. While nothing is pending, the doctor warns of what the next migration will refuse instead of passing silently. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he server's tree Logging in with LOOM_CH_PASSWORD alone did not prove a loom_reader was Loom's: a no_password user accepts any password, and a probe that failed for another reason fell through to OR REPLACE. ch-setup now rebuilds an existing reader only when it is a password user on the settings profile of its own name and the probe actually logged in; anything else stops untouched. The recovery hint drops the profile too, since DROP USER alone left an orphan that blocked every rerun, and a reader created halfway is dropped so the next run starts clean. In the image the `loom` command imported the venv's copy of `server`, which ships no schemas/, so the CLI saw no migrations while boot did. PYTHONPATH=/app gives both one tree: doctor and `loom migrate` now judge the same journal as the server. ch-setup always checks as if a migration were pending, since preparing for the next one is its job, and the pending check reads the ledger through migrate's own reader. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a half-made one fully A read timeout or 5xx while probing the reader proved nothing about who owns it, yet ch-setup advised dropping it, the account production reads run as. Only an authentication refusal now leads to the DROP hint; any other probe error asks for a rerun. The cleanup of a reader created halfway ran both DROPs in one try, and ClickHouse checks the DROP USER privilege even for a user that does not exist, so the orphaned profile survived and blocked the rerun; each DROP now stands alone. The doctor's WARN said the same prefix and SQL pointer once per reason, and the reader-step refusal blamed user creation when the GRANT was what failed. `make dev` printed a guessed ClickHouse port without the bundled profile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ch-setup probed the reader's login before looking at whose account it was, so it signed in to a foreign no-password account, and every first run left a failed login in the server's log. Ownership is now read first and the probe runs only for an account that may be Loom's. A reader from the server's config now gets the fix for what is actually wrong: a probe error asks for a rerun and a password mismatch names the password, where both used to say to raise the XML profile. The boot log names each refusal the next migration will hit once, with one pointer to the SQL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he fix it needs check() logged what it deferred, so `loom doctor` printed every reason twice, once as a raw log line and again on its report. check() now only returns what it found, and preflight.warnings() renders it as one line that boot and `loom migrate` log and the doctor and ch-setup show. ch-setup's refusals named the wrong thing in three places: a reader it could not see the owner of hid that the probe said the password was wrong; a shared profile with no user was called an existing user; and a lowered cap was told to "raise" the XML profile. The reader step now handles a missing reader first and creates it straight away, so each later branch only deals with an account that exists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…SER opt out The health fix for a refused reader told every operator to install the bundled server's XML and restart ClickHouse, which Cloud cannot do and a self-managed server need not: `loom ch-setup` is the fix now everywhere but the bundled server. Compose's `:-` turned an empty LOOM_CH_READER_USER back into loom_reader, so the documented opt-out never took effect; `-` keeps an empty value. The preflight logged two raw driver errors of its own beside the line boot prints, so those go. Its warning says "the next migration" rather than "boot", since `loom migrate` prints it too; ch-setup names the GRANT for an unreadable telemetry table instead of pointing at itself, and flushes its progress before each refusal so a pipe keeps the order. A reader that may be missing is no longer reported as having a wrong password. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The empty value was documented as the opt-out, but ch-setup still read it as "use loom_reader", and the installer runs ch-setup on every install: a user who may not create users failed the install over a reader it would never use, and one who may got a second login on the shared password it had opted out of. Set but empty now skips the reader, in the printed SQL as well; unset still means the default reader. The boot test runs the real check so a log line put back inside it would fail it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…igned to others Dropping skip_unavailable_shards from the replica query still left it to the user's profile, which can turn it on and silently omit an unreachable replica from both the preflight and the condition-cache check; the query now sets it to 0 itself. A settings profile can reach other accounts by direct assignment (TO user, role or ALL) as well as by inheritance, and ch-setup only looked at inheritance, so it could replace another account's limits; such a profile is now foreign. The recovery hint quotes the reader's name, as the setup SQL does, so a hyphenated name runs as printed. The analyzer corpus still imported migrate._applied, and the dropped- response retry test read the server default window, which migration 028 no longer changes, so it skipped; it now reads the table's own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…for both The admin SQL grants SELECT on system.processes, which Loom needs to see whether its own provider statements still run, and which shows every user's running queries with their literals as query_log shows past ones. Only query_log was named, so an operator who applied the row policy would think the exposure closed; the docs and the SQL comment now name both, and the policy covers both tables. A unit assert pins skip_unavailable_shards = 0 in the replica query, so dropping it fails a test; two docstrings no longer describe a warning that is not logged and a server config this branch removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…say about --env-file ch-setup confirmed the reader could read loom.* but not that this was all it could do, so a reader someone had widened to SELECT ON *.* passed as ready while the docs promised it cannot read system.query_log. The check now reads the reader's own SHOW GRANTS and expects that one grant; a wider reader in ch-setup's shape is rebuilt like any other drift. With compose.yaml at the root as the first file, Compose finds the root .env itself, so the docs no longer call --env-file required; only the cloud stack, whose first file is under dev/, needs it. The condition cache note names where the guard lives, the reader step's docstring says what it settles before replacing anything, and the profile rows are a small NamedTuple rather than positional tuples. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… check's edges Since the reader is held to SELECT on loom.* alone, a role, grant or REVOKE an admin gives it is undone the next time ch-setup runs, which the installer does on every install and upgrade; the docs said only a profile mismatch was rebuilt. They now say so. The grant check's test now covers a reader name ClickHouse quotes and a narrowed reader. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the installed .env belongs The block-column test named memory and memory_embeddings by hand; the server-wide XML that gave every table those columns is gone, so a new lightweight UPDATE on another table would quietly become a mutation per call. The test now takes the tables from the UPDATE statements in the analyzer corpus. A reader login that lands as another user (an auth mapping) is reported as that, not as a caps mismatch; the docs say the installed .env is read by Compose, whose escapes python-dotenv reads differently; env.example says how to switch a bundled install by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The installer honoured LOOM_PORT, LOOM_BIND_HOST and LOOM_IMAGE_REPOSITORY from the shell for its own run but left .env on the template's 7777 and the public image. Every later `docker compose` in the install directory, including the `ch-setup` rerun the installer prints, then bound 7777 and pulled the public image: on a host whose 7777 is taken by another Loom, a test install's bare `compose up` tried to publish on that port. The values given now go into .env, a rerun without them keeps them, and the health check reads the port from .env. A value .env cannot hold as written is refused before anything is written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With LOOM_BIND_HOST now kept in .env, every rerun of an install bound to a specific address waited three minutes on 127.0.0.1 before calling a healthy Loom unhealthy; the health check polls the published address (bracketed for IPv6), loopback when bound to every interface. A port outside 1-65535 passed the digits check and only failed at `compose up`, after .env was written; it is refused up front. The server stops warning on every boot about the Compose-only names an install's .env now carries. The docs say an install from an earlier release passes its port once more on upgrade, and the CHANGELOG lists the change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ress, and name ch-setup before a prepared start Docker publishes `::` on IPv6 only, so polling 127.0.0.1 for it timed out on a healthy Loom; it polls [::1] now. The dashboard line printed 127.0.0.1 whatever the bind address, and now prints the address polled. A prepared install (LOOM_SKIP_START=1) on an outside ClickHouse exited without saying the reader still had to be created, so the documented pull and up left every caller-shaped read failing; the installer and the quickstart name `ch-setup` as the step before `up`. The quickstart says a non-loopback LOOM_BIND_HOST needs LOOM_PUBLIC_BASE_URL and sign-in first, and the deployment docs give the order for a cap change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…L .env cannot hold The replica and runner-table checks relaxed when nothing was pending, but the DDL grants stayed strict, so an up-to-date deployment on a DML-only user that booted on main stopped booting. They are now checked like the others: refused while a migration is pending, a doctor warning otherwise. A ClickHouse user or host from the URL went into .env as written, so a `$` or space there reached Loom mangled; both are now held to what .env and ch-setup's SQL take. Boot logs the preflight reason before the traceback, the docs give a failure-free order for raising and lowering a cap, the cloud stack's mount is named again, and the checkout recreate commands start the bundled profile like `make dev`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the grants it misses Deferring them while nothing was pending let a DML-only user boot, but the running server's workers set retention TTLs, compact, refresh views and rebuild provider tables on those same grants, so it failed later on every pass instead of once at boot. The check is strict again; only the replica and runner-table checks, which only migrations use, relax. A refusal now names just the grants the user is missing rather than the whole set, so it no longer reads as if SELECT and INSERT were revoked, the warning line keeps each reason's own SQL advice apart, and brackets in a ClickHouse host are accepted only around an IPv6 address. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n version out of Compose The migrate check said the workers' grants were covered, but the set held only the migrations' privileges: a user with exactly those passed the preflight and the doctor, then compaction (OPTIMIZE), the provider rebuild (TRUNCATE) and view retirement (SYSTEM REFRESH VIEW) failed on every pass. They are in the set now; GRANT CURRENT GRANTS ON loom.* covers them on Cloud and on a self-managed server. The installer left its own LOOM_VERSION and an exported COMPOSE_PROJECT_NAME in the environment, where Compose prefers them to .env: a `v`-prefixed version pulled a tag that does not exist, and `latest` started a different image from the one .env pins. Both are unset with the other target settings. oldest_version records what a strict check would refuse instead of check() asking the server twice, and the one-function vector_floor module moves into ch.py, its only caller. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 tasks done
…r one that migrates The workers' OPTIMIZE, TRUNCATE and SYSTEM REFRESH VIEW sat in the migrate set, so a standalone `loom migrate` refused a migration-only user over grants no migration uses, while a server with boot migrations off and its workers on passed the check and failed on every worker pass. They are their own set now, checked whenever the process may run the workers (any LOOM_BACKGROUND_WORKERS but off, not a read replica), and by ch-setup, which prepares for a full server. The narrower SYSTEM REFRESH VIEW replaces the SYSTEM VIEWS group. The replica refusal names the call it could not run, the condition-cache probe tags its query, the deployment docs list the grants each process is checked for, and the CHANGELOG says what an upgrade on an outside ClickHouse needs first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The worker grants followed LOOM_BACKGROUND_WORKERS and the DDL grants followed LOOM_BOOT_MIGRATE, but neither matched what runs: provider rebuilds (CREATE, TRUNCATE, DROP) run in any process that can win the configuration lock, workers off or not, and a workers container with boot migrations off sets retention TTLs with ALTER TABLE, so following the documented grants left retention silently unenforced. Every process but a read replica is now checked for the DDL grants plus OPTIMIZE, TRUNCATE and SYSTEM REFRESH VIEW; LOOM_BOOT_MIGRATE only decides whether it creates the database and reads what the migrations read. The workers flag goes, the preflight's own queries carry a query tag, and the docs and CHANGELOG say which grants every boot needs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thout SYSTEM REFRESH VIEW `need="migrate"` had come to mean any Loom server but a read replica, so boot passed need="migrate" with migrates=False; the levels are now server, replica and read, and `migrates` alone decides what only a migrating process does. SYSTEM REFRESH VIEW's one runtime user tolerates a refusal (the scheduled refresh removes the rows), so lacking it is a warning instead of a stop. The installer keeps LOOM_CLICKHOUSE_IMAGE in .env as it does the Loom image, so a later bare `up` does not move the bundled server back to the pinned release over the same data. An OTel exporter that disables itself for want of the ClickStack tables says so at INFO unless the ClickHouse exporter was chosen. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once the grant became a warning, ch-setup, the installer's only check, stayed silent about it while migrate and the doctor warned, so an install finished without hearing of it. It now prints the grant to run, like an unreadable telemetry table. Test names use the server and replica terms, the exporter's test moves beside the other exporter tests, and the grant's comment and the docs read cleanly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The installer keeps LOOM_CLICKHOUSE_IMAGE in .env, so a bare `up` never moves the bundled server off the release it ran, but the docs said only the port and Loom image were kept and that a newer Loom moves ClickHouse. The quickstart, CHANGELOG, environment reference and upgrade guide now say the saved line pins ClickHouse until it is deleted, and that one left exported in the shell is written back. The condition-cache tests move beside the code they test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The quickstart now names it as an installer variable, and the docs test counts only settings fields and the listed Compose and installer names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eplica retry The reader probe opened its own client without a query tag, so its statements reached query_log unattributed. The installer read COMPOSE_PROFILES with any quotes Compose accepts, so a hand-quoted "bundled" was taken for an outside server and ch-setup ran against a ClickHouse that was never started. A replica that does not answer during a rolling upgrade now says to retry once every replica is up, like every other refusal names its fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… out the CHANGELOG A reader rebuilt for new caps leaves the running server's sessions on the old ones until it is recreated, and its caller-shaped reads fail on the bounds meanwhile; ch-setup now says so where it rebuilds. A read-only `loom migrate --status` no longer warns about telemetry tables it never reads. The installer reads an unquoted .env value without a trailing comment, as Compose does, and prints a stop command with the bundled profile only for a bundled install. The boot reader probe carries a query tag. The CHANGELOG lists the image's `loom migrate` fix and the exporters' quieter self-disable, as one list each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…te hint only after a caps rebuild Dropping --profile bundled from the stop hint for an outside ClickHouse left a bundled server from before a switch running, and `down` then failed on its network; the profile only adds a stop for that container. The recreate hint came before the rebuild ran, and on rebuilds that changed no caps; it now follows a successful rebuild for a profile mismatch. A reader statement the server rejects for another reason than access is one refusal line, not a traceback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e who owns the reader A caller-shaped cap below its floor, or negative, was pinned as a constraint with its maximum under its minimum, so ch-setup reported the reader ready while every caller-shaped read then failed; it is refused with the value to use instead. The admin SQL now also grants SELECT on system.users and the settings-profile tables ch-setup reads to tell who owns a reader of the name, which it otherwise could never do without an admin, and the refusal names those tables. Driver errors reach every refusal as the server's own first line, without the driver's prefix and URL. After the admin path, ch-setup says to recreate Loom if the caps changed; the doctor names a URL given as LOOM_CH_HOST and grades a skipped preflight as a warning. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…estore two lost notes The ownership-table grants never let a user made by the admin SQL do anything: creating or replacing the reader takes global privileges it does not hold, while the grants showed it every account and settings profile on the server. They go, and the refusal says an admin has to run the SQL. The recreate hint after the admin SQL appears only when a reader already existed. The caps' floors live in one place for the profile and the check. Two notes the requirements rewrite dropped come back: how long a run id claim key lives, and what the reader probe reports before migrations have run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…at exists A Loom user made by the admin SQL cannot see who owns the reader, so a first install took that path and was told to recreate Loom after a cap change that never happened. The hint now needs a reader that logged in. The CHANGELOG says the installer replaces the old top-level config with the bundle's copies, as every rerun did, rather than moving it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the cache probe's error plainly The rebuild hint told an installer run to recreate Loom, which the installer's own `up` had just done; it now says so, like the admin-SQL path. The condition-cache probe's failure log uses the server's first line instead of the driver's prefix and URL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # tests/unit/test_schema_baseline.py
Main took 031 for the run budgets, so the table settings migration becomes 032; it was never applied under 031 outside this branch's test stacks. 031 only alters loom.agent_runs, which 032 already covers. The analyzer's shapes file is regenerated for the merged schema dump, and the CHANGELOG main removed stays removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zlareb1
added a commit
that referenced
this pull request
Oct 16, 2026
Main added 032_table_settings.sql (#35), so entity_triple_rows, projection_failure_abandoned, entity_triple_seen_at and graph_restore_id move to 033-036 and the row-links migration name follows; the statement corpus is re-rendered for the merged schema dump. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Loom only installed with its own ClickHouse container. The installer's compose file hard-coded
LOOM_CH_HOST: clickhouseand always started the bundled server. Pointed at a fresh self-managed server or a new Cloud service, the first connect failed withUNKNOWN_DATABASE, because nothing created theloomdatabase. The read-onlyloom_readeruser only existed in the bundled server's XML, so everywhere else the caller-shaped reads ran as the read-write user.This PR supports three targets: the bundled container (still the default), a self-managed server, and ClickHouse Cloud.
What changes
One compose stack
compose.yamlat the repo root replacesdeploy/standalone/compose.yaml. Theclickhouseservice sits behind abundledprofile, and Loom'sdepends_onisrequired: false(Compose 2.20+), so the stack works without it.LOOM_CH_*come from.envand default to the bundled service.The release bundle now has the same layout as the repo (
compose.yaml,deploy/clickhouse-config/,deploy/lemmagen3/), so a clone and~/.loomrun the same file.dev/docker-compose.dev.ymlbecomes an override on top of it for source builds.dev/docker-compose.cloud.ymlkeeps its web + workers shape.Installer
install.shwith no flags is unchanged: bundled ClickHouse.install.sh --clickhouse <url>(orLOOM_CH_URL) writesLOOM_CH_*to.env, emptiesCOMPOSE_PROFILES, and runsloom ch-setupbeforeup.LOOM_CH_PASSWORD, or a silent prompt. It goes only into.env(mode 600, escaped so Compose reads it back exactly) and is never printed. A rerun for the same server keeps it.LOOM_PORT,LOOM_BIND_HOST,LOOM_IMAGE_REPOSITORYandLOOM_CLICKHOUSE_IMAGEpassed to the installer are saved in.env. Before, a laterdocker compose upin the install directory went back to port 7777 and the public image..envand volumes, getsCOMPOSE_PROFILES=bundled, and has its config moved underdeploy/.loom ch-setupCreates the
loomdatabase andloom_reader. The reader getsSELECTonloom.*and nothing else, plus a profile that pins the caller-shaped caps asMIN/MAXconstraints. It is safe to rerun: an unchanged reader is left alone, and a drifted one is rebuilt.If the user can't do a step, it prints the SQL for an admin with the password as a placeholder.
--print-sqldoes that without connecting. The SQL usesGRANT CURRENT GRANTS ON loom.*because Cloud rejectsGRANT ALL, andREAD ON REMOTEbecause plainREMOTEon Cloud also allows writes to other hosts.It never takes over someone else's account. An existing
loom_readeris only replaced if it looks like onech-setupmade (a password user on its own profile, not shared) and logs in withLOOM_CH_PASSWORD. Ownership is checked before logging in as it. SettingLOOM_CH_READER_USER=to empty skips the reader, and the reads run as the Loom user.Preflight
Boot,
loom migrate,loom doctorandch-setupshare one set of checks. Each runs before any DDL and stops with a one-line fix:loomdatabase (created where this process migrates and the user may)Grants depend on the process. Anything other than a read replica needs the DDL grants plus
OPTIMIZEandTRUNCATE, whether or not it runs migrations, because it also sets retention TTLs, compacts and rebuilds provider tables. A missingSYSTEM REFRESH VIEWis only a warning. A read replica needsSELECT, INSERT, ALTER UPDATE, ALTER DELETE.The replica-version and system-table checks are only strict while a migration is pending, so an up-to-date server still restarts if those reads get narrowed.
loom doctorwarns about what the next migration will refuse.Less server config
032_table_settings.sqlsetsnon_replicated_deduplication_window = 1000on every MergeTree table, so a retried insert lands once on any server. It also turns on block numbers forloom.memoryandloom.memory_embeddings, the two tables updated with lightweightUPDATE.merge_tree_settings.xml, which set these server-wide, is gone.Before 26.8 a vector read can poison the query condition cache (ClickHouse #112086). That used to be handled only on the bundled server. Now every Loom session turns the cache off when any replica is older than 26.8.
Smaller fixes
loom migrateandloom ch-setupimported the venv's copy ofserver, which has noschemas/, and failed with "migrations directory not found". The image now setsPYTHONPATH=/app.default.otel_*.Version policy
26.4 is the floor because it's the oldest release that applies every migration: 26.3 fails on
stem()and 25.12 on the text index. During a Cloud rolling upgrade, replicas can answer on two versions and the older one still runs DDL, so the oldest replica is what counts. CI tests the latest release, and a release bundle pins the release it was built against. Newer features (the Quantized codec,aiEmbed, lightweightUPDATE) are still detected where they're used.Choices worth knowing
.env, not two compose files or a rewritten file.LOOM_CH_PASSWORD, as the bundled reader already does, so there's still only one secret.system.query_logandsystem.processes, which show other users' queries. Loom needs both. The docs give a row policy to narrow them on a self-managed server; Cloud doesn't allow one on system tables.loom_readerbelowSELECT ON loom.*is left for later. It matches main's reader today.Tested end to end
memory.aggregateran asloom_reader;.envis 600loomdatabase, password with$and:UPDATEworks; condition cache offloom_reader.envand volumes kept; old memory reads back; 032 applied; reader worksloom_readeron all three targets (system.query_log)make format,make lint,make typecheck,make test-unitandmake schema-checkpass.🤖 Generated with Claude Code