fix(kanban): sweep deferred scratch parent on non-scratch child completion + tests

Follow-up on the deferred-cleanup salvage (#33774): _cleanup_workspace
returned early for a non-scratch ('dir'/'worktree') task and never ran the
parent sweep, so a scratch parent waiting on a 'dir' child would leak its
deferred workspace forever. Run the parent sweep before the early return.

Adds regression tests: deferred-while-child-active, swept-after-last-child,
and dir-child-unblocks-scratch-parent.
This commit is contained in:
teknium1
2026-06-07 09:50:44 -07:00
committed by Teknium
parent 9405cd0812
commit 76f01780f0
2 changed files with 89 additions and 0 deletions
+4
View File
@@ -3838,6 +3838,10 @@ def _cleanup_workspace(conn: sqlite3.Connection, task_id: str) -> None:
kind: Optional[str] = row["workspace_kind"]
path: Optional[str] = row["workspace_path"]
if kind != "scratch" or not path:
# This task's own workspace isn't a removable scratch dir, but its
# completion may still unblock a deferred parent scratch cleanup
# (e.g. a 'dir' child whose scratch parent was waiting on it). #33774
_try_cleanup_parent_workspaces(conn, task_id)
return
# Check if this task has children that still need the workspace.
# If any child is not yet done/archived, defer cleanup so the