Skip to content

fix(worktrees): resolve the execution host at both worktree-create entry points - #18545

Merged
nwparker merged 1 commit into
mainfrom
fix/worktree-create-execution-host-route
Sep 3, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/worktree-create-execution-host-route

Conversation

@nwparker

@nwparker nwparker commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​397 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​397
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​108 $\color{#cf222e}{\Huge{\mathbf{−}}}$​24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​84

The mix

Two entry points create the same workspace and disagreed about how to read its host.

  • Runtime (src/main/runtime/orca-runtime-create-managed-worktree.ts:63) resolved through getRepoSshConnectionId, then explicitly normalized the row at :101-104 with a comment saying it does so because "the remote-create pipeline reads repo.connectionId! at every depth."
  • IPC (src/main/ipc/worktrees/create/register-worktree-create-handlers.ts:66-69) branched createRemoteWorktree vs createLocalWorktree off raw repo.connectionId.

So a repo naming its owner only as executionHostId: 'ssh:<target>' created remotely through the runtime and ran git worktree add on the client, against a remote path through IPC (#11163). One sibling compensated for the pipeline's raw reads and the other didn't. Same repo, two entry points, different answers.

Both now take one route, resolved through the existing layer (getRepoExecutionHostId → #18296's resolveGitRouteForHost). No new resolver.

Is the runtime path's normalization the right pattern? No — it's a workaround.

Verdict: workaround. Three reasons:

  1. It compensates at the call site for a defect in the callee. createRemoteWorktree and its callees re-read repo.connectionId! at five depths — ipc/worktree-remote.ts:1627, 1847, 1848, 1865, 2029. Handing them a normalized row only works because those reads exist.
  2. It travels only as far as the object does. It fabricates a Repo value that isn't in the store; anything downstream re-reading the row by repo.id still gets the unnormalized one. The compensation is invisible at the boundary where it stops holding.
  3. It cannot express the runtime: refusal. getRepoSshConnectionId deliberately returns the nested target for a runtime: row (its own doc says callers routing a client-local Git provider want getSshTargetIdForExecutionHost instead). Normalizing with it produces a row that says "dial this SSH target from this client" — the wrong-namespace bug feat(providers): dispatch git and filesystem providers by execution host #18296 names, traded for the silent-local one.

This PR keeps the normalization (deleting it would break the remote-create pipeline outright) but moves it behind the shared route with the reason written down, and adds the refusal the raw form could not express.

What a proper fix takes, deliberately not done here: give createRemoteWorktree, prefetchRemoteWorktreeCreateBase and the registerRequiredSshWorktreeCreateRoots call sites an explicit connectionId (or route) parameter resolved once by the caller, then delete repo.connectionId! from worktree-remote.ts so every reader becomes a compile error — the #18307/#18325 technique. That is a change inside a 2800-line module plus its callers, and it wants its own PR rather than riding along here.

Three answers that used to collapse into one

repo row before (IPC) before (runtime) now (both)
executionHostId: 'ssh:t', no connectionId local (git worktree add on the client) ssh:t ssh:t
executionHostId: 'local' + connectionId: 't' remote local local
runtime:<env> (± nested target) local, or dials a same-named client target dials the nested target in this client's namespace refused

runtime: is refused because the worktree is created by that environment's own server, and its repo row's SSH target is that server's nested one, addressable only as (environmentId, targetId). The renderer already routes runtime-environment creates over worktree.create RPC (store/slices/worktrees/create/create-worktree.ts — target.kind === 'local' picks the IPC channel, otherwise callRuntimeRpc), so reaching either entry point with a runtime row is a routing mistake, not a fallback. Matches workspace-cleanup-git-route and runtime-git-command-target.

Folder workspaces are untouched

A folder workspace is a registration, not a filesystem create, so it is host-agnostic. On the IPC side the route is resolved inside the non-folder branch, so folder creation cannot start failing. On the runtime side only the agent trust write consumes the connection, and a runtime: host now yields null there instead of the nested target — so the write stops going to a same-named target in this client's table.

Wire / persistence

No change. The normalized row is a local value handed to the create pipeline and never stored; CreateWorktreeResult and the create RPC params are untouched. Nothing new is published, so nothing here reaches an old client (docs/reference/remote-wire-compatibility.md Rule 3).

Tests

7 failed-first, 7 pass after, plus 8 new unit cases on the route module (new module, so failed-first does not apply there).

src/main/ipc/worktrees-create-execution-host-routing.test.ts (5, all failed-first):

  • an executionHostId: 'ssh:target-a'-only row creates on that host, and the local addWorktree is never reached
  • two simultaneously registered SSH hosts — a ssh:target-b row never touches target-a's provider
  • runtime: with no nested target refuses, no local create
  • runtime: with a nested target that is dialable here refuses, and that provider is untouched
  • the contradictory local + connectionId row creates locally, matching the runtime sibling

orca-runtime-tests/worktree-create-execution-host.spec.ts (2, failed-first): the runtime sibling refuses both runtime: shapes.

src/main/worktree-create-execution-host-route.test.ts (8): route-level coverage including two SSH hosts registered at once and both runtime: shapes.

Verification

  • pnpm tc clean
  • pnpm test src/main/ipc — 3721 pass; src/main/ipc + src/main/runtime + the route test — 10008 tests, only load-dependent flakes that also fail on the unmodified tree in the same scope and pass in isolation (pty-spawn-env-terminal-basics, automation-change-publication, different one each run)
  • pnpm run check:code-quality:changed — 0 findings
  • npx oxlint --deny-warnings on all 6 changed files, exit 0
  • max-lines and ts-nocheck ratchets OK, no new suppressions

…try points

Two entry points create the same workspace and disagreed about how to read its
host. `orca-runtime-create-managed-worktree.ts:63` resolved through
`getRepoSshConnectionId` and then normalized the row; the `worktrees:create` IPC
handler branched on raw `repo.connectionId`
(`register-worktree-create-handlers.ts:66-69`). So a repo naming its owner only
as `executionHostId: 'ssh:<target>'` created remotely through the runtime and ran
`git worktree add` on the client against a remote path through IPC (#11163).
Same repo, two entry points, different answers.

Both now take one route, resolved through the existing layer
(`getRepoExecutionHostId` -> #18296's `resolveGitRouteForHost`). No new resolver.

The row normalization on the `ssh` variant is kept, and it is a **workaround, not
the pattern**. `createRemoteWorktree` and its callees re-read `repo.connectionId!`
at five depths in `ipc/worktree-remote.ts` (1627, 1847, 1848, 1865, 2029), so the
resolved connection has to reach them through the field they already read. It
travels only as far as that object does — anything downstream that re-reads the
row from the store still sees the unnormalized one, and it cannot express the
`runtime:` refusal on its own. Proper fix, deliberately not done here: give that
pipeline an explicit connection parameter and delete `repo.connectionId!` from it
so every reader becomes a compile error, the technique #18307/#18325 used. That
is a change inside a 2800-line module plus its callers, and it wants its own PR.

Three answers that used to collapse into one, now distinct at both entry points:

- `executionHostId: 'ssh:*'` with no `connectionId` -> that SSH host (IPC used to
  create locally);
- `executionHostId: 'local'` with a surviving `connectionId` -> local, since a
  local row cannot nest an SSH namespace. This is what `getRepoSshConnectionId`
  and therefore the runtime sibling already answered; IPC used to go remote;
- `runtime:<env>` -> refused. Its worktree is created by that environment's own
  server and the SSH target on its repo row is that server's nested one,
  addressable only as (environmentId, targetId). The renderer already routes
  runtime-environment creates over `worktree.create` RPC rather than this IPC
  channel, so reaching either entry point with one is a routing mistake. Matches
  `workspace-cleanup-git-route` and `runtime-git-command-target`.

Folder-workspace creation is untouched on both sides: it is a registration, not a
filesystem create, so the route is resolved after that branch on the IPC side, and
on the runtime side only the agent trust write consumes it — where a `runtime:`
host now yields `null` instead of the nested target, so the write stops going to a
same-named target in this client's table.

No wire or persistence change: the normalized row is a local value passed to the
create pipeline, never stored, and `CreateWorktreeResult` is untouched.
@pullfrog

pullfrog Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: d5e907da-ed28-4458-889a-ec8db1b90bc7

📥 Commits

Reviewing files that changed from the base of the PR and between 04ae622 and e8960b5.

📒 Files selected for processing (7)
  • src/main/ipc/worktrees-create-execution-host-routing.test.ts
  • src/main/ipc/worktrees/create/register-worktree-create-handlers.ts
  • src/main/runtime/orca-runtime-create-managed-worktree.ts
  • src/main/runtime/orca-runtime-tests/worktree-create-execution-host.spec.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/worktree-create-execution-host-route.test.ts
  • src/main/worktree-create-execution-host-route.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Worktree creation now resolves execution hosts through one shared route model. IPC and runtime creation paths dispatch local and SSH worktrees from the resolved route. Runtime-host rows raise ExecutionHostNotDispatchableError instead of using local or unrelated SSH providers. Tests cover legacy repository data, multiple SSH hosts, local-host precedence, runtime rejection, and provider selection.

Merge Risk: ⚪ Minimal · up to e8960

Worktree creation now consistently selects the configured execution host and avoids dispatching runtime-owned repositories through local or unrelated SSH providers. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives detailed coverage of the change, rationale, linked issue #11163, tests, verification, compatibility, and deferred work. However, it omits several required template sections and c… Use the repository template headings and complete the missing required sections. Add an explicit issue entry such as "Fixes #11163", add Visual Proof with "N/A" and a reason if no UI or interaction changed, complete the Agent skill upstream…
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: resolving the execution host at both worktree-create entry points.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives detailed coverage of the change, rationale, linked issue #11163, tests, verification, compatibility, and deferred work. However, it omits several required template sections and checklist items, including an explicit Linked Issue entry using "Fixes #", Visual Proof or an N/A explanation, Agent skill upstream boundary, Review, Notes, and the required checklist.

Resolution

Use the repository template headings and complete the missing required sections. Add an explicit issue entry such as "Fixes #11163", add Visual Proof with "N/A" and a reason if no UI or interaction changed, complete the Agent skill upstream boundary checkbox, Review, Notes, and Checklist sections, and state AI usage if applicable.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

nwparker commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Note on the red static analysis check — it is pre-existing drift on main, not from this PR.

src/renderer/src/i18n/en-runtime-required.json no longer covers en.json.
  components.onboarding.integrations.capabilities.browseIssues
  components.onboarding.integrations.capabilities.managePullRequests
  components.onboarding.integrations.capabilities.reviewStatus
  components.onboarding.integrations.capabilities.startWorkspaceFromIssue

Those keys come from c79e1c097b7 fix(i18n): localize remaining onboarding UI, which landed on main without regenerating the runtime-required catalog. Reproduced locally on a tree whose src/renderer/src/i18n/** is byte-identical to main — this branch touches no i18n file. It needs pnpm run sync:localization-runtime-catalog on main; deliberately not done here so the fix is not buried in an unrelated PR. verify is red only because it gates on static analysis.

Everything else is green: all 8 test shards, typecheck, package, package (windows).

@nwparker
nwparker merged commit 5d8532f into main Sep 3, 2026
26 of 29 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…try points (stablyai#18545)

Two entry points create the same workspace and disagreed about how to read its
host. `orca-runtime-create-managed-worktree.ts:63` resolved through
`getRepoSshConnectionId` and then normalized the row; the `worktrees:create` IPC
handler branched on raw `repo.connectionId`
(`register-worktree-create-handlers.ts:66-69`). So a repo naming its owner only
as `executionHostId: 'ssh:<target>'` created remotely through the runtime and ran
`git worktree add` on the client against a remote path through IPC (stablyai#11163).
Same repo, two entry points, different answers.

Both now take one route, resolved through the existing layer
(`getRepoExecutionHostId` -> stablyai#18296's `resolveGitRouteForHost`). No new resolver.

The row normalization on the `ssh` variant is kept, and it is a **workaround, not
the pattern**. `createRemoteWorktree` and its callees re-read `repo.connectionId!`
at five depths in `ipc/worktree-remote.ts` (1627, 1847, 1848, 1865, 2029), so the
resolved connection has to reach them through the field they already read. It
travels only as far as that object does — anything downstream that re-reads the
row from the store still sees the unnormalized one, and it cannot express the
`runtime:` refusal on its own. Proper fix, deliberately not done here: give that
pipeline an explicit connection parameter and delete `repo.connectionId!` from it
so every reader becomes a compile error, the technique stablyai#18307/stablyai#18325 used. That
is a change inside a 2800-line module plus its callers, and it wants its own PR.

Three answers that used to collapse into one, now distinct at both entry points:

- `executionHostId: 'ssh:*'` with no `connectionId` -> that SSH host (IPC used to
  create locally);
- `executionHostId: 'local'` with a surviving `connectionId` -> local, since a
  local row cannot nest an SSH namespace. This is what `getRepoSshConnectionId`
  and therefore the runtime sibling already answered; IPC used to go remote;
- `runtime:<env>` -> refused. Its worktree is created by that environment's own
  server and the SSH target on its repo row is that server's nested one,
  addressable only as (environmentId, targetId). The renderer already routes
  runtime-environment creates over `worktree.create` RPC rather than this IPC
  channel, so reaching either entry point with one is a routing mistake. Matches
  `workspace-cleanup-git-route` and `runtime-git-command-target`.

Folder-workspace creation is untouched on both sides: it is a registration, not a
filesystem create, so the route is resolved after that branch on the IPC side, and
on the runtime side only the agent trust write consumes it — where a `runtime:`
host now yields `null` instead of the nested target, so the write stops going to a
same-named target in this client's table.

No wire or persistence change: the normalized row is a local value passed to the
create pipeline, never stored, and `CreateWorktreeResult` is untouched.
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