fix(frontmatter walkers): skip .git, node_modules, .obsidian in collectFiles + scanBrainSources walkDir (closes #799)#922
Closed
jeremyknows wants to merge 2 commits into
Conversation
…ectFiles `collectFiles` in src/commands/frontmatter.ts (the walker used by `gbrain frontmatter validate`) recurses into every subdirectory without filtering. Two other walkers in the same codebase already skip these directories: - `walkDir` at frontmatter.ts:421 (the `generate` subcommand): skips `.git`, `node_modules`, `.obsidian` - `disk-walk.ts:56` (canonical brain walker): skips dot-directories and `node_modules` `collectFiles` was the outlier. Result: `gbrain frontmatter validate <path>` on any project with installed dependencies floods the report with dozens of MISSING_OPEN false-positives on third-party HISTORY.md / CHANGELOG.md / readme.md files in `node_modules/`. Observed on a 59-file vfkb source: 126 reported issues, 71 of which were in `node_modules/` after fixing the 55 real content files. With this fix, the same source reports 0 issues — matching the `generate` subcommand's pre-existing behavior. The fix is one block of three skip-cases, applied at the same place in the loop as the existing symlink-skip. No public API change.
…/ .obsidian Companion to the first commit's `collectFiles` fix. Doctor's `frontmatter_integrity` check (src/commands/doctor.ts:1561) calls `scanBrainSources` (src/core/brain-writer.ts:249) → `scanOneSource` → `walkDir(src/core/brain-writer.ts:350)`. The walker had the same gap as `collectFiles`: no skip-list, recurses into `node_modules/`, flags every third-party dependency's HISTORY.md / CHANGELOG.md / readme.md as MISSING_OPEN. This is the walker filed in garrytan#799 — issue body shows 869 doctor warnings on three federated code sources, all entirely from `node_modules/` files that `sync` deliberately skipped. Fix matches the existing skip-list pattern from the other walkers (`src/commands/frontmatter.ts:421` and `src/core/disk-walk.ts:56`). Together with the first commit (`collectFiles`), both walkers used by the frontmatter surface now agree on what counts as source content.
This was referenced May 12, 2026
Owner
|
Thanks @jeremyknows — already shipped in master as of v0.35.5.0. The new If your install is still seeing MISSING_OPEN warnings from |
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.
Summary
Two walkers used by the frontmatter surface —
collectFiles(used bygbrain frontmatter validate) andwalkDir(used byscanBrainSources→ doctor'sfrontmatter_integritycheck) — were recursing into every subdirectory without filtering. Two other walkers in the same codebase already skip the same three directories — these two were the outliers:walkDir()atsrc/commands/frontmatter.ts:421(used bygbrain frontmatter generate):if (entry === '.git' || entry === 'node_modules' || entry === '.obsidian') continue;src/core/disk-walk.ts:56(canonical brain walker):if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;Result:
gbrain frontmatter validateANDgbrain doctoron any project with installed dependencies flood the report with MISSING_OPEN false-positives on third-partyHISTORY.md,CHANGELOG.md, andreadme.mdfiles insidenode_modules/.Closes #799 (filed by @metaWuming, 2026-05-10) — reporter saw 869 doctor warnings on three federated code sources, all entirely from
node_modules/.Diff scope
Two commits, both apply the same skip-list pattern at the existing per-entry filter point. No API change. Match the exact pattern at
frontmatter.ts:421anddisk-walk.ts:56for consistency.Real-behavior proof
Environment: macOS 14, bun 1.3.8, gbrain on
master(post-rebase) → branched asfix/frontmatter-validate-skip-node-modules. Test source:~/projects/veefriends-kb(Next.js project, realnode_modules/with 71 third-party MD files).Before (origin/master)
gbrain frontmatter validate(collectFiles walker):gbrain doctor(scanBrainSources walkDir):(Per #799 reporter on a different project: 869 doctor warnings, all node_modules MISSING_OPEN.)
After (this PR)
gbrain frontmatter validate:55 files scanned instead of 126 — node_modules/ correctly skipped.
gbrain doctor:Drop of 71 (= the vfkb node_modules false-positives now correctly excluded). The remaining 2099 are real MISSING_OPEN cases in registered diary paths, not node_modules.
Regression check — non-node_modules source still reports real issues
Same count before and after on a source without
node_modules/.Verification
What was NOT tested
.obsidianexclusion wasn't exercised against a real Obsidian vault in this session. Followed the existing pattern fromwalkDir():421which includes.obsidian— behavior is identical to that walker.test/frontmatter-*.test.tsfiles don't have a fixture for "walker recurses into excluded directories." Adding one would require a fixture project with anode_modules/shim. Happy to add one if you'd prefer.Test plan
gbrain frontmatter validate <any-node-project>pre and post fix; node_modules entries should disappear post-fixgbrain doctoron the same project;frontmatter_integritycount should drop by the number of node_modules.mdfilesgbrain frontmatter validate <non-node-project>reports the same count before and after (regression check)Commits
75151d9fix(frontmatter validate): skip .git, node_modules, .obsidian in collectFiles5cd7c12fix(doctor): scanBrainSources walkDir also skips .git / node_modules / .obsidianCloses #799.