fix(kanban): defer scratch workspace cleanup until linked children finish (#33774)#41352
Merged
Conversation
Contributor
🔎 Lint report:
|
…33774) When a Kanban task with workspace_kind=scratch completes, the _cleanup_workspace() function immediately deletes the workspace directory. If the task has children linked via task_links, those children find the workspace deleted when they start. This fix adds two checks: 1. Before deleting, check if any children are still active (todo/ready/running). If so, defer cleanup. 2. After a child completes, check if parent workspace can now be cleaned up (all children terminal). Fixes #33774
…etion + 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.
465a07f to
710d089
Compare
This was referenced Jun 7, 2026
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.
Summary
A Kanban scratch parent now keeps its workspace until every linked child is terminal, so dependency-chain handoffs (
parents=[A]) can actually read A's artifacts.Previously
complete_task→_cleanup_workspaceshutil.rmtree'd a scratch dir the instant the task completed, with no check for active children. A child created withparents=[A]started, found$HERMES_KANBAN_WORKSPACEalready deleted, and either crashed withFileNotFoundErroror silently re-derived A's output. (#33774)Changes
hermes_cli/kanban_db.py:_cleanup_workspace: defer thermtreewhentask_linksshows any child still intodo/ready/running. (@annguyenNous)_try_cleanup_parent_workspaces: after a child completes, sweep any parent whose children are now all terminal. (@annguyenNous)dir/worktree) child returned early and never ran the parent sweep — leaking the scratch parent's deferred dir forever. Run the sweep before that early return.tests/hermes_cli/test_kanban_db.py: +3 regression tests (deferred-while-child-active, swept-after-last-child, dir-child-unblocks-scratch-parent).Validation
dirchild of scratch parent completestests/hermes_cli/test_kanban_db.pycleanup/handoff subset: 9/9 pass. E2E verified end-to-end with real DB + file I/O in an isolatedHERMES_HOME— A writessummary.txt/guide.md, completes; artifacts survive; B reads them; both scratch dirs reaped once terminal.Salvages #33916 (@annguyenNous) onto current main with authorship preserved. Supersedes #38454 (different lifecycle approach — never-delete-on-complete). The decomposer's "everything forced to scratch" complaint in the issue comments is already addressed by #37172 / #37182 (children inherit the root workspace).
Closes #33774.
Infographic