Skip to content

fix(lsp): honour --max-files and --exclude in LSP mode - #35

Merged
anvanster merged 2 commits into
mainfrom
fix/issue-33-max-files
Nov 15, 2026
Merged

anvanster merged 2 commits into
mainfrom
fix/issue-33-max-files

Conversation

@anvanster

@anvanster anvanster commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

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

  • LSP mode now passes the engine's --max-files and --exclude (directory names) to the backend through a new LaunchOptions. This is kept separate from CodeGraphConfig, which the client replaces on every settings push. Before this, an engine started with --max-files 30000 still stopped at 5,000 files. The --watch daemon now forwards its --max-files as maxFiles. Passing --graph-only in LSP mode now logs a warning that it is not applied there. The limit warning now names both --max-files and codegraph.maxFiles. The default limit stays at 5,000.
  • New client setting maxFiles: VS Code codegraph.maxFiles and 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.
  • This branch is stacked on fix: cap engine CPU threads and harden VS Code engine download #34 (fix/engine-thread-cap), so the delta from 590c2ca also 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 MCP fetch-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 30000 stopped at 5,000 in both LSP and --watch modes. Then I confirmed the fix on every path the change touches: initial index, reindex command, client settings pushes, maxFiles precedence (positive, 0, absent), --exclude, the unchanged 5,000 default, the new limit-warning text, the --graph-only warning 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.

  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Regression repro: shipped 0.21.0 engine run with --max-files 30000 behind an LSP client stops at 5000 files ✅ pass live 00-baseline-0.21.0-maxfiles-30000.log: 'Incremental index: 5000 parsed' + 'Reached max indexed file limit of 5000'
