Skip to content

Preserve checkout identity through Worktree cleanup - #504

Merged
JacobStephens2 merged 3 commits into
mainfrom
issue-503
Oct 7, 2026
Merged

JacobStephens2 merged 3 commits into
mainfrom
issue-503

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #503.

Successful Worktree acquisition now carries pinned checkout and registration identity through both lifetime owners. Recreated or uncertain resources survive cleanup, even when pathname, administrative pathname, Issue branch and HEAD match the original.

acquire under the worktree lock and recovery guard
  pin checkout, administrative and common-repository directories
scope exit under the completion worktree lock
  verify the acquired instance and current attached/detached identity
  remove only the owned checkout
  inspect every registration before deleting an Issue ref
  atomically compare-and-delete the observed ref head
  remove only unchanged local branch configuration while the ref is absent
uncertain ownership or failed cleanup
  retain resources and report path, branch, available head and reason

Evidence

  • Before: an_old_owner_retains_a_recreated_checkout_even_with_the_same_paths_branch_and_head failed because dropping the old owner deleted replacement.txt (NotFound).
    After: the same regression and its detached Architecture review counterpart preserve replacement files, registrations and exact refs, and assert retention warnings.
  • All 27 focused cleanup cases pass, including directory/admin/common replacement, symlinks, damaged registrations, acquisition capture recovery for all four acquisition states, failed removal, ref/configuration interleavings, and SIGINT/SIGTERM/SIGHUP completion.
  • Existing acquisition, synchronization, preservation and relevant command lifecycle checks pass.
  • Final Linux checks pass: cargo fmt --check, cargo clippy --all-targets -- -D warnings, and the full cargo test suite (1,400 passed, one existing ignored test).
  • Linux and macOS CI and the release build/smoke checks pass on final commit bc2db46.

Test seams

  • Worktree fresh/Continuation acquisition, use and scope exit with real local Git and a temporary origin.
  • ReviewWorktree acquisition and scope exit with real local Git.
  • Existing isolated process/signal seam for interruption and controlled Git faults/interleavings; observe files, registrations, exact refs and progress diagnostics.

Unaddressed findings

Standards

None. The one heuristic finding, identity expectations coupled to directory names, was addressed with explicit attached/detached expectations.

Spec

None. The Spec review reported no findings.

Merge Danger

Door: two-way

No persistent format or acquisition policy changes; the implementation can be reverted.

Blast Radius: Worktrees

Shared scope-exit cleanup for Runs, Spec runs and Architecture reviews. Uncertain evidence retains local resources for manual recovery; owned checkout and review scratch disposal remains unchanged.

Built with codex · gpt-6.1-sol · xhigh

@JacobStephens2
JacobStephens2 merged commit a2faf4f into main Oct 7, 2026
13 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-503 branch October 7, 2026 09:45
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 7, 2026
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.

Deepen Worktree ownership through successful cleanup

1 participant