fix(kanban): preserve scratch workspace on completion, clean up on archive#38454
fix(kanban): preserve scratch workspace on completion, clean up on archive#38454PINKIIILQWQ wants to merge 1 commit into
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
Review of PR #38454: fix(kanban): preserve scratch workspace files on task completion
Issues
- Found secret pattern in diff; double-check.
- Found debug pattern in diff; double-check.
- Found todo pattern in diff; double-check.
Reviewed by Hermes Agent
62095b6 to
9574ba6
Compare
…chive Two complementary lifecycle fixes for kanban scratch workspaces: Part A — Preserve scratch workspace on task completion _cleanup_workspace() was silently deleting all worker output on kanban_complete via shutil.rmtree. Remove the rmtree call so files the worker wrote to $HERMES_KANBAN_WORKSPACE remain accessible. - kanban_db.py: delete shutil.rmtree from _cleanup_workspace() - kanban.py: add workspace path/ls/cp/link CLI subcommands - prompt_builder.py: update KANBAN_GUIDANCE; document scratch vs dir workspace types - test_kanban_db.py/test_kanban_tools.py: update assertions Part B — Clean up scratch workspace on archive When a scratch task was archived, its workspace directory stayed on disk indefinitely. Add _cleanup_archive_workspace(): rmtree the scratch dir + null out workspace_path in the DB. - Only touches workspace_kind='scratch'. dir/worktree preserved. - Uses _is_managed_scratch_path() containment guard. - Called from archive_task() after DB txn + recompute_ready(). Closes NousResearch#33774
9574ba6 to
fc8afd5
Compare
|
Validation Full test suite: 211/211 passed (test_kanban_db.py). Also validated in production on a multi-task pipeline (
|
|
Closing in favor of #41352, which fixes #33774 with a smaller, targeted change: scratch workspaces are deferred (not deleted) while linked children are active, then swept once all children are terminal. Your approach (never delete on completion, only on archive) changes the scratch lifecycle contract more broadly — the disk-growth tradeoff there is a separate product decision we'd rather handle on its own. Appreciate the thorough writeup on the silent-deletion problem; it helped frame the fix. Thanks! |
Hey Teknium, This isn't really about a specific PR. Over the last week I've been experimenting with building a kanban-centric software development / issue-fixing workflow around Hermes. During that process I've gone through roughly 3B tokens, contributed a handful of small PRs (mostly around usability, visibility, and workflow improvements), and spent a lot of time reading related issues and discussions. One thing I've started noticing is that several seemingly unrelated problems actually feel connected. The scratch workspace discussion is what made me realize it. After reading through #28818, #33774, #33916, #38454, #41352 and the related user reports, I think the engineering side of the problem is fairly clear. #41352 solves the parent-child handoff issue without changing the overall workspace lifecycle, which makes sense as a focused fix. What I found more interesting was the user feedback. The recurring theme wasn't really "I disagree with auto-deletion." It was closer to:
That distinction feels important. From an engineering perspective, "scratch" often implies temporary or disposable storage. But looking at the reports, many users seem to interpret it as "create a new workspace from scratch" rather than "create a workspace that will be automatically removed later." The docs are clear. The tip exists. Yet multiple users still independently arrive at the same misunderstanding. To me, that's usually a sign that the issue is less about documentation and more about how information is surfaced during the workflow itself. One other observation that might be relevant: I suspect the Hermes audience today may be broader than many of us assume. A growing number of users seem to be coming from AI-assisted development workflows rather than traditional software engineering backgrounds. Some are vibe coders, product builders, founders, designers, or people who learned programming through AI tools rather than through conventional engineering environments. For those users, terms like "scratch" may not naturally imply disposable storage. The more common interpretation is often simply:
— a fresh workspace, not a temporary one. I also noticed that parts of the Kanban experience remain untranslated for non-English users. In those cases, users may see the raw term "scratch" without any additional context in their native language. That makes the mental-model gap even more understandable. What's interesting is that I've noticed a similar pattern elsewhere too. Many of the usability improvements I've worked on recently weren't really about adding new capabilities. They were about making existing system state more visible at the moment users make decisions. That's why I no longer think the most interesting question here is whether scratch should auto-delete or not.
Anyway, I don't have a strong proposal here. I just wanted to share an observation from the perspective of a very heavy user who is trying to build real development workflows around Hermes. For what it's worth, Hermes is one of the most interesting agent systems I've used, which is exactly why I've spent so much time thinking about these things. |



Problem
Scratch workspace files have two lifecycle bugs:
1. Silent deletion on
kanban_complete_cleanup_workspace()callsshutil.rmtree(wp)on the entire workspace directory, destroying all files the worker wrote to$HERMES_KANBAN_WORKSPACEwith no recovery path. (#28818, #30151, #33774)2. Stale workspace on archive
When a scratch task is archived, its workspace directory stays on disk indefinitely. New decomposed children inheriting the same
workspace_pathwould write into a defunct folder, mixing old and new output.Changes
Part A — Preserve scratch workspace on completion
hermes_cli/kanban_db.pyshutil.rmtree(wp)from_cleanup_workspace(). Tmux session cleanup preserved.agent/prompt_builder.pyscratchvsdirworkspace types. Files are permanent after completion.hermes_cli/kanban.pykanban workspace path/ls/cp/linkCLI subcommands for file access.tests/hermes_cli/test_kanban_db.pydir preservedafter complete).tests/tools/test_kanban_tools.pyPart B — Clean up scratch workspace on archive
hermes_cli/kanban_db.py_cleanup_archive_workspace(): rmtree scratch dir + null outworkspace_pathin DB so future inheritors cannot pick up the stale path. Onlyscratchkind;dir/worktreepreserved. Uses_is_managed_scratch_path()containment guard. Called fromarchive_task().Behavior summary
Recommended usage
For project-based boards (e.g. building an app in a git repo), set the board's
default_workdirand create tasks with--workspace dir:This makes
$HERMES_KANBAN_WORKSPACEpoint directly to the project directory, so worker output lands in the repo without any extra file copying.Backward compatibility
No schema changes. No new config.
dir:/worktreeworkspaces unchanged. Path guard (#28818) still works.