Container user runs the engine with --max-files 30000 and the extension indexes all 5,500 files ✅ pass live 01-fix-maxfiles-30000-exclude-generated.log: 'Incremental index: 5500 parsed', config max_files=30000
Client maxFiles 5200 wins over engine --max-files 30000 ✅ pass live 03-fix-client-maxfiles-5200-overrides-flag.log: 5200 parsed, limit warning 5200
Adversarial: client sends maxFiles 0 and the engine flag still applies ✅ pass live 05-fix-client-maxfiles-0-defers-to-flag.log: 5500 parsed, max_files=30000
Adversarial: client settings push (wholesale config replace) without maxFiles keeps --max-files; push with 5200 overrides; push with 0 reverts ✅ pass live 09-fix-settings-push-keeps-engine-flag.log: reindex 5500 / 5200 / 5500
--exclude generated skips that directory in LSP mode (merged with the defaults) ✅ pass live 01 log (5500 with --exclude) vs 02 log (5800 without)
With no flag and no client setting, the limit stays 5000 and the warning names --max-files and codegraph.maxFiles ✅ pass live 04-fix-defaults-stay-5000.log: 5000 parsed, 'Raise it with --max-files or the codegraph.maxFiles setting'
Reindex Workspace command honours --max-files ✅ pass live 07-fix-reindex-command-keeps-flag.log: 'Workspace reindexed: 5500 files'
--watch daemon forwards --max-files (5300 vs baseline 5000) ✅ pass live 08-fix-watch-daemon-maxfiles-5300.log vs 00b-baseline-watch-daemon-maxfiles-5300.log
--graph-only passed in LSP mode logs that it is not applied ✅ pass live 06-fix-graph-only-warns.log: 'WARN --graph-only is not applied in LSP mode'
codegraph.maxFiles edited in the VS Code / JetBrains settings UI reaches the engine ⏸️ untested no Needs a VS Code Extension Development Host or a JetBrains sandbox IDE (runIde) with GUI automation and the macOS Screen Recording permission for screenshots, none of which is available in this headles…
Evidence: Baseline 0.21.0 repro: --max-files 30000 still stops at 5000
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5000 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:17:47.555760Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true
[stderr] �[2m2026-11-15T22:17:57.536035Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5000; stopping
[stderr] �[2m2026-11-15T22:17:57.536084Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5000; stopping
[stderr] �[2m2026-11-15T22:17:57.909935Z�[0m �[33m WARN�[0m �[2mcodegraph_server::memory�[0m�[2m:�[0m [MemoryManager::initialize] only 1465 MB available — skipping embedding model to avoid OOM; semantic search disabled (graph-only). Set CODEGRAPH_SKIP_MEMORY_CHECK=1 to override.
[stderr] �[2m2026-11-15T22:17:57.909950Z�[0m �[31mERROR�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m Memory store initialization failed: Other("insufficient memory (1465 MB available) to load embedding model; running graph-only (set CODEGRAPH_SKIP_MEMORY_CHECK=1 to override)")
DONE
Evidence: Fix: --max-files 30000 --exclude generated indexes all 5500
$ codegraph-server --max-files 30000 --exclude generated   (initializationOptions={"indexOnStartup":true}, REINDEX=)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5500 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:18:25.417775Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=30000
[stderr] �[2m2026-11-15T22:18:34.644602Z�[0m �[33m WARN�[0m �[2mcodegraph_server::memory�[0m�[2m:�[0m [MemoryManager::initialize] only 1460 MB available — skipping embedding model to avoid OOM; semantic search disabled (graph-only). Set CODEGRAPH_SKIP_MEMORY_CHECK=1 to override.
[stderr] �[2m2026-11-15T22:18:34.644615Z�[0m �[31mERROR�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m Memory store initialization failed: Other("insufficient memory (1460 MB available) to load embedding model; running graph-only (set CODEGRAPH_SKIP_MEMORY_CHECK=1 to override)")
DONE
Evidence: Fix: without --exclude, generated/ is indexed too (5800)
$ codegraph-server --max-files 30000   (initializationOptions={"indexOnStartup":true}, REINDEX=)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5800 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:18:36.883969Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=30000
DONE
Evidence: Fix: client maxFiles 5200 overrides --max-files 30000
$ codegraph-server --max-files 30000   (initializationOptions={"indexOnStartup":true,"maxFiles":5200}, REINDEX=)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5200 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:19:03.222904Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=5200
[stderr] �[2m2026-11-15T22:19:11.110138Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5200; stopping. Raise it with --max-files or the codegraph.maxFiles setting
[stderr] �[2m2026-11-15T22:19:11.110186Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5200; stopping. Raise it with --max-files or the codegraph.maxFiles setting
DONE
Evidence: Fix: default limit stays 5000, warning names both knobs
$ codegraph-server    (initializationOptions={"indexOnStartup":true}, REINDEX=)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5000 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:19:27.545106Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=5000
[stderr] �[2m2026-11-15T22:19:34.763906Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5000; stopping. Raise it with --max-files or the codegraph.maxFiles setting
[stderr] �[2m2026-11-15T22:19:34.763952Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5000; stopping. Raise it with --max-files or the codegraph.maxFiles setting
DONE
Evidence: Fix: client maxFiles 0 defers to --max-files
$ codegraph-server --max-files 30000 --exclude generated   (initializationOptions={"indexOnStartup":true,"maxFiles":0}, REINDEX=)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5500 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:19:51.005870Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=30000
DONE
Evidence: Fix: --graph-only logs the not-applied-in-LSP warning
$ codegraph-server --graph-only   (initializationOptions={"indexOnStartup":true,"maxFiles":100}, REINDEX=)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 100 parsed, 0 skipped (unchanged)
[stderr] �[2m2026-11-15T22:20:16.722159Z�[0m �[33m WARN�[0m �[2mcodegraph_server�[0m�[2m:�[0m --graph-only is not applied in LSP mode; the client's settings decide embedding
[stderr] �[2m2026-11-15T22:20:16.723008Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=100
[stderr] �[2m2026-11-15T22:20:16.760827Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 100; stopping. Raise it with --max-files or the codegraph.maxFiles setting
[stderr] �[2m2026-11-15T22:20:16.760886Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 100; stopping. Raise it with --max-files or the codegraph.maxFiles setting
DONE
Evidence: Fix: codegraph.reindexWorkspace honours --max-files
$ codegraph-server --max-files 30000 --exclude generated   (initializationOptions={"indexOnStartup":true}, REINDEX=1)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5500 parsed, 0 skipped (unchanged)
[reindexWorkspace] {"status": "success", "message": "Workspace reindexed: 5500 files", "files_indexed": 5500}
[stderr] �[2m2026-11-15T22:20:32.800150Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=30000
DONE
Evidence: Fix vs baseline: --watch daemon forwards --max-files 5300
$ HOME=<fresh> codegraph-server --watch --workspace /tmp/nm33.XYC8/ws --max-files 5300
2026-11-15T22:21:36.208555Z  INFO codegraph_server::backend: CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=5300
2026-11-15T22:21:45.348287Z  WARN codegraph_server::indexer: Reached max indexed file limit of 5300; stopping. Raise it with --max-files or the codegraph.maxFiles setting
2026-11-15T22:21:58.589497Z  INFO codegraph_server::daemon: CodeGraph daemon watching "/private/tmp/nm33.XYC8/ws" (slug ws-d356)
Evidence: Baseline --watch daemon ignores --max-files 5300 (stops at 5000)
$ HOME=<fresh> codegraph-server --watch --workspace /tmp/nm33.XYC8/ws --max-files 5300
2026-11-15T22:22:24.313631Z  WARN codegraph_server::indexer: Reached max indexed file limit of 5000; stopping
2026-11-15T22:22:24.313698Z  WARN codegraph_server::indexer: Reached max indexed file limit of 5000; stopping
2026-11-15T22:22:37.866395Z  INFO codegraph_server::daemon: CodeGraph daemon watching "/private/tmp/nm33.XYC8/ws" (slug ws-d356)
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 files

$ codegraph-server --max-files 30000 --exclude generated  (then client settings pushes via codegraph.updateConfiguration, each followed by codegraph.reindexWorkspace)
[logMessage] CodeGraph LSP server initialized
[logMessage] Incremental index: 5500 parsed, 0 skipped (unchanged)
[settings push] {"indexOnStartup": true, "excludePatterns": [], "embedOnOpen": true} -> {"status": "ok"}
[reindexWorkspace] Workspace reindexed: 5500 files
[settings push] {"indexOnStartup": true, "maxFiles": 5200} -> {"status": "ok"}
[reindexWorkspace] Workspace reindexed: 5200 files
[settings push] {"indexOnStartup": true, "maxFiles": 0} -> {"status": "ok"}
[reindexWorkspace] Workspace reindexed: 5500 files
[stderr] �[2m2026-11-15T22:24:02.423078Z�[0m �[32m INFO�[0m �[2mcodegraph_server::backend�[0m�[2m:�[0m CodeGraph config: index_on_startup=true, exclude_patterns=[], index_paths=[], max_file_size_kb=1024, embed_on_open=true, max_files=30000
[stderr] �[2m2026-11-15T22:24:57.990073Z�[0m �[33m WARN�[0m �[2mcodegraph_server::indexer�[0m�[2m:�[0m Reached max indexed file limit of 5200; stopping. Raise it with --max-files or the codegraph.maxFiles setting
DONE
Evidence: LSP stdio driver used for all runs
"""Drive codegraph-server over real LSP stdio, like the VS Code client does.

usage: drive.py <binary> <workspace> <fake_home> <init_options_json> [server args...]
Prints every window/logMessage the server sends until indexing reports, then shuts down.
"""
import json, os, subprocess, sys, threading, time

binary, ws, home, init_opts = sys.argv[1:5]
extra = sys.argv[5:]
env = dict(os.environ, HOME=home, CODEGRAPH_TELEMETRY='0', DO_NOT_TRACK='1')
p = subprocess.Popen([binary, *extra], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE, env=env)
stderr_lines = []
threading.Thread(target=lambda: [stderr_lines.append(l.decode(errors='replace')) for l in p.stderr],
                 daemon=True).start()

def send(msg):
    b = json.dumps(msg).encode()
    p.stdin.write(b'Content-Length: %d\r\n\r\n' % len(b) + b)
    p.stdin.flush()

def recv():
    headers = {}
    while True:
        line = p.stdout.readline()
        if not line:
            return None
        line = line.strip()
        if not line:
            break
        k, v = line.decode().split(':', 1)
        headers[k.lower()] = v.strip()
    return json.loads(p.stdout.read(int(headers['content-length'])))

uri = 'file://' + ws
send({'jsonrpc': '2.0', 'id': 1, 'method': 'initialize', 'params': {
    'processId': os.getpid(), 'rootUri': uri, 'capabilities': {},
    'workspaceFolders': [{'uri': uri, 'name': 'ws'}],
    'initializationOptions': json.loads(init_opts)}})
done = False
start = time.time()
while time.time() - start < 600:
    m = recv()
    if m is None:
        break
    if m.get('id') == 1 and 'result' in m:
        send({'jsonrpc': '2.0', 'method': 'initialized', 'params': {}})
        continue
    if 'id' in m and 'method' in m:  # server->client request: ack it
        send({'jsonrpc': '2.0', 'id': m['id'], 'result': None})
        continue
    if m.get('method') == 'window/logMessage':
        msg = m['params']['message']
        print('[logMessage]', msg)
        if msg.startswith('Indexed ') or msg.startswith('Incremental index:'):
            done = True
            break
if done and os.environ.get('REINDEX'):
    send({'jsonrpc': '2.0', 'id': 3, 'method': 'workspace/executeCommand',
          'params': {'command': 'codegraph.reindexWorkspace', 'arguments': []}})
    while True:
        m = recv()
        if m is None:
            break
        if 'id' in m and 'method' in m:
            send({'jsonrpc': '2.0', 'id': m['id'], 'result': None}); continue
        if m.get('id') == 3:
            r = m.get('result') or m
            print('[reindexWorkspace]', json.dumps({k: r.get(k) for k in ('status','message','files_indexed')}) if isinstance(r, dict) else r)
            break
def call(i, command, args):
    send({'jsonrpc': '2.0', 'id': i, 'method': 'workspace/executeCommand',
          'params': {'command': command, 'arguments': args}})
    while True:
        m = recv()
        if m is None:
            return None
        if 'id' in m and 'method' in m:
            send({'jsonrpc': '2.0', 'id': m['id'], 'result': None}); continue
        if m.get('id') == i:
            return m.get('result', m)
if done and os.environ.get('PUSHES'):
    for n, cfg in enumerate(json.loads(os.environ['PUSHES'])):
        r = call(100 + 2 * n, 'codegraph.updateConfiguration', [cfg])
        print('[settings push]', json.dumps(cfg), '->', json.dumps(r)[:120])
        r = call(101 + 2 * n, 'codegraph.reindexWorkspace', [])
        print('[reindexWorkspace]', r.get('message') if isinstance(r, dict) else r)
send({'jsonrpc': '2.0', 'id': 2, 'method': 'shutdown'})
time.sleep(1)
send({'jsonrpc': '2.0', 'method': 'exit'})
try:
    p.wait(timeout=20)
except subprocess.TimeoutExpired:
    p.kill()
for l in stderr_lines:
    if any(k in l for k in ('max indexed file limit', 'CodeGraph config', 'graph-only', 'Indexed')):
        print('[stderr]', l.rstrip()[-300:])
print('DONE' if done else 'NO INDEX RESULT')

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 --exclude now apply to workspace scans in LSP mode (index_config_from_lsp). They do not apply on the did_open/did_change path, which only checks build_exclude_set() (glob exclude_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.

  • Live validation: ✅ go - 11 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Base engine with --max-files 30000 over LSP stops at 5000 (reproduces issue #33) ✅ pass live A_base_flag30000_repro.txt
Fixed engine with --max-files 30000 over LSP indexes all 5800 files ✅ pass live B_new_flag30000.txt
Client initializationOptions maxFiles 5200 wins over --max-files 30000 ✅ pass live C_new_client5200_over_flag.txt
--exclude generated skips that directory in LSP mode (5500 of 5800) ✅ pass live D_new_exclude_generated.txt
No flags: the default limit stays 5000 and the warning names --max-files and codegraph.maxFiles ✅ pass live E_new_default_limit.txt
Adversarial: a settings push without maxFiles, then a reindex, still uses --max-files 30000 ✅ pass live F1_push_without_maxFiles_keeps_flag.txt
Adversarial: a settings push with maxFiles 0 (VS Code default), then a reindex, still uses the flag ✅ pass live F2_push_maxFiles0_keeps_flag.txt
A settings push with maxFiles 5100 takes effect on the next reindex ✅ pass live F3_push_maxFiles5100_overrides.txt
Adversarial: client maxFiles 0 does not mean zero or unlimited; it defers to --max-files 2000 ✅ pass live H_new_client0_flag2000.txt
--graph-only in LSP mode logs the not-applied warning ✅ pass live G_new_graph_only_warns.txt
The --watch daemon forwards --max-files 5300 to its backend ✅ pass live I_watch_daemon_max_files5300.txt
VS Code codegraph.maxFiles and JetBrains 'Maximum files to index' settings UI send maxFiles ⏸️ untested no Needs a GUI VS Code / JetBrains IDE instance with the extension or plugin loaded, plus macOS Screen Recording permission for screenshots. Neither is available in this headless gate run.
  • Built base 590c2ca and target da65854 codegraph-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 dir
  • A: base binary --max-files 30000 -> stops at 5000 (repro)
  • B: new binary --max-files 30000 -> 5800 indexed
  • C: --max-files 30000 + initializationOptions maxFiles 5200 -> 5200
  • D: --max-files 30000 --exclude generated -> 5500
  • E: 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 -> 5100
  • G: --graph-only in LSP mode -> WARN logged, indexing proceeds
  • H: client maxFiles 0 + --max-files 2000 -> 2000
  • I: codegraph-server --watch --workspace ws --max-files 5300 -> daemon config max_files=5300, stops at 5300

✅ No issues found.

  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Regression repro: shipped 0.21.0 engine run with --max-files 30000 behind an LSP client stops at 5000 files ✅ pass live 00-baseline-0.21.0-maxfiles-30000.log: 'Incremental index: 5000 parsed' + 'Reached max indexed file limit of 5000'
Container user runs the engine with --max-files 30000 and the extension indexes all 5,500 files ✅ pass live 01-fix-maxfiles-30000-exclude-generated.log: 'Incremental index: 5500 parsed', config max_files=30000
Client maxFiles 5200 wins over engine --max-files 30000 ✅ pass live 03-fix-client-maxfiles-5200-overrides-flag.log: 5200 parsed, limit warning 5200
Adversarial: client sends maxFiles 0 and the engine flag still applies ✅ pass live 05-fix-client-maxfiles-0-defers-to-flag.log: 5500 parsed, max_files=30000
Adversarial: client settings push (wholesale config replace) without maxFiles keeps --max-files; push with 5200 overrides; push with 0 reverts ✅ pass live 09-fix-settings-push-keeps-engine-flag.log: reindex 5500 / 5200 / 5500
--exclude generated skips that directory in LSP mode (merged with the defaults) ✅ pass live 01 log (5500 with --exclude) vs 02 log (5800 without)
With no flag and no client setting, the limit stays 5000 and the warning names --max-files and codegraph.maxFiles ✅ pass live 04-fix-defaults-stay-5000.log: 5000 parsed, 'Raise it with --max-files or the codegraph.maxFiles setting'
Reindex Workspace command honours --max-files ✅ pass live 07-fix-reindex-command-keeps-flag.log: 'Workspace reindexed: 5500 files'
--watch daemon forwards --max-files (5300 vs baseline 5000) ✅ pass live 08-fix-watch-daemon-maxfiles-5300.log vs 00b-baseline-watch-daemon-maxfiles-5300.log
--graph-only passed in LSP mode logs that it is not applied ✅ pass live 06-fix-graph-only-warns.log: 'WARN --graph-only is not applied in LSP mode'
codegraph.maxFiles edited in the VS Code / JetBrains settings UI reaches the engine ⏸️ untested no Needs a VS Code Extension Development Host or a JetBrains sandbox IDE (runIde) with GUI automation and the macOS Screen Recording permission for screenshots, none of which is available in this headles…
  • 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 HOME
  • drive.py &lt;new&gt; ws &#39;{&#34;indexOnStartup&#34;:true}&#39; --max-files 30000 --exclude generated -> 5500 files
  • drive.py &lt;new&gt; ws &#39;{&#34;indexOnStartup&#34;:true}&#39; --max-files 30000 -> 5800 (exclude not given, generated/ indexed)
  • drive.py &lt;new&gt; ws &#39;{&#34;indexOnStartup&#34;:true,&#34;maxFiles&#34;:5200}&#39; --max-files 30000 -> 5200
  • drive.py &lt;new&gt; ws &#39;{&#34;indexOnStartup&#34;:true}&#39; (no flag) -> 5000 plus the new warning text naming both settings
  • drive.py &lt;new&gt; ws &#39;{&#34;maxFiles&#34;:0}&#39; --max-files 30000 --exclude generated -> 5500
  • drive.py &lt;new&gt; ws &#39;{&#34;maxFiles&#34;:100}&#39; --graph-only -> the --graph-only LSP warning is logged
  • REINDEX=1 drive.py ... --max-files 30000 --exclude generated -> codegraph.reindexWorkspace reports 5500
  • PUSHES=[...] drive.py ... --max-files 30000 --exclude generated -> codegraph.updateConfiguration without maxFiles / with 5200 / with 0, each followed by a reindex -> 5500 / 5200 / 5500
  • watch.sh running --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 -- --check shows 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 separate chore: cargo fmt follow-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.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🔍 CodeGraph PR Review

13 files changed (+185/−19, 25 functions) · Risk: 🟡 medium

Blast radius

70 direct callers affected (11 breaking) across codegraph-server/src/handlers, codegraph-server/src/mcp, crates/codegraph-server/src

⚠️ Test gaps (11 functions, 0 coverage)

  • execute_command (crates/codegraph-server/src/backend.rs) — body_changed
  • initialized (crates/codegraph-server/src/backend.rs) — body_changed
  • index_directory (crates/codegraph-server/src/backend.rs) — body_changed
  • default (crates/codegraph-server/src/backend.rs) — signature_changed
  • did_open (crates/codegraph-server/src/backend.rs) — body_changed
  • run (crates/codegraph-server/src/daemon.rs) — body_changed
  • index_directory (crates/codegraph-server/src/indexer.rs) — body_changed
  • run (crates/codegraph-server/src/main.rs) — body_changed
  • getInitializationOptions (jetbrains/src/main/kotlin/ai/codegraph/jetbrains/server/CodeGraphConnectionProvider.kt) — body_changed
  • apply (jetbrains/src/main/kotlin/ai/codegraph/jetbrains/settings/CodeGraphConfigurable.kt) — body_changed
  • …and 1 more

Suggested reviewers

Andrey Vasilevsky (101 lines), anvanster (39 lines)

Suggested commit: feat(handlers): <describe the change> · 25 tests cover the changes
🤖 Generated by CodeGraph

@anvanster
anvanster changed the base branch from fix/engine-thread-cap to main November 15, 2026 22:12
anvanster and others added 2 commits November 15, 2026 14:14
…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
@anvanster
anvanster force-pushed the fix/issue-33-max-files branch from 040abfc to 031370b Compare November 15, 2026 22:26
@anvanster
anvanster changed the base branch from main to fix/engine-thread-cap November 15, 2026 22:27
@anvanster anvanster changed the title fix(codegraph-server): honour --max-files and --exclude in LSP mode fix(lsp): honour --max-files and --exclude in LSP mode Nov 15, 2026
@anvanster
anvanster changed the base branch from fix/engine-thread-cap to main November 15, 2026 22:27
@anvanster
anvanster merged commit 16c9aa0 into main Nov 15, 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.

1 participant