Fix cleanup_stale destroys git worktree branch on re-invoked execute (#11121) #11136

Closed
freemo wants to merge 1 commits from feature/fix-issue-11121-cleanup-stale-reinvoke into master

1 Commits

Author SHA1 Message Date
freemo b589ce2f8e Fix _create_sandbox_for_plan to preserve existing worktree branch on re-invoke (#11121)
CI / push-validation (pull_request) Successful in 45s
CI / helm (pull_request) Successful in 56s
CI / lint (pull_request) Failing after 1m9s
CI / build (pull_request) Successful in 1m16s
CI / quality (pull_request) Successful in 1m26s
CI / tdd_quality_gate (pull_request) Failing after 1m27s
CI / typecheck (pull_request) Successful in 1m53s
CI / security (pull_request) Successful in 1m54s
CI / integration_tests (pull_request) Successful in 3m56s
CI / e2e_tests (pull_request) Successful in 4m22s
CI / unit_tests (pull_request) Failing after 6m15s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
When plan execute is re-invoked for a plan that already has an active worktree
branch, _create_sandbox_for_plan was unconditionally calling cleanup_stale()
which destroyed the branch containing LLM output artifacts. This prevented
plan apply from finding any changes to merge.

The fix now checks whether the worktree branch already exists before attempting
cleanup_stale — if present, the branch is preserved so plan-apply can discover
the expected artifacts.

ISSUES CLOSED: #11121
2026-05-12 03:26:59 +00:00