Repository navigation
fix(runtime): a terminal spawn names its host; the removed-project fence keys by host (R4-2) - #30798
Merged
Merged
Conversation
…nce is per (project, host) acquireWorktreeTerminalSpawn takes the spawn's HostWorktreeTarget instead of a bare id plus an optional connectionId that defaulted to this machine. The removal fence records ExecutionHostIds and only counts surviving rows that run in this process, so a paired server's same-id residue row no longer readmits a removed local project's spawn.
…the spawn connection (review)
7 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When you remove a project, Orca fences it so no new terminal can start inside it. To decide, the fence asks: "is there still a project with this id on the host this terminal would run on?" The "which host" half of that question was optional. A caller that left it out was silently treated as "this computer", even when its terminal was about to start on an SSH host. Now the host is required, so the compiler refuses to build a caller that leaves it out.
What Changed
acquireWorktreeTerminalSpawnis the lease every terminal spawn takes. It now takes aHostWorktreeTarget: the workspace id plus the host whose provider runs the spawn. Before, it took a bare id and an optionalconnectionIdthat defaulted to this computer.spawn-options.ts,spawn-execute.ts) build the target with the newspawnWorktreeTarget(worktreeId, connectionId), from the sameconnectionIdthat picks their PTY provider. So the fence and the provider can't disagree about the host.project-terminal-stop.tsand keeps, for each removed project id, the execution host each removed copy was on (localorssh:<target>, as anExecutionHostId). It compares that against the spawn's host. Before, it kept a raw connection string.Before and after, as the user sees it: no difference today. Every current caller already passed its connection, so the fence's answers are unchanged. That includes the case where a local copy and an SSH copy share an id (already covered by tests). This PR closes the door for the next caller: one that forgets the host no longer compiles, where before it got "this computer" silently.
Why
This is the last step of R4-2: store writes and the spawn fence take the row's host instead of a bare id.
Alternatives considered:
connectionIdrequired instead. A caller could still pass the wrong kind of id, and it wouldn't match theHostWorktreeTargetshape the rest of R4-2 uses.rowsRunHere) as survivors. That was this PR's first draft. The Opus review showed it would refuse spawns for a project a paired client registered on this server: such rows carry aruntime:stamp, andrepo-execution-host.tssays that stamp names files on this host. So the fence keeps counting every row, and a test pins that case.Linked Issue
Part of SSH hardening round 4 (R4-2, the spawn fence). There is no GitHub issue.
Visual Proof
N/A: nothing the user sees changes. This is a type-level change to an in-process lease.
Testing
New twin test in
src/main/runtime/project-removal-terminal-stop.test.ts. An SSH row and a self-stampedruntime:row share an id. After the SSH row is removed, an SSH spawn is refused and a local spawn for the surviving row is admitted. It fails on this PR's first draft and passes now. The existing local/SSH twin tests still pass.No fail-before on main: main's behaviour was already right for every current caller. The gain is the required host.
Static analysis: every step of the static-analysis job ran locally: the oxlint suites, changed-code quality, React Doctor, every ratchet, the RPC catalog check and
typecheck:ci.Units, single worker:
src/main/ipc/pty/,src/main/ipc/pty-launch*,src/shared/worktree,orca-runtime.test.ts, and every runtime suite that takes the lease.orca-runtime.test.ts. They compare/varwith/private/var, a macOS temp-path issue that fails the same way without this change.Not verified live. In-process only; there's no wire or host-side change.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
rowsRunHeresurvivors would refuse self-stamped rows. Reverted to all rows, with a test.normalizeHostPart), as before.projectSiblingSharesFenceandreleaseProjectHostSessionsstill userowsRunHere, so the file has two meanings of "surviving row". The comment now says why the spawn fence counts every row. Follow-up below.Agent skill upstream boundary
Notes
runtime:rows as residue. A paired server holding a local row and a self-stamped row with the same id stops both rows' terminals when the local one is removed. The store can't tell a self stamp from a foreign one at that layer.local, as before.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)