Skip to content

fix(wrap): leased branch delete, busy check, safe sweep lock - #1266

Merged
tieubao merged 5 commits into
masterfrom
l312-wrap
Dec 3, 2026
Merged

tieubao merged 5 commits into
masterfrom
l312-wrap

Conversation

@tieubao

@tieubao tieubao commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

What

Wrap no longer loses work in three race windows.

  1. Busy check: wrap apply and the archive path always check whether a live process holds a worktree; the test-only disable switch is gone.
  2. Leased branch delete: after a merge, wrap deletes a branch only if it still points at the commit wrap saw, and never while any worktree is rebasing or bisecting it.
  3. Sweep lock: a recycled pid is told apart from the live holder by its start time (read with LC_ALL=C TZ=UTC0) against the lock age, and reclaim is serialized so two reclaimers cannot evict a live holder.
  4. Sweep rows carry deleted_tip, the tip commit of each deleted branch, so it can be restored.

Demo

Commit to a merged branch between wrap's read and its delete: deleted before, kept after.

Proof

docs/verification/wrap-safety.md

  • Verdict: works: no tested race deletes a live worktree, a moved branch, or a branch mid-rebase, and a live sweep holder is never evicted.
  • Proof: test-wrap-busy-no-switch 36/36 and test-wrap-sweep-lock 25/25 red on master and green after on bash 3.2 and 5; run-all --changed 58/58 including test-wrap-apply and test-wrap-sweep; planted faults red; one fresh review with real races, and both of its blockers (time zone, rebase or bisect) were fixed.
  • Risk: wrap now keeps a branch or worktree in more cases, so a few more need a manual tidy; undo with a revert.
  • Needs Han: nothing.

Bookkeeping

no-board-row: leftover audit slice tracked on the devkit leftovers item

@tieubao tieubao closed this Dec 3, 2026
@tieubao tieubao reopened this Dec 3, 2026
@tieubao
tieubao merged commit 64ca6ef into master Dec 3, 2026
9 checks passed
@tieubao
tieubao deleted the l312-wrap branch December 3, 2026 04:22
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.

1 participant