Repository navigation
fix(wsl-mover): fence terminals by folder during a move and re-prove exit before commit (audit addendum R45-R47) - #31952
Closed
nwparker wants to merge 4 commits into
Conversation
nwparker
marked this pull request as ready for review
October 22, 2026 10:05
nwparker
force-pushed
the
nwparker/wsl-mover-audit-addendum
branch
from
October 22, 2026 10:14
eb09014 to
ee4517a
Compare
nwparker
changed the base branch from
nwparker/wsl-mover-d1b-9-move-ux
to
nwparker/wsl-mover-d1b-7f2-registry-complete
October 22, 2026 10:15
…al exit before commit (R46, WIP)
…peated move generations (R45, R46, R47)
… reason (R46 review)
nwparker
force-pushed
the
nwparker/wsl-mover-audit-addendum
branch
from
October 22, 2026 10:27
ee4517a to
21fb600
Compare
…locks it (R46 follow-up)
This was referenced Oct 22, 2026
Contributor
Author
|
Contained in the dark landing PR #34059 (its head commit is an ancestor of the landing branch). Closing in favour of it; branch kept. |
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 Orca moves a WSL project to the host program running inside the distro, it first pauses every terminal in that project and checks they have all stopped. Then it copies the project's state, which can take a while, and only then switches over.
A terminal could still start during the copy without belonging to the project: a floating terminal, a Windows project's WSL tab, or
orca terminal create --cwdpointed into the project's folder. Nothing stopped it, and nothing checked again before the switch. That terminal kept running on the old path after the move. An agent in it reported its status to the desktop under a project the desktop no longer owns, so two places claimed that agent's status.This PR closes the gap two ways:
What Changed
R46: terminals during a move (behaviour change, behind the gate)
assertWorkspaceAcceptsNewPtyinsrc/main/ipc/pty/host-env/spawn-cwd.ts, called from both the IPC and the runtime/CLI spawn preflight). A new local terminal whose requested folder is inside a project a move is taking is refused, whatever workspace it names. It gets the same "this project is moving" error the per-project fence already gives.wslMoveScopeRootPaths): each moved repo, folder workspace, and carried worktree. They are fenced fromsource-fenceduntil the commit.wsl-move-comparable-path.ts:wsl$/wsl.localhostaliases, distro case, Linux spelling, and trailing separators all count as the same folder.localPtySpawnCwd).blobs-transferred. Only synchronous code runs between this census and the commit request.exited, the move resets to zero throughresetWslMoveToZero(fix(wsl-mover): reset an interrupted move to zero, or finish it once the host proves a commit #29825), and the result is the existing refusalwsl_move_pause_failed, which the dialog already maps ("Orca could not pause the terminals in these projects, so nothing was moved…").terminals-started-after-pause, orexit-unverifiable: <reason>, matching the wording of the quiesce-time proof.sendWslMoveBlobsno longer advances the journal; the driver does that after the proof. A cancel is also now checked before that advance, so a cancel there likewise resets without the host.R45 and R47: tests only
R45: the WSL host browser cookie jar is pinned:
No distro registry-id check was added.
R47: two WSL moves with the same generation number but different migration ids and manifests stage, commit, abort, and keep receipts independently on the host.
Why
cds into a moved folder.blobs-transferredrather than literally just before the commit: fromblobs-transferredon, a reset must ask the host whether the commit landed, and an unreachable host leaves the projects read-only until it answers. One phase earlier, no commit can exist, so a refusal always resets cleanly. Nothing awaits between the proof and the commit request.wsl_move_pause_failed: the copy already says nothing moved and to try again.wsl_move_terminals_blockedexpects a list of blockers, which this case doesn't have.Golden-image keypair finding (R45 follow-up)
Where the key lives. Orcad's identity key is
~/.orca/orca-e2ee-keypair.json, not~/.orca-remote.loadOrCreateE2EEKeypair(src/main/runtime/e2ee-keypair.ts) creates it once if it is missing and reuses it if present. It has no per-machine salt. An image that bakes in~/.orcatherefore shares one orcad key across machines, along with its device registry.Safe: pairing. Every desktop pairs with its own random device id and token, and WSL hosts are keyed by
wsl:<distro>. Separate machines, and separate distros on one desktop, get separate pairings. Now pinned by a test.Safe: browser jar. It hashes profile, environment id and key, so distros on one desktop never share a jar. Now pinned by a test.
Real, not fixed here (outside the mover):
sha256(publicKey). Golden-image hosts on different machines look like the same host to it if phones pair with them directly.wsl-host-ssh-orcad-conflict.ts). That check exists to catch one orcad reached two ways, and a cloned key can't be told apart from that by key alone.None of these is minimal to fix safely, because the fix would mean rotating per-install keys. Recommended as a follow-up.
Linked Issue
Internal: WSL-via-orcad audit addendum, risks R45, R46 and R47.
Visual Proof
N/A: nothing on screen changes. The refusal reuses existing dialog copy, and everything is behind the internal gate.
Testing
pnpm tcpasses.pnpm testpasses forsrc/main/persistence/moving-wsl-projects,src/main/ipc/pty(spawn-cwd, the spawn preflight and the PTY spawn tests), the new browser jar and generation-reuse tests,runtime-environment-wsl-host-store, andpersistence-orcad-migration-catalog: 153 files, 1556 tests.check:code-quality:changed, the max-lines ratchet and the path-literal ratchet pass.New tests:
spawn-cwd-wsl-move.test.ts: refused in the moving folder in UNC,wsl$, case-folded and Linux spellings, and for a floating terminal, another project, or a folder workspace started there. Allowed for a sibling with a shared prefix, the parent folder, another distro, a Windows drive, other Linux folders, no folder, and SSH. Reattaching a live session is still allowed, and the fence lifts at commit.wsl-move-driver-commit-reproof.test.ts: the re-proof runs last before the commit with the quiesce's scope. Aliveorunverifiableresult blocks the commit and resets both sides, including when the host is unreachable. The real fence refuses a spawn into the moved folder during the copy.wsl-host-browser-jar-identity.test.ts, the new case inruntime-environment-wsl-host-store.test.ts, andpersistence-orcad-migration-wsl-generation-reuse.test.ts.An adversarial review covered over-refusal and the risk of a stuck move. Its two MEDIUM findings are fixed here: spawns that name a workspace are now fenced too, and the refusal now carries the proof's reason.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Shared path touched: the PTY spawn admission check (
assertWorkspaceAcceptsNewPty) on the IPC and runtime spawn paths. It is a no-op unless a move journal has a fenced move, which only ever exists on Windows behind the internal gate.Terminals elsewhere in the same distro don't block a move. Both exit proofs (at the pause and before the commit) sort each live terminal with no workspace by its known folder. That folder is the shell's live working directory, reported by the shell itself.
unverifiableis reserved for a terminal whose folder is unknown, or a Linux path inside the move whose distro can't be told.Before this, any terminal with no workspace in the moving distro counted as unknown, because it could have
cd'd into a moved folder. Since the folder is the live one, a shell that latercds into a moved folder is now counted as inside the move.Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)