Skip to content

fix(git): refuse mirror deletion when status is unknown - #81

Merged
cloader merged 1 commit into
devfrom
fix/mirror-status-guard
Nov 1, 2026
Merged

cloader merged 1 commit into
devfrom
fix/mirror-status-guard

Conversation

@cloader

@cloader cloader commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What changed?

A failed git status was treated as a clean worktree, allowing mirror removal to force-delete uncommitted files and then recursively remove leftovers. With a corrupt worktree index, the previous implementation reports success after deleting the agent's work.

  • Refuse unknown status in both mirror preflight and the per-worktree removal guard, including rejected status calls. Verify the reported worktree root so an orphan cannot inherit its parent repository's clean status. A failed worktree-list query no longer means unregistered.
  • Stop immediately if a child cannot be removed. Before removing its parent, require every child path to be gone or empty, including paths reported as unregistered.
  • Remove the three recursive filesystem fallbacks from worktree removal, purge, and orphan cleanup. Mirror cleanup only removes verified empty directories with non-recursive rmdir; leftover files and symlinks are preserved. Plain multi-repo containers remain supported when their contents are verified children and empty directories.

How verified?

  • Windows, Node 22.23.1 and Node 26.13.0: typecheck, build, and all 48 test files / 639 tests pass on current dev, including fix(host): contain background failures and retry execution settlement #80.
  • 17 new regressions cover unknown/rejected status, inherited status, failed registration lookup, child failures/leftovers, all three HTTP entry points, empty containers, and real Git mirrors.
  • The real corrupt-index regression fails against the pre-change implementation because removal resolves instead of refusing. The fix preserves the uncommitted file and worktree registration. Existing root/nested and gitlink mirror integration tests still pass.
  • An initial Node 26 full run encountered EPERM in the unchanged Windows cross-process ledger-lock test; its isolated rerun and the subsequent full run passed.

Nonempty unregistered leftovers now require inspection or manual preservation rather than automatic recursive deletion.

Related issue

Fixes #73.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Removing a task mirror can force-delete uncommitted agent work: a failed git status is treated as "clean"

1 participant