Skip to content

feat(hosts): every instance knows the fleet, and one join pairs it with every member - #466

Merged
nplez1 merged 39 commits into
mainfrom
nplez1/host-graph-discovery
Nov 26, 2026
Merged

nplez1 merged 39 commits into
mainfrom
nplez1/host-graph-discovery

Conversation

@nplez1

@nplez1 nplez1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

What this does

Every Orca instance now knows which machines you own, counts them honestly, and — with one action per
machine — becomes paired with all of them. Then the workspace list is identical on every host, because each
host reads every other member's projects and workspaces.

The user's requirement, verbatim: "The workspace list on EVERY host should look identical including
workspaces from all of the hosts in the group."

Why it needed two halves

Discovery. Pairing is directional — the caller holds the environment record — so a hub-and-spoke pairing
showed a different fleet on each machine: the hub counted one host, a leaf counted three, and a Windows host
counted none. Each host now reports the edges it owns, a client address, and what each peer reported, with
hearsay labelled as hearsay and aged out. The status bar counts the fleet it can actually see and names the
peer that said so.

The group. Discovery shows the fleet; it does not pair anything. A mesh group is what makes the
sidebar identical: joining one member pairs the newcomer with every existing member, so n machines need n
actions instead of n(n−1). Every member can then run work on every other (orca-np --environment <label>),
and losing any one member leaves every other pair intact.

The decision that shapes it

pairing.createOffer is pairing-admin, and that tier is owner-only — "paired clients and phones never hold
pairing-admin"
. Minting on a peer's behalf would turn every pairing into a grant to widen that peer's access.
So no host mints an offer for another: each host mints its own with no grants, seals it to the one machine
allowed to redeem it (nacl.box static-static over a domain prefix), and the introducer is a courier for a
box it can neither open nor alter.

Consent is off by default and is one action per machine: Allow this computer to be added to a group.
A paired desktop therefore cannot bootstrap this host into a group, mint offers on its behalf, or make it dial
out.

Upgrading an existing install

Nothing is rewritten. The group lives in its own host-mesh.json, the pairing table is untouched, and a build
without the mesh ignores the file.

On the first launch of a build with the mesh, one migration runs and records that it did: it reads the pairing
table — the same edges discovery already reports — and groups this computer with every machine it is already
paired with. It mints and dials nothing, so every link starts awaiting its offer and an unrepaired fleet looks
unrepaired. A machine with no pairings records that it had nothing to group, which is why pairing a second
machine later does not silently create a group you never asked for; and because the file is written, leaving a
group is never undone by the next launch. The pane says where the group came from.

Two machines upgrading independently derive different group ids, because a leaf sees only the hub. So a host
takes on another's group when that group contains its own and every machine in it is either already paired here
or vouched for by a member that is. The id is derived from the members rather than random, so two machines that
saw the same fleet agree outright, and containment rather than overlap, so two fleets sharing one machine never
merge through it.

Two structural gaps surfaced here and are fixed: a host with no group at all was refused an introduction, so a
machine that had never joined could not be brought in by anyone — the opposite of one join pairing it with
everyone; and sync answered a member whose group id differed with an empty member list, which is precisely
what kept an upgraded fleet split. Membership now decides that rather than the id, and a non-member learns
nothing.

Updating one machine at a time is handled explicitly, because that is the normal case — the machine
holding every pairing goes first. An old-build peer answers method_not_found, which is recorded as
Needs update rather than an unreachable network, and no offer is minted for it: the repair would
otherwise hand out a live device row at a machine that cannot redeem it, on every sync. A successful sync
proves its link, which is what lets a migrated group start repairing itself, and migration carries each
peer's public key from the pairing record — without it nothing can be sealed to that member and the fleet
never completes. Three simulations cover the rollout: the hub updating first mints nothing and reports both
peers as needing an update; a leaf converges on the hub's group the moment it updates and learns the member
it had never met; and when the last machine updates, all three hold one group with every pair complete.

