Skip to content

fix: skip hidden dirs when discovering task worktrees - #200

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/heart-worktree-drift-hidden-dirs
Sep 4, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/heart-worktree-drift-hidden-dirs

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Closes #198.

heart/checks/worktree_drift.py::scan enumerated every directory under the worktree root as a task worktree:

for entry in sorted(wt_root.iterdir()):
    if entry.is_dir():
        note(entry, entry.name)

The wt root is an ordinary directory that the user's other tools also write into — JetBrains puts its project dir at ~/Code/PyAutoLabs-wt/.idea. That directory is claimed by neither active.md nor parked.md, so it was reported as an ORPHAN on every tick: permanent drift no one can ever clear, for something that is not a worktree and never will be.

Discovery now skips hidden names (entry.name.startswith(".")).

The claims leg is deliberately untouched. for c in active_claims + parked_claims: note(...) still runs unconditionally, so a task whose worktree: genuinely points at a dotted path — PyAutoLabs/.codex-worktrees/<task>, the case the path-test in #123 exists for — is still noted, still counted in on_disk, and still never reported MISSING. The filter governs what the sweep discovers, not what the Mind claims.

API Changes

None. scan()'s signature and return shape are unchanged; only which directories it discovers under the wt root. The check is monitoring-only (heart/checks/worktree_drift.py docstring) and never a readiness reason, so the readiness verdict is untouched either way.

Test Plan

  • pytest tests/ -q in the task worktree — 681 passed in 60.09s
  • The new test fails without the fix. Reverting only the startswith(".") guard and re-running tests/test_worktree_drift.py: 1 failed, 9 passed, with At index 0 diff: '.idea' != 'mystery' — i.e. the guard is what the assertion is measuring, not incidental.
  • Live check against the real wt root, which currently holds a .idea: orphans: [], on_disk_count: 7 (before: .idea was in the orphan list).

Two tests added to tests/test_worktree_drift.py:

  • test_hidden_dirs_under_wt_root_are_not_orphans — a .idea dir (with a workspace.xml child) beside a genuine unclaimed worktree; asserts orphans names only the genuine one and on_disk_count == 1.
  • test_hidden_dir_that_is_explicitly_claimed_is_still_tracked — a claimed .codex-worktrees/some-task; asserts missing == [], orphans == [], on_disk_count == 1. This is the regression guard for the leg that was not filtered.

Heart gate

pyauto-heart readiness --json at ship time was RED for a reason unrelated to this branch and pre-dating it:

This PR is opened, not merged. Merge stays a human decision and should wait on that RED clearing or an explicit human call.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GnXNPigN6qWxLZy2cqhDBX

`worktree_drift.scan` enumerated every directory under the wt root as a task
worktree. `~/Code/PyAutoLabs-wt/.idea` — the user's JetBrains project dir — is
a directory, is claimed by neither active.md nor parked.md, and was therefore
reported as an ORPHAN on every tick: drift no one can ever clear, for something
that is not a worktree and never will be.

Discovery now skips hidden names. The claims leg is deliberately untouched: an
explicit `worktree:` claim on a dotted path (`.codex-worktrees/<task>`) is
still noted, so it is neither dropped from `on_disk` nor reported missing. The
filter is about what the sweep *discovers*, not what the Mind *claims*.

Two tests: the `.idea`-beside-a-real-orphan case (fails without the guard —
`orphans` came back `['.idea', 'mystery']`), and a regression guard proving a
claimed dotted path still tracks.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GnXNPigN6qWxLZy2cqhDBX
@Jammy2211 Jammy2211 added the pending-release Awaiting a published release label Sep 4, 2026
@Jammy2211
Jammy2211 merged commit 911d774 into main Sep 4, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/heart-worktree-drift-hidden-dirs branch September 4, 2026 16:31
@Jammy2211 Jammy2211 removed the pending-release Awaiting a published release label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: worktree drift reports hidden dirs (.idea) under the wt root as orphans

1 participant