From 480ab85ee4598482fb1d9e87c2d312ad3ab0e490 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman Date: Tue, 12 May 2026 03:35:21 +0000 Subject: [PATCH] fix(sandbox): preserve LLM-plan artifacts when cleanup_stale encounters committed branches (#11120) `cleanup_stale` previously destroyed both the worktree directory AND the branch reference whenever it found a stale branch, even if that branch carried LLM- generated commits from a previous execute cycle. On re-invoked `plan execute`, this erased those artifacts so `plan apply` could find zero changes to merge. The fix adds artifact-safe mode to `cleanup_stale`: branches with committed changes beyond HEAD are preserved (worktree removed, branch ref retained) so that `plan apply` can still merge them later. Branches with no commits past their base are fully cleaned up as before. Includes the new helper method `_remove_worktree_only()` and Behave regression tests. ISSUES CLOSED: #11120 -- 2.52.0