Repository navigation
The router's directory and placement API: a cell places a new org, and a client finds an org's cell - #497
Merged
Conversation
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-router-directory
branch
from
November 10, 2026 17:53
f231077 to
ff70202
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-router-directory
branch
from
November 10, 2026 18:03
ff70202 to
3e31c94
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-router-directory
branch
from
November 10, 2026 18:19
3e31c94 to
d3938ba
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-router-directory
branch
from
November 10, 2026 18:29
d3938ba to
7a95877
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-router-directory
branch
from
November 10, 2026 18:38
7a95877 to
53b7498
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 18:44
554b22f to
efee739
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 18:44
53b7498 to
8383574
Compare
8 of 9 tasks
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 18:55
efee739 to
f5cc402
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 18:55
8383574 to
daae05f
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:01
f5cc402 to
d1659a8
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 19:02
daae05f to
f4ecbd8
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:08
d1659a8 to
b5ca0a7
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 19:08
f4ecbd8 to
60d08cf
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:15
b5ca0a7 to
6a0afc1
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 19:16
60d08cf to
981c2fa
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:26
6a0afc1 to
8b323f7
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 19:26
981c2fa to
8cb4810
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:38
8b323f7 to
9a7b711
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 19:39
8cb4810 to
929cc06
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 19:44
9a7b711 to
5a66340
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 19:44
929cc06 to
4e38927
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-router-directory
branch
from
November 10, 2026 19:54
4e38927 to
0d530d8
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-router-directory
branch
from
November 10, 2026 21:20
9843da4 to
a9f693d
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-router-directory
branch
from
November 10, 2026 21:31
a9f693d to
04dd2b3
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-router-directory
branch
from
November 10, 2026 21:48
04dd2b3 to
cc282a1
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 21:55
ae67c41 to
51e200f
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 21:55
cc282a1 to
0da0733
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:00
51e200f to
9ab7df9
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:00
0da0733 to
6540f8d
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:06
9ab7df9 to
ffc312f
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:06
6540f8d to
efd90d1
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:12
ffc312f to
fde7d8b
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:14
efd90d1 to
bef0d53
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:22
fde7d8b to
1736406
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:23
bef0d53 to
605c59f
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:29
1736406 to
889b55c
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:29
605c59f to
185f57d
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:35
889b55c to
56aeba6
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:35
185f57d to
f51f337
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:41
56aeba6 to
dfd3ab9
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:41
f51f337 to
bc38a97
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:47
dfd3ab9 to
f276fe8
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:49
bc38a97 to
8e96148
Compare
zlareb1
force-pushed
the
feat/cell-cli-orgs
branch
from
November 10, 2026 22:54
f276fe8 to
b570c28
Compare
zlareb1
force-pushed
the
feat/cell-router-directory
branch
from
November 10, 2026 22:54
8e96148 to
e8086ce
Compare
This was referenced Nov 11, 2026
…d a client finds an org's cell 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):
loom router serveruns the router's placement API and org lookup from its own Postgres directory (LOOM_ROUTER_PG_DSN,loom router migrate). A cell places a new org through it, and a client finds an org's cell withGET /cells/lookup.Why
The fourth of the pull requests that implement cells. It stacks on #484. The tenancy check (#473) already calls
POST /cells/v1/placementswhen a cell inenforcedmeets an org it does not hold; this is the service that answers it, with the directory the design describes ("The router"). Routing requests by host and issuer (rules 1 to 4), the routing cache and its snapshot come in the next pull request; the directory's operator commands (loom cell attach,place,limit,credential) after that.Design
server/router/, a platform package (tests/unit/test_package_contracts.py), run byloom router servefrom the same image as a deployment, on a release of its own. It takes the cell-name grammar, the fingerprint's version and defaults (server/core/cell.py) and the org-free names (server.auth.tenancy.ORG_FREE) from the cells' own modules. Its fingerprint rule (_agrees) is stricter than the cell's own gate (cell.matches): a field this build knows and the caller leaves out is judged at its default, since the caller, not the router, chose what to post; a field only the row's value names and the caller does not send is a newer build's, left to the cell's own gate, so an older pod behind an older router still places.schemas/router_migrations/001_directory.sql, schemaloom_router), in the router's own Postgres database:cells: the row the design lists (host, state, mode, closed, quota, the SHA-256 of the cell's credential, deployment id, bucket, issuers, keys fingerprint, probe URL, break-glass bots,currentandnextfingerprints); at most one first cell;placements: one row per org, never updated, deleted or truncated (triggers); the cell'splacedcounts them;hosts, andaudit(each placement, bycell:<name>, in the placement's own transaction).synchronous_commit = onandread committed, whatever the database's defaults, as the memory authority's pool does, and the pool's statements and idle transactions are bounded on the server (statement_timeout,idle_in_transaction_session_timeout), so a stalled router never keeps a cell's row lock: a placement the router answered survives a failover, and a later placement of one org sees the earlier one. A call's whole wait for a connection (a lookup's slot, the pool's opening, the connection) is bounded by the sameSTATEMENT_TIMEOUT_S, and lookups, which any client may send, hold at most half the pool's connections, so a lookup flood leaves placements their connections.pg_migrate.migratetakes the connection, ledger schema and advisory lock as arguments, defaulting to the memory authority's; the directory migrates with the same runner under its own lock andloom_router.pg_migrations.POST /cells/v1/placements(server/router/app.py), the contracttenancy._placealready speaks ({org, cell, fingerprint}in,{cell, deployment_id}out):hmac.compare_digest) or the directory has no such cell. The cells' credential hashes are kept in memory and read from the directory at most once perLOOM_ROUTER_DIRECTORY_CACHE_S(a failed read stands for the window too, answering 503), so a call with a wrong credential reads nothing and can lock no cell out; the placement checks the credential again on the locked row, and a credential the row no longer holds answers 401 there too, with the cached hashes read again on the next call;Retry-After: the seconds until its oldest counted call leaves the window, which the cell passes on to its client), not attached (neitherservingnor the first cellattachingonce the directory recordsenforced(attach step 3)), closed, past its quota, or calling with a fingerprint that agrees with neithercurrentnornext: every field the row or this build names must be equal, a missing one at its default, each of the same type (a posted1is not a storedtrue), and the version must be the integer this build reads, so a field this build knows and the caller leaves out is judged, and a field this build does not know is passed over unless the caller sends it (a newer cell's or a newer row's, which the cell's own gate judges), or when the directory cannot be read;FOR UPDATE) and judged as it is then (attached, open, fingerprint,placedunderplacements_max), the placement is inserted,placedcounted, and the audit row written. A cell closed, limited or updated meanwhile is judged on its new row, and the quota holds across router replicas.GET /cells/lookup?org=: the org's cell and host, or the first cell for an org with no placement; unauthenticated, limited per client address (429 withRetry-After, from the same window), 503 while the directory cannot be read or holds no cell.server/router/limits.py): a 60-second window per key, counted by each replica (LOOM_ROUTER_PLACEMENTS_PER_MINUTE,LOOM_ROUTER_LOOKUPS_PER_MINUTE), at most 10,000 keys remembered. The directory's quota is the bound across replicas./livez, and/readyzwhile the directory answers, read at most once a second however often it is probed.LOOM_ROUTER_PG_DSN(a secret: the pattern now matches any*_pg_dsn), the two limits, andLOOM_ROUTER_DIRECTORY_CACHE_S.loom router serveandmigraterefuse without the DSN, and with one equal toLOOM_PG_DSN;migratealso refuses a database that holds a memory authority's ledger (loom.pg_migrations): the directory is never a cell's database.Scope and risk
Nothing runs unless
loom router servedoes. The server's only change is the migration runner's new arguments, whose defaults keep its behaviour (tests/unit/test_pg_authority.pypasses).The placement rate is per cell and counted by each router replica; only
placements_maxholds across replicas, as the page says.The design also rotates a cell's router credential (
loom cell credential --next,--finish): the directory then holds a next hash beside the current one and the router accepts both. That comes with the directory's operator commands; until then a cell has the one hashcredential_sha256records, andloom cell limit --closed, which writes only the directory, is the stop for a leaked one once that command lands.Two router pieces the page describes come after this one, before
loom cell prepareships: the state read in #519 and the lookup cache andNO_CELLin #520. As first planned they were to come with the routing pull request (no command writes a mode row until then): the state readGET /cells/v1/cells/<cell>, which a first cell inrecordingmakes before it records a new org (until it lands,ensure_heldrecords whenever the mode row readsrecording), and the cache of placed lookups that keeps answering them while the directory is down (until then every lookup answers 503 in an outage). Before any cell is registered a lookup answers 503, as the page now says.The lookup's clients come with that pull request too:
loom login --org, which starts a flow at the host the lookup names, keeps the host it was given on the no-cell answer (#520 gives that answer the codeNO_CELL, which the client the routing pull request adds matches instead of the message) and on a 404 from a deployment with no router, waits a 429'sRetry-Afterfor at most--wait(default 2 minutes) and then refuses as a rate refusal, and refuses on any other answer; the first cell's sign-in page that asks for the org first; the typedWRONG_CELLerror in the SDKs comes in #521.Compatibility, rollout and rollback
loom router migrate, thenloom router serve).Tests
tests/unit/test_router.py(54), against a fake directory: a placement and its retry; an org placed elsewhere answering its cell from a closed cell, an attaching cell, a fingerprint matching neither value, and a replaced credential still cached; a retry of an org placed already counted against the rate; a flood of wrong credentials reading the directory once and leaving the cell's own call placing; no bearer reading nothing; readiness reading the directory once for ten probes and again past its second; a replaced credential hash placing once the cache window passes; the replaced credential answering 401 within the window and placing nothing; an unreadable directory read once per window; fingerprints with fields left out refused, a field only a newer cell posts passed over, and a field only a newer build's row names left to the cell's gate when the pod does not send it; a credential naming another cell placing nothing there; 401 for a wrong or empty credential and an unknown cell; 400 for each malformed body, including one past the bound; 503 and nothing placed for each refusal (attaching, a first cell beforeenforced, closed, unmatched fingerprint, quota) and an unreadable directory; the first cell placing once attach setenforced; anextvalue placing; fingerprints of another shape; the per-cell rate; lookups (placed org, first cell, none yet, no org) and their per-client limit; the limiter's window, key bound and itsRetry-Afterwait; a rate refusal carryingRetry-After; the directory connections: lookups holding at mostLOOKUP_SLOTS(half the pool) while a placement still gets a connection, and a wait pastSTATEMENT_TIMEOUT_Sanswering the directory unavailable; and the refusal of a missing or shared DSN.tests/integration/test_router_directory_pg.py, against a Postgres database of its own: the migrations apply and then find nothing pending; a pool connection showssynchronous_commit = on,read committedand the two server-side timeouts; two cells placing one org while its lock is held elsewhere both wait (seen inpg_locks), read back one winner, and leave one audit row, the winner's; ten concurrent placements in a cell with a quota of three write three, refuse seven and count three; an org placed already answers its cell whatever the cell's state; a refusal on the locked row writes nothing;UPDATE,DELETEandTRUNCATEon placements are refused; a second cell recording another's credential hash is refused (UNIQUE);migraterefuses the memory authority's database. It passed against a local Postgres.LOOM_ROUTER_PG_DSN) and runs this file (A cell serves only the orgs it holds, and places a token's new org through the router #473 already runstests/integration/test_cell_tenancy_pg.pythere).test_package_contracts,test_cli_surface_snapshot,test_settings_defaults,test_doc_links,test_public_copy,test_pg_authority, and every unit test naming the CI workflows: pass. Lint and typecheck pass.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