Skip to content

fix(map): raise the git ls-files buffer so large repos keep tracked files - #1156

Merged
DietrichGebert merged 1 commit into
DietrichGebert:mainfrom
HyperionBurn:fix/map-git-ls-files-maxbuffer
Oct 17, 2026
Merged

DietrichGebert merged 1 commit into
DietrichGebert:mainfrom
HyperionBurn:fix/map-git-ls-files-maxbuffer

Conversation

@HyperionBurn

Copy link
Copy Markdown
Contributor

Fixes #1149

What

listFiles() in hooks/ponytail-map.js called execFileSync('git', ['ls-files']) without a maxBuffer, so it inherited Node's 1 MiB default. When a repository's tracked-file list exceeds that, the call throws ENOBUFS. The surrounding catch treats every error as "not a git repo" and falls back to the directory walk, which does not honour .gitignore — so the map injected at SessionStart lists untracked and ignored folders instead of tracked source, and those entries consume the 2,000-character budget.

The change adds maxBuffer: 64 * 1024 * 1024 to that call, plus a comment explaining why the number is what it is. The result is already capped at MAX_FILES * 5 lines immediately afterwards, so the larger buffer cannot make the map bigger.

Why this one and not the fallback change

The issue also suggests narrowing the catch so the walk is only used when git actually reports "not a git repository". That is a behaviour change to a different failure mode (timeouts), so I left it out to keep this to one concern. Happy to follow up separately if you want it.

Verification

  • Confirmed the current code at hooks/ponytail-map.js:39 passes no maxBuffer, and that hooks/ponytail-map.js:42 swallows the error with catch (e) { /* not a git repo: walk below */ }.
  • Confirmed the 1 MiB default is what actually bites, by running a 2 MiB-stdout child through execFileSync with default options: ERRCODE=ENOBUFS. Repeating with maxBuffer: 64 * 1024 * 1024: ok.
  • Confirmed the threshold scales with path length: in a 1,816-file checkout git ls-files prints 60,239 characters (~33 chars per path), so roughly 32k tracked files at that depth would cross 1 MiB. The reported repo with ~21k files prints ~1.7 MB.
  • npm test — 172 passed, 0 failed, 2 skipped, exit 0.
  • node scripts/check-rule-copies.js — rule copies match, exit 0.
  • node scripts/check-versions.js — 7 version files pinned at 5.3.2, exit 0.
  • node --check hooks/ponytail-map.js — parses.

Per CONTRIBUTING this is a hook fix, so no benchmark: the change touches none of the ruleset, skills/, AGENTS.md, or the rule copies.

Scope

One file, one added option. No behaviour change for repositories where git ls-files already fits in the default buffer.

…iles

listFiles() called execFileSync('git', ['ls-files']) with Node's default 1 MiB maxBuffer. In a repo whose tracked-file list exceeds that, the call throws ENOBUFS, the catch treats every error as 'not a git repo', and the map silently falls back to a directory walk that does not honour .gitignore, so untracked and ignored folders are listed instead of tracked source. Raise maxBuffer to 64 MiB; the result is already capped at MAX_FILES * 5 lines. Fixes DietrichGebert#1149.
@DietrichGebert

Copy link
Copy Markdown
Owner

Thanks! Tested it, works great. Merged, will be in the next release.

@DietrichGebert
DietrichGebert merged commit f7bfbb9 into DietrichGebert:main Oct 17, 2026
1 check passed
Sign up for free to 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.

SessionStart codebase map falls back to a directory walk in large repos (git ls-files output exceeds execFileSync's 1 MiB maxBuffer)

2 participants