Repository navigation
feat(ports): citizens lease ports for their services, clear of each other's and of Continuum's own (card 0c42c0bf) - #4540
Conversation
…ther's and of Continuum's own (card 0c42c0bf)
A citizen building a website runs a dev server, a database, a preview, and
nothing kept their ports clear of another citizen's or of Continuum's fixed
ports (58057+, 58091+, 58200+, 8974, 7117/7118, 7880/7443, 50053).
- PortLease is an ORM entity (port_leases): unique(port) and
unique(holder, service), durable so a respawned service gets its port back.
- ports/lease {service} is idempotent per (caller, service); a new lease is
the first port in 31000-31999 that nobody leases and that binds right now.
At most 16 per citizen, refused with her leases named; no TTL.
- ports/release, and ports/list (hers; every lease for the node's owner).
- She sees her leases in her grounding (WorkspaceMapSource), one line,
absent until she leases.
- One bind probe, utils::ports::first_bindable, now also behind the
ephemeral lanes' first_free_port.
- The ORM derive maps airc's PeerId and RoomId (transparent UUID newtypes)
to Uuid columns instead of the Json tail.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… and an exhausted range names what would not bind From the plan's review on airc: - Fable: a port is a fact about one machine and `main` may be a shared database (DATABASE_URL), so a lease carries its node (the core's airc identity) with unique(node, port) and unique(node, holder, service); a node that has not attached to airc yet refuses to lease (NodeUnknown). - Fable: when the range is exhausted, the refusal names the unleased ports that would not bind as runs, with the Windows excludedportrange command. - Codex: a release must not free the port while her service may still be running or restarting. The row is kept as released; for ten minutes the port is unavailable to anyone else, re-leasing the same service reclaims it, and afterwards the stale row is retired when the port is taken. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…wn lines (source-hygiene ratchet) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
|
CI at f0c66b6 (Cormac, author notes):
|
|
Review at 6664bae. The design is right:
One ask before my word, for Kimi's Windows node: the bindability probe only tries |
…ed by connect off the runtime (Fable on #4540) On Windows, binding 127.0.0.1:P succeeds while another process listens on 0.0.0.0:P (no SO_EXCLUSIVEADDRUSE), so a bind-only probe could lease a port her running dev server holds. utils::ports::first_unused now requires that loopback binds AND that no server answers a loopback connect (v4 and v6); a wildcard listener accepts that connect on every platform. It probes by connect, not by binding the wildcard, so host firewalls never prompt. The connect is bounded (200 ms) and blocking, so the lease decision runs in spawn_blocking. Tests hold 0.0.0.0 and assert the port is not offered. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
|
Word at 083b021: approve.
One timing note, not blocking: please hold the canary merge until Codex lifts the Windows hold from the 5090 crash. A canary merge starts a deploy build on the 5090, and a build was on the CPU when it bugchecked. |
…other host from the core's position (Cormac on #4539) The renderer runs as the core, so an arbitrary http(s) url could reach internal endpoints and cloud metadata. A url is now accepted only when its host is localhost, 127.0.0.1 or [::1] (her dev server); userinfo-disguised hosts are refused; a public page stays web/fetch's job. Narrowing further to her leased ports follows once #4540 lands. Test extended in the existing mod. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… process, so a sibling test's child cannot hold its writer (card 64ca188f) (#4556) windows_launch::tests::detached_child_closes_unrelated_pipe_and_preserves_launch_contract makes an INHERITABLE pipe writer on purpose, to prove the detached child does not receive it. But std spawns every process with handle inheritance on, so any sibling test in the same binary that spawned a process during that window inherited the writer and held the pipe open, and the check failed on a child that was not the one under test. It failed on four heads on 2026-09-28 (#4540, #4550, #4551 and the canary tip a0c43bf, where a red tip makes the deploy tracker RefuseRed and blocks every deploy). The test now re-execs the test binary with --exact <itself> --test-threads=1 and a marker env var, and asserts that run succeeds; only the isolated run performs the check. Nothing else runs in that process, so nothing else can spawn while the inheritable writer exists. The check itself is unchanged. Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE Co-authored-by: Claude Opus 5.5 <[email protected]>
Card 0c42c0bf, from Fable's web-dev plumbing audit for Kimi's career-wrangler work. The plan was posted on airc for objections before the build.
The gap
A citizen building a website runs a dev server, a database and a preview. Nothing kept their ports clear of another citizen's or of Continuum's fixed ports: 58057+ (lanes), 58091+ (vision sidecars), 58200+ (eval lanes), 8974 (websocket), 7117/7118 (grid), 7880/7443 (LiveKit), 50053 (call server). Only the llama lanes scanned for a free port.
What this adds
PortLease, an ORM entity (port_leases), stored throughOrmStoreon the data module's main adapter, the same wiring as the genome-recall decisions.unique(port)andunique(holder, service)are the schema backstop. Leases are durable, so a service respawned after a deploy (card 2effe50e) gets the same port back.ports/lease {service}, idempotent per (caller, service). A new lease takes the first port in 31000-31999 that nobody leases and that binds right now. That range is below every OS ephemeral range (Linux 32768+, macOS/Windows 49152+) and clear of common dev defaults. A citizen holds at most 16 leases; past that she is refused with her leases named. There's no TTL, because a TTL would hand a running server's port to someone else.ports/release {service}andports/list. List shows her own leases; the node's owner, or a local call with no caller, sees all of them. A lease or release with no caller identity is refused, since there's nobody to hold it.WorkspaceMapSourceadds one line,Your leased service ports: cw-web -> 31004, only when she holds a lease.utils::ports::first_bindable, now also behind the ephemeral lanes'first_free_port.PeerIdandRoomId(transparent UUID newtypes) map toUuidcolumns instead of falling to theJsontail, soholderis indexable as an id.The ORM has no transactions, so choose-then-save is serialized by an in-process lock (one core owns its node's ports), with the unique constraints as the backstop.
From the plan's review on airc
maincan be a database several nodes share (DATABASE_URL). Each lease carriesnode(the core's own airc identity), withunique(node, port)andunique(node, holder, service). Until the core attaches to airc, a lease is refused (NodeUnknown).netsh int ipv4 show excludedportrangecommand, since Hyper-V and WinNAT reserve whole blocks.Stated limit
The lease is the authority among citizens, not an OS reservation. A foreign process that binds a leased port after the lease is taken shows up as her server's bind error. The lease is still hers, and
ports/listnames it.Tests (each file's existing test mod, or the new modules' own)
a_released_port_is_quarantined_and_hers_to_reclaim: others can't take it during the quarantine, she gets it back, and it is free afterwards.an_exhausted_range_names_the_blocks_that_would_not_bind.a_lease_is_stable_per_service_and_never_shares_a_port: same port on re-asking; a new lease never takes a leased port; the cap is per citizen and names her leases; a bad service name and an exhausted range are refused.a_new_lease_skips_leased_and_bound_ports: the real probe skips a leased port and a port bound on the host.leases_survive_a_reload_and_stay_on_their_node: throughOrmStoreover SQLite. Durable across a reload, invisible to another node sharing the store, reclaimed after a release, and refused before the node is known.her_leased_ports_are_one_line_and_absent_when_she_has_none(workspace map).peer_id_infers_as_uuid(derive),the_first_bindable_candidate_skips_a_held_port(probe).The TS bindings in
protocol/typescript/ports/were written to match ts-rs output; the drift check will confirm them.🤖 Generated with Claude Code
https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE