Repository navigation
fix(lsp): honour --max-files and --exclude in LSP mode - #35
Merged
Merged
Conversation
🔍 CodeGraph PR Review13 files changed (+185/−19, 25 functions) · Risk: 🟡 medium Blast radius70 direct callers affected (11 breaking) across
|
…setting (#33) LSP mode built its backend without the parsed command line, so the file limit always came from the 5,000 default. An engine started with `--max-files 30000` - the usual way to raise it when the engine runs in a container behind the extension - still stopped at 5,000 files, and the extension had no setting for it at all. - LaunchOptions carries --max-files and --exclude into the LSP backend. It is kept apart from CodeGraphConfig, which the client replaces wholesale on every settings push, so the flag survives settings changes. - New client option maxFiles (VS Code codegraph.maxFiles, JetBrains "Maximum files to index"); a positive value wins, 0 leaves it to the engine flag. The --watch daemon forwards its --max-files the same way. - The limit warning now says how to raise it. - --graph-only is documented as not applied in LSP mode, and LSP mode warns when it is passed; the client's settings decide embedding there. Verified over real LSP stdio on a 5,500-file workspace: the shipped 0.21.0 engine with --max-files 30000 stops at 5,000; this build indexes all 5,500, and a client maxFiles of 5,200 overrides the flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017rVbt7rENTwXkdHt3Bpgb5
…e engine's --max-files
anvanster
force-pushed
the
fix/issue-33-max-files
branch
from
November 15, 2026 22:26
040abfc to
031370b
Compare
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.
Intent
Fix GitHub issue #33: the reporter runs codegraph-server in a container with --max-files 30000 behind the VS Code extension, but indexing still stopped at 5000 files because LSP mode built its backend without the parsed CLI args. The maintainer asked for the open issues to be fixed. Decisions made: LaunchOptions carries --max-files and --exclude (directory names, matching MCP semantics) into the LSP backend, kept separate from CodeGraphConfig because the client replaces that wholesale on every settings push; a new client option maxFiles (VS Code codegraph.maxFiles and JetBrains 'Maximum files to index', default 0) wins when positive, otherwise the engine flag applies; the --watch daemon forwards its --max-files the same way; the limit warning names both knobs. --graph-only is deliberately NOT implemented for LSP mode (that would mean gating several separate embedding paths; out of scope) - it is documented as not applied there and LSP mode logs a warning when it is passed. The default limit stays 5000. This branch is stacked on PR #34 (fix/engine-thread-cap) because both change crates/codegraph-server/src/main.rs, so the PR targets that branch. Verified over real LSP stdio on a 5,500-file workspace: shipped 0.21.0 with --max-files 30000 stops at 5000; this build indexes all 5500; client maxFiles 5200 overrides the flag. CHANGELOG.md must not be edited manually (maintainer rule).
What Changed
--max-filesand--exclude(directory names) to the backend through a newLaunchOptions. This is kept separate fromCodeGraphConfig, which the client replaces on every settings push. Before this, an engine started with--max-files 30000still stopped at 5,000 files. The--watchdaemon now forwards its--max-filesasmaxFiles. Passing--graph-onlyin LSP mode now logs a warning that it is not applied there. The limit warning now names both--max-filesandcodegraph.maxFiles. The default limit stays at 5,000.maxFiles: VS Codecodegraph.maxFilesand JetBrains "Maximum files to index", both defaulting to 0. A positive value overrides the engine flag, and 0 falls back to--max-files. The engine, VS Code, and MCP READMEs document this. New unit tests cover which limit wins, how excludes merge, and that the flag survives a settings push.fix/engine-thread-cap), so the delta from590c2caalso includes that PR's changes: capped engine CPU threads for embedding and indexing, and a hardened engine download in the VS Code extension and in the MCPfetch-engine.js, with new tests.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is well-bounded and meets the stated intent. In LSP mode, a positive client maxFiles takes precedence, otherwise the engine's --max-files applies. That fallback survives wholesale config replacement, because a missing maxFiles deserializes to 0 through serde's default. --exclude directory names merge with the defaults, the daemon forwards maxFiles, --graph-only is only documented and warned about in LSP mode, and CHANGELOG.md is untouched.
Testing
The test workspace held 5,500 Python files plus a 300-file
generated/directory. I built the engine at the target commit and drove it over real LSP stdio the way the VS Code and JetBrains clients do, giving each run a fresh HOME. First I reproduced the bug on the 0.21.0 baseline:--max-files 30000stopped at 5,000 in both LSP and--watchmodes. Then I confirmed the fix on every path the change touches: initial index, reindex command, client settings pushes,maxFilesprecedence (positive, 0, absent),--exclude, the unchanged 5,000 default, the new limit-warning text, the--graph-onlywarning and daemon forwarding. All scenarios passed. Evidence is transcripts, not screenshots: the change has no rendered UI, only an engine protocol plus client settings plumbing. The VS Code and JetBrains settings UIs were not launched. Their payloads were reproduced exactly as LSP messages instead. The full suite and linters were not run, per the phase rules.Evidence: Baseline 0.21.0 repro: --max-files 30000 still stops at 5000
Evidence: Fix: --max-files 30000 --exclude generated indexes all 5500
Evidence: Fix: without --exclude, generated/ is indexed too (5800)
Evidence: Fix: client maxFiles 5200 overrides --max-files 30000
Evidence: Fix: default limit stays 5000, warning names both knobs
Evidence: Fix: client maxFiles 0 defers to --max-files
Evidence: Fix: --graph-only logs the not-applied-in-LSP warning
Evidence: Fix: codegraph.reindexWorkspace honours --max-files
Evidence: Fix vs baseline: --watch daemon forwards --max-files 5300
Evidence: Baseline --watch daemon ignores --max-files 5300 (stops at 5000)
Evidence: Fix: settings pushes keep the engine flag; client maxFiles wins when positive
$ codegraph-server --max-files 30000 --exclude generated [logMessage] Incremental index: 5500 parsed, 0 skipped (unchanged) [settings push] {indexOnStartup:true, excludePatterns:[], embedOnOpen:true} -> ok [reindexWorkspace] Workspace reindexed: 5500 files [settings push] {indexOnStartup:true, maxFiles:5200} -> ok [reindexWorkspace] Workspace reindexed: 5200 files [settings push] {indexOnStartup:true, maxFiles:0} -> ok [reindexWorkspace] Workspace reindexed: 5500 filesEvidence: LSP stdio driver used for all runs
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found ✅
crates/codegraph-server/src/backend.rs:1596- Directories passed with--excludenow apply to workspace scans in LSP mode (index_config_from_lsp). They do not apply on the did_open/did_change path, which only checksbuild_exclude_set()(globexclude_patterns). So a file inside an--excluded directory that the user opens in the editor still gets parsed and embedded. The built-in default exclude dirs such as node_modules already behave this way, so this matches existing semantics rather than being a regression. Noted for awareness only.✅ No issues found.
✅ **Test** - passed
✅ No issues found.
Built base 590c2ca and target da65854codegraph-server(dev profile, CARGO_TARGET_DIR under /tmp)Generated a workspace of 5,800 Python files: 5,500 under src/ and 300 under generated/lsp_drive.py/run.sh: a real LSP JSON-RPC client over stdio (initialize -> initialized -> window/logMessage, optional workspace/executeCommand codegraph.updateConfiguration + codegraph.reindexWorkspace), with HOME isolated to a temp dirA: base binary--max-files 30000-> stops at 5000 (repro)B: new binary--max-files 30000-> 5800 indexedC:--max-files 30000+ initializationOptions maxFiles 5200 -> 5200D:--max-files 30000 --exclude generated-> 5500E: no flags -> 5000 (default unchanged)F1/F2: settings push without maxFiles / with maxFiles 0, then reindexWorkspace -> 5800 (flag survives)F3: settings push maxFiles 5100, then reindexWorkspace -> 5100G:--graph-onlyin LSP mode -> WARN logged, indexing proceedsH: client maxFiles 0 +--max-files 2000-> 2000I:codegraph-server --watch --workspace ws --max-files 5300-> daemon config max_files=5300, stops at 5300✅ No issues found.
cargo build -p codegraph-server --bin codegraph-server(target commit 031370b)Baseline: 0.21.0 engine (/tmp/nm-cg-target-base/debug/codegraph-server) driven over LSP stdio with--max-files 30000, initializationOptions{indexOnStartup:true}, fresh HOMEdrive.py <new> ws '{"indexOnStartup":true}' --max-files 30000 --exclude generated-> 5500 filesdrive.py <new> ws '{"indexOnStartup":true}' --max-files 30000-> 5800 (exclude not given, generated/ indexed)drive.py <new> ws '{"indexOnStartup":true,"maxFiles":5200}' --max-files 30000-> 5200drive.py <new> ws '{"indexOnStartup":true}'(no flag) -> 5000 plus the new warning text naming both settingsdrive.py <new> ws '{"maxFiles":0}' --max-files 30000 --exclude generated-> 5500drive.py <new> ws '{"maxFiles":100}' --graph-only-> the --graph-only LSP warning is loggedREINDEX=1 drive.py ... --max-files 30000 --exclude generated-> codegraph.reindexWorkspace reports 5500PUSHES=[...] drive.py ... --max-files 30000 --exclude generated-> codegraph.updateConfiguration without maxFiles / with 5200 / with 0, each followed by a reindex -> 5500 / 5200 / 5500watch.shrunning--watch --workspace ws --max-files 5300: new build -> limit 5300; baseline -> limit 5000✅ **Document** - passed
✅ No issues found.
✅ No issues found.
🔧 **Lint** - 1 issue found ✅
crates/codegraph-zig/tests/integration_tests.rs-cargo fmt --all -- --checkshows formatting drift in about 59 files across crates this change does not touch (language parsers, codegraph-harness, codegraph-memory examples and tests). None of the drift is in the codegraph-server files this change edits. Reformatting the whole workspace is out of scope here, so it is proposed as a separatechore: cargo fmtfollow-up. The clippy warnings in backend.rs and indexer.rs and the eslint no-explicit-any warnings in extension.ts were also already there before this change.✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.