00c184170b
Kanban worktree workspaces were never removed by anything: _cleanup_workspace preserved them by design, the CLI startup pruner explicitly defers t_* trees to 'hermes kanban gc', and gc only sweeps scratch — so every worktree task leaked its checkout forever (measured ~130GB on one estate). - _cleanup_workspace now dispatches worktree workspaces to a new _cleanup_worktree_workspace, which removes the worktree and its auto-generated wt/<task-id> branch only when the tree is clean AND every commit is reachable from a remote-tracking ref (reusing cli.py's _worktree_is_dirty / _worktree_has_unpushed_commits predicates). Any doubt preserves the worktree. dir workspaces stay untouched. - The #33774 active-children deferral now covers worktree parents, and _try_cleanup_parent_workspaces reaps deferred worktree parents when the last child reaches a terminal state. - archive_task reaps workspaces too; tasks archived without completing previously leaked forever. - 'hermes kanban gc' gains a backstop sweep for archived worktree tasks that predate these hooks. Tests: tests/hermes_cli/test_kanban_worktree_teardown.py (10 cases: removal, dirty/unpushed/custom-branch/main-checkout/non-git preservation, complete/ archive integration, deferred-parent handoff). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>