Repository navigation
fix(kanban): auto-promote scratch workspace to worktree for code-fix tasks - #85087
Open
matsromblad wants to merge 1 commit into
Open
matsromblad wants to merge 1 commit into
matsromblad wants to merge 1 commit into
Conversation
…tasks When a task is created without `--project` (legacy imports, manual dashboard creates, or older code paths), `resolve_workspace` lands it under `<board-root>/workspaces/<id>/` — an empty tmp dir. Workers running such tasks must `cd` into the source tree manually on every turn, and any tool that resolves paths against TERMINAL_CWD lands in the empty dir instead of the project repo. Auto-promote at resolve time: if the task body contains code-fix markers (`src/agents/`, `tests/test_`, `docs/audits/`, `pytest`, `ruff`, `git worktree`) AND a registered project shares a basename substring with the body, promote the workspace to a linked worktree on that project's primary_path. The body never names an absolute path we would trust — only project basenames from the user's own projects.db — so this is loose-by-design but safe: a false match wastes a worktree under a real registered repo, not under an attacker-chosen path. This is the dispatcher-side complement to the project-binding fix in `tools/kanban_github_sync/import_github_issues.py` (which sends `--project <slug>` on the importer side). Together they close the loop on a class of Kanban tasks that have been silently landing in empty workspaces since the auto-improve miner started dispatching Tier-1/Tier-2 audit findings in early August. Tests in `tests/hermes_cli/test_scratch_to_worktree_promotion.py`: - 3× positive (src/agents/, tests/, pytest + project basename in body) - 1× negative (non-code task body) - 1× negative (code markers but no registered project matches) - 1× fail-closed (projects_db unreachable → None)
fix(kanban): auto-promote scratch workspace to worktree for code-fix tasks — dispatcher-side promotion from scratch to a linked worktree when the body signals a code-fix task and a registered project matches. Reasonable heuristic with good fail-closed tests.
|
12 of 19 tasks
This branch has not been deployed
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 is created without
--project(legacy imports, manual dashboard creates, older code paths),resolve_workspaceinhermes_cli/kanban_db.pylands it under<board-root>/workspaces/<id>/— an empty tmp dir. Workers running such tasks mustcdinto the source tree manually on every turn, and any tool that resolves paths againstTERMINAL_CWDlands in the empty dir instead of the project repo.This has been silently affecting auto-improve-miner-dispatched tasks since early August 2026 (the miner imports Tier-1/Tier-2 audit findings via
tools/kanban_github_sync/import_github_issues.py, which didn't bind--projectuntil a parallel fix was added).Fix
Add a body-driven auto-promotion helper in
hermes_cli/kanban_db.py:_CODE_TASK_MARKERS— narrow tuple of source-tree tokens (src/agents/,tests/test_,docs/audits/,pytest,ruff,git worktree). Kept narrow on purpose: false positives waste a worktree under a real registered repo; false negatives are recoverable (the worker can manuallycd)._maybe_promote_scratch_to_worktree(task)— returns the matching project'sprimary_pathif both conditions hold, elseNone. Substring match on the project'sslug/name/ repo basename — loose-by-design but safe (only matches project names from the user's ownprojects.db).resolve_workspacecalls the helper at the top of thescratchbranch; on match it mutates the task in-memory toworkspace_kind='worktree'and delegates to the existing_resolve_worktree_workspacepath.The helper fail-closes on
projects_dboutage: any exception →None. Tested explicitly intest_no_promotion_when_projects_db_lookup_fails.Tests
tests/hermes_cli/test_scratch_to_worktree_promotion.py(6 cases, 6/6 green):src/agents/+ project basename in bodytests/test_+ project basenamepytest+ project basenameNoneifprojects_db.connect_closingraisesExisting test suite verified — 52 pass, 4 fail (all pre-existing on
mainat HEAD~1:test_protocol_violation_budget_not_consumed_by_other_failures,test_rate_limit_exit_requeues_without_counting_failure,test_worktree_workspace_explicit_target_materializes_linked_worktree,test_resolve_hermes_argv_falls_back_to_module_form_when_no_path_shim). No regressions introduced.ruff checkclean on both files.Companion fix
tools/kanban_github_sync/import_github_issues.py(Chiron-side, separate repo) sends--project <slug>on the importer side as of today. This Hermes-side patch is the dispatcher-side fallback for tasks created without that binding (legacy imports, manual creates, future code paths). They are independent: each one closes the loop on its own failure mode, and together they leave no path where a code-fix task lands in an empty scratch workspace.