fix(search): stop silently returning zero results on large trees (v2.3.1) - #5
Conversation
…3.1)
On a monorepo-scale tree, ripgrep's verbose --json output overflowed the
50MB execFileSync buffer. The resulting ERR_CHILD_PROCESS_STDIO_MAXBUFFER
error carries no .status, so it fell through the status checks to a
`return []` — a scan that matched thousands of files reported finding
NONE. This made `duplicate-literals` scan zero files on a large repo
(verified: 0 files on verticalint/tools' cli/ tree; 1208 after the fix)
— a hollow result that would silently no-op any drift gate built on it.
Fix:
- Add { filesOnly: true } to search: discovery uses `rg -l` / `grep -rl`
(one path per line) instead of per-match JSON, so it stays bounded on
any tree size. discoverFiles (the duplicate-literals discovery path)
now uses it.
- Never swallow a buffer overflow: both engines classify it
(isMaxBufferError) and THROW an actionable error instead of returning
[]; any other unexpected failure is thrown too, not silently zeroed.
- Raise the buffer cap 50MB -> 256MB as defense for full match searches.
Tests: filesOnly returns the same file SET as a full search (one row per
file, no line/text), overflow-error classification, buffer-cap floor,
parseFilesList shaping. 188/188 pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AI review (advisory) — cycle 1
SummaryCorrect fix for a real hollow-scan bug (silent zero results on a large tree), found by running v2.3.0 on the actual tools monorepo. The fix is at the right layer and fails loud rather than silent — the important safety property for anything a drift gate sits on. Verified
Findingsnit: No blockers. HandoffMerge → the Verdict (8324a1b): APPROVE (handoff — merge is yours) |
What
Fixes a silent-zero-results bug in
searchthat madeduplicate-literalsscan nothing on a large tree, and ships it as v2.3.1.The bug (found by using v2.3.0 on a real monorepo)
Pointing
duplicate-literalsat verticalint/tools'cli/tree returned 0 findings / 0 files scanned. Root cause: ripgrep's--jsonoutput (one JSON object per submatch) overflows the 50MBexecFileSyncbuffer on a big tree. The resultingERR_CHILD_PROCESS_STDIO_MAXBUFFERerror has no.status, so it fell straight through theerr.status === 1 / === 2checks to a finalreturn []. A scan that matched thousands of files reported finding none — a hollow result that would silently no-op any drift gate built on top of it.Fix
filesOnlydiscovery.search(..., { filesOnly: true })usesrg -l/grep -rl(one path per line) instead of per-match JSON, so discovery stays bounded regardless of tree size.discoverFiles(theduplicate-literalsdiscovery path) now uses it.isMaxBufferError) and throw an actionable error ("narrow the paths, or pass{ filesOnly: true }") instead of returning[]. Any other unexpected failure is thrown too — silent-zero is gone.Verified
duplicate-literalsoncli/→ 0 files scanned. After: 1208 files scanned, 68 regex / 683 string findings surfaced.filesOnlyreturns the same file SET as a full search (one row/file, no line/text), overflow-error classification, buffer-cap floor,parseFilesListshaping. 188/188 pass.Why 2.3.1 now
The verticalint/tools DEV-5868 drift gate is built directly on this
duplicate-literalsscan; a hollow scan there means a gate that passes green while detecting nothing. Fixing at the tool layer ("strengthen the tool first") protects every consumer. Publishing is now tokenless via Trusted Publishing (OIDC), so merging this auto-publishes 2.3.1.