Repository navigation
The router registers a cell once its probe listener answers the cell's deployment id and prepare's nonces - #535
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/cell-register
branch
2 times, most recently
from
November 11, 2026 17:42
727a959 to
91c8331
Compare
9 tasks done
zlareb1
force-pushed
the
feat/cell-probe-route
branch
from
November 12, 2026 02:48
4829f2c to
97d2fa9
Compare
…yment id and the nonces prepare wrote to its stores Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/cell-register
branch
from
November 12, 2026 03:37
f842140 to
a48636a
Compare
zlareb1
marked this pull request as ready for review
November 12, 2026 03:38
This was referenced Nov 12, 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):
The router registers a cell through its operator API (
POST /cells/v1/operator/cells/<cell>/register, whichloom cell preparecalls), once the cell's probe listener answers its deployment id and the nonces prepare wrote to its stores; the first cell is probed at the router's ownLOOM_ROUTER_UPSTREAM_PROBE_URL.Why
The twelfth of the pull requests that implement cells. It stacks on #529. A
bucket_prefixwithout a bucket is refused, as the fingerprint counts none, and so is a bucket whose prefix is empty or has a leading or trailing/, which a cell's own settings refuse. "Preparing a cell" and "The tenancy check and placement" have prepare register the cell in the directory asattaching, under the directory lock, after proving it was given the live stores; the directory had no way to add a cell. The CLI that writes the nonces and the cell's rows,loom cell prepare, follows on top of this.Design
server/router/app.py,register): operator credential, then the cell name, then the body (host, deployment id, credential SHA-256, bucket and prefix, a later cell'sprobe_url, andnoncesfor postgres, clickhouse and bucket, the last null without a bucket). The host is normalised as routing compares it; the cell is the first when its host isLOOM_ROUTER_SHARED_HOST, and with that setting unset no cell registers (409 naming it).LOOM_ROUTER_SHARED_HOST, checked byloom router serve) must pass the address rule label by label and, for IPv6, be in its compressed spelling (routing.usable_host): a host is written once and never moved, so one address has one row.LOOM_ROUTER_UPSTREAM_PROBE_URL(a first cell's body may not name an address); both the router's addresses and a later cell's are checked in the shape the forward's upstreams take (routing.usable_upstream:http(s)://host[:port], printable, no?or#even empty, read by httpx alone, the parser the forward sends with, and a host that is a DNS name, label by label (no empty label, none starting or ending with a hyphen, a fully qualified name's final dot kept), or an IP address, a host of numbers only as a dotted-decimal IPv4 address (10.1,0xa.0.0.1,010.0.0.1or10.0.0.1.would be a second spelling of one), and a port 1 to 65535 in ASCII digits (httpx alone takes-1,1_0,77900or another script's digits); that function now reads an address only as httpx does, so a leading spaceurlsplitwould strip, an IPv4 address out of range, a host IDNA cannot encode, an unclosed[or a host such aseu|2is refused by the forward, registration andloom router servealike, a typo answering 400 instead of a retryable 503) and a later cell's at itsprobe_url, and registers only when it answers the deployment id, the bucket and prefix the body names (checked before the nonces, so a listener storing elsewhere is told so), and exactly the nonces sent (the listener answers the ones it stores under, A deployment answers its id on a probe route, and a probe listener echoes prepare's nonces #529: a probe object's absence is the normal state of a bucket in use, so a body naming no bucket could otherwise pass for a cell that has one). The call reads no proxy from the environment but trusts the certificate authorities the forward does (SSL_CERT_FILE,SSL_CERT_DIR), so a cell behind a private CA is probed as it is reached; it is bounded as a whole (15 s) and its answer as received to what a valid body makes the listener echo (the deployment id, bucket and prefix at their 1024-character cap and the nonces at their 128, six bytes a character at most as JSON): it asksAccept-Encoding: identityand refuses an encoded answer unread, so no compressed answer is inflated. A copy of another deployment's stores answers that deployment's id or none of this prepare's nonces. For the first cell the router also asks its upstream's main port (GET /v1/health/deployment, answered from memory) and refuses an upstream that reports another deployment id (409), or something that is not Loom (409), or one answering no deployment id (it runs without the Postgres authority, and never will: 409), or the probe listener's answer there (409), or names it unreachable, past a proxy's rate or behind a gateway's 502/503/504 (503PROBE_UNREACHABLE), since registration copies the upstream into the row. A listener past its rate answers 503PROBE_BUSYwith itsRetry-Afterwhen that is one to six ASCII digits and not 0 (a zero would have prepare ask again at once; else 1: the listener's text is not the router's, andstr.isdigittakes any script's digits); an unreachable one (a connection failure, or a gateway's 502 or 504 in front of it), or one that cannot read a store (its own 503, naming the store), 503PROBE_UNREACHABLE; a 503 naming no store of the listener's is a gateway's and is named as unreachable (both registered inserver/core/errors.py, so every 503 the operator API gives still carries a code); anything else answers 409.server/router/directory.py,register): in one transaction under the directory lock, the row asattachingwith its probe address, the first cell'supstream_urlset toLOOM_ROUTER_UPSTREAM_URL(the deployment the router fronts, so registering it changes no route; a later cell's stays '' until attach), the moderecording(first) orenforced(later) andmode_set_at, its host row and an audit row (naming its addresses, the copied upstream included). Refused (409): a second first cell, a later cell before the first, a new first cell whileLOOM_ROUTER_UPSTREAM_URLis unset or unusable (the router passes it as none; only a new row copies it, so a rerun needs none), a credential hash any cell holds as current or next, a deployment id or host another cell holds (the hosts table included), a bucket prefix sharing objects with another cell's in a bucket of the same name (one is the other or lies under it by path segment; the empty prefix holds all). A rerun for the row of the same name, deployment id and host answers that row (registered: false), refusing a hash that is neither its current nor its next, another bucket or prefix (they never change after prepare) and another probe address (loom cell update --probe-url's for a later cell); for the first cell, whose addresses are copied from the router's configuration at registration, a rerun reaching a router replica configured with anotherLOOM_ROUTER_UPSTREAM_PROBE_URLorLOOM_ROUTER_UPSTREAM_URLis refused, naming the registered address and the setting to set back (a later cell's: the--probe-urlto rerun with), so no rerun moves an address; every rerun check is one function (_rerun_refusal), and a new cell is put through every refusal registration would give (read-only, without the lock); the route runs them before the probe (refusal_before_probe), so a refusal is named at once as a 409 instead of a probe being retried as unreachable, andregisterruns again under its lock. Addresses are written one way however they are spelled (lower-case host, IDNA, IPv6 compressed, no default port, no trailing/; a fully qualified name keeps its final dot, as the forward resolves it), so replicas that spell one address differently agree (a replica not yet restarted in a router rollout cannot keep or revert one unseen, and an upstream is never written that no probe checked;loom cell updatemoves them, once every replica runs the new values), and runs none of the other checks; another id or host for that name is refused, and so is a rerun whose first-cell standing (its host against the shared host) differs from the row's.OPERATOR_CHANGE_MAX_Scoverslimitandcredentialonly. A registration's answer is bounded byREGISTER_ANSWER_MAX_S(server/router/app.py): the read before the probe (directory.REFUSAL_READ_MAX_S, a connection wait and six statements), the probe and the first cell's upstream check (15 s each), then the write (directory.REGISTER_MAX_S, a connection wait and thirteen statements), each connection also counting the pool's reset as it is released (asyncpg's, at the client bound;OPERATOR_CHANGE_MAX_Snow counts it too); a unit test counts both statement numbers against what the code sends through a counting connection, so a statement added to either path fails until the bound counts it.loom cell prepare's client (next PR) waits at least that long.nextnaming the router's operator credential's hash is refused (400): a cell holding it could make every operator change. The other way round, the operator API takes only anlco_credential, so a cell'slcr_one never operates even if its hash were configured as the operator's.LOOM_ROUTER_UPSTREAM_PROBE_URL("" = no first cell can register); registering the first cell also needsLOOM_ROUTER_UPSTREAM_URL.loom router serverefuses to start with either upstream address set in another shape, as it did for the upstream alone, and with aLOOM_ROUTER_SHARED_HOSTnaming no valid host (registration refuses one too, rather than taking every cell for a later one). The probe's transport is aRouterargument (probe_transport, None for the network), so tests serve a listener in process.Scope and risk
New route and setting only; nothing calls the route until
loom cell preparelands. The router's other answers are unchanged.Compatibility, rollout and rollback
No migration: the columns exist since router migrations 001 to 003. A router of the build before this answers the path 404 (
/cells/{rest:path}), which the CLI reads as a refusal. Rollback: the route goes with the build; rows it wrote stay valid for the later steps.Tests
tests/unit/test_cell_register.py(96): the first cell is probed at the router's own address and registers asrecording, at the fronted deployment's upstream, which must report the same deployment id and be reachable (a gateway's answer is retried, a page that is not Loom, a 500, the probe listener's answer and one without the Postgres authority refused); neither a registration nor a rotation takes the operator credential's hash, and a cell's credential never operates; a host normalising to the shared host is the first; a later cell at its own address, its host normalised, asenforced; an address spelled with capitals, a default port or a trailing/is written one way; a rerun the directory refuses is refused before the probe; IPv6, final-dot and default-port spellings are written one way (and a directory that cannot be read then answers 503BACKEND_UNAVAILABLE); a first cell naming a probe address is refused, no first cell is probed without the router's probe address (empty or without a scheme), and an unusable upstream (empty, without a scheme, or with a path the forward would drop) reaches the directory as none; a later cell's probe address must be http or https with a host (no user, query, fragment, path or control character, an empty?or#, a port that is no ASCII number from 1 to 65535, a host that is no DNS name or IP address, or one with an empty or hyphen-edged label, and read as httpx reads it, a leading space included); a probe answering another id, the main port's answer (named as a probe address that points at the main port), other nonces, another bucket or prefix, a page, a 404 or 500 (no listener at that port), an answer past the cap (and one echoing every field and nonce at its longest, six bytes a character, read) or nested past the parser's depth or a compressed answer (asked uncompressed) refuses with 409; a body naming no bucket is refused by a listener that stores under one; a busy, an unreachable, a store-failing probe and a gateway's 502 or 504 answer 503 with their codes (andRetry-After, 1 when the listener names none); a cell with no bucket registers against a listener with none; a listener'sRetry-Afterpasses only as a short count; a probe past its deadline isPROBE_UNREACHABLE; after a written registration, a rerun and a 503 the new cell's credential is read at once by the same replica; malformed bodies, each refusal naming the bound (a lone surrogate, which Postgres cannot store, a NUL, a field past 1024 characters, a nonce past 128, the credential instead of its hash, no host or id, a bucket without its nonce, an empty one, or the reverse, extra keys, wrong types) answer 400 and probe nothing; the directory's refusal is 409 and its outage 503BACKEND_UNAVAILABLE; the operator credential and a valid cell name are required; no cell registers withLOOM_ROUTER_SHARED_HOSTunset, a malformed body (a prefix without its bucket, a malformedprobe_url) being refused as such first; the registration bounds count the statements the code sends; the probe trusts the forward's certificate authorities;loom router serverefuses an upstream probe address with no scheme, a path or a control character.tests/integration/test_router_directory_pg.py: against a real Postgres, a later cell before the first, and a first with no upstream, are refused; the first registers, with every column of its row and its audit detail read back; the shared host's route is still the fronted deployment; a rerun answers it and writes nothing, with or without an upstream and with the cell's next credential during a rotation, another hash, id, bucket prefix or later cell's probe address is refused, and a rerun at a router replica configured with another probe address or upstream is refused (the first cell's namingloom cell update), the row keeping the ones registration wrote, and the read before the probe answers exactly whatregisterrefuses for each rerun case, and names a later cell before the first, a first with no upstream, and a new cell's taken credential, deployment id or host, every overlapping prefix and a second first cell, and nothing for a new cell or a passing rerun; the test runs in a directory database of its own, so its first cell is no other test's; a rerun whose host is no longer, or is newly, the shared host is refused; a second first, and a later cell holding the first's hash, id or host or an overlapping prefix (under it, over it, empty) are refused; a sibling prefix and another bucket register; the audit rows in order. Passed locally.test_deeply_nested_hidden_html_parses_in_bounded_time, is a timing test that fails the same way without this change), the router directory and probe store integration tests,make lintandmake typecheck.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: lint, typecheck and the targeted unit tests pass; the full unit suite has not run on this stack.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