The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): gc must never delete the scratch workspaces root itself
Kyle Caponi37e89a7abe41
diff --git a/hermes_cli/kanban_ops.py b/hermes_cli/kanban_ops.pyindex d0b3587bcd0..401fce640a2 100644--- a/hermes_cli/kanban_ops.py+++ b/hermes_cli/kanban_ops.py@@ -329,6 +329,10 @@ def _cmd_gc(args: argparse.Namespace) -> int:if row["workspace_kind"] != "scratch":continuepath = Path(row["workspace_path"] or (scratch_root / row["id"]))+ # Same containment predicate as completion cleanup (#28818): strictly below a+ # managed root, never the root itself (which holds every task's scratch dir).+ if not kbw._is_managed_scratch_path(path):+ continuetry:path = path.resolve()except OSError:diff --git a/tests/hermes_cli/test_kanban_gc_retention.py b/tests/hermes_cli/test_kanban_gc_retention.pyindex afd545755a6..60f1f077f64 100644--- a/tests/hermes_cli/test_kanban_gc_retention.py+++ b/tests/hermes_cli/test_kanban_gc_retention.py@@ -109,3 +109,22 @@ def test_slash_kanban_gc_retention_bounds(board, days, expected):with kbc.connect_closing() as conn:assert _event_rows(conn, tid) > 0assert log.exists()+++def test_cmd_gc_never_removes_the_workspaces_root_itself(board):+ # A scratch task whose workspace_path is the managed root itself (reachable via+ # kanban_create) must never make gc wipe every other task's scratch dir.+ root = kb.workspaces_root()+ sibling = root / "t_other"+ sibling.mkdir(parents=True)+ (sibling / "work.txt").write_text("another task's scratch")+ with kbc.connect_closing() as conn:+ tid = kb.create_task(conn, title="archived scratch")+ with kb.write_txn(conn):+ conn.execute(+ "UPDATE tasks SET status='archived', workspace_kind='scratch', "+ "workspace_path=? WHERE id=?",+ (str(root), tid),+ )+ assert kanban_ops._cmd_gc(_args()) == 0+ assert (sibling / "work.txt").exists()