Repository navigation
Every CLI command that connects declares the orgs it writes, and a cell refuses one it does not hold - #484
Merged
Conversation
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
3 times, most recently
from
November 10, 2026 14:44
091c589 to
d7759cb
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 15:46
2c22732 to
a1c8ff0
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 15:52
d7759cb to
7a5d4a3
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 15:56
a1c8ff0 to
397f333
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 15:58
7a5d4a3 to
8d51721
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 16:15
397f333 to
ca8bcf8
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 16:16
8d51721 to
784b289
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 16:31
ca8bcf8 to
4de78f0
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 16:44
784b289 to
e71021f
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 16:50
4de78f0 to
7b99500
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 16:51
e71021f to
2928bad
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 17:07
7b99500 to
6db45da
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 17:07
2928bad to
b1a465b
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 17:20
6db45da to
038d76c
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 17:20
b1a465b to
247cf1e
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 17:31
038d76c to
ce1c191
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 17:34
247cf1e to
a6f6c31
Compare
8 of 9 tasks
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 17:43
ce1c191 to
a991311
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 17:44
af64ff2 to
836e2f1
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 18:03
a991311 to
dc4467a
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 18:03
87349e9 to
c635787
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 18:19
dc4467a to
85b33db
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 18:19
c635787 to
b124006
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 18:29
85b33db to
ab3b97c
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 18:29
b124006 to
4727f29
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 18:37
ab3b97c to
ce4c529
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 18:37
4727f29 to
554b22f
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 19:53
52e1d94 to
78b4166
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:54
5a66340 to
821af96
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 19:58
78b4166 to
3e5b1ed
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:59
821af96 to
983c225
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:03
3e5b1ed to
020b505
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 20:04
983c225 to
051bad2
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:09
020b505 to
3bbcb34
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 20:10
051bad2 to
8b264be
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:18
3bbcb34 to
d528030
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 20:19
8b264be to
8c2b613
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:25
d528030 to
4f64737
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 20:25
8c2b613 to
6fe7d2a
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:32
4f64737 to
93d8d1a
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 20:32
6fe7d2a to
35b2f8f
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:47
93d8d1a to
a1c7f0c
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 20:49
35b2f8f to
220a979
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 20:57
a1c7f0c to
458d411
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 21:01
220a979 to
07adf98
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 21:15
458d411 to
defead1
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 21:19
07adf98 to
e786cd7
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 21:30
defead1 to
bca1c48
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 21:31
e786cd7 to
cc22e80
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 21:46
bca1c48 to
cabdeb4
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 21:47
cc22e80 to
ae67c41
Compare
zlareb1
force-pushed
the
feat/cell-tenancy
branch
from
November 10, 2026 21:54
cabdeb4 to
6b1faed
Compare
…ll refuses one it does not hold 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]>
…ith no reader 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 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):
On a cell, a CLI command refuses, before it runs, an org the cell does not hold. Every command that connects declares the orgs it writes, or why it writes for none. On any deployment, a
loom codecommand that reads its repository entry (_repo_cfg) and whose org has no configured entry now refuses instead of indexing the first entry's checkout under that org.Why
The third of the pull requests that implement cells. The design is #452; this stacks on #473, the tenancy check on requests. A CLI command is not a request, so the transports' check never sees it, but it writes too: an import into an org, a bot, a rechunk, a reembed. Without a check of its own, an operator could write memory for an org another cell holds into this cell's stores.
Design
server/cli/_ch.py:run_connected,connect_checkedand a newconnect_declaredeach takeorgs=(the orgs a command writes) ororg_free=(why it writes for none). A call with neither raisesTypeError.orgs=that is passed but unset (a command's optional--org) names no org and checks nothing.connect_declaredconnects and checks the orgs.connect_checkedisconnect_declaredwith the memory-authority check it already made (check_authority=True).connect_code_plane(ch, args)declares the org a code-index command writes: its--org, elseLOOM_CODE_ORG, ascode_run._identityresolves it, and none on a--dry-run(answers-purge,coverage-import,repack). It resolves the org and namespace before it connects.scip-fullandbackfill's index phase resolve their entry first (backfill --phase embedreads no entry; it reads its first page of pending chunks oncode_run's connection and declares its--orgonly when there are chunks to embed, so a mistyped--orghas none and is never recorded, while the pass's status row, keyed by namespace, still lands), and_repo_cfgrefuses a fallback entry of another org, so a mistyped--orgis never indexed under that org's checkout;reembedandvector-twincheck their model first;scip-retryreads its batch before it declares the org. A code command that refuses its own arguments therefore exits before arecordingcell records anything. A pass over every configured repository (the SCIP delta,code_run's registry read and drain) declares none: configured orgs are placed at attach.compactdeclares none: it optimizes whole tables.scip-retryandentry-lockdeclare their--org.connect_declaredfirst runs the deployment check (check_configured), so a tenancy row is written only into this deployment's own Postgres.The check (
check_orgs), withLOOM_CELLset and an org declared, reads the cell's rows (cell.refresh, with the deployment id set as boot sets it: a CLI process has read neither), after handing in the code orgs' reader (cell.set_code_orgs(repos.operator_orgs)), as boot does for a server, so its fingerprint is the one its server reports. It then applies the transports' gate: the command is refused whencell.gate_reason()is non-empty, so a shell whoseLOOM_CELLor configuration is not its cell's records nothing, as the server would serve nothing. It then runstenancy.ensure_held(org, None)for each declared org, before the command runs:recording, it records the org, as a request's org is recorded;enforced, it refuses an org the cell does not hold (OrgNotHeld, aSystemExitnamingloom cell place, so the operator reads the message, not a traceback);BackendUnavailableError) refuses with its message.Every command declares. Every
run_connected,connect_checkedandconnect_declaredcall declares orgs or a reason. Examples:orgs=(args.org,)for the org-scoped commands, andorgs=dry_run_orgs(args)for those with--dry-run: a dry run only reads, so it declares no org (namespaces-gcdeclares its org only with--erase;reextract's connection only reads, and its replay writes through the server at--base-url);_identityresolves, throughconnect_code_plane, forbackfill-reviews,backfill-itemsandbackfill-assignees(equal to the entry's org, since_repo_cfgrefuses a mismatch), andorgs=(cfg.org,)forreconcileonly with--heal; without itreconcileonly reads and declaresorg_free="reads";sensitivity-sweep, and its "repairs" variant forintegrity-repair;readsfor every read-only command (entity-export,audit-namespace,mentor,drops,deploy-delta,doctor, the claim lookup before a release, andloom code stats,export-matrix,export-pairs,lint-instructions --symbols): a read records no org, and a CLI argument is free text that arecordingcell would otherwise keep for good.The direct
.connect()calls (the code-index commands,doctor, the analytics export,sql-access, the re-extract session read) now go throughconnect_declared,connect_code_planeorsql_access._connected. Outside a cell the code-index commands keep their behaviour. On a cell they gain the tenancy check and, throughconnect_declared, the deployment check. Those outsiderun_connected,doctor's two reads included, now close with_ch.disconnect, which closes the Postgres pool the tenancy read opens.connect_declaredleaves an already connected client as it is (CHClient.connected; the tests' fake clients sayconnected = False), so aloom codecommand's connect insidecode_run's no longer replaces the open driver.The census (
tests/unit/test_cell_cli_orgs.py) reads the syntax tree of every module underserver/cli/, plus the two callers outside it (a benchmark harness and the op-reach census). It fails on:orgs=nororg_free=;.connect()underserver/cli/outside_ch.py, other than the setup command's own admin client and SQLite files;loom codecoroutine that resolves its org (_identity,_repo_cfg) without a connect of its own;orgs=(args.org,)while it, or a function of its module it calls, readsargs.dry_run.Scope and risk
With
LOOM_CELLunset,check_orgsreturns at once, and a connect must say what it writes: a refusal at the call site, which the census catches in CI, not at run time. The design's gate for a CLI withLOOM_CELLunset comes later, with the gate for server processes that #468 defers. Two of the page's CLI rules come with #519, which first makes the CLI call the router: recording only while the directory answersattaching(read withLOOM_CELL_ROUTER_TOKEN), and the refusal of a command that declares an org while that credential is set outside a first cell inrecording. Until thencheck_orgsrecords whenever the mode row readsrecording.The all-repository passes (
scip-delta, the drain) stay org-free because #468's fingerprint counts the org of eachLOOM_CODE_REPOS_JSONentry the code config keeps among the configured orgs, which attach places. One change reaches every deployment:_repo_cfg, with no entry for the addressed org and namespace and no--namespacenaming another, used to fall back to the first entry whatever its org, soLOOM_CODE_ORG=otherwith only anacmeentry indexed acme's checkout underother. It now exits non-zero, naming the remedy:--namespaceof the org's own entries when it has some, else--orgof the first entry, or an entry for the org and namespace.Compatibility, rollout and rollback
enforcedcell refuses a command for an org it does not hold; on any deployment, aloom codecommand that reads its repository entry (_repo_cfg) and whose org has no configured entry refuses rather than indexing another org's (a scheduled run that relied on that fallback passes--orgof the entry, or gets an entry of its own).Tests
tests/unit/test_cell_cli_orgs.py:backfill --phase embeddeclares its org only once its first page has chunks, and an empty pass still writes its status row;check_orgspasses the gate (test_a_cli_counts_the_code_orgs_as_its_server_does; it fails without the hand-in);loom code reconcileon arecordingcell records nothing without--healand records its entry's org with it, through the realconnect_declaredandcheck_orgs;enforced(the cell's rows readrecording) records nothing and refuses, namingloom cell place, with no placement call;run_connected,connect_checkedand_connectedaccept the declaration (bench/test_docparse.pyincluded). The entry-lock tests stub the connectentry-locknow makes. After the rebase ontomain, every code, CLI, SCIP and cell test file withbench/test_docparse.py(two workers): 5512 passed; the census foundloom reconcile, new onmain, undeclared (now declared); the other three failures aretest_code_regex_cost.pytiming cases, which fail on the base too.test_a_cli_process_reads_the_cells_mode_before_it_checksdrives the realensure_heldagainst fake Postgres reads:recordingrecords a new org,enforcedrefuses it;test_a_cell_whose_rows_cannot_be_read_refuses_every_declared_org;test_a_cell_the_transports_would_close_refuses_the_command;test_an_unread_tenancy_refuses_with_its_message;test_a_dry_run_declares_no_org;test_a_connected_client_is_not_connected_again.test_a_code_index_command_declares_the_org_it_writes(its--org, elseLOOM_CODE_ORG, else none) andtest_on_a_cell_a_declared_connect_verifies_the_deployment_first.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 full unit suite result follows in Tests).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