Repository navigation
fix(ssh): route four host-blind seams through the resolved execution host - #17919
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Worktree scan and cache routing —
orca-runtime-refresh-repo-worktree-scan.ts,orca-runtime-list-known-resolved-worktrees-for-explicit-target.ts, andinvalidateSshWorktreeScanCacheInternalnow resolvesshConnectionIdviagetRepoSshConnectionId, so anexecutionHostId: 'ssh:*'-only repo scans over its SSH provider, gets anssh:<target>:<generation>cache key instead oflocal:default, and invalidates when the provider generation changes. - Managed worktree create —
orca-runtime-create-managed-worktree.tsresolves the host once; folder workspaces route agent trust to the owning host, and git workspaces normalize{ ...repo, connectionId: sshConnectionId }before the remote-create pipeline. - Project host setup —
runtime-project-host-setup-controller.tssplits the blanket SSH refusal sosetup-existing-folderroutesssh:*through the desktop IPC handler's ownaddRemoteRepoFromPathwhilesetupClonestill refuses with an accurate message. - Dedupe and host matching —
addRemoteRepoFromPathandruntimeRepoMatchesExecutionHostcompare on the resolved execution host, so either spelling of SSH ownership dedupes/matches correctly while a genuinely host-less legacy row stays adoptable. - CLI path guard —
setup-existing-foldertreats anssh:*host as off-client for relative--pathresolution, rejecting relative paths instead of resolving them against the client cwd.
The fail-before/pass-after tests exercise both spellings (connectionId-only and executionHostId-only) and pin the PTY routing, scan provider, and trust targets; the assertions are exact rather than loose.
ℹ️ Nitpicks
- The comment above
getRequiredHostIdinsrc/cli/handlers/project.ts:71-73still says the runtime rejects everyssh:host "for those operations" — after this PR that is only true ofsetup-clone;setup-existing-foldernow routesssh:*to the remote registration. Worth a one-line touch-up so the rationale matches the split. runtime-project-host-setup-controller.test.tsnames its local-registration test "local and runtime hosts" but only exerciseshostId: 'local'; adding aruntime:<env>case would make the title honest.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (ca0fa60), the delta is a two-file import swap that closes the Node-bootability regression the PR itself introduced:
- Direct SSH registry import —
remote-home-path.tsandremote-repo-registration.tsnow importgetActiveMultiplexerfromssh-target-registryinstead of theipc/sshbarrel, so the runtime path throughaddRemoteRepoFromPathno longer pullsipcMain/BrowserWindow(and the wider Electron graph) into the Node-bootable runtime bundle.ipc/ssh.ts:23re-exports the same function from that registry, so the swap is behavior-preserving on the desktop side. - Electron-free transitive graph confirmed — the two files' other imports (
ssh-git-dispatch,repo-icon-autodetect) andssh-target-registryitself import no Electron runtime modules, so the seam is fully closed rather than partially.
The targeted suites still pass (38/38 across runtime-project-host-setup-controller.test.ts and repos-remote.test.ts).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
2654842 to
2358260
Compare
f0deb06 to
8619642
Compare
2358260 to
0b15240
Compare
8619642 to
14577e3
Compare
0b15240 to
5f2c410
Compare
5ac7c85 to
680e21d
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (f0deb06), the delta is one commit closing the three remaining host-blind twins — launchAgentTerminal, workspace-session export, and remote-repo registration:
- Agent-launch trust write —
launchAgentTerminalnow resolves the launch host viaresolveWorktreeLaunchHost(the main-side adapter overresolveWorktreeExecutionHost) and writes agent trust with the resolvedconnectionId, throwingworktree_execution_host_unresolvedon ambiguous rows instead of the host-blindgetRepo(id)?.connectionId. - Session export routing —
remote-workspace.tstargetForWorktreeroutes throughresolveWorktreeExecutionHost+createRepoRowExecutionHostLookup, so a session exports to nobody on unresolved ownership rather than the host-blindgetRepo(id)?.connectionId. - Unified spelling at creation —
addRemoteRepoFromPathnow stampsexecutionHostId: toSshExecutionHostId(connectionId)and dedupes ongetRepoSshConnectionId, so the runtime's SSH registration path no longer mintsconnectionId-only rows or missesexecutionHostId-only duplicates.
The new suites (agent-terminal-launch-trust-host.test.ts, remote-repo-registration.test.ts) and the getRepos projections in the remote-workspace mocks exercise the previously-uncovered two-distinct-SSH-host case with exact assertions rather than loose ones; all 22 tests across the four touched suites pass.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…tion Three issues in one defect class: a resolver reads one spelling of one arbitrarily chosen row instead of resolving the worktree's execution host, so something local answers a question about a remote. returned that row's connectionId. With duplicate repo rows for one repo id it could pair a runtime owner with a client-owned SSH connection. It now resolves through the same ambiguity-aware index getRuntimeEnvironmentIdForWorktree uses, prefers the repo row for the host the worktree names, and derives the connection from the resolved host. Conflicting rows return `undefined` (this module's documented "cannot determine the host"), never `null`. `store.getRepo(worktree.repoId)?.connectionId ?? null`. `getRepo` is host-blind and the same repo id can exist on local, SSH and runtime hosts, so a remote worktree could spawn its PTY on the client with the remote cwd. resolveWorktreeLaunchHost picks the row for the worktree's host and reads the connection off that host; conflicting rows are unresolved, not local. session-partition owner maps that contradict each other. Both now compute through one shared function whose argument records the divergence. No behaviour change on either side: converging needs a read-both migration, since both partitions hold real data written by shipping builds.
…time host getRepoSshConnectionId read only the resolved execution host, so a repo row owned by a runtime that reaches a nested SSH target (connectionId: ssh-*, executionHostId: runtime:*) resolved to no connection — answering 'local' for a remote worktree, the same defect #17909 fixed in the other direction.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (8619642), the delta is a rebase onto the reworked #17909 base plus a retitle, not a code change to this PR's own surface:
- Shared resolver inherited, not re-derived —
worktree-execution-host-resolution.ts,worktree-launch-host-repo.ts(now a thin adapter over it), the rendererconnection-owner-resolution.tschange, and thegetRepoSshConnectionIdcomposition (getSshTargetIdForExecutionHost(getRepoExecutionHostId(repo))) all moved into the base branch, so they no longer appear in this PR's diff. The PR's own 21 files are byte-identical to the previously reviewed version (same per-file diff hashes). getRepoSshConnectionIdcomposition — the base now makes the execution host authoritative, so alocal/runtime:*row no longer hands out a staleconnectionId. This is the exact behavior the PR's newremote-repo-registration.test.tscase (does not dedupe onto a local row that carries a stale connection id) depends on, and it resolves the pullfrog finding this PR wired in.- Comment reword —
launchAgentTerminal's rationale comment was reworded; no behavior change.
The touched suites still pass (26/26 across the five changed/resolved test files).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ne rule The renderer resolver leaked between two different SSH hosts: a worktree on `ssh:m4air` whose only indexed repo row belonged to `openclaw` answered 'openclaw', because the host-scoped lookup missing fell through to an id-only one. Main's resolver, in the same change, answered 'm4air' — two resolvers, one right and one wrong, on identical input. Both sides now adapt one shared rule (`worktree-execution-host-resolution.ts`): the worktree's own host outranks every repo row, and a row on a different host is never evidence about this one. The renderer's WeakMap index becomes the memoizing adapter it always was; `resolveWorktreeLaunchHost` becomes main's mapping of unresolved onto its throw. Settles the rule the change previously answered two ways. `getRepoSshConnectionId` and `getSshTargetIdForExecutionHost` disagreed for a runtime host carrying a nested `connectionId`; they now compose, so the execution host is the single authority. On a `runtime:*` row that field is a paired HUB's private SSH target, spread through by `repoWithFetchedOwner` and unaddressable from this client — the project-first successor of the row nulls it for exactly that reason. That also fixes the `kind !== 'ssh'` fallback, which fired for `local`: a row declaring itself local handed out an SSH connection.
5f2c410 to
05bc9aa
Compare
… create The worktree scan and createManagedWorktree both picked remote-vs-local from repo.connectionId, so a row stamped only executionHostId: 'ssh:*' was scanned and created on the client against a remote path. The folder branch returns before the check, so its agent-trust write landed locally too. Refs #11163
runtimeRepoMatchesExecutionHost rejected an unstamped SSH repo against its own ssh:<connectionId>, so repo-add/clone dedupe could register a second row for a path the host already owns. assertHostIsSupported made the CLI/runtime RPC refuse --host ssh:* while the same process's IPC handler routed it correctly; setupExistingFolder now shares that registration. Clone still refuses, because nothing in this process clones onto an SSH host. Refs #11163
… it prevents setupProjectExistingFolder now registers the remote path through the same addRemoteRepoFromPath the desktop IPC uses, so it fails on the host's terms (connection not registered) rather than a categorical refusal. The local clone/probe side effects it exists to catch are still asserted absent. Refs #11163
…H host Routing --host ssh:* to the remote registration made relative paths newly reachable there, and they were resolved against the client cwd — registering a path that names the wrong machine. Refs #11163
…bootable Routing runtime project setup through addRemoteRepoFromPath dragged ipc/ssh -- and its 25-module electron graph -- into the runtime bundle. ssh-target-registry already exists for exactly this; ipc/ssh only re-exports it.
Three sites left on the legacy spelling, all the same shape as the ones this branch already fixed: - `launchAgentTerminal` did `getRepo(worktree.repoId)` then wrote agent trust with that row's `connectionId`. Host-blind, so a repo id carried by two SSH hosts wrote a remote path into the *client's* Codex/Cursor/Copilot config and the agent on the host never saw the trust. Every sibling call site already passes the resolved `workspace.connectionId`; this was the last that did not. - `targetForWorktree` (workspace-session export) fell back to the same host-blind read, so a session could be published to a machine that never owned the worktree. Unresolvable ownership now exports to nobody. - `addRemoteRepoFromPath` minted `connectionId`-only rows while being the routing path this branch adds, so it kept creating rows in exactly the spelling the branch works around. It now stamps `toSshExecutionHostId(connectionId)` at creation; `reassignSshTargetId` already migrates both spellings, so target rename stays correct. Tests cover two *different* SSH hosts throughout — the case none of the earlier duplicate-row tests had, all of which were local-vs-ssh or runtime-vs-ssh.
680e21d to
36f6ce6
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (680e21d), the delta is a force-pushed rebase that re-sequences and retitles the six commits without changing the PR's runtime surface:
- Re-sequenced commits, identical content — the commits now read
cbdaeebf7(worktree scan + managed create) →a9c58bba9(host-setup split) →69a502d01(guard-spec retarget) →f7fb1a64f(CLI absolute-path guard) →bb72699f8(SSH-registry import swap) →36f6ce64(agent-launch + session-export twins). Each maps one-to-one onto a previously reviewed change; the PR's own 21 files are content-identical to the last reviewed version. - Shared resolver stays in the base —
resolveWorktreeExecutionHost,getRepoSshConnectionId, andworkspaceSessionPartitionHostIdcontinue to live infix/execution-host-resolution(#17909) rather than this PR.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…t a raw field (#18294) `repoIsRemote` read `repo.connectionId` directly. That is one of four spellings of host ownership, so the predicate was wrong in both directions: a row carrying only `executionHostId: 'ssh:<target>'` read as local and got the Linux-only `orca-ide` rename it cannot resolve through the relay shim, while a row that declares itself `local` with a stale `connectionId` read as remote and lost the rename it needs on a Linux desktop. The predicate now resolves the host first and asks "does an SSH target hold this row's files" via `getRepoSshConnectionId`. That keeps a `runtime:` host's nested SSH target remote (that machine reaches the files through its own relay shim) while a runtime with no nested target - a full Orca install - stays local, as do WSL and local. Its call sites did not all want that question: - The four launch-scope sites in main already hold the resolved PTY route on `TerminalWorkspaceLaunchScope.connectionId`. `scope.repo` is documented display metadata and can be a row from a different host than the worktree names, so they now read the route they will actually spawn on. A launch shape that disagrees with its own route is the bug, not a second predicate. - `launchAgentInNewTab` picked its repo row with a host-blind `store.repos.find`, so a worktree that names its own host could be shaped by another host's row. It now resolves through `getConnectionIdFromState`, the same rule the file already used for transcript readability. - `resolveAgentBackgroundLaunchHost` derived the route, the trust write and the launch shape from three reads of the raw field; one resolution now feeds all three. Also converts the raw `repo.connectionId` agent-detection probe eight lines above `buildWorktreeStartupForDraft`'s launch shape, which #17919 deferred precisely because converting it alone would have left that file internally inconsistent. Tests cover two distinct SSH hosts (a single-host fixture passes even when the answer comes off the wrong row, which is how the `ssh:m4air` -> openclaw leak survived review) and a `runtime:` host carrying a nested SSH target.
…connectionId (#18307) `RuntimeGitTarget` carried `connectionId?: string` and no host id, so `undefined` spelled three different answers at once — "runtime: host", "unresolved", and "genuinely local". Its sole resolver read `store.getRepo(worktree.repoId)?.connectionId` and never looked at `worktree.hostId`, which outranks every repo row, so one arbitrarily chosen row decided the execution host for 36 downstream dispatches. The target now carries `executionHostId: ExecutionHostId` (never null, never optional), resolved through the shared rule that landed with #17909/#17919 and dispatched through the host-keyed routes from #18296. Dispatch sites call `requireRuntimeGitProvider`, where `null` means exactly one thing: the host is `local` and the command runs here as free functions. Four answers that used to collapse into one: - `ssh:x` with a rival row on `ssh:y` — routes to x. Previously the first row won, which is the reproduced cross-host leak. - `local` with a surviving `connectionId` — a row contradicting itself; no SSH connection is handed out. - `runtime:<env>` — throws `ExecutionHostNotDispatchableError`. Its repo row's connection names a target in the *server's* namespace; dialling it here reaches a same-named target on this client. - rival rows disagreeing with no worktree host — `worktree_execution_host_unresolved`, matching the launch path rather than guessing a row. An unreachable SSH host still throws `SSH_GIT_PROVIDER_UNAVAILABLE_MESSAGE`; loss of contact is never evidence of locality (docs/reference/ssh-execution-boundary.md). `resolveWorktreeLaunchHost` keeps its exact signature and now delegates to `resolveWorktreeHostRouting`, the same resolution answering "which host is this on" rather than "what may this client dial" — the git target needs the first question because `local` and `runtime:` are two different non-SSH answers. No wire change: `RuntimeGitTarget` is main-process internal, and the SSH and local model-discovery host keys are byte-identical to before. `RuntimeFileTarget` has the same defect in ~30 filesystem dispatches and is deliberately left for a follow-up.
…host (stablyai#17919) * fix(host-routing): resolve the execution host before reading a connection Three issues in one defect class: a resolver reads one spelling of one arbitrarily chosen row instead of resolving the worktree's execution host, so something local answers a question about a remote. returned that row's connectionId. With duplicate repo rows for one repo id it could pair a runtime owner with a client-owned SSH connection. It now resolves through the same ambiguity-aware index getRuntimeEnvironmentIdForWorktree uses, prefers the repo row for the host the worktree names, and derives the connection from the resolved host. Conflicting rows return `undefined` (this module's documented "cannot determine the host"), never `null`. `store.getRepo(worktree.repoId)?.connectionId ?? null`. `getRepo` is host-blind and the same repo id can exist on local, SSH and runtime hosts, so a remote worktree could spawn its PTY on the client with the remote cwd. resolveWorktreeLaunchHost picks the row for the worktree's host and reads the connection off that host; conflicting rows are unresolved, not local. session-partition owner maps that contradict each other. Both now compute through one shared function whose argument records the divergence. No behaviour change on either side: converging needs a read-both migration, since both partitions hold real data written by shipping builds. * fix(host-routing): keep nested SSH connections resolvable under a runtime host getRepoSshConnectionId read only the resolved execution host, so a repo row owned by a runtime that reaches a nested SSH target (connectionId: ssh-*, executionHostId: runtime:*) resolved to no connection — answering 'local' for a remote worktree, the same defect stablyai#17909 fixed in the other direction. * fix(host-routing): resolve both sides of the execution host through one rule The renderer resolver leaked between two different SSH hosts: a worktree on `ssh:m4air` whose only indexed repo row belonged to `openclaw` answered 'openclaw', because the host-scoped lookup missing fell through to an id-only one. Main's resolver, in the same change, answered 'm4air' — two resolvers, one right and one wrong, on identical input. Both sides now adapt one shared rule (`worktree-execution-host-resolution.ts`): the worktree's own host outranks every repo row, and a row on a different host is never evidence about this one. The renderer's WeakMap index becomes the memoizing adapter it always was; `resolveWorktreeLaunchHost` becomes main's mapping of unresolved onto its throw. Settles the rule the change previously answered two ways. `getRepoSshConnectionId` and `getSshTargetIdForExecutionHost` disagreed for a runtime host carrying a nested `connectionId`; they now compose, so the execution host is the single authority. On a `runtime:*` row that field is a paired HUB's private SSH target, spread through by `repoWithFetchedOwner` and unaddressable from this client — the project-first successor of the row nulls it for exactly that reason. That also fixes the `kind !== 'ssh'` fallback, which fired for `local`: a row declaring itself local handed out an SSH connection. * fix(ssh): resolve the execution host in the worktree scan and managed create The worktree scan and createManagedWorktree both picked remote-vs-local from repo.connectionId, so a row stamped only executionHostId: 'ssh:*' was scanned and created on the client against a remote path. The folder branch returns before the check, so its agent-trust write landed locally too. Refs stablyai#11163 * fix(ssh): stop over-rejecting and refusing SSH hosts the process owns runtimeRepoMatchesExecutionHost rejected an unstamped SSH repo against its own ssh:<connectionId>, so repo-add/clone dedupe could register a second row for a path the host already owns. assertHostIsSupported made the CLI/runtime RPC refuse --host ssh:* while the same process's IPC handler routed it correctly; setupExistingFolder now shares that registration. Clone still refuses, because nothing in this process clones onto an SSH host. Refs stablyai#11163 * test(ssh): retarget the SSH host-setup guard spec at the substitution it prevents setupProjectExistingFolder now registers the remote path through the same addRemoteRepoFromPath the desktop IPC uses, so it fails on the host's terms (connection not registered) rather than a categorical refusal. The local clone/probe side effects it exists to catch are still asserted absent. Refs stablyai#11163 * fix(cli): require an absolute path when setting a project up on an SSH host Routing --host ssh:* to the remote registration made relative paths newly reachable there, and they were resolved against the client cwd — registering a path that names the wrong machine. Refs stablyai#11163 * fix(repos): read the SSH registry directly so the runtime stays Node-bootable Routing runtime project setup through addRemoteRepoFromPath dragged ipc/ssh -- and its 25-module electron graph -- into the runtime bundle. ssh-target-registry already exists for exactly this; ipc/ssh only re-exports it. * fix(ssh): close the agent-launch and session-export host-blind twins Three sites left on the legacy spelling, all the same shape as the ones this branch already fixed: - `launchAgentTerminal` did `getRepo(worktree.repoId)` then wrote agent trust with that row's `connectionId`. Host-blind, so a repo id carried by two SSH hosts wrote a remote path into the *client's* Codex/Cursor/Copilot config and the agent on the host never saw the trust. Every sibling call site already passes the resolved `workspace.connectionId`; this was the last that did not. - `targetForWorktree` (workspace-session export) fell back to the same host-blind read, so a session could be published to a machine that never owned the worktree. Unresolvable ownership now exports to nobody. - `addRemoteRepoFromPath` minted `connectionId`-only rows while being the routing path this branch adds, so it kept creating rows in exactly the spelling the branch works around. It now stamps `toSshExecutionHostId(connectionId)` at creation; `reassignSshTargetId` already migrates both spellings, so target rename stays correct. Tests cover two *different* SSH hosts throughout — the case none of the earlier duplicate-row tests had, all of which were local-vs-ssh or runtime-vs-ssh.
…t a raw field (stablyai#18294) `repoIsRemote` read `repo.connectionId` directly. That is one of four spellings of host ownership, so the predicate was wrong in both directions: a row carrying only `executionHostId: 'ssh:<target>'` read as local and got the Linux-only `orca-ide` rename it cannot resolve through the relay shim, while a row that declares itself `local` with a stale `connectionId` read as remote and lost the rename it needs on a Linux desktop. The predicate now resolves the host first and asks "does an SSH target hold this row's files" via `getRepoSshConnectionId`. That keeps a `runtime:` host's nested SSH target remote (that machine reaches the files through its own relay shim) while a runtime with no nested target - a full Orca install - stays local, as do WSL and local. Its call sites did not all want that question: - The four launch-scope sites in main already hold the resolved PTY route on `TerminalWorkspaceLaunchScope.connectionId`. `scope.repo` is documented display metadata and can be a row from a different host than the worktree names, so they now read the route they will actually spawn on. A launch shape that disagrees with its own route is the bug, not a second predicate. - `launchAgentInNewTab` picked its repo row with a host-blind `store.repos.find`, so a worktree that names its own host could be shaped by another host's row. It now resolves through `getConnectionIdFromState`, the same rule the file already used for transcript readability. - `resolveAgentBackgroundLaunchHost` derived the route, the trust write and the launch shape from three reads of the raw field; one resolution now feeds all three. Also converts the raw `repo.connectionId` agent-detection probe eight lines above `buildWorktreeStartupForDraft`'s launch shape, which stablyai#17919 deferred precisely because converting it alone would have left that file internally inconsistent. Tests cover two distinct SSH hosts (a single-host fixture passes even when the answer comes off the wrong row, which is how the `ssh:m4air` -> openclaw leak survived review) and a `runtime:` host carrying a nested SSH target.
…connectionId (stablyai#18307) `RuntimeGitTarget` carried `connectionId?: string` and no host id, so `undefined` spelled three different answers at once — "runtime: host", "unresolved", and "genuinely local". Its sole resolver read `store.getRepo(worktree.repoId)?.connectionId` and never looked at `worktree.hostId`, which outranks every repo row, so one arbitrarily chosen row decided the execution host for 36 downstream dispatches. The target now carries `executionHostId: ExecutionHostId` (never null, never optional), resolved through the shared rule that landed with stablyai#17909/stablyai#17919 and dispatched through the host-keyed routes from stablyai#18296. Dispatch sites call `requireRuntimeGitProvider`, where `null` means exactly one thing: the host is `local` and the command runs here as free functions. Four answers that used to collapse into one: - `ssh:x` with a rival row on `ssh:y` — routes to x. Previously the first row won, which is the reproduced cross-host leak. - `local` with a surviving `connectionId` — a row contradicting itself; no SSH connection is handed out. - `runtime:<env>` — throws `ExecutionHostNotDispatchableError`. Its repo row's connection names a target in the *server's* namespace; dialling it here reaches a same-named target on this client. - rival rows disagreeing with no worktree host — `worktree_execution_host_unresolved`, matching the launch path rather than guessing a row. An unreachable SSH host still throws `SSH_GIT_PROVIDER_UNAVAILABLE_MESSAGE`; loss of contact is never evidence of locality (docs/reference/ssh-execution-boundary.md). `resolveWorktreeLaunchHost` keeps its exact signature and now delegates to `resolveWorktreeHostRouting`, the same resolution answering "which host is this on" rather than "what may this client dial" — the git target needs the first question because `local` and `runtime:` are two different non-SSH answers. No wire change: `RuntimeGitTarget` is main-process internal, and the SSH and local model-discovery host keys are byte-identical to before. `RuntimeFileTarget` has the same defect in ~30 filesystem dispatches and is deliberately left for a follow-up.

Closes four of the five residual host-blind sites #17909 identified and left. The unifying rule throughout: resolve the execution host via
getRepoExecutionHostId/getWorktreeExecutionHostId, never the rawconnectionIdfield — SSH ownership has two spellings, and code reading only one is wrong for half the rows.Site 1 — the worktree scan (this is the one that mattered)
orca-runtime-refresh-repo-worktree-scan.tskeyed onrepo.connectionId, so a repo stampedexecutionHostId: 'ssh:*'without aconnectionIdnever resolved a remote worktree at all. Its caller mattered as much as the sites #17909 listed: anssh:*-only row was also getting a local project runtime and alocal:defaultscan cache key — so the scan never re-ran when the SSH provider generation changed — and a failed remote scan was cached as authoritative.This unblocked the end-to-end proof #17909 attempted and abandoned:
That
selector_not_foundis exactly the blocker #17909 described. A third case (legacyconnectionId-only) proves the fix is not just "route everything remotely".Site 2 — managed-worktree create, and the
isFolderRepoquestion:90now branches on the resolved SSH connection. The remote pipeline readsrepo.connectionId!at a dozen depths, so rather than teach each one the second spelling, the row is normalised once at the branch.On
isFolderReporeturning before the check — it is a real bug, but narrower than it looks. The create itself is host-agnostic: a folder workspace is a registration, not a filesystem operation, and its terminals route through the resolver #17909 fixed. The actual leak is one line —markTrustedwas hard-wired tomarkLocalWorkspaceTrustedForAgent, so a folder repo on an SSH host wrote Codex/Cursor/Copilot trust into the client's config keyed by a remote path. The remote agent never sees the trust; the client gets a bogus entry.Site 3 —
runtimeRepoMatchesExecutionHostA row naming a host in either spelling now matches only that host, while a genuinely host-less legacy row stays adoptable — the documented case the old shape existed to protect.
Site 4 —
assertHostIsSupported, split, and the split is the findingThe two operations behind that one guard are not the same:
setupExistingFoldernow routesssh:*throughaddRemoteRepoFromPath— the exact function the desktop IPC handler in the same process already uses.setupClonestill refuses, with an accurate message. There is no remote clone anywhere in this process:cloneReporunsgit cloneon the client and there is noprojectHostSetups:cloneIPC handler at all. Acceptingssh:*would have registered the client's copy as the host's repo. The old message was wrong for both — false for existing-folder, misleading for clone.Two consequences handled rather than left:
spawnSpynot called,reposempty), which still holds.--host ssh:*reachable made relative CLI paths newly reachable there, andresolveRepoPathArgumentonly guards when the client is remote — so--host ssh:x --path ./orcasent the client's cwd as the remote path. Guarded, with its own fail-before test showing that literal value.Also fixed the mirror-image blindness in
addRemoteRepoFromPath's dedupe, since the runtime now routes through it.Site 5 —
getRepo(id): handed off with data, not attemptedOf the 45 non-test
.getRepo(call sites:orca-runtime-persist-headless-terminal-title.ts:168(every runtime git exec) and:189;register-worktree-create-handlers.ts:40;register-worktree-catalog-handlers.ts:170.worktree-removal-repo-owner.ts:36,folder-repo-git-upgrade.ts:121,first-work-folder-rename.ts:42(irreversiblemoveWorktree).That is a store-contract change needing a host argument or an ambiguity refusal threaded through 33 real decision sites, several destructive. Doing it alongside four other fixes would make all five unreviewable. Two host-safe patterns already exist to migrate onto:
resolveWorktreeLaunchHost, and thegetRepoExecutionHostId-filteredgetRepos()used correctly atbase-ref-query-handlers.ts:198-203and two other sites. Suggested order: the destructive three first (cheap to fail closed), then the git/filesystem target resolvers, then the rest.Verification
src/main/runtime+ipc+persistencesrc/cliorca-runtime.test.tspnpm tc:node,pnpm tc:clicheck:code-quality:changedIs #11163 closable?
Not yet — but the gap is now one named thing instead of five. Sites 1-4 have fail-before/pass-after tests, and site 1 is closed provably. What remains is site 5, plus one residual worth naming:
runtime-worktree-agent-startup.ts:60still branches agent detection on rawrepo.connectionId— same shape, and it belongs with the site-5 sweep rather than bolted on here.Refs #11163
Update — retitled, rebased, and two more twins closed
Retitled. The old title, "close the remaining host-blind seams behind #11163", was not what this
does. Measured on
src/main+src/renderer, non-test, rawrepo.connectionId/repo?.connectionIdreads: 532 on
main, 519 after both PRs — 13 converted, ~2%. The body already admitted this("Not yet — but the gap is now one named thing instead of five"); the title now says it too.
Rebased onto current
mainand onto the reworked #17909.en.jsonverified byte-identical tomain(the rebase-loss check, since a stale branch copy silently dropping keys is how three revertshappened in this sweep).
Inherited from #17909: one shared resolver
getRepoSshConnectionIdno longer fires for alocalhost, which fixes the pullfrog findingthis PR depended on. That matters here specifically: this PR wires that function into the scan, its
cache key, fingerprint capability, cache invalidation, and the remote-repo dedupe — and the old
kind !== 'ssh'fallback madesetup-existing-folder --host ssh:developfalsely dedupe onto alocal row. Covered by a test.
The fix is narrow on purpose. An earlier revision also dropped the field for a
runtime:host;review caught that as a regression (it removed a nested-SSH pane's reconnect affordance and made a
remote transcript read as locally readable), so a runtime host keeps its nested target. The
distinction matters to this PR's own uses:
fingerprintCapablewants the ownership answer — aruntime-hosted row is not locally fingerprintable — which is what it now gets.
Two named twins, now closed rather than listed
orca-runtime-terminal-create-deduplication.ts:151—launchAgentTerminaldidgetRepo(worktree.repoId)thenmarkWorkspaceTrustedForAgent(agent, repo.connectionId, …): theidentical trust-write bug this PR fixes for folder creates, still live for agent launches. Every
sibling call site already passes the resolved
workspace.connectionId; this was the last that didnot. Fail-before/pass-after with two SSH hosts.
remote-workspace.ts:103—targetForWorktreekept the host-blindgetRepo(repoId)?.connectionIdfallback that is the [Bug]: SSH worktree/terminal operations are validated locally instead of routing to the connected SSH target (DaemonProtocolError: working directory does not exist) #11163 defect, deciding which SSH targeta workspace session is exported to. Unresolvable ownership now exports to nobody rather than
guessing.
addRemoteRepoFromPathno longer mints legacy-only rowsIt created repos with
connectionIdand noexecutionHostId, so this PR's new routing path keptminting rows in exactly the spelling the PR works around. It now stamps
toSshExecutionHostId(connectionId)at creation. Safe for target rename:reassignSshTargetIdalready migrates both spellings (
ssh-target-reassignment.ts:70-80).Tests
Every duplicate-row case in this PR was local-vs-ssh or runtime-vs-ssh. Added two different SSH
hosts throughout — including a dedupe case where two hosts hold the same path, the mirror image of
the id-only lookup this PR removes.
pnpm tcsrc/main+renderer/src/lib+shared+clissh/runtime/persistence/ipc/lib/shared/cli)check:code-quality:changedTwo failures seen only under the full 4300-file parallel run (
ssh-remote-commands.test.ts30stimeout; a daemon scrollback spec) pass in isolation and touch untouched timing paths.
Still open
Site 5 (
getRepo(id)itself, ~30 host-deciding call sites, 3 destructive) is unchanged and stillthe named gap, with the same suggested order.
runtime-worktree-agent-startup.ts:60also stillbranches agent detection on raw
repo.connectionId.