Skip to content

loom cell limit and credential write the router's directory through its operator API, and loom cell which reads its lookup - #526

Merged
zlareb1 merged 1 commit into
mainfrom
feat/cell-operator-commands
Nov 12, 2026
Merged

zlareb1 merged 1 commit into
mainfrom
feat/cell-operator-commands

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New feature

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 cell limit closes, reopens or bounds a cell to new orgs, loom cell credential makes a router credential (new) and rotates a cell's (--next, --finish, --revert), and loom cell which --org names an org's cell. limit and credential write the router's directory alone, through a new operator API (which reads the public lookup and sends no credential) the router answers with its operator credential, so they work while a cell is down.

Why

The tenth of the pull requests that implement cells. It stacks on #523. The page's Operations section names these commands, and the router's credential rotation needs a next hash it accepts beside the current one; neither existed.

Design

  • Operator credential. lco_ and 128 lowercase hex (512 bits), which loom cell credential new --operator makes offline; any other form of LOOM_ROUTER_OPERATOR_TOKEN is refused when settings load, and the setting is masked as a secret (the secret-name classifier now covers operator_token). The CLI holds it; the router keeps only its SHA-256, LOOM_ROUTER_OPERATOR_SHA256 (64 lowercase hex), compared in constant time. With none configured, the operator API answers 503 with the code NO_OPERATOR_CREDENTIAL; a wrong credential 401. Refusals are not rate-limited: behind an ingress every caller shares one client address, so a limit would let one stranger lock out every operator while slowing no guess of a 512-bit credential. No cell's configuration holds it.
  • Operator API (server/router/app.py): POST /cells/v1/operator/cells/<cell>/limit with closed and/or placements_max (a whole number or null), and POST /cells/v1/operator/cells/<cell>/credential with a step (next with the new credential's sha256, finish, revert). Bodies are bounded and checked (400: unknown keys, an explicit closed: null, a rotation with extra keys); a name no cell can have answers 404 before the directory is asked, an unknown cell 404, a refused change 409; the answer is the cell's limit state and whether a next credential is pending. A rotation step makes the replica that took it read the hashes again on its next call; a read that began before the change is not kept for a window (a generation counter). Other replicas see it within LOOM_ROUTER_DIRECTORY_CACHE_S, which the page now says: the new credential goes into the pods only after that.
  • Directory (server/router/directory.py): set_limit and rotate_credential each run in one transaction under the directory lock (an advisory lock apart from placement's per-org one), lock the cell's row, write it in one statement and an audit row (actor operator). next is refused while one is pending and when any cell records the hash as current or next; finish makes next current and drops the old; finish and revert refuse with none pending.
  • Next credential. A new column, cells.credential_next_sha256 (schemas/router_migrations/003_cell_next_credential.sql, unique where set). directory.credentials() gives each cell's current and next hashes, and the placement call and the state read accept either (Cell.holds), as the page says.
  • CLI (server/cli/cell.py): loom cell credential new makes lcr_ and 128 lowercase hex offline and prints it with its SHA-256; --next takes the hash only, refusing the credential itself; loom cell limit needs one of --closed, --open, --placements-max; loom cell which --org asks the public lookup and prints its answer. Its body does not say whether an org is placed: an org with no placement gets the first cell's answer with the same body as an org placed there. Only a placed org's answer is cached, so timing and an outage can still tell the two apart; an org name is not treated as a secret. The router is --router, else LOOM_CELL_ROUTER_URL; an answer that is not the router's JSON object (another service's page at that URL) fails, so no change reads as made; a --cell no cell can have is refused before the operator credential is sent anywhere (a path such as ../../v1/… would otherwise carry it to another route); --placements-max takes ASCII digits only; no router is a usage error (exit 2); the operator credential goes only to an https router, or http on loopback with no proxy from the environment; a router URL with no host, a bad port, a path, a query, a fragment or a user is refused before any call (the router answers its API at its root and forwards anything else to a cell), and the CLI sets the operator path as the URL's path, so it cannot land in a query and carry the credential to a route the router forwards to a cell. A call sent but not answered within the router's longest operator change plus 10 s (OPERATOR_CHANGE_MAX_S: the connection wait and eight statements at their client bound, 98 s) says the change may have been made, since the router can still commit it, and what a retry shows (a credential step refused as already pending or done was made; a limit is safe to repeat); a connect failure, connect timeout or a proxy that refuses the tunnel is an unreachable router. The outcome is known only when the connection never opened or the router itself answered (200 with a JSON object naming the cell or org asked about, or one of its refusals with an error string; a gateway's 502 or 504, JSON or not, is not the router's answer), other than with the code BACKEND_UNAVAILABLE (every 503 the lookup and the operator API give carries a code, so one without is a proxy's; the operator API's directory 503, after which a COMMIT that waited past its bound on the standby may have landed); after a timeout, a dropped connection or a gateway's page the CLI says the change may have been made. A lookup's read waits out its two directory reads (the org, then the first cell) plus 10 s, not the operator bound, and which tells a router that did not answer from one it could not reach. None connects to a cell's stores.
  • Settings, generated reference, schema, example, CLI reference and CLI snapshots are regenerated; the page's code map names the operator API.

Scope and risk

Router and CLI only. Still to come: loom cell prepare, attach, update, place, restore and each, which write a cell's own rows besides the directory.

Compatibility, rollout and rollback

The lookup's 503 for a directory it cannot read (an org it has not cached) now carries the code BACKEND_UNAVAILABLE; loom login --org matches only NO_CELL and reads it as before. An additive directory column. Run loom router migrate before rolling out this router (it reads the new column; without it placements, state reads and the lookup of an org with no placement answer 503, and /readyz reports unready, since its check reads every cells column this build needs, so a rollout ahead of the migration halts), and start a rotation only once every router replica runs this build (an older one reads credential_sha256 alone). The router needs LOOM_ROUTER_OPERATOR_SHA256 set for the operator API; without it the API refuses and nothing else changes. Rollback: an older router reads credential_sha256 alone, so it refuses a pod already on the next credential; roll back with no next pending (--revert first). It fails closed.

Tests

  • tests/unit/test_cell_operator.py (109): a new credential's form and hash; every malformed credential invocation refused before any call; each rotation step and each limit sent to the operator API with the operator credential; an empty or malformed limit refused; no operator credential refused; a refusal printed and failing; which asking the lookup; no router refused. The API: a wrong, missing or unconfigured operator credential answers 401 or 503 and writes nothing; a limit is written and answered; malformed limits and rotations answer 400; an unknown cell 404 and a refused rotation 409; a pending next is named; a row holds its current and next hash; an operator credential is lco_; a limit setting nothing, a rotation with extra keys and a name no cell can have write nothing; a run of wrong credentials answers 401 each time and the right one still works; a rotation is read again by its replica on the next call, and a read begun before a change is not kept (the directory is read again); a page that is not the router's answer fails which and limit; a cell name no cell can have (a ../ path, uppercase, empty, too long) is refused with no call; --placements-max with ², +5, a space or a value past the directory's bigint is refused (the API answers 400 for one); credential new with --router is refused; an http router that is not loopback gets no call. A timed-out change (read, write or pool timeout) says it may have been made, and a connect timeout says the router could not be reached; an operator change the directory cannot take answers 503, with the code BACKEND_UNAVAILABLE, and the CLI says that change may have been made; a read error, a dropped connection and a gateway's 502 or 504, HTML or JSON, say so too, while a connect failure, an unconfigured router's 503 and a 409 do not.
  • tests/unit/test_router.py: a cell's next credential places and reads its state during a rotation, and after --finish the old one answers 401; the lookup answers an org with no placement exactly as an org placed in the first cell.
  • tests/integration/test_router_directory_pg.py: a limit set and its quota cleared with closed kept, an unknown cell refused, a rotation refused for another cell's current hash, finish refused with none pending, next recorded and returned by credentials(), a second next refused while one is pending, another cell refused that next hash, finish making it current, revert dropping a pending next and refused with none, a retried next of the same hash named as already the cell's next, directory.ping (which /readyz runs; test_router.py shows a failed ping answers 503) failing without a column this build reads, the operator audit rows in order with every field of their detail, and two cells asking for one next hash at once with exactly one let in. Passed against a local Postgres.
  • At this head: the operator, router, routing, CLI-snapshot, settings (env contract, secret masking), SDK-credential and doc tests (516 passed); make lint and make typecheck pass. 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 typecheck and make test-unit pass: lint, typecheck and the targeted unit tests pass; the full unit suite has not run on this stack.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/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).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch 2 times, most recently from 26316a5 to 20425bd Compare November 11, 2026 09:05
@zlareb1 zlareb1 changed the title loom cell limit, credential and which act on the router's directory through its operator API loom cell limit and credential write the router's directory through its operator API, and loom cell which reads its lookup Nov 11, 2026
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from 29aca52 to 7cda6fb Compare November 11, 2026 13:25
@zlareb1
zlareb1 force-pushed the feat/cell-router-routing branch from 069cab7 to 10a4863 Compare November 11, 2026 14:48
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from 7cda6fb to c9a4216 Compare November 11, 2026 14:48
@zlareb1
zlareb1 force-pushed the feat/cell-router-routing branch from 10a4863 to 14bdc3f Compare November 11, 2026 15:11
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from c9a4216 to 3f1d204 Compare November 11, 2026 15:11
@zlareb1
zlareb1 force-pushed the feat/cell-router-routing branch from 14bdc3f to 35acd3c Compare November 11, 2026 15:31
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from 3f1d204 to 180449d Compare November 11, 2026 15:31
@zlareb1
zlareb1 force-pushed the feat/cell-router-routing branch from 35acd3c to c93c4b7 Compare November 11, 2026 15:47
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from 180449d to 2ea8282 Compare November 11, 2026 15:47
@zlareb1
zlareb1 force-pushed the feat/cell-router-routing branch from c93c4b7 to 988b5e8 Compare November 12, 2026 01:55
@zlareb1
zlareb1 changed the base branch from feat/cell-router-routing to main November 12, 2026 01:55
…ts operator API, and loom cell which reads its lookup

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from 2ea8282 to 28d2eef Compare November 12, 2026 02:22
@zlareb1
zlareb1 marked this pull request as ready for review November 12, 2026 02:22
@zlareb1
zlareb1 merged commit 4e56298 into main Nov 12, 2026
21 checks passed
@zlareb1
zlareb1 deleted the feat/cell-operator-commands branch November 12, 2026 02:22
@zlareb1 zlareb1 mentioned this pull request Nov 12, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant