Repository navigation
fix(worktree): recognise the Windows profile through WSL's drvfs view - #20051
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Home guard re-derives ops from
worktreePathalone —isHomeDirectoryRemovalPathnow takes(worktreePath, home)and computesgetPathOps(worktreePath)internally, so a POSIX worktree path paired with a WSL UNC repo spelling no longer falls underwin32ops and silences every POSIX home shape. - drvfs Windows-profile recognition —
isLikelyWslDistroHomeDirectoryroutes a/mnt/<letter>tail throughtoWindowsWslDrivePathand applies the WindowsUsersrule, protecting\\wsl.localhost\Ubuntu\mnt\c\Users\bobwhile leaving/MNTand nested subdirectories deletable. - Tests now exercise the real entry point — the guard's unit helper calls
isHomeDirectoryRemovalPathdirectly (dropping the single-arg paraphrase), and four mutation-proven mixed-pair rows plus a drvfs table and a "linked WSL worktree stays deletable" case were added.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
98efec6 to
bb5a35e
Compare
0ec10eb to
a43dc36
Compare
bb5a35e to
1505500
Compare
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
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; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds explicit client and execution-host home authorities for worktree removal. It adds POSIX, Windows, and WSL path checks and updates removal safety APIs to receive the authority. SSH routes resolve the remote home from active relay sessions. Registered, unregistered, managed, and local removal flows pass the resolved authority into safety checks and cleanup. New tests cover route resolution, path semantics, host-home rejection, and orphan child removal. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to Worktree deletion safety checks now compare paths against the home directory of the machine that will actually perform the delete, including remote SSH hosts and Windows profiles reached through WSL. Behavior for existing local deletions is unchanged, protections are strengthened for remote removals, and new tests cover the mixed path formats, so no merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the defect, fix, rationale, and verification, but it does not follow the required template. It omits the required Linked Issue format, Visual Proof or N/A statement, testing checkboxes and platform details, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist sections. Resolution Add all required template sections. Include a valid issue reference using the required "Fixes #..." format, state "N/A" with a reason for Visual Proof, document manual and automated testing with tested platforms, complete the AI Disclosure and Agent skill boundary sections, address the Notes items, and complete the Checklist. ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
Comment |
`/mnt/<letter>` under a WSL UNC alias is the distro's drvfs mount of a Windows volume, so `\\wsl.localhost\Ubuntu\mnt\c\Users\bob` is `C:\Users\bob` wearing a Linux spelling. The Windows-profile rule excludes every WSL UNC path by design (the aliases normally front a Linux filesystem) and the POSIX shapes never match a `/mnt/...` tail, so that path fell through both and read back as deletable. The spelling is producible by the product: `resolveWslRepoWorktreeBasePath` maps a `/mnt/c/...` worktree base against a WSL repo into exactly this UNC form, and `getWslFilesystemBoundaryDistro` already treats it as the drvfs crossing. A drvfs tail now takes the Windows rule on its drive form, via the existing `toWindowsWslDrivePath`. Scoped to the UNC branch, where `parseWslUncPath` has proven the path is a WSL alias — a plain Linux host's `/mnt/c/...` is untouched. The lowercase-only `/mnt` match is deliberate: `/MNT` is an ordinary case-sensitive Linux directory, never the automount.
a43dc36 to
2ca2b00
Compare
… WSL UNC alias `\\wsl.localhost\Ubuntu\mnt\c` is the whole C: volume and `\\wsl.localhost\Ubuntu\mnt` holds every drvfs volume. Neither is caught by the root check in `isDangerousWorktreeRemovalPath` (their win32 root is the distro share) nor by the Windows-profile rule on the drive form (`C:\` is not `C:\Users`), so both read as deletable. Measured on a Windows 11 host with WSL2: `rm -rf` inside the distro on the `/mnt/c` spelling deletes on the Windows drive.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Refused the drvfs volume root — in the WSL UNC drvfs branch, a resolved drive path equal to its own win32 root (
/mnt/c→C:\, any volume) is now treated as dangerous, so\\wsl.localhost\Ubuntu\mnt\cno longer reads as an ordinary deletable directory. The comment correctly explains why the outer root check cannot catch it: the UNC spelling's win32 root is the distro share. - Refused the automount parent — when the tail does not translate to a drive,
linuxPath === '/mnt'is refused, since the automount holds every volume and therefore every profile./MNTstays an ordinary case-sensitive directory. - Tests extended with teeth — four rows added (volume root, trailing slash,
/mnt, and a nested/mnt/c/src/repothat must stay deletable). I verified the three→ truerows fail when the4a7a835production hunk is reverted; the→ falserows stay green.
I ran worktree-removal-home-guard + worktree-removal-safety — 85 passed. No open threads from the prior review.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Note
Rebased onto
main2026-09-18, and cut from two commits to one.This was stacked on #19865, which has since squash-merged. The first of its two
commits — "let the worktree path alone decide whose home it is" — landed
inside that squash, solved a different way:
isHomeDirectoryRemovalPathnowre-reads the worktree path under its own path ops and refuses if either
reading names a home. Measured on
main: all five of that commit's assertionsalready pass, so it is dropped rather than re-applied. Only the second commit
remains.
a43dc36b187(4 files, +70/−10)2ca2b008fcd(2 files, +29/−2)The defect
/mnt/<letter>under a WSL UNC alias is the distro's drvfs mount of a Windowsvolume, so
\\wsl.localhost\Ubuntu\mnt\c\Users\bobisC:\Users\bobwearing aLinux spelling.
The guard's Windows-profile rule excludes every WSL UNC path by design — those
aliases normally front a Linux filesystem — and the POSIX home shapes never match
a
/mnt/...tail. So that path falls through both rules and reads back as anordinary deletable directory, in front of a recursive delete.
Still reproducible on
mainat7063c2cbdd3:The spelling is producible by the product, not hypothetical:
resolveWslRepoWorktreeBasePathmaps a/mnt/c/...worktree base against a WSLrepo into exactly this UNC form, and
getWslFilesystemBoundaryDistroalreadytreats it as the drvfs crossing.
The fix
A drvfs tail now takes the Windows profile rule on its drive form, via the
existing
toWindowsWslDrivePath. Scoped to the UNC branch, whereparseWslUncPathhas already proven the path is a WSL alias — a plain Linuxhost's
/mnt/c/...is untouched.The lowercase-only
/mntmatch is deliberate:/MNTis an ordinarycase-sensitive Linux directory, never the automount.
Why this shape and not the alternatives
Widening the POSIX home shapes to include
/mnt/<letter>/Users/<name>was theother option. It is wrong in both directions: it would fire on a plain Linux box
where
/mnt/c/Users/bobis just a directory somebody made, and it would stillmiss every other Windows-profile shape the drive form already handles
(
\\server\share\Users\bob, non-C:volumes). Translating to the drive form andreusing the one Windows rule keeps a single answer to "is this a Windows
profile".
Verification
worktree-removal-home-guard+worktree-removal-safety— 81 passed on therebased tree.
config/tsconfig.node.json— clean.pnpm run check:code-quality:changed— passed, 0 findings.two
-> truerows fail by name, the two-> falserows (/MNT, and a realworktree under the profile) stay green.