fix: defer scratch workspace cleanup when task has active children (#33774)#33916
Closed
annguyenNous wants to merge 1 commit into
Closed
fix: defer scratch workspace cleanup when task has active children (#33774)#33916annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
…ousResearch#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 NousResearch#33774
Collaborator
|
Given the potential for data loss, particularly with the auto decomposer defaulting to 'scratch', I think there is an argument to upgrade this from a P3? |
1 task
|
Contributor
|
Merged via #41352. Your commit was cherry-picked onto current main with your authorship preserved in git log (commit 9405cd0). Added a follow-up fix (a non-scratch |
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.
Problem
When a Kanban task (workspace_kind=scratch) completes,
_cleanup_workspace()immediately deletes the workspace viashutil.rmtree(). If the task has children linked viatask_links(created withparents=[A]), those children start and find the workspace already deleted —FileNotFoundErroror silent data loss.Fix
Two changes to
_cleanup_workspace()inhermes_cli/kanban_db.py:Deferred cleanup: Before deleting, queries
task_links+tasksto check if any children are still active (status NOT IN done/archived/failed/cancelled). If so, logs a debug message and returns without deleting.Parent cleanup trigger (
_try_cleanup_parent_workspaces): After a child task's workspace is cleaned up, checks if the child's parents now have all children terminal. If so, cleans up the parent's deferred scratch workspace.Changes
hermes_cli/kanban_db.py: +61 lines_cleanup_workspace()(active children check)_try_cleanup_parent_workspaces()Design
try/except: pass) — cleanup never blocks task completion.task_linkstable and task status — no schema changes.Fixes #33774