Skip to content

Run Loom on its bundled ClickHouse, a self-managed server or ClickHouse Cloud - #35

Merged
zlareb1 merged 55 commits into
mainfrom
feat/clickhouse-targets
Oct 16, 2026
Merged

zlareb1 merged 55 commits into
mainfrom
feat/clickhouse-targets

Conversation

@zlareb1

@zlareb1 zlareb1 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Why

Loom only installed with its own ClickHouse container. The installer's compose file hard-coded LOOM_CH_HOST: clickhouse and always started the bundled server. Pointed at a fresh self-managed server or a new Cloud service, the first connect failed with UNKNOWN_DATABASE, because nothing created the loom database. The read-only loom_reader user 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.yaml at the repo root replaces deploy/standalone/compose.yaml. The clickhouse service sits behind a bundled profile, and Loom's depends_on is required: false (Compose 2.20+), so the stack works without it. LOOM_CH_* come from .env and 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 ~/.loom run the same file. dev/docker-compose.dev.yml becomes an override on top of it for source builds. dev/docker-compose.cloud.yml keeps its web + workers shape.

Installer

  • install.sh with no flags is unchanged: bundled ClickHouse.
  • install.sh --clickhouse <url> (or LOOM_CH_URL) writes LOOM_CH_* to .env, empties COMPOSE_PROFILES, and runs loom ch-setup before up.
  • The password comes from the URL, 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_REPOSITORY and LOOM_CLICKHOUSE_IMAGE passed to the installer are saved in .env. Before, a later docker compose up in the install directory went back to port 7777 and the public image.
  • The health check polls the address Loom is actually published on.
  • An existing install keeps its .env and volumes, gets COMPOSE_PROFILES=bundled, and has its config moved under deploy/.

loom ch-setup

Creates the loom database and loom_reader. The reader gets SELECT on loom.* and nothing else, plus a profile that pins the caller-shaped caps as MIN/MAX constraints. 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-sql does that without connecting. The SQL uses GRANT CURRENT GRANTS ON loom.* because Cloud rejects GRANT ALL, and READ ON REMOTE because plain REMOTE on Cloud also allows writes to other hosts.

It never takes over someone else's account. An existing loom_reader is only replaced if it looks like one ch-setup made (a password user on its own profile, not shared) and logs in with LOOM_CH_PASSWORD. Ownership is checked before logging in as it. Setting LOOM_CH_READER_USER= to empty skips the reader, and the reads run as the Loom user.

Preflight

Boot, loom migrate, loom doctor and ch-setup share one set of checks. Each runs before any DDL and stops with a one-line fix:

  • address and credentials
  • the oldest replica's version: 26.4 or newer, with every replica asked
  • the loom database (created where this process migrates and the user may)
  • grants
  • the system tables the migrations read

Grants depend on the process. Anything other than a read replica needs the DDL grants plus OPTIMIZE and TRUNCATE, whether or not it runs migrations, because it also sets retention TTLs, compacts and rebuilds provider tables. A missing SYSTEM REFRESH VIEW is only a warning. A read replica needs SELECT, 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 doctor warns about what the next migration will refuse.

Less server config

032_table_settings.sql sets non_replicated_deduplication_window = 1000 on every MergeTree table, so a retried insert lands once on any server. It also turns on block numbers for loom.memory and loom.memory_embeddings, the two tables updated with lightweight UPDATE. 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

  • In the image, loom migrate and loom ch-setup imported the venv's copy of server, which has no schemas/, and failed with "migrations directory not found". The image now sets PYTHONPATH=/app.
  • The release job checks the bundle against the builder's own file list instead of a hand-kept one.
  • The OTel exporters turn themselves off quietly when the Loom user can't write 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, lightweight UPDATE) are still detected where they're used.

Choices worth knowing

  • One switch: a Compose profile in .env, not two compose files or a rewritten file.
  • The reader shares LOOM_CH_PASSWORD, as the bundled reader already does, so there's still only one secret.
  • No Keeper is a warning, not a stop. The lease-row fallback and the skipped KeeperMap migrations already exist.
  • The Loom user can read system.query_log and system.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.
  • Narrowing loom_reader below SELECT ON loom.* is left for later. It matches main's reader today.

Tested end to end

Case Result
Bundled install, image from a registry healthy; memory set/get; memory.aggregate ran as loom_reader; .env is 600
Self-managed 26.5, no Loom config, no loom database, password with $ and : database and reader created; password never printed; lightweight UPDATE works; condition cache off
Cloud, replicas on 26.4 and 26.6, admin user everything created; healthy; reads as loom_reader
Cloud, a user with no grants installer stopped with the SQL; an admin ran it; the rerun passed
Upgrade of a bundled install from the previous release .env and volumes kept; old memory reads back; 032 applied; reader works
Failures: 26.3, wrong password, URL as host, nothing listening, TLS mismatch, no CREATE privilege, no Keeper each stops with a one-line fix before DDL; no Keeper only warns
Caller-shaped reads run as loom_reader on all three targets (system.query_log)

make format, make lint, make typecheck, make test-unit and make schema-check pass.

🤖 Generated with Claude Code

zlareb1 and others added 2 commits October 15, 2026 07:25
…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
zlareb1 force-pushed the feat/clickhouse-targets branch from b0894d0 to bf9096c Compare October 15, 2026 07:28
zlareb1 and others added 10 commits October 15, 2026 07:29
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]>
zlareb1 and others added 16 commits October 15, 2026 11:20
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]>
zlareb1 and others added 9 commits October 15, 2026 18:45
…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]>
zlareb1 and others added 15 commits October 15, 2026 22:32
…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 zlareb1 changed the title Install Loom against its own ClickHouse, a self-managed server or ClickHouse Cloud Run Loom on its bundled ClickHouse, a self-managed server or ClickHouse Cloud Oct 16, 2026
@zlareb1
zlareb1 merged commit d845c79 into main Oct 16, 2026
20 checks passed
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]>
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