Skip to content

emrg: fix dirty-tree probe for linked git worktrees (.git as file) - #981

Merged
argszero merged 1 commit into
masterfrom
feature/linked-worktree-dirty-probe
Aug 25, 2026
Merged

emrg: fix dirty-tree probe for linked git worktrees (.git as file)#981
argszero merged 1 commit into
masterfrom
feature/linked-worktree-dirty-probe

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Follow-up to #980 (structural dirty-tree guard, community issue #979). The dirty-tree probe used os.path.isdir(source_dir / ".git"), which silently fails open for linked git worktrees: there .git is a file (gitdir: ... pointer), not a directory. In a worktree-based setup the read-only sandbox guard was bypassed without any signal.

Changes

  • emrg/server/scheduler.py_is_dirty_tree_sync() now accepts the .git marker as either a directory (regular repo) or a file (linked worktree). Still fail-open for bare/non-git dirs, still runs via asyncio.to_thread, still keeps the local subprocess import invariant.
  • tests/test_scheduler.py — new test test_is_dirty_tree_linked_worktree: creates a repo, adds a linked worktree, asserts .git is a file there, and verifies both states (clean worktree → False, untracked file → True).
  • Agent.md — documented pytest collected count synced 1078 → 1079 (doc-count guard emrg: sync test counts to 484 + guard test against doc drift (recurs #426/#430/#510) #511, new test added).

Verification

  • pytest tests/ -q1078 passed, 1 skipped
  • Existing dirty-tree tests still pass (4 passed incl. the new worktree test)
  • Import check from emrg.client.app import run_client ✅, python -m emrg --help

@how2how2how2-archhow2how2how2-arch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle. The probe now treats .git as a dir (regular repo) OR a file (linked worktree), closing the fail-open bypass from #980. Test covers both states (clean → False, untracked → True) with a real linked worktree, CI test+test-windows green. Nice complement to the #980 regression follow-ups.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle.

Re-verified head 4b26e16 + CI green (test + test-windows pass, run 32844466255). The linked-worktree probe fix is correct: _is_dirty_tree_sync now accepts .git as dir (regular repo) OR file (linked worktree gitdir: pointer), preserving fail-open for bare/non-git dirs, the local subprocess import invariant, and asyncio.to_thread. Test asserts .git is a file in a real linked worktree and covers both states (clean → False, untracked → True). Full suite locally: 1078 passed, 1 skipped.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260825-201154.

Head 4b26e16 unchanged, merge state CLEAN, CI test+test-windows pass (run 32844466255). Linked-worktree probe fix verified in prior cycle: .git accepted as file or dir, fail-open preserved, local subprocess import invariant intact, dual-state test (clean → False, untracked → True). Third consecutive ✅.

@argszero
argszero merged commit b9f689d into masterAug 25, 2026
2 checks passed
Sign up for freeto 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.

2 participants

@argszero@how2how2how2-arch