Repository navigation
Run Loom from ClickHouse and its Keeper, with every instance a full replica - #32
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/ch-only-portability
branch
10 times, most recently
from
October 15, 2026 14:53
afef00d to
45f25aa
Compare
zlareb1
force-pushed
the
feat/ch-only-portability
branch
2 times, most recently
from
October 15, 2026 16:39
3bb0553 to
d5b5b1a
Compare
5 of 9 tasks
zlareb1
force-pushed
the
feat/ch-only-portability
branch
15 times, most recently
from
October 16, 2026 09:20
4975c1b to
8eedfa8
Compare
zlareb1
force-pushed
the
feat/ch-only-portability
branch
2 times, most recently
from
October 16, 2026 11:12
427790c to
5583ac2
Compare
…ull replica A Loom process pointed at the same, a moved or a restored ClickHouse gets every feature back: uploaded originals, signing keys, admin overrides, sign-in limits, the workers lease, graph-walk marks, deferred conflict judgements and similarity calibration live in ClickHouse and its Keeper (migrations 028–033). N identical replicas serve behind one URL without sticky sessions, builds N-1 and N side by side; readiness, drift checks and a column-carry barrier keep a rolling upgrade from losing writes. The design rationale, review rounds and upgrade notes are in the PR description. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/ch-only-portability
branch
from
October 16, 2026 11:36
5583ac2 to
eb62fb6
Compare
zlareb1
added a commit
that referenced
this pull request
Oct 16, 2026
…-038 Main's #32 took 033-038 for ClickHouse-only and shared replica state, so this PR's graph-row, abandoned-failure, seen_at and restore_id migrations follow it; none of main's DDL touches the tables or columns they add. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zlareb1
added a commit
that referenced
this pull request
Oct 16, 2026
Main's #32 replaced the file-backed GraphWriteMarks object with module functions, so the PR's ALTER-based closes and reopens called an API that no longer exists and mypy failed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zlareb1
added a commit
that referenced
this pull request
Oct 16, 2026
…irror flag Main's #32 moved the key write lock onto Keeper leases, which the Undo now holds, and added a judged argument to the status mirror the tests replace. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zlareb1
added a commit
that referenced
this pull request
Oct 16, 2026
… a cluster lease and its single-process mode goes Main (#32) took migrations 033-038, so bi-temporal memory moves to 039. With a Keeper required everywhere, LOOM_MEMORY_TEMPORAL_PUBLISHER, the in-process publisher, the second-writer check, memory.temporal_status's publisher field and the memory_writes_refused problem are gone: a namespace's commits are serialized by leases.cluster_lease, renewed while held. Main's revisions to memory.update (the deferred judge gets the vector's version, time and hash), write_versions_by_ids (judged) and the lock wording are carried into this branch's reworked paths. 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.
Related: #29
Related: #35
Changelog category (leave one):
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):
Loom keeps all of its state in ClickHouse, so you can run any number of identical replicas behind one URL and move a deployment by moving its ClickHouse, its env and
LOOM_JWT_SECRET. The ClickHouse server now needs a Keeper (the bundled one has one, and so does ClickHouse Cloud).Why
Loom kept some state on the host it ran on: uploaded originals on a blob volume, rate-limit overrides in a file, the workers lock as a flock, graph-walk marks in a directory, sign-in counters in memory. A second replica, or the same ClickHouse restored somewhere else, lost all of it. This moves that state into ClickHouse and its Keeper.
LOOM_BLOB_DIRloom.document_blobs, keyed by sha256.loom blobs import <dir> --applymoves an old directory in once.LOOM_JWT_SECRETS_JSON/ACTIVE_KIDloom.signing_keys, sealed withLOOM_JWT_SECRET(still kiddefault), managed withloom signing-key. A new key verifies everywhere before it signs anywhere.loom.runtime_overrides, picked up by every process withinLOOM_RUNTIME_OVERRIDES_REFRESH_SECONDS.loom.graph_projections.loom.auth_attempts, counted with sequential reads.Git mirrors stay a cache that each replica clones on start.
Three things shaped the design.
Anything decided once (a sign-up name, a spent OAuth code, a grant change, the workers leader) has to be decided once for the whole deployment, so it is a claim in Keeper (a KeeperMap key under strict mode). That is the only compare-and-set ClickHouse has. I first had a fallback for servers without a Keeper (insert a row, wait, read back), but a review showed it can let two holders in while an earlier insert is still in flight, so it's gone: Loom refuses to start without a Keeper. The claims from #29 move onto the same leases.
Replicas lag each other, so reads that must see another replica's acknowledged write use sequential consistency (the keyring, sign-in counts, OAuth state, usage credits).
During a rolling upgrade the old and new builds write the same tables, and an old build's version row would reset a column only the new build knows. Each process acknowledges the column lists it writes with in
loom.carry_acks, and a booting process waits for every live process to acknowledge its schema before it serves. ClickHouse also checks each carried insert itself: the batch goes out asINSERT … SELECT … FROM input(…)with athrowIfthat refuses it if the table has gained a column, or if it starts after its deadline, so a request stuck in a proxy past anALTERlands nothing. It adds about 5 ms permemory.setat p50.Other changes that fell out of this:
/v1/health/liveand/v1/health/readyfor load balancers. On SIGTERM a replica stops being ready first, keeps servingLOOM_SHUTDOWN_READY_DELAY_S, drains, and does its last ClickHouse writes under one deadline that fits the 75 s stop grace.loom.instances) and never drop below one request.loom participant retiredoes it./. Old/melinks redirect.Scope and risk
This touches every place that held per-host state: auth (keyring, sign-in limits, OAuth, sign-up), the version-write path, the workers leader, provider reconfiguration, backup and restore,
install.shandloom ch-setup, and the compose stack. Tenant isolation and erasure keep their shape, and the new tables are in the erasure census.Known limits:
refinesverdict that lands after its source was revised acts as if it landed just before the revision, so the newer revision's conflict link can name a superseded row (only visible in the review queue).loom doctorwarns about this.Compatibility, rollout and rollback
033_clickhouse_only_stateto038_embedding_write_sha, all additive.deploy/clickhouse-config/keeper.xmlin itsconfig.d/(or add a<zookeeper>section for a Keeper you already run) and restart it. Boot,loom migrate, the preflight andloom ch-setupall say so if it's missing, andinstall.sh --bundledswitches an install back to the bundled ClickHouse.LOOM_JWT_SECRETS_JSON, runloom signing-key import --active <kid>before the new build serves (add--algorithm RS256for an RS256 map). Boot refuses while those variables are set.loom blobs import <old LOOM_BLOB_DIR> --applyonce. Until then older originals answer 410.LOOM_JWT_SECRETS_JSON,LOOM_JWT_ACTIVE_KID,LOOM_SUPERVISOR_LOCK_PATH,LOOM_BOOT_MIGRATE_LOCK_PATH,LOOM_BOOT_MIGRATE_LEASE_SETTLE_S,LOOM_GRAPH_WRITE_MARKS_*,LOOM_TASK_LEASE_BACKEND, andLOOM_READ_REPLICA_*. New ones are indocs/reference/configuration.md.LOOM_TRUSTED_PROXIEShas to name it, or every client shares one sign-in limit.oauth_claimsandgrant_claimstables from Cap token claims at the live grant, serialize grant changes, and bound all_mine search #29 are no longer written and can be dropped in a later release.Tests
make test-mixed-version: the previous and this build side by side on one ClickHouse.scripts/gates/docker_quickstart_smoke.pyagainst a freshly built image, including a SIGKILL in the middle of a provider rebuild.ALTER, a cancelled insert held until it ended, a request refused after its deadline, and a boot that waits out a killed writer's running insert.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, checked by a separate reviewer agent and by external review over many rounds. Every finding was fixed with a regression test.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/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).main; no merged migration is edited.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code