Proven by a three-host simulation of the upgrade itself: three machines that only ever knew the hub each migrate
to their own group, and after two syncs each they hold one group and know all three members.

Keeping the upstream sync cheap

The measured surface is 40 lines across 8 upstream-owned files; everything else is new files. The register
is local/checks/host-mesh-upstream-seams.mjs, wired into local/gate-lint.mjs: it fails when an
upstream-owned file is touched without being declared, or when a declared seam grows past its budget. Per-seam
resolution notes are in local/design/host-mesh.md § Upstream sync surface.

Upstream file Lines Seam
status-bar/.../SshStatusSegment.tsx 21 call site of RelayedFleetStatusItems, one hook, two counts
cli/hosts/host-handler-groups.ts 6 import + HOST_MESH_HANDLER_GROUP
startup/.../main-process-runtime-launch.ts 3 import + installHostMeshRuntime(runtimeRpc) + a lint directive
settings/.../RuntimeEnvironmentsPane.tsx 3 import + <HostGroupSection />
rpc-method-registry.ts, protocol-version.ts, cli/specs/index.ts 2 each one import and one entry
cli/dispatch/remote-selection-scope.ts 1 one condition

Three decisions bought most of that:

  • Four upstream files were deleted from the diff, not edited. The mesh service is a configured singleton,
    so threading it through RpcContext put this feature into core.ts, the admission prologue, the mobile
    pairing subclass and the stream options — to copy a constant. The handler resolves it itself.
  • No comment above upstream's code. The fork's own check-upstream-file-comments ratchet measured 162 of
    233 conflicts in a past sync coming from exactly that, so this patch adds zero fork comment lines to
    upstream files; the register lives in the two fork-owned documents instead.
  • Every remaining seam calls a fork-owned module (installHostMeshRuntime, FORK_RPC_METHODS,
    HOST_MESH_HANDLER_GROUP, notifyHostGraphOfConnectionChange, RelayedFleetStatusItems), so a conflict is
    resolved by keeping one line, not by re-reading an implementation.

The fork's ratchets also shaped the code: staleness now uses upstream's shared clock instead of a new interval,
the store has no direct sync-fs probes, the machine-identity ssh read is async, and the store is split at its
mailbox seam so it needs no max-lines exemption. Two fork-owned files still carry one (declared in
local/lint-known-red.json with the split as named follow-up), plus upstream's launch script, which sits
exactly at its 300-line cap and cannot be split by a fork.

Verification

  • Unit gate @a938bc44: PASS — 10,941 passed, 0 failed
  • Lint gate @a938bc44: PASS — 54 green, 0 new red (3 declared known reds: two fork-owned files pending a
    split, one upstream launch script at its line cap)
  • 94 tests on the new code, including a three-host simulation that drives the real protocol through a fake
    transport with the real reducer, admission rules and sealed boxes: a join reaches every pair; every host
    renders the same fleet; a refused introduction shows as a gap rather than a false pairing and is repaired by
    one sync; a removal cuts both directions and a tombstone refuses re-introduction; a host whose owner never
    opted in refuses the join and mints nothing.
  • Verified live in the running app: Settings → Remote Orca Servers → Host group renders real state (hidden
    renderer via CDP, no focus stolen), and toggling writes host-mesh.json beside orca-e2ee-keypair.json in
    the canonical user data directory.

Reviewed by Opus 5.5, high: R1 (3 blocking fixed), delta (1 new blocker fixed, not re-reviewed)

Known limits, also in LOCAL-PATCHES.md: member lists arrive unauthenticated, which is the conceded cost
of auto-pairing — one member can name a machine it controls and every member will pair with it, bounded by the
opt-in, the attribution on every row, the 12-member cap, four introductions an hour and ejectability. Any
workspace caller can drain another host's pending boxes (a denial of service: only the addressee can open
one). The store has no lock, so two concurrent RPCs can lose an update.

