Skip to content

fix(kanban): isolate and protect linked worktree anchors - #89734

Closed
roycepersonalassistant wants to merge 3 commits into
NousResearch:mainfrom
roycepersonalassistant:fix/kanban-linked-anchor-worktree-20260818-v2
Closed

roycepersonalassistant wants to merge 3 commits into
NousResearch:mainfrom
roycepersonalassistant:fix/kanban-linked-anchor-worktree-20260818-v2

Conversation

@roycepersonalassistant

@roycepersonalassistant roycepersonalassistant commented Aug 19, 2026 •

Copy link
Copy Markdown

Summary

  • treat a persistent linked checkout as an exact repository anchor and materialize each task at <anchor>/.worktrees/<task-id> on its requested branch
  • derive repository identity from Git's verified common directory, never from a filesystem repository that merely surrounds the anchor
  • reuse existing task targets only when both .worktrees/<task-id> path ownership and branch ownership match exactly; fail closed otherwise
  • allow deferred completion cleanup to remove only exact task-owned worktrees, preserving canonical and unrelated linked checkouts
  • add real-Git regression coverage for resolver isolation, cross-repository nesting, wrong-branch reuse, deferred cleanup, and legacy stale task rows

Root cause

The earlier resolver-only repair covered one branch-mismatch path but was never merged/installed, so the live runtime repeated the old behavior. Independently, _cleanup_worktree_workspace treated any clean linked checkout outside the repository's primary checkout as removable. A stale task row pointing at a canonical linked checkout therefore remained eligible for deferred cleanup.

The review also found two sibling ownership gaps: matching-branch linked anchors could still be reused directly, and an existing target on the wrong branch could be silently accepted. Finally, the surrounding-path fallback could select an unrelated repository when a linked anchor lived inside another checkout. The updated implementation closes all three gaps with exact path, branch, and Git-common-dir identity checks.

Validation

  • RED/GREEN: the deferred-cleanup regression failed because the canonical linked checkout was deleted, then passed after the ownership guard
  • RED/GREEN: matching-branch reuse and wrong-branch target tests both failed before the resolver hardening, then passed
  • RED/GREEN: source-nested and unrelated-repository anchor tests selected the wrong target/repository before the common-dir fix, then passed
  • python -m pytest tests/hermes_cli/test_kanban_worktree_isolation.py tests/hermes_cli/test_kanban_worktree_teardown.py tests/hermes_cli/test_worktree_command.py -o addopts= -q — 29 passed
  • python -m ruff check hermes_cli/kanban_db.py tests/hermes_cli/test_kanban_worktree_isolation.py tests/hermes_cli/test_kanban_worktree_teardown.py — passed
  • python -m py_compile hermes_cli/kanban_db.py tests/hermes_cli/test_kanban_worktree_isolation.py tests/hermes_cli/test_kanban_worktree_teardown.py — passed
  • git diff --check — passed
  • broad tests/hermes_cli/test_kanban*.py comparison reproduced the same 16 unrelated failures on clean current origin/main; the focused worktree suites are clean
  • independent pre-commit review passed with no security concerns or logic errors after two earlier review rounds exposed and drove the ownership fixes above

Risk / rollback

The cleanup policy is intentionally conservative: an explicit/custom target that is not exact .worktrees/<task-id> ownership, or whose branch drifted, is retained rather than deleted. This can leave an orphan for manual review but cannot remove an ambiguously owned checkout. A linked anchor that requests the branch already checked out at the anchor fails closed because Git cannot attach that branch to a second nested worktree; callers must use a distinct task branch.

No live Hermes runtime, DailyGameHints content, cron, Vercel, environment, schema, GSC, or indexing state is changed by this PR. Before merge, rollback is closing the PR. After merge, revert the resulting PR commit through normal review.

Supersedes the same core resolver direction from closed/conflicted PR #70585 and replaces #89727 with GitHub noreply author metadata for contributor-attribution compliance.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cron Cron scheduler and job management labels Aug 19, 2026
@roycepersonalassistant roycepersonalassistant changed the title fix(kanban): isolate linked worktree anchors fix(kanban): isolate and protect linked worktree anchors Aug 20, 2026
@roycepersonalassistant

Copy link
Copy Markdown
Author

Superseded by #90529 without rewriting published history. The replacement includes the original linked-anchor resolver fix plus the deferred-cleanup ownership guard and follow-up repository/branch identity regressions, committed with GitHub noreply author metadata so attribution can resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants