From d6b140b40c2db2530db5443b3f82c85ad176296e Mon Sep 17 00:00:00 2001 From: Maximilian Wedekind Date: Fri, 14 Aug 2026 14:20:25 +0200 Subject: [PATCH] fix(excludes): skip .worktrees and .phpstan when building the CPG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two directory kinds slipped past DEFAULT_EXCLUDES/IGNORE_DIRS and broke the build on a Laravel monorepo: - `.worktrees/` holds full second checkouts (the layout `git worktree add` gets pointed at most often). Every symbol was indexed once per worktree — in the repo this was measured on, 13,344 of 18,630 indexed files came from three worktrees, so `lmc find` returned every hit four times and `impact` overstated the blast radius by the same factor, mixing in stale branch states that no longer exist anywhere. - `.phpstan/` is PHPStan's cache. Its `resultCache.php` reaches double-digit MB (23 MB here); php2cpg reads the parser output into memory in one go (IOUtils.contentFromBufferedSource) and dies with java.lang.OutOfMemoryError. Measured on the same repo, `lmc build` on 4,493 files: previously it aborted with `joern-parse exit 1` and fell back to the tree-sitter index, now the Joern CPG completes in 18 s. --- lmc/config.py | 2 +- lmc/joern.py | 2 ++ lmc/server/graph.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lmc/config.py b/lmc/config.py index d79e9fd..241a189 100644 --- a/lmc/config.py +++ b/lmc/config.py @@ -37,7 +37,7 @@ IGNORE_DIRS = { ".git", "node_modules", "vendor", ".venv", "venv", "dist", "build", "__pycache__", ".idea", ".vscode", "target", "bower_components", - "storage", "var", "cache", + "storage", "var", "cache", ".worktrees", ".phpstan", } CONFIG_NAME = "lumos.yml" diff --git a/lmc/joern.py b/lmc/joern.py index e338545..3b5ae6a 100644 --- a/lmc/joern.py +++ b/lmc/joern.py @@ -31,6 +31,8 @@ DEFAULT_EXCLUDES = ( "vendor", "node_modules", ".venv", "venv", "__pycache__", "storage", "public", "dist", "build", "target", ".git", + ".worktrees", # git worktrees: ganze Zweit-Checkouts, sonst kommt jeder Treffer n-fach + ".phpstan", # PHPStan-Cache: resultCache.php wird zweistellig MB gross -> OOM beim Einlesen ) # ponytail: joern-parse kennt kein --exclude, und was nach --frontend-args kommt, diff --git a/lmc/server/graph.py b/lmc/server/graph.py index ad99e29..c89e26d 100644 --- a/lmc/server/graph.py +++ b/lmc/server/graph.py @@ -337,7 +337,7 @@ def _walk(node, src, file, idx, def_stack): _IGNORE = { ".git", "node_modules", "vendor", ".venv", "venv", "dist", "build", "__pycache__", ".idea", ".vscode", "target", "bower_components", - "storage", "var", "cache", "__pycache__", + "storage", "var", "cache", "__pycache__", ".worktrees", ".phpstan", } _LANG_EXTS = {