Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (17)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughRemoval safety now uses an explicit client or execution-host home authority. SSH routes resolve the host home from the active relay session. Local and remote removal flows pass this authority to registered-worktree, orphan, and leftover cleanup checks. The guard detects POSIX, Windows, and WSL home paths without cross-syntax client-home comparisons. Tests cover host-home protection and orphan removal. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No verified merge-blocking issue remains in the supplied change set. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: d04d79ee-6380-4afd-a895-d0242ffab5d9
📒 Files selected for processing (2)
src/main/worktree-removal-safety.test.tssrc/main/worktree-removal-safety.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
- Home-dir guard gated on path syntax —
isDangerousWorktreeRemovalPathnow consultsos.homedir()only when the path syntax matchesprocess.platform((process.platform === 'win32') === (pathOps === win32)), so a POSIX client no longer applies its own homedir to a Windows remote path and vice versa. - Windows user-profile shape detection — new
isLikelyWindowsUserProfileDirectoryflags{root}Usersand{root}Users\<name>usingpathOps.parse().root, leaving children of a profile (e.g.C:\Users\bob\wt\foo) deletable. POSIX/home/<user>and/Users/<user>detection is unchanged. - Tests — a new
isDangerousWorktreeRemovalPathdescribe block with table cases plus awithProcessPlatform('darwin')+os.homedirspy regression test that would fail under the old homedir behavior.
The fix is sound: the XNOR gating drops os.homedir() only in the two cross-syntax cases where it was previously meaningless, so no protection is lost and remote home directories (Windows or POSIX) gain coverage via path shape. The containsPath direction is preserved, keeping linked worktrees under a home deletable, and the new tests genuinely pin the behavior rather than passing trivially.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior review (bc6b8d9), the author added one test commit (992b82d) that addresses the raised nit and strengthens the regression test:
- Pinned non-
C:drive profiles — addedD:\Users\bob(dangerous) andD:\Users\bob\wt\foo(safe) table cases, closing the coverage gap the implementation'sparse().rootbehavior implied. - Made the homedir-unused assertion real — replaced the
os.homedirspy with anode:osmodule mock (viavi.hoisted), so the regression test now assertshomediris never called on a cross-syntax path rather than relying on a spy that could not wrap the named export.
The mock is scoped to this file, delegates to the real homedir in its implementation, and mirrors the node:os mock pattern already used in the bitbucket and codex-accounts suites. The D: cases are correctly handled by isLikelyWindowsUserProfileDirectory (parse().root → D:\), and the test suite passes (35 tests, run locally).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Reviewed this against the issue and against a repro on this client. The core of it is right and it is the low-risk shape of this fix: gating the I had built an overlapping fix at #19865 before triage pointed me here. It covers three cases this one leaves open, which I'd rather hand over than duplicate: 1. A remote host whose home is not in a standard place gets no protection at all. After this change the client home is (correctly) not consulted for a remote path, and path shape only recognises The host already tells us its home: 2. WSL UNC paths are unprotected. 3. Nothing pins the call site. The guard is right, but Also worth adding regardless: Happy either way on sequencing — this PR is small and correct and could land now with the host-reported home layered on after, or the pieces above could come across into it. I don't want to duplicate the work. |
|
One framing point on my first gap, because it changes what a reviewer should do with this PR rather than just adding a to-do. Removing the So this is a fix that narrows coverage in one dimension while widening it in another — a hole the reported bug didn't have. That's not an argument against merging it; the Windows case it fixes is real and the shape of the fix is right. It's an argument for merging it as step one rather than as complete, with the host-reported home ( Happy to bring that follow-up myself on top of this once it lands — I have it written and mutation-tested, and rebasing it onto this reduces it to the additive parts. |
…d take
`isDangerousWorktreeRemovalPath` read `os.homedir()` — the machine running
Orca — and then applied POSIX-only shape rules. SSH orphan cleanup feeds it
remote paths, so a Windows host profile (`C:\Users\bob`) was unrecognised from
a macOS/Linux desktop and the recursive delete lost its last guard, while a
coincidental client-home prefix could refuse a legitimate remote delete.
The removal route already resolves one execution host for the whole removal;
it now resolves one home authority the same way. `WorktreeRemovalHomeAuthority`
is `{ kind: 'client' }` or `{ kind: 'executionHost'; homePath }`, required at
every guard entry point, so the ambient read is unreachable from a remote
removal. The host's answer is the `$HOME` the SSH session already read on the
host during relay deploy — no new probe. Unresolved stays `null`, meaning
unknown, never "same as this client's".
Path-shape rules now cover Windows profiles (`C:\Users`, `C:\Users\<name>`,
any drive or UNC root, case-insensitively) and WSL UNC aliases, which front a
Linux filesystem and so take the POSIX shapes.
Fixes stablyai#18275
The focused code-quality plugins deny `import/no-duplicates`.
…me refusal Mutation testing found four survivors in the home guard: - Swapping the IPC unregistered-removal call site to the client's home passed every suite while the remote delete could reach the host's own home. Only the runtime call site was pinned. Add the mirror test for the IPC path. - Falling back to os.homedir() when the execution host reported nothing was indistinguishable from refusing; the client home never coincided with the probed path. Assert the fallback stays off with homedir pinned to the path. - Comparing an execution-host home across path syntaxes survived because no row exercised the win32 home under POSIX ops: path.resolve manufactures <cwd>/C:/Users/bob, which every ancestor of the cwd contains. - Dropping the bare /Users rule survived; add the row. Also cover the forward-slash C:/Users/bob form normalizeRemoteHome reports for a Windows host, which no existing row used.
992b82d to
675c910
Compare
|
Folded #19865 onto this branch (rebased on current The guard now takes an explicit home authority from the execution host ( |

ELI5
When Orca cleans up leftover worktrees over SSH, it used the desktop's home folder to decide whether a path is too dangerous to delete. That is the wrong machine. A Windows remote home like
C:\Users\bobdid not look like a home from a Mac/Linux client, so the extra guard was weaker than local. This change recognizes home directories from the shape of the path (/home/alice,/Users/alice,C:\Users\bob) and only usesos.homedir()when the path syntax matches the client OS.What Changed
isDangerousWorktreeRemovalPathno longer callsos.homedir()when worktree/repo path ops do not matchprocess.platform.{root}Usersand{root}Users\<name>viapathOps.parse().root(no hardcodedC:)./home/<user>and/Users/<user>detection is unchanged./home/alice/wt/foo,C:\Users\bob\wt\foo) stay deletable —containsPathis still "worktree contains home", not the reverse.Why
SSH orphan cleanup (
runtime-unregistered-worktree-removal.ts) passes remote paths into the client-side guard. Clientos.homedir()plus POSIX-only regexes cannot protect a Windows SSH profile from a POSIX desktop, and can also refuse a safe POSIX remote delete when the client home string coincidentally interacts with the remote path. Path-shape detection is the intended fix; no new RPC for the remote user's home.Linked Issue
Fixes #18275
Visual Proof
N/A — no visual or interaction change. This is a path-safety guard used during unregistered/orphan worktree directory removal.
Testing
Verification (plan 008):
pnpm test src/main/worktree-removal-safety.test.ts— 33 passed (table cases + stubbedos.homedir()to/Users/ciondarwinstill treatsC:\Users\bobas dangerous)pnpm tc:node— exit 0pnpm run check:code-quality:changed— exit 0Platforms actually exercised: macOS unit tests with POSIX and win32 path fixtures (no live SSH). Windows profile cases run under
process.platform === 'darwin'viawithProcessPlatform.Review
getPathOps/path.posix/path.win32; Windows profiles usepathOps.parse().rootsoD:\Users\bobis covered, not onlyC:.docs/reference/remote-wire-compatibility.md); no execution-host substitution (docs/reference/ssh-execution-boundary.md).containsPath.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Local: plan verification commands (
pnpm test src/main/worktree-removal-safety.test.ts,pnpm tc:node,pnpm run check:code-quality:changed). Fullpnpm lint/pnpm buildleft to CI per plan.