fix(parsers): route summarization failures through the logger (LIB-11) - #2119
Merged
Conversation
summarizeFileDiff and summarizeDirectoryDiff both caught LLM errors, logged via bare console.error, and silently returned the unsummarized diff. console.error bypasses --quiet and the run's normal output channel entirely — and the silent fallback is exactly what blows the token budget the summarizer exists to protect, so a run that lost every summarization would go on to trim real content in enforcePromptBudget with no indication why. Both functions already had a logger threaded into their options (summarizeDirectoryDiff's is optional, hence the ?. guard) — routes the failure through logger.error instead, which reaches the run's normal output and survives testing via a mock rather than a console.error spy.
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
summarizeFileDiff(summarizeLargeFiles.ts) andsummarizeDirectoryDiff(summarizeDiffs.ts) both caught LLM summarization errors, logged via bareconsole.error, and silently returned the unsummarized diff.console.errorbypasses--quietand lands on a different channel than the rest of the run's output — and the silent degradation itself is the real problem: returning the unsummarized diff is exactly what blows the token budget the summarizer exists to protect, so a run that quietly lost every summarization call would go on to trim real content inenforcePromptBudgetwith no visible indication why.loggerthreaded into their options (summarizeDirectoryDiff's is optional, hence the?.guard) — this routes the failure throughlogger.errorinstead ofconsole.error.Closes #1931
Test plan
.test.tsassertlogger.erroris called with the failing file/directory and the underlying error message, and thatconsole.erroris not called#1700test that spied onconsole.error(no longer needed — the new test covers that channel explicitly)npx jest src/lib/parsers/default/utils— 22 suites / 243 tests passed (35 in the two touched files)npx eslint <touched files>andnpx tsc --noEmit -p .— cleannpx jest(full suite) — pre-existing, unrelated tree-sitter WASM failures only (same 4 failures present on a cleanorigin/maincheckout in this worktree)Scope note
The issue's suggested fix also mentions counting failures so the caller can report "summarization degraded for N files." That would mean threading a warnings/counter return value through
summarizeLargeFiles/preprocessLargeFiles/summarizeDiffsand every caller that consumes them — a much larger, separate change. This PR fixes the core bug (bypassing the logger, silent degradation with no visible signal) without that broader refactor.