Skip to content

P2: Include WSL worktree roots in orphan sweep and retention GC #1401

Closed

Description

@currentbits

Gap

resolveWorktreeDir places WSL project worktrees inside the distro at <repoParent>/.solenta/worktrees/<threadId> (or /tmp/solenta-worktrees for a mounted repo). On origin/main e2924af, both sweepOrphanWorktrees and gcScanInner enumerate only worktreeBase, the Windows app-data directory. The periodic retention sweeper passes only that base. As a result, WSL worktrees never become orphan or retention candidates, so #434's correct placement can accumulate disk indefinitely. The source comment notes the boot orphan limitation; no WSL GC coverage was found.

Change

Enumerate worktree roots derived from configured WSL projects alongside the normal app-data root, using the existing candidate classification, dirty/unmerged guards, grace rules, and branch-preserving removal. Keep scanning bounded to known Solenta worktree roots. Include WSL usage in the GC view and periodic retention.

Check

A WSL-root clean, settled worktree past retention is discovered and reclaimed; a dirty or live WSL worktree is kept; an orphan is classified using the same safety rules. Native Windows and macOS roots retain current behavior.

Activity

  1. currentbits commented on Oct 1, 2026

    @currentbits
    OwnerAuthor

    Isolated path probe: resolveWorktreeDir({path: '\\\\wsl.localhost\\Ubuntu\\home\\user\\repo'}, 'C:\\Users\\user\\AppData\\Solenta\\worktrees', 'thread-1', 'win32') returns the UNC directory \\\\wsl.localhost\\Ubuntu\\home\\user\\.solenta\\worktrees\\thread-1 and Linux add path /home/user/.solenta/worktrees/thread-1. The returned directory is outside the base passed to both GC scanners. This probe checks path routing only; it is not a Windows end-to-end GC run.

  2. added and removed on Oct 13, 2026
  3. currentbits commented on Oct 13, 2026

    @currentbits
    OwnerAuthor

    The change itself is already on main. It landed in 70b5595 (#1544, part of #1531). worktreeRoots in electron/worktrees-gc.js now adds the WSL roots resolveWorktreeDir uses, including /tmp/solenta-worktrees for mounted repos, as non-app-owned roots. Three things use it: the boot orphan sweep, gcScan (the GC view's usage) and enforceRetention (the periodic sweeper). In a non-owned root, GC only considers dirs named like a thread id that are registered linked worktrees of a known project, and it never force-removes a dir git can't read.

    Traced on win32:

    • registeredWorktrees maps git worktree list linux paths back to UNC with linuxPathToUnc.
    • --git-common-dir returns a linux path, and path.win32.resolve(UNC, "/home/...") turns it into the UNC repo path. Checked by hand.
    • Later git calls are routed through wsl.exe by resolveGitCommand.

    Test coverage is in branch coder/p2-include-wsl-worktree-roots-in-orphan--5643f1, commit 12db5ac. It adds a retention test on a non-owned root: a clean settled worktree past keep-N is reclaimed, and the dirty and working ones are kept. The WSL roots go through this same code path, and worktree-wsl.test.js already covers the root enumeration. Orphan classification in a non-owned root was already covered by "sweeps only registered app worktrees in a custom root". The native Windows and macOS root is unchanged: it is still the only app-owned root.

    Not covered: nothing runs against a real \\wsl$ distro. That needs a Windows+WSL machine.

  4. added and removed on Oct 13, 2026
  5. currentbits commented on Oct 13, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "P2: Include WSL worktree roots in orphan sweep and retention" (PR #1623). Closed on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions