fix: persist the delete-branch opt-in across a daemon restart - #488
Open
Sma1lboy wants to merge 1 commit into
Open
fix: persist the delete-branch opt-in across a daemon restart#488Sma1lboy wants to merge 1 commit into
Sma1lboy wants to merge 1 commit into
Conversation
Task deletion is a daemon-owned, persisted state machine, but the store's load coercion dropped the `deleteBranch` flag, so a deletion queued with branch cleanup that survived a restart removed the worktree while silently keeping the branch. Round-trip `deleteBranch` in coerceDeletion alongside the other persisted fields, and cover the reload path in the deletion tests.
|
Claude finished @Sma1lboy's task in 2m 2s —— View job Reviewing PR #488
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Direction
Bugs / correctness — found by code review of the daemon-owned persisted state machines (orchestrator index store codec).
Problem
Task deletion is a durable, daemon-owned background state machine (
TaskDeletionState):prepare()persists adeletionblock totasks.json(phase, force,deleteBranch, requestedAt), then a separatebegin()→finish()run does the physical cleanup. The whole point of persisting it is to survive a daemon restart in the queued/running window (and the error-retry path keeps it on disk indefinitely).But the load-path coercer
coerceDeletioninstore-codec.tsreconstructed every field exceptdeleteBranch. So:deletion.deleteBranch: trueis written to disk.finish()runs → the store reloads, anddeleteBranchis silently dropped (reads backundefined).finish()computesdeleteBranch: task.deletion.deleteBranch === true→false, and removes the worktree while keeping the branch the user explicitly asked to delete — no error, no signal.Every other optional deletion/task field is round-tripped precisely to avoid this class of "silently forgotten on every daemon restart" bug;
deleteBranchwas the one gap.Fix
One line in
coerceDeletion— round-tripdeleteBranchwhen it's a boolean, alongside the existingerrorpassthrough:Verification
test/orchestrator/task-deletion.test.tsthat persists a deletion withdeleteBranch: true, reloads through a freshTaskIndexStore+Orchestrator, and asserts the opt-in survives andfinish()callsworktrees.remove(..., { deleteBranch: true }). Confirmed it fails without the fix (reads backundefined→deleteBranch: false) and passes with it.bun run typecheckandbun run lint— both green.test/orchestrator/task-deletion.test.ts— all 8 tests pass.Note: the full
bun run testrun has one unrelated pre-existing failure —test/state/layout-migration.test.ts > … partial failure and retries— which fails on a cleanorigin/maincheckout too, because it injects a failure via a read-only directory that the container's root user bypasses. Not related to this change.Follow-ups (deliberately out of scope)
A separate code-review pass surfaced a second, unrelated one-line correctness bug worth its own PR:
hasLiveEngineTab(src/cli/api/tab-snapshot.ts) counts a scratch task's shelltab-1as a live engine tab because the snapshot-free floor fires unconditionally, making a scratch shell sitting at a prompt reportrunning: trueto a coordinating agent. Left for a focused follow-up to keep this PR to one slice.Generated by Claude Code