Repository navigation
The router routes every other request to one cell by host, SCIM, issuer or the first cell - #523
Merged
Merged
Conversation
8 of 9 tasks
zlareb1
force-pushed
the
feat/cell-login-org
branch
from
November 11, 2026 14:48
452ee5c to
9ce65fe
Compare
zlareb1
force-pushed
the
feat/cell-router-routing
branch
from
November 11, 2026 14:48
069cab7 to
10a4863
Compare
zlareb1
force-pushed
the
feat/cell-login-org
branch
from
November 11, 2026 15:11
9ce65fe to
7d23c72
Compare
zlareb1
force-pushed
the
feat/cell-router-routing
branch
from
November 11, 2026 15:11
10a4863 to
14bdc3f
Compare
zlareb1
force-pushed
the
feat/cell-login-org
branch
from
November 11, 2026 15:31
7d23c72 to
649c4e8
Compare
zlareb1
force-pushed
the
feat/cell-router-routing
branch
from
November 11, 2026 15:31
14bdc3f to
35acd3c
Compare
zlareb1
force-pushed
the
feat/cell-login-org
branch
from
November 11, 2026 15:47
649c4e8 to
6002130
Compare
zlareb1
force-pushed
the
feat/cell-router-routing
branch
from
November 11, 2026 15:47
35acd3c to
c93c4b7
Compare
zlareb1
force-pushed
the
feat/cell-login-org
branch
from
November 12, 2026 01:40
6002130 to
b5f0cad
Compare
…er or the first cell, and forwards it streamed Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/cell-router-routing
branch
from
November 12, 2026 01:55
c93c4b7 to
988b5e8
Compare
zlareb1
marked this pull request as ready for review
November 12, 2026 01:55
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 servenow routes every request that is not its own to one cell: a cell's own host to that cell, SCIM on the shared host to the first cell, a token-bearing request on the shared host to the cell that accepts its issuer, and everything else to the first cell (or, before one is registered, toLOOM_ROUTER_UPSTREAM_URL). Requests and answers are streamed through, with the client's host, scheme and address inX-Forwarded-*.Why
The ninth of the pull requests that implement cells. It stacks on #522. Until now the router answered only its own paths; the page's rules 1 to 4 are what make one URL serve many cells.
Design
server/router/routing.py):buildmakes aTablefrom the directory'scells(name, host, state, first mark, issuers, upstream address) andhostsaliases;decidereads the host, path,Authorizationand, forPOST /oauth/revoke, the revoked token:LOOM_ROUTER_SHARED_HOST, the first cell's own host and itshostsaliases (the setting's description now says so);serving, everything on the shared host goes to rule 4's cell, which verifies it;/scim/v2/Groupswith a JWT, which goes by its issuer;iss, read unverified, picks the cell that lists it; one no cell lists answers 401 withWWW-Authenticate: Bearer error="invalid_token", as a cell's own 401 carries a challenge; a bearer that is no JWT names no issuer;cells.upstream_url(schemas/router_migrations/002_cell_upstream.sql), an address inside the deployment's network, since a cell's public host names the router itself. Attach writes it (attach is not in the stack yet);LOOM_ROUTER_UPSTREAM_URLis rule 4's cell before the first cell is registered. The page now says this, in a paragraph after the rules.server/router/app.py,Router.forward,proxy_client): one sharedhttpx.AsyncClientwith a 5 s connect timeout, no read timeout (an event stream may idle) and no bound on open connections, so a request never waits for a pool slot (PROXY_TIMEOUT,PROXY_LIMITS); the request goes on as the client sent it (raw path and query, its ownHost) with the router's ownX-Forwarded-For,-Protoand-Hostreplacing what the client claims (andForwardeddropped), minus the hop-by-hop headers and thoseConnectionnames; every header line of the answer is kept (a sign-in's twoSet-Cookielines); both bodies stream, and a request that sent no body is forwarded with none framed; an unreachable cell answers 502, and a raw path httpx cannot carry answers 400. A revocation's body is read only on the shared host once the first cell serves, bounded at 64 KiB (413 past it, the same bounded read the placement body uses), and its lasttoken, blank ones kept, is used, as the cell's own form reading takes it. The router's own paths come first,/livezand/readyzanswer 405 for any other method, and a path under/cells/it does not serve answers 404 rather than being forwarded.LOOM_ROUTER_DIRECTORY_CACHE_S. Once there is one, a stale table is answered at once and read again in the background, so a directory that hangs delays no request; the read is stamped when it ends, failed or not, and a failed read keeps the last table. Before the first read every request answers 503.loom router serve's help says it routes every other request to a cell (the CLI reference and snapshots regenerated).LOOM_ROUTER_SHARED_HOSTandLOOM_ROUTER_UPSTREAM_URL(catalog, generated reference, schema and example regenerated).loom router serverefuses an upstream that is nothttp(s)://host[:port]with no path, and a directoryupstream_urlof another shape is treated as missing (503), logged.Scope and risk
Router only; nothing changes unless
loom router serveruns in front of a deployment. Still to come: the signed snapshot of the last table on shared storage (so a replica that restarts during a directory outage still routes), and the first cell's org-first sign-in page.Compatibility, rollout and rollback
A new column in the router's own directory,
NOT NULL DEFAULT '', additive.Operator step: each cell behind the router lists the router's addresses in
LOOM_TRUSTED_PROXIES. Otherwise the cell reads every client as the router's address (one abusive client then throttles everyone's sign-in) and the scheme as the router's; the page says so. A router build without routing answers only its own paths, as before.Tests
tests/unit/test_router_routing.py(43): a cell's own host (any case or default port) goes to it; an unknown host answers 421; the shared host and an alias go to the first cell; a JWT goes by its issuer and an unknown issuer answers 401; a bearer that is no JWT names no issuer; SCIM on the shared host goes to the first cell even with a JWT, but/scim/v2/Groupswith a JWT goes by issuer; a revocation goes by the revoked JWT's issuer, an opaque one to the first cell; before the first cell serves, everything goes to rule 4's cell or the pass-through; a cell with no upstream answers 503. Through the app: a request reaches the cell whole (method, path, query, body,Host,X-Forwarded-*), its answer streams back with the cell's status and without hop-by-hop headers; a revocation is forwarded with the body it was routed by;/cells/paths are never forwarded; an unreachable cell answers 502; the table is read once a window and kept through an outage; no table yet answers 503; twoSet-Cookielines both reach the client and a header the cell'sConnectionnames does not; the raw path and query (%3F,%2F) reach the cell unchanged; spoofedX-Forwarded-*,Forwardedand aConnection-named header are replaced or dropped; a revocation goes by its lasttoken, past 64 KiB on the shared host answers 413 unforwarded, and at a cell's own host streams on unread;POST /livezand/readyzanswer 405 unforwarded; a hung directory read delays none of three requests; the forward's pool has no bound; an issuer two cells list answers 401; an upstream that is no bare http(s) address (no scheme, bad bracket, a path, another scheme, userinfo, a query) answers 503, andloom router serverefuses such a pass-through; a request with no body is forwarded with none framed; a revocation whose lasttokenis blank goes to the first cell; an issuer no cell lists answers 401 with a Bearer challenge, unforwarded; a registered first cell with no upstream answers 503; a payload nested 5000 deep names no issuer.tests/integration/test_router_directory_pg.py:directory.routing()reads each cell with itsupstream_url(empty until attach). Passed against a local Postgres.servedoes;make lintandmake typecheckpass. The full unit suite has not run on this stack.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