fix(kanban): stop new project tasks from starting on stale commits - #86611
fix(kanban): stop new project tasks from starting on stale commits#86611fangliquanflq wants to merge 10 commits into
Conversation
|
I reproduced one uncovered default-branch case against When the remote default is Minimal reproduction result: The fixture was a bare Suggested fix: resolve and verify |
|
Fixed in 007d2dc by checking the verified remote default before falling back to Verification:
|
|
Thanks — 007d2dc closes the fresh-clone main+trunk case. I found one remaining stale-clone counterexample: after cloning while main is default, change the bare remote HEAD to trunk but keep main alive. git fetch --prune leaves refs/remotes/origin/HEAD pointing to main, so the updated helper still selects the old main commit. Reproduction on 007d2dc: selected=refs/remotes/origin/main Narrow draft against your exact branch: fangliquanflq#4 It resolves the remote HEAD after fetch and only falls back to the local symbolic ref if that lookup fails. Fresh validation: 9/9 isolation tests, 23 Kanban core tests + 1 skip, Ruff, Windows checker, and diff-check pass. |
|
Fixed in b57720d. The worktree-base resolver now queries the live remote HEAD first and explicitly refreshes that branch before selecting it, including repositories with restricted fetch refspecs or stale pre-existing tracking refs. The regression now keeps stale local origin/main and origin/trunk refs while verifying the new task starts from the latest remote trunk commit.\n\nVerification:\n- scripts/run_tests.sh tests/hermes_cli/test_kanban_worktree_isolation.py tests/hermes_cli/test_kanban_project_link.py tests/hermes_cli/test_kanban_board_project.py — 17 passed\n- uvx ruff check hermes_cli/kanban_db.py tests/hermes_cli/test_kanban_worktree_isolation.py — passed\n- git diff --check hermes/main...HEAD — passed\n- Real Git reproduction with a changed remote default, stale tracking refs, and a main-only fetch refspec — previous tip selected main; current tip selects the latest trunk commit |
fix(kanban): stop new project tasks from starting on stale commits
|
|
Thanks for the detailed review. I checked each point against the current branch:
Pushed through Verification:
|
|
Thanks for flagging the overlap. I reviewed the three referenced implementations against #86574 and the current branch:
The current regression suite covers stale/diverged So I agree this is now a maintainer contract-selection decision rather than a new code defect identified in this branch; no additional code change is needed for this comment. |
What does this PR do?
This fixes new Kanban project tasks starting from a stale local checkout instead of the fetched remote default branch. Without the fix, newly dispatched work can begin before already-landed upstream changes and require manual branch recovery.
Symptom
When a project's persistent checkout is stale or locally diverged, a newly created task worktree inherits that checkout's
HEADeven afterorigin/mainhas advanced.Impact
New project task branches can omit upstream commits that were already present on the protected remote default branch. Existing task branches are not affected and continue to reuse their current tips.
Bug Cause
Trigger:
hermes_cli/kanban_db.py:7680/_ensure_git_worktree/ the task branch does not exist yet.Causal chain:
git worktree add -bwith the checkout's incidental localHEADas its base without fetching or resolving the remote default.Why it is wrong: The persistent checkout is only an anchor for creating linked worktrees; its local branch can legitimately lag or diverge and is not the source of truth for a new task branch.
Working sibling / contrast: The existing-branch path intentionally checks out the recorded task branch and must preserve its tip for retry idempotence. Local-only repositories have no remote source of truth and must retain the
HEADfallback.Ruled out: Existing task-branch reuse is not the cause. Focused tests confirm that path keeps its prior tip even when the remote advances.
Fix
Fetch
originnon-interactively before creating a new task branch, resolve a verified remote default ref with support for non-mainand changed defaults, and use that ref as the worktree base. Fall back to localHEADwhen fetch or remote-default resolution is unavailable, and leave the existing-branch path unchanged.Related Issue
Closes #86574
Type of Change
Changes Made
hermes_cli/kanban_db.py- fetch and resolve the remote default only for newly created task branches, with a safe local fallback.tests/hermes_cli/test_kanban_worktree_isolation.py- cover stale and divergentmain, non-maindefaults, changed defaults, existing branches, and repositories withoutorigin.How to Test
origin/main.HEADmatches the freshly fetched remote default tip.The focused test command completed with 14 passing tests on Windows 11.
Checklist
Code
Documentation & Housekeeping