Not verified on real machines: endpoint reachability across LAN and Tailscale (the likeliest cause of a
half-join) and removal while a member sleeps. Loopback is refused outside tests, so a real offer exchange needs
two real Electron main processes. Treat a group as proven on one network and unproven across two until a
Studio + laptop + VM run happens.

@nplez1 nplez1 changed the title feat(hosts): hosts know each other, so every instance shows the same fleet feat(hosts): every instance knows the fleet, and one join pairs it with every member Nov 25, 2026
… hub and its leaf agree on the fleet

The first version composed only the answers to the questions it asked, so a machine that is
called and never calls learned nothing: on the documented hub the Studio showed two hosts,
the laptop three, and the VM and Windows box zero. The driver now composes the reports it
holds as well, and an answer's revision covers the hearsay, so a new caller is not invisible
for as long as the caller keeps asking.
…minting records the row removal revokes, and a sync that learns a removal cuts the credential
… is old, mints nothing for it, and joins each machine when it updates
The group needs a handful of hooks in upstream's tree. Each is now a single
line behind a fork-owned helper, carries a local(hosts) marker, and has a line
budget enforced by local/checks/host-mesh-upstream-seams.mjs.

Deleted rather than moved: the mesh service is a configured singleton, so
threading it through RpcContext touched four upstream files (core, the
admission prologue, the mobile pairing subclass, the stream options) for a copy
of a constant. The handler resolves it itself instead.
…above upstream code

The fork's own ratchet measures fork comments in upstream-owned files: 162 of the
233 conflicts in the 2026-10-28 sync came from them. This feature had added eight,
so all of them go, and the register moves to local/checks/host-mesh-upstream-seams.mjs
plus LOCAL-PATCHES.md — forty-three lines across nine upstream files, budgeted.
The lint gate was red on this PR for a step that passes locally: CI checks out
the pull request's merge commit and fetches no branch ref, so the register's
`origin/main` base did not exist and its `upstream/main` ownership ruler did not
either. The first crashed the step inside `git merge-base`; the second would
have made every touched file look fork-owned, which passes while checking
nothing.

The base is now the merge commit's first parent where there is one (the rule
`check:code-quality:changed` already follows, reused from
config/scripts/git/pr-diff-base), else `origin/HEAD`, `origin/main`, `main`. The
ruler is `upstream/main` where the clone has it, else the upstream commit the
sync baseline records — the fallback `check-upstream-file-comments` already
makes. Neither resolving is exit 2 with the fetch that fixes it, not a stack
trace whose last line is all the gate can quote.

Qualified by local/checks/host-mesh-upstream-seams.test.mjs, which builds both
shapes in a fixture repo: a merge commit with no branch ref, and a tree with no
upstream remote.
@nplez1
nplez1 force-pushed the nplez1/host-graph-discovery branch from 577da51 to 008aa17 Compare November 25, 2026 20:10
@nplez1
nplez1 merged commit 1504c94 into main Nov 26, 2026
19 checks passed
@nplez1
nplez1 deleted the nplez1/host-graph-discovery branch November 26, 2026 07:29
nplez1 added a commit that referenced this pull request Nov 26, 2026
…er feature's PR (#484)

#466 wired `check-host-mesh-upstream-seams` into the lint gate, where it runs on every pull
request, and it failed on any upstream-owned file a diff touched. The first branch to run it
after that merge was #471, a workspace state fix touching eight upstream renderer files and no
host-group seam at all, so the gate went from green to red for a whole class of work.

A register of one feature's surface cannot demand a declaration from features it does not
describe. The budget of a declared seam still fails hard — that is the guarantee the file
exists to keep — and an undeclared upstream file is reported as a note. `--strict` restores
the red for the host group's own branches, where an undeclared hook is exactly the sprawl the
check was built to catch.

The same change fixes a latent crash the old exit-early path hid: the verbose listing read
`seam.budget` for every touched file.
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