Skip to content

gbrain frontmatter validate walks node_modules/, inflating MISSING_OPEN counts in doctor #923

@donogeme

Description

@donogeme

Summary

gbrain frontmatter validate <path> (and by extension the frontmatter_integrity check in gbrain doctor) walks every subdirectory under <path>, including node_modules/, .git/, and other non-content directories. This produces large false-positive counts of MISSING_OPEN warnings on any source repo that vendors npm packages.

The sibling gbrain frontmatter generate walker filters these directories correctly. The two walkers should behave consistently.

Repro

```bash
mkdir test-source && cd test-source
npm init -y && npm i express
gbrain sources add test --path "$(pwd)"
gbrain doctor 2>&1 | grep frontmatter_integrity
```

Expected: 0 issues (no content yet).
Actual: tens to hundreds of `MISSING_OPEN` issues, all inside `node_modules/`.

I hit this on a real-world setup pointing gbrain at a TypeScript project (Bun + node_modules + a docs/ folder). 7 real content issues got drowned in 226 false positives from npm package READMEs.

Root cause

Two walkers in `src/commands/frontmatter.ts`:

  • `generate` walker (line ~421) correctly skips:
    ```ts
    if (entry === '.git' || entry === 'node_modules' || entry === '.obsidian') continue;
    ```

  • `validate` walker (lines ~243–264) has no such filter. It pushes every directory onto its DFS stack and only filters per-file via `isSyncable`, which doesn't reject the `node_modules` prefix.

Result: doctor's `frontmatter_integrity` check (which uses the validate path) reports inflated counts that operators cannot resolve via `--fix` since the files aren't theirs. The warning becomes load-bearing noise that erodes trust in doctor's output.

Suggested fix

Add the same skip predicate to the validate walker:

```ts
for (const name of entries) {
if (name === '.git' || name === 'node_modules' || name === '.obsidian') continue;
// ...existing per-entry logic
}
```

Both walkers should ideally share a single helper (`shouldSkipDirEntry(name)`) to prevent this from drifting again.

Environment

  • gbrain v0.33.0
  • Windows 11, Bun 1.3.13
  • Postgres engine (Supabase pooler)
  • Reproduces against vanilla `node_modules/` from `npm init`

Notes

Happy to send a PR for the one-line fix if useful — let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions