emrg: fix dirty-tree probe for linked git worktrees (.git as file) - #981
Conversation
how2how2how2-arch
left a comment
There was a problem hiding this comment.
✅ 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.
argszero
left a comment
There was a problem hiding this comment.
✅ 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.
argszero
left a comment
There was a problem hiding this comment.
✅ 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 ✅.
Uh oh!
There was an error while loading. Please reload this page.
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.gitis 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.gitmarker as either a directory (regular repo) or a file (linked worktree). Still fail-open for bare/non-git dirs, still runs viaasyncio.to_thread, still keeps the localsubprocessimport invariant.tests/test_scheduler.py— new testtest_is_dirty_tree_linked_worktree: creates a repo, adds a linked worktree, asserts.gitis 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/ -q→ 1078 passed, 1 skippedfrom emrg.client.app import run_client✅,python -m emrg --help✅