Skip to content

Guard Worktree disposal through every Git attempt - #529

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

JacobStephens2 merged 3 commits into
mainfrom
issue-528

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Run cleanup, live Architecture review cleanup and eligible stale review disposal now share one private operation that owns authority across checkout, local Issue branch and configuration removal.

checkout → local Issue branch → local branch configuration
  before each attempt: verify that stage's authority
  after success: verify the expected removal
  after failure: verify original authority before any retry
  changed or partial state: stop and retain remaining resources

Live cleanup finishes after Command interruption; stale recovery remains interruptible and rechecks durable evidence. Healthy cleanup preserves other local and included configuration.

Closes #528

Evidence

  • Before: cargo test --bin thirdshift checkout_replacement_during_removal_retry_is_retained_for_every_lifetime -- --nocapture exited 101: replacement work was deleted on retry.
    After: passes for Run, live review and stale review disposal; the replacement checkout and its registration survive.
  • Before: cargo test --bin thirdshift same_head_attachment_during_ref_removal_retry_retains_branch_and_configuration -- --nocapture exited 101: a branch newly attached elsewhere at the same head was deleted.
    After: passes; the branch, manual checkout and configuration survive.
  • Before: configuration-retry and changed-stale-evidence regressions exited 101 after deleting replacement configuration or scratch.
    After: both pass, alongside controls for unchanged-authority retries, partial failures, repository changes, reappearing paths and success without the expected transition.
  • Review regression: the Spec reviewer's exact command, cargo test --bin thirdshift worktree::cleanup_tests::disposal_tests::stale_disposal_failure_identifies_detached_state -- --exact --nocapture, failed before the diagnostic fix and passed afterward; the test is retained.
  • Checks: cargo fmt --check, cargo clippy --all-targets -- -D warnings, and the full cargo test suite all passed.

Test seams

Pre-agreed in #528 decisions 12–13: Worktree scope exit (Run and live Architecture review cleanup) and ReviewWorktree acquisition (eligible stale review disposal), with real temporary repositories and the existing isolated Git fault adapter.

Review coverage

Reviewed against main (fee9a58) using thirdshift-code-review, including a follow-up on the fixes. Standards S1 (duplicated fault classifier) and Spec P1 (missing detached state in stale retention diagnostics) are addressed. Both axes read every changed file; unread changed files: none.

Unaddressed findings

  • Standards: None.
  • Spec: None.

Merge Danger

Door: two-way

Internal disposal changes; no data migration or evidence-format change.

Blast Radius: Worktree

Cleanup may retain resources and report a warning when refreshed authority cannot be established. Advisory locks cannot exclude arbitrary external writes between the final check and Git's mutation (#528 decision 4).

CI notes

  • test-macos: existing timing-sensitive failure in interrupting_a_live_session_after_cli_exit_stops_the_command_holding_stdout (2 s deadline includes Failed run preservation and cleanup); reproduced 3/3 on unchanged main (54c31ee) with 10 ms per Git invocation while the stdout holder was already stopped; unmodified branch stress passed 4/5 before the same deadline failure.

Built with codex · gpt-6.1-sol · xhigh

@JacobStephens2
JacobStephens2 merged commit 1cf8fa9 into main Oct 7, 2026
14 of 15 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-528 branch October 7, 2026 22:24
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 8, 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 disposal with per-attempt ownership checks

1 participant