Repository navigation
Description
What happens
The worktree/mirror delete path conflates "git status failed" with "nothing is dirty", then removes
the worktree with --force and rm -rf:
src/host/git.ts:362-366—dirtyLines()returnsundefinedwhengit status --porcelain
fails;src/host/isolation.ts:219—await git.dirtyLines(target.path).catch(() => undefined)turns a
throw into the sameundefined;src/host/isolation.ts:228— only defined, non-empty lines count as dirty, so the aggregate
dirty-mirrorrefusal at:230-238never fires;src/host/isolation.ts:250-251— the root worktree is then removed withforce: true;src/host/git.ts:399-412—removeWorktree's own guard isif (status.ok && dirty)— a failed
status skips the guard too, soworktree remove --force(:413-415) deletes the directory;src/host/routes.ts:1254-1258— the delete route thenrm -rfs the path as well.
This is exactly the opposite of the documented contract: "refuses uncommitted changes"
(routes.ts:1238), "one dirty repo refuses the WHOLE mirror before anything is deleted"
(isolation.ts:14-16), and "dirty worktrees are kept — never a data-loss primitive"
(execution.ts:1028-1030).
Trigger (realistic)
git status is a quick call with a 2 s timeout (QUICK_TIMEOUT_MS, git.ts:29) and a 4 MB stdout
cap (git.ts:238). The mirror is a fresh checkout, and the execution framing explicitly tells the
agent it may need to install dependencies inside it (execution.ts:1315). A mirror containing
node_modules (tens of thousands of untracked files) can exceed the timeout or the buffer on
Windows; a corrupt index (killed git during add/commit) fails outright. Then:
- A worktree-isolated task has uncommitted work.
- The user clicks Remove worktree (or a purge/cleanup flow runs).
git statusfails inside the mirror → no dirty refusal →worktree remove --force+rm -rf.- The GUI reports success; the agent's uncommitted work is gone.
How I verified it
Reproduced against real git with the plugin's own createGitFace() / removeMirror():
- control: a dirty root mirror rejects with
{ code: 'dirty-mirror' }and the file survives; - status-failure variant: corrupt the worktree's index →
dirtyLines(root)returnsundefined→
removeMirror(...)resolves, the mirror directory is gone, and the work file is gone; - at the git level,
git worktree remove --forcesucceeds on a registered worktree whose status
command now fails.
Environment
- dsh-taskboard
0.9.7/dev@fb97e7f(originally reproduced on0.9.6@3054eba) - DSH
0.2.1-rc.5, Windows 11, git 2.51
Suggested fix
Stop representing "unknown" as clean. Return a sentinel ('unsupported'/'failed') or let
dirtyLines throw, and make removeMirror/removeWorktree refuse with a readable message
("cannot verify worktree status; refusing to delete") instead of forcing. It is better to leave a
mirror behind for a retry than to delete work no one can recover. A regression test can script the
git face's status failure and assert the refusal + surviving directory.
Dedupe
#15 introduced multi-repo mirrors and the 0.6.3 review fixed false dirty refusals; the inverse
(status failure → silent force delete) has no issue. The broken promise is documented in-repo.
Activity