Repository navigation
A cell's process serves only while its own rows in Postgres accept its configuration - #468
Merged
Merged
Conversation
8 of 9 tasks
zlareb1
force-pushed
the
docs/pg-placement-units
branch
from
November 10, 2026 16:22
9397c1c to
f4d106d
Compare
zlareb1
force-pushed
the
feat/cell-own-state
branch
28 times, most recently
from
November 10, 2026 21:58
435bd7b to
4dd3a95
Compare
zlareb1
force-pushed
the
feat/cell-own-state
branch
4 times, most recently
from
November 11, 2026 00:48
2e92f51 to
25c701e
Compare
8 of 9 tasks
zlareb1
force-pushed
the
feat/cell-own-state
branch
6 times, most recently
from
November 11, 2026 01:16
7248993 to
2069569
Compare
zlareb1
force-pushed
the
docs/pg-placement-units
branch
from
November 11, 2026 01:24
b6bd271 to
10312a3
Compare
zlareb1
force-pushed
the
feat/cell-own-state
branch
4 times, most recently
from
November 11, 2026 02:17
3df557f to
d33c739
Compare
9 tasks done
…s configuration Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nt: tested; one refusal helper; the migration header names the rows prepare writes Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ing comments Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…de config keeps, checked against the code config; the mode cache's comment states its bound Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…lformed value; the test covers an unset code org Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…n at boot, not by parsing its settings Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…LOOM_CELL Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ent names only its boot hand-ins Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This was referenced Nov 11, 2026
Merged
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.
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):
A process with
LOOM_CELLset serves only while its cell's rows in Postgres are read and accept its configuration; until then it answers 503AUTH_UNAVAILABLEto everything but its health probes and runs no worker. WithLOOM_CELLunset nothing changes.Why
The first of the pull requests that implement cells (the design is #452, which this stacks on and which merges with the stack). A cell must never serve with a configuration its directory row did not accept, for example a cell set up to accept another cell's issuer or a host it was not attached with. The check lives in each process, so it holds wherever a request reaches the process, not only behind the router's readiness gating. Later pull requests write these rows (
loom cell prepare, attach, update) and add the tenancy check, the router, per-cell SCIM and the enforced-mode org triggers.Design
Settings: with the SCIM refusal, before anything touches a store,
LOOM_CELL(1 to 32 ofa-z,0-9,-; "" = not a cell) andLOOM_TENANCY_MODE_CACHE_S(default 5 s, at least 1, beside the keyring's refresh:LOOM_JWT_REVOCATION_MAX_STALE_SECONDSmust be at least three times it, as for the keyring, a check that applies only withLOOM_CELLset). A process withLOOM_CELLset refuses to boot without the Postgres authority, authentication on every transport, orLOOM_PUBLIC_BASE_URL.Postgres (
008_cells.sql):loom.cell_first: one row, which triggers refuse to update, delete or truncate;loom.tenancy_mode:recordingorenforced;loom.tenancy: one row per org the cell holds, never deleted;loom.cell_self: the accepted fingerprints,currentand, during a change,next, each a JSON object by constraint.All four are classified as holding no memory content.
ClickHouse (
094_cell_heartbeats.sql):loom.cell_heartbeats, one KeeperMap key per process beside itsloom.instancesrow, written with every beat. It holds theLOOM_CELLthe process runs with, the mode it last read and its fingerprint. Prepare and attach will compare these across a cell's processes. It is a table of its own because ClickHouse refusesALTER TABLE … ADD COLUMNon a KeeperMap table (NOT_IMPLEMENTED). Every build from this one reports its fingerprint, even outside a cell, because prepare reads it beforeLOOM_CELLrolls out. Under the Postgres authority that fingerprint carries the deployment id from boot on,LOOM_CELLset or not, so the first cell's processes report the same value before and after the rollout.The fingerprint (
server/core/cell.py) is a set of named fields under a schema version:normalise_host);oidc_jit_org, an open signup's org,LOOM_CODE_ORG, the org of eachLOOM_CODE_REPOS_JSONentry the code config keeps, andLOOM_TRACKER_ORG; a test checks the repository orgs against the code config itself, sinceserver.coremay not import it);A process matches a value when every field both know is equal; a field the value lacks counts as equal only at its default. An added field keeps the version; a changed meaning raises it, and a build matches only values of its own version. Two builds with one configuration therefore match one row.
The gate: with
LOOM_CELLset, the gate holds while any of the three rows is unread, while one is absent, while the first row names another cell, or while the fingerprint matches neithercurrentnornext. Then:AUTH_UNAVAILABLE, from the middleware that already refuses a drifted process, so sign-in, minting, OAuth, device, SCIM and pages are covered;verify_tokenchecks the gate first, before the end-user issuer branch (CellUnavailable, anAuthUnavailable);cell), and the heartbeat'sservingis 0;autoas a drifted process does, and inonthe lease loop now runs for a cell and starts or stops the supervisor on the gate, starting nothing at boot. Only the deployment's leader registers tracker namespaces when it starts them, as at boot.The three rows are re-read in one statement every
LOOM_TENANCY_MODE_CACHE_S; a failed read, or a row that does not decode as this build reads it, keeps the last rows for at mostLOOM_JWT_REVOCATION_MAX_STALE_SECONDS, the bound the signing keyring trusts its own snapshot for, and is retried on schedule; past it the process is gated until a read lands. The workers child reads them itself, since its passes verify tokens. The verdict is computed once per read, not per request.Alternatives weighed: a readiness check alone, which a pod IP, a port-forward or a deployment without readiness gating bypasses; and new columns on
loom.instances, which KeeperMap refuses.Scope and risk
Every code path is behind
settings.cell, with two exceptions: the cell heartbeat, a single extra Keeper write per beat that every process makes, and, under the Postgres authority, one read ofloom.authorityat boot for the deployment id the fingerprint carries. Nothing writes the cell rows yet, so a process withLOOM_CELLset stays gated untilloom cell preparelands; the setting is not useful before that pull request.The design also has a process with
LOOM_CELLunset read, in one statement, the mode andfirstrows and whether anyloom.tenancyorloom.cell_selfrow exists, and be gated (health probes and the probe route still answering) in every state but open (both rows absent with no tenancy or own row) and the first cell inrecording. Nothing writesenforceduntil attach lands, so that gate comes with the pull request that reads the router's cell state, with its test; here a process withLOOM_CELLunset reads no cell row.Compatibility, rollout and rollback
AUTH_UNAVAILABLEfrom a gated cell.008_cells.sqlfollowsmain's006_erasure_ledger.sqland007_knowledge_datasets.sql, so a build N-1 reads it as a newer build's file;094_cell_heartbeats.sqlfollowsmain's093_service_account_saves_to.sql.schemas/schema.sqlis dumped from a ClickHouse migrated from empty in that order.loom.cell_heartbeatsrow, and prepare (later) reads a live instance without one as a build before cells. Neither migration changes an existing table. The Postgres migration that adds the org triggers (cells.md, "Rolling upgrades") comes with attach in a later pull request of the same release;008_cells.sqladds none. Itsloom.cell_firsttriggers, which refuse an update, delete or truncate of thefirstrow, areENABLE ALWAYS, so they fire undersession_replication_role = replicatoo (checked on Postgres 16).Tests
tests/unit/test_cell.pytest_only_the_first_cell_reads_recording: only the first cell ever records. On a later cell (firstread as(false, …)),cell.mode()readsenforcedwhatever the mode row says, so the tenancy check and the CLI place, never record, there; the gate still reads the raw row, so an absent mode row still gates (test_a_cell_is_gated_until_its_rows_accept_it; the table'sCHECKrefuses any other value).tests/unit/test_cell.py(105, parametrized cases included):LOOM_CODE_REPOS_JSONentry the code config keeps, compared withrepos._configured_from_envover kept, skipped and malformed entries, withLOOM_CODE_ORGandLOOM_CODE_REPOset and unset;onprocess registers tracker namespaces only withLOOM_DEPLOYMENTset;currentornextaccepted;verify_tokenrefusing first;autoandon:start_lease_loopruns for a cell'sonprocess, andkeep_leasestarts, stops and restarts its supervisor as the gate opens, closes and opens;servingand cell row;refresh, and the stale bound;test_schema_baseline,test_settings_defaults(snapshot),test_every_table_is_classifiedandtest_pg_authoritypass with the new tables and settings.eu-1:cell: this cell's first row is absent), answered 503AUTH_UNAVAILABLEand started no worker;currentthat no longer matched, with this process's value asnext, still served;nextcleared it answered 503 and stopped its workers within one refresh;UPDATEandDELETEonloom.cell_firstwere refused by the trigger.tests/integration/test_cell_heartbeat.py: a running server'sloom.cell_heartbeatsrow sits beside its instance row withcelland mode empty, every fingerprint field present, and, under the Postgres authority, the deployment id both stores record. It passed against a local server on the Postgres authority at this head.test_cell.py,test_pg_authority.py,test_instances.pyand the mutation inventory, run in one process beforetest_code_compiler_tier_runner.py, pass (a test of the workers child had left the process's lease set). The full unit suite has not run since the rebase ontomain; it runs before merge.test_deeply_nested_hidden_html_parses_in_bounded_timefails on this machine onmain; the other seven (five intest_decision_retirement.py, two intest_agent_claim.py) pass when run alone at this head (7 passed): load on a shared host. Earlier runs found the untestedLOOM_TENANCY_MODE_CACHE_S, the exception text in the cell's reason, a boot test missing the deployment-id stub and a stale settings schema, all fixed.current_fpis refused by the constraint,TRUNCATE loom.cell_firstby the trigger, and rows read through asyncpg's JSON codec make the cell ready.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.
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.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.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