Skip to content

fix(ssh): a missing relay inventory never proves terminals exited, and the Windows census covers every desktop's relays - #25611

Merged
OrcaWin merged 1 commit into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-astra3-census
Oct 5, 2026
Merged

OrcaWin merged 1 commit into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-astra3-census

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​316 $\color{#cf222e}{\Huge{\mathbf{−}}}$​48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​268
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​393 $\color{#cf222e}{\Huge{\mathbf{−}}}$​111 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​282

ELI5

Before Orca converts an SSH host to a managed server, it has to be sure no terminal is still running on the host's old relays. If one is, converting would strand it. Two gaps let a running terminal slip through:

  1. Silence read as "nothing running". When this computer had no record of any terminal on the host, Orca treated "I couldn't ask the relays" the same as "the relays say nothing is running".
  2. Other computers' terminals on Windows were invisible. On a Windows host, Orca only looked for relays started by this computer, so a terminal another computer opened on the same Windows account was never seen.

Now Orca converts only when it has actually confirmed that nothing runs.

What Changed

1. A missing inventory is never "exited" (Astra-3 finding 3, high).

  • Before: assessOrcadMigrationTerminals returned exited as soon as this desktop had no detached or expired lease, before checking whether the current or earlier relays had answered. A failed listing plus no leases meant "exited". The delta move and the conversion acted on that, and the later fence only checks local leases.
  • After:
    • If either relay listing fails, or the earlier relays can't be asked (incomplete census, a Windows earlier relay that can't be bridged, a relay that didn't answer), the result is unverifiable whatever the lease count.
    • With no relay session at all, the gate no longer reads the silence as exit. It returns unverifiable with needsHostCensus, or takes a host census, which must prove the endpoints idle.
    • The connect passes its own census result to the conversion it starts (convert(target, hostProof)). The explicit conversion and the delta move run the same host census themselves (censusHostRelayTerminalsFor).
    • A census that can't list endpoints (unenumerable) now maps to unverifiable, not to exit.

2. The Windows census covers every desktop's relays (Astra-3 finding 4, medium).

  • Before: censusWindowsHostRelays derived the two pipe names per version directory from this desktop's target id. Another desktop's relay on the same Windows account has a different target id, so it was never probed.
  • After:
    • The census lists every orca-relay-* pipe on the machine (\\.\pipe\). It maps each pipe to the relay instance that owns it through that instance's <sock>.credential file or .windows-active-pipe-<sock> marker in its version directory (ssh-host-relay-windows-inventory.ts), and asks each instance through its own bridge with its own credential.
    • A pipe no directory accounts for is unverifiable, unless a connect attempt proves it belongs to another Windows account (EACCES/EPERM) or is already gone (ENOENT).
    • A pipe table or version directory that can't be read makes the whole census unverifiable.

docs/reference/ssh-execution-boundary.md describes both rules.

Why

The execution-boundary rule is that losing contact is never evidence of exit. "Nothing leased here" says nothing about terminals another desktop or the CLI started, so only an inventory that actually answered can prove the host is idle.

Separating "needs a host census" from "authoritative empty" keeps a connect with no session able to convert after its census proves the host idle, instead of either trusting silence or never converting.

For Windows, the machine's pipe table is the only complete list. Each relay instance already writes its credential and pipe marker next to its version directory, which is enough to find the right credential for each pipe without knowing other desktops' target ids.

Linked Issue

Fixes #

Astra review 3, findings 3 and 4.

Visual Proof

N/A: no UI change. Hosts with unproven relay terminals stay on the relay, as the status already reports.

Testing

  • Gate:

    • with no leases, a current-relay failure and an earlier-relay failure (including a Windows earlier relay that can't be bridged) are unverifiable;
    • with no session, the gate asks for a census, and the census verdicts (exited, live, unverifiable, thrown) map correctly;
    • the relay lister proves exit only when every relay answers.
  • Connect: an unenumerable census is unverifiable. A session whose current or earlier relay can't answer is unverifiable with no leases, and the host isn't asked.

  • Conversion: with no session, it converts only on a host census proving idle, and refuses on live or missing proof.

  • Windows census:

    • two target ids on one Windows account: desktop A's census asks desktop B's live relay with B's credential;
    • a pipe found only through its marker;
    • an unmapped pipe is unverifiable unless it belongs to another account;
    • an unreadable inventory is unverifiable;
    • an owned pipe that can't be asked is unverifiable;
    • idle cases.
  • Inventory script: it runs on the host's Node against a temporary directory, and the parser rejects incomplete inventories.

  • Existing move, delta-move and conversion harnesses now give their host census explicitly.

  • src/main/ssh, the SSH and orcad IPC suites, the cross-version wire suite, pnpm tc:node and the changed-code quality gate pass locally.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Windows: one inventory exec per connect census, plus one access check only when unmapped pipes exist. It's bounded at 32 pipes, above which the census is unverifiable.
  • No wire changes. Old relays are only listed and asked, never changed.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…d the Windows census covers every desktop's relays

- The migration terminal gate returned `exited` whenever this desktop held no unresolved lease, even
  when the current relay or the earlier relays could not be asked. A failed or incomplete inventory
  is now `unverifiable` regardless of local leases. With no relay session at all the gate asks for a
  host census (`needsHostCensus`) instead of reading the silence as exit; the connect, conversion and
  delta move pass that census in, and the connect hands its own census result to the conversion it
  starts. A census that cannot list endpoints (`unenumerable`) is unverifiable too.
- The Windows connect-time census derived pipe names from this desktop's target id only, so another
  desktop's relay on the same account was never probed. It now lists every `orca-relay-*` pipe on
  the machine and maps each to the relay instance that owns it through that instance's credential
  file or active-pipe marker, asking each with its own credential. A pipe no version directory
  accounts for is unverifiable unless the host proves it another account's (or gone), and an
  inventory that could not be read is unverifiable.
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p3-astra3-census branch from c22d8e3 to 4f9367a Compare October 5, 2026 15:14

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

One missed caller: assessOrcadMigrationTerminals now treats a ListRelayPtyIds without previous as "the earlier relays could not be asked", and the Windows host-lane cell still passes a bare lister and asserts exited. Details inline.

Reviewed changes

  • A missing inventory is never exited (finding 3). The gate no longer short-circuits on unresolved.length === 0 before checking the relay listings: a null current or earlier listing is unverifiable whatever the lease count. With no relay session, a new withoutRelaySession() blocks as needsHostCensus unless a censusHost proves the host's endpoints none/idle.
  • Host-census fallback plumbed through conversion. HostRelayTerminalProof / censusHost now reach orcad-runtime-conversion, orcad-migration-delta-move, the move handler, and conversionCollaborators; relayTerminalsOnConnect always supplies a lazy census wrapper and the connect hands its own verdict to convert as hostProof so no second census runs.
  • Windows census covers every desktop (finding 4). censusWindowsHostRelays enumerates every \\.\pipe\orca-relay-<20hex> on the machine and maps each to its owning instance through that directory's *.credential files and .windows-active-pipe-* markers, bridging with the owner's own credential; unmapped pipes stay unverifiable unless the host proves them another account's (EACCES/EPERM) or gone (ENOENT). The cap moved from version directories to 32 pipes.
  • Docs. docs/reference/ssh-execution-boundary.md describes both rules.

ℹ️ Nitpicks

  • needsHostCensus: true is declared and set on the unverifiable verdict but read nowhere in production code (only the type declaration and one test assert it). Either consume it or drop it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes (incremental since c22d8e3c75)

  • Windows host-lane cell now supplies the earlier-relay lister. orcad-windows-relay-terminal-gate-test-cell.ts starts this deploy's previous-relay census (startPreviousRelayCensus(conn, targetId, deployed)), wraps its pty.listProcesses lister with previous: () => listPreviousRelayPtyIds(targetId), and clears the census in finally. With no earlier endpoints the census is complete and empty, so the gate proves exited after the PTY is shut down — the bare-lister case from the previous review is resolved.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 9bad9b2 into OrcaWin/node-rt-phase3 Oct 5, 2026
52 checks passed
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