feat(extraction): make MAX_FILE_SIZE configurable via CODEGRAPH_MAX_FILE_SIZE (#1016)#1030
Open
maxmilian wants to merge 1 commit into
Open
feat(extraction): make MAX_FILE_SIZE configurable via CODEGRAPH_MAX_FILE_SIZE (#1016)#1030maxmilian wants to merge 1 commit into
maxmilian wants to merge 1 commit into
Conversation
…ILE_SIZE (colbymchenry#1016) The 1 MB skip threshold was a hardcoded constant, so repos with legitimately large hand-written sources (1-5 MB) had no way to index them. Add a resolveMaxFileSize() helper that honours the CODEGRAPH_MAX_FILE_SIZE env var (bytes), mirroring the existing resolve*() env idioms in mcp/daemon.ts, and falling back to the 1 MB default for unset/non-numeric/non-positive values. The existing recycleWorker() memory-safety after large parses already guards the WASM heap, so no extra lifecycle work is needed. Closes colbymchenry#1016
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.
Closes #1016.
What
The 1 MB file-size skip threshold in
src/extraction/index.tswas a hardcodedconst, so repos with legitimately large hand-written sources (1–5 MB) had no way to get them indexed.This adds a
resolveMaxFileSize()helper that honours aCODEGRAPH_MAX_FILE_SIZEenvironment variable (in bytes), mirroring the existingresolve*()env idioms insrc/mcp/daemon.ts:Unset / non-numeric / non-positive values fall back to the 1 MB default, so existing behaviour is unchanged unless the var is explicitly set. Both existing size-check sites (single-file and bulk paths) are unchanged — they read the same module
MAX_FILE_SIZE.Why this is the whole change
The issue also suggested complementary WASM memory-safety (recycle the worker after large parses). That guard already exists —
recycleWorker()is already invoked after large-file parses — so making the threshold configurable is safe on its own and needs no lifecycle changes.Tests
__tests__/resolve-max-file-size.test.ts— default fallback, valid override, fractional flooring, and invalid/zero/negative/non-numeric fallback (9 cases, all pass).__tests__/extraction.test.ts— 377 pass, no regression.tsc --noEmit— clean.README updated with the override next to the existing 1 MB documentation.