fix(graph): skip .git by path component, not substring, in _walk_md#4
Merged
Conversation
_walk_md skipped any directory whose path contained the substring os.sep+'.git', which over-matches: sibling dirs like .github/.gitdata, and — worst — a root whose ancestor has a '.git'-prefixed segment (e.g. --in /x/.gitdata/brain) made EVERY walked dir match, so build_graph silently collected zero docs, wrote nothing, and stale-removal skipped everything. Prune dirs in-place by exact name so only real .git subtrees are skipped and the root/ancestor path is never matched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
Gate: adversarial verify → clean (SAFE)The verifier tried five refutation angles; all failed to find a defect:
All 5 tests pass, 100% coverage of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
_walk_mdskipped directories withif os.sep + ".git" in d— a substring test over the full directory path, not a path-component test. It over-matches:.github/and.gitdata/are silently skipped (their path contains/.git).--inroot lives under a.git-prefixed ancestor (e.g.--in /srv/.gitdata/brain-md), then every directoryos.walkyields contains/.git, so all of them are skipped.build_graphcollects zero docs, writes nothing, and stale-removal likewise skips everything — a silent total-data-loss failure that returns{"docs": 0}with no error.Fix
Prune the walk in-place by exact directory name (
dirs[:] = [sub for sub in dirs if sub != ".git"]), the canonicalos.walkidiom. This skips only real.gitsubtrees (VCS internals — the stated intent) and never inspects the root/ancestor path, so a.git-prefixed ancestor can't empty the tree.Test
Two regression tests in
test_build.py:test_build_graph_walks_root_under_git_prefixed_ancestor— a brain-md dir under.gitdata/is processed (docs == 1); verified to fail on the pre-fix substring check.test_build_graph_still_skips_real_git_subtree— a directory literally named.gitis still pruned (intent preserved; passes before and after).Full graph suite: 23 passed, coverage 98% (gate 75%). Offline evals: 8/8 green (graph metric included).
ruff check pipeline evalsclean.Found by the autonomous bughunt loop (iteration 4), from a lead surfaced during iteration 1's sweep. Dry-run mode — human merges.
🤖 Generated with Claude Code