Skip to content

A deployment answers its id on a probe route, and a probe listener echoes prepare's nonces - #529

Merged
zlareb1 merged 9 commits into
mainfrom
feat/cell-probe-route
Nov 12, 2026
Merged

zlareb1 merged 9 commits into
mainfrom
feat/cell-probe-route

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):

Every deployment answers GET /v1/health/deployment with the deployment id it verified at boot, and LOOM_CELL_PROBE_PORT starts a probe listener that also answers the values under loom cell prepare's nonce keys in Postgres, ClickHouse and the document bucket, with the bucket and prefix it stores under.

Why

The eleventh of the pull requests that implement cells. It stacks on #526. "Preparing a cell" has prepare prove it was given the live stores of the deployment it registers: it writes a nonce to each store and reads it back through the deployment's probe route, and attach checks the deployment id a cell's host reports. Neither the route nor the listener existed; prepare follows on top of this.

Design

  • Main port (server/health.py): GET /v1/health/deployment answers {"deployment_id": ...} from memory, the id the process verified at boot ('' before). It reads no store, takes no credential, is not rate-limited, answers whatever the Host, and passes the cell gate as the other health paths do (server/transport/model_maintenance.py).
  • Probe listener (server/core/cell_probe.py): with LOOM_CELL_PROBE_PORT set, every web process runs a second uvicorn server on that port, on a socket bound on every address (:: with IPv4 too; 0.0.0.0 where IPv6 cannot open or bind; a port another program holds without SO_REUSEPORT fails at once; a process of the same user that sets it shares the port) with SO_REUSEPORT, so each process of the host accepts its share. It keeps the process's logging (no log_config) and installs no signal handlers, both the main server's. Shutdown asks it to exit and waits, so uvicorn closes its own servers. Its ClickHouse read is tagged cell.probe. Only the web lifespan starts it (boot.start_probe_listener); the workers child, which shares the container's network, never binds it. A port it cannot bind is logged as an error and the process serves on without it. It answers the same path with the id and nonces: the Postgres row loom.cell_probe and the KeeperMap key in loom._migration_lock, each named cell-probe, and the bucket object <prefix>/_cell_probe (null without a bucket or a value). Each is read on the request from the process's own connections. A store that fails answers 503 naming it (store) and the error's type, and is logged with the error's text; past 60 answers a minute per process, 429 with Retry-After. It runs with or without LOOM_CELL, since prepare reads it on a deployment before LOOM_CELL rolls out; the process then verifies its id and reads no cell row. LOOM_CELL_PROBE_PORT needs LOOM_STORAGE_AUTHORITY=postgres and authentication on, each refused at boot (with auth off the main port answers only its own hosts, so the route would not answer attach's host check).
  • Storage: Postgres migration 009_cell_probe.sql adds loom.cell_probe (name, nonce, written_at), classified in PG_NO_MEMORY_CONTENT (prepare writes and deletes its row; no tenant data). The KeeperMap key and the object need no schema.
  • Alternatives: serving the nonces on the main port would let anyone who reaches the ingress read store state and flood the reads, which the page rules out; a separate process would need its own store connections and lifecycle, while a second server in the process reads through the same connections the process serves with, which is what the echo has to prove.

Scope and risk

Off by default: with LOOM_CELL_PROBE_PORT unset nothing listens and boot is unchanged. The main-port route reads memory only. The listener binds every address, not LOOM_BIND_HOST (the published address, which in a container differs from the one listened on); who may reach the port is the operator's network policy, as the page says.

Compatibility, rollout and rollback

An additive Postgres migration (an N-1 build never reads the table) and an additive setting. Rollback: unset the port; the table may stay.

Tests

  • tests/unit/test_cell_probe.py: the main port answers the in-memory id with any Host and reads no store, and '' before boot verifies one. The listener answers the id and each store's nonce; a store that fails answers 503 naming it and is logged with the store, the error's type and its text; past its rate it answers 429 with Retry-After, and again a minute on. A second process binds and listens on the port while the first listens (it fails without SO_REUSEPORT); a port it cannot bind is logged and no listener starts; a host whose IPv6 will not bind takes 0.0.0.0. start_listener binds the configured port and serves on it; the listener serves on a real port, leaves the main server's SIGTERM and SIGINT handlers and the uvicorn loggers' levels in place, and stops when asked rather than by cancellation. The listener answers the bucket and prefix it stores under ('' and '' without a bucket). The bucket nonce is the object <prefix>/_cell_probe, read through the object-store fake, and reads None without the object or a bucket. Every test binds port 0. Not covered: the bucket read against a real object store, and the web lifespan starting and stopping the listener end to end.
  • tests/unit/snapshots/settings_defaults.json pins the new setting's default.
  • tests/unit/test_cell.py: a gated cell still answers /v1/health/deployment; the web lifespan step starts the listener only with the port set; the probe port without the Postgres authority or without auth is refused. Not covered: the workers child never starting a listener (it calls only start_cell_state, which starts none).
  • tests/integration/test_cell_probe_stores.py: against a real Postgres and ClickHouse, a nonce under each reserved name reads back and none reads as null. Passed locally.
  • tests/unit/test_cell_tenancy.py: the route census classes /v1/health/deployment as a health probe.
  • At this head's stack: every repo-wide ratchet, census and snapshot test file (the 243 files grep -rlE "rglob\(|walk_packages|BASELINE|snapshot|ratchet|census" tests/unit names: 7101 passed), the probe, cell and tenancy tests, make lint and make typecheck. 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 from 29aca52 to 7cda6fb Compare November 11, 2026 13:25
@zlareb1
zlareb1 force-pushed the feat/cell-probe-route branch from a805c3d to d8e6b86 Compare November 11, 2026 13:28
@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-probe-route branch from 999d3d6 to 750ad9c Compare November 11, 2026 14:48
@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-probe-route branch from 750ad9c to 32b4e1c Compare November 11, 2026 15:11
@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-probe-route branch from 32b4e1c to 5098e96 Compare November 11, 2026 15:31
@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-probe-route branch from 5098e96 to 21aad8a Compare November 11, 2026 15:47
@zlareb1
zlareb1 force-pushed the feat/cell-operator-commands branch from 2ea8282 to 28d2eef Compare November 12, 2026 02:22
@zlareb1
zlareb1 changed the base branch from feat/cell-operator-commands to main November 12, 2026 02:22
zlareb1 and others added 9 commits November 12, 2026 02:37
…hoes prepare's nonces

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he bucket nonce has a test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/cell-probe-route branch from 4829f2c to 97d2fa9 Compare November 12, 2026 02:48
@zlareb1
zlareb1 marked this pull request as ready for review November 12, 2026 02:48
@zlareb1
zlareb1 merged commit 42c9d21 into main Nov 12, 2026
@zlareb1
zlareb1 deleted the feat/cell-probe-route branch November 12, 2026 02:48
@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