Skip to content

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

Closed

Description

@Jammy2211

Overview

heart/checks/worktree_drift.py::scan treats every directory under the worktree root (~/Code/PyAutoLabs-wt/) as a task worktree. The user's JetBrains project directory ~/Code/PyAutoLabs-wt/.idea is a directory, is claimed by neither active.md nor parked.md, and is therefore reported as an ORPHAN — a permanent, unfixable drift line for something that is not a worktree and never will be. It degrades the Heart worktree-drift surface with pure noise.

Plan

  • Skip hidden entries (name starting with .) in the wt-root discovery sweep only.
  • Leave the claimed-path leg untouched: a task whose worktree: claim genuinely points at a dotted path is still tracked and never reported missing. The filter is about what the sweep discovers, not about what the Mind claims.
  • Extend tests/test_worktree_drift.py with a case placing a .idea directory under the wt root beside a genuine unclaimed worktree, asserting only the genuine one is reported as an orphan.
  • Run pytest tests/ -q in the task worktree.
Detailed implementation plan

Affected Repositories

  • PyAutoHeart (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoHeart main clean

Suggested branch: feature/heart-worktree-drift-hidden-dirs

Implementation Steps

  1. heart/checks/worktree_drift.py — in scan(), the wt-root sweep

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

    gains a hidden-name guard so dot-directories are not noted as discovered worktrees. The for c in active_claims + parked_claims: note(...) loop below it is deliberately left alone.

  2. Module docstring — record that the wt-root sweep skips hidden dirs and why the claims leg does not.

  3. tests/test_worktree_drift.py — add test_hidden_dirs_under_wt_root_are_not_orphans: a .idea directory (with a plausible child) beside a real unclaimed worktree under the wt root; assert orphans names exactly the real one, and that on_disk_count counts one.

Key Files

  • heart/checks/worktree_drift.py — scan() wt-root enumeration (~line 107)
  • tests/test_worktree_drift.py — existing categorisation tests over synthetic trees

Original Prompt

Click to expand starting prompt

heart/checks/worktree_drift.py (line 107, for entry in sorted(wt_root.iterdir()): if entry.is_dir(): note(entry, entry.name)) treats every directory under the worktree root (/Code/PyAutoLabs-wt/) as a task worktree, so the user's JetBrains .idea project dir is reported as an orphan and degrades Heart readiness. Fix: skip hidden directories (name starts with "."). Extend the existing worktree_drift test in PyAutoHeart/tests/ (find it) with a case where a .idea dir sits under the wt root beside a real orphan and assert only the real one is reported.

Activity

  1. Jammy2211 commented on Sep 4, 2026

    @Jammy2211
    ContributorAuthor

    Library PR Created

    PR: #200 (feature/heart-worktree-drift-hidden-dirs, label pending-release)

    Discovery under the wt root now skips hidden names; the claims leg is untouched so .codex-worktrees/<task> claims still track.

    • pytest tests/ -q in the task worktree: 681 passed in 60.09s
    • New test proven to fail without the guard (1 failed, 9 passed, '.idea' != 'mystery')
    • Live scan of the real wt root: orphans: [] (was ['.idea'])

    Workspace impact: (iii) none. heart/checks/worktree_drift.py is Heart-internal, monitoring-only, and imported by nothing outside PyAutoHeart; scan()'s signature and return shape are unchanged. No workspace script or downstream library reads it.

    Heart readiness at ship time was RED on release validation FAILED (stage integrate) — pre-existing, unrelated to this branch, and already owned by profiles-jit-powerlaw-exact-zero-atol. The run ends at PR-open; merge stays human.

  2. Jammy2211 commented on Sep 4, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Merged in #200 (merge commit 911d7740).

    heart/checks/worktree_drift.py::scan now skips hidden directory names when it
    discovers worktrees under the wt root, so ~/Code/PyAutoLabs-wt/.idea (and any
    other tool's dotted dir) stops being reported as a permanent ORPHAN.

    The claims leg is deliberately untouched: active.md / parked.md claims still go
    through note() unconditionally, so a task whose worktree: genuinely points at a
    dotted path (PyAutoLabs/.codex-worktrees/<task>) is still tracked and never
    reported MISSING. The filter governs what the sweep discovers, not what the Mind
    claims.

    Two tests added to tests/test_worktree_drift.py:

    • test_hidden_dirs_under_wt_root_are_not_orphans — a .idea dir beside a genuine
      unclaimed worktree; only the genuine one is an orphan.
    • test_hidden_dir_that_is_explicitly_claimed_is_still_tracked — the regression
      guard for the leg that was not filtered.

    CI green on both pytest legs for c9d3c89f; pytest tests/ -q was 681 passed
    in the task worktree, and the new test fails without the guard.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions