| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Add 'crates' to IGNORE_DIRS in both the TypeScript WASM engine and the mirrored Rust native engine constant. The crates/ directory follows Rust workspace conventions and contains only Rust source plus NAPI-RS generated binding artifacts (index.js / index.d.ts). Without this exclusion the WASM engine (which does not respect .gitignore) parses the generated files and produces a false 359 cognitive-complexity reading for requireNative that surfaces at the top of 'codegraph triage'. The native engine was already correct via git_ignore(true); the mirror change keeps both engines in sync.
…s.ts McpToolContext was defined in server.ts, which imported TOOL_HANDLERS from tools/index.ts (the barrel). Every tool module imported McpToolContext back from server.ts, creating a 37-file circular dependency flagged by codegraph cycles in two consecutive architectural audits. Fix: extract McpToolContext and McpToolHandler into src/mcp/types.ts, which only depends on db/index.js (outside the MCP subtree). server.ts and all 35 tool modules now import from types.ts instead of server.ts, eliminating the cycle. server.ts re-exports McpToolContext for backward compatibility.
Replace `any` return types with `typeof Database` from the installed @types/better-sqlite3 package in src/db/better-sqlite3.ts and src/mcp/types.ts, completing the migration away from hand-rolled better-sqlite3 type declarations. Closes #1622
…-native edges Two-part fix for the confidence regression introduced when the ts-native resolution pass added 12,776 cross-module edges at 0.3 confidence: 1. Exclude sink edges (confidence=0.0) from the confidence ratio denominator in both the JS (computeQualityMetrics) and Rust (fetch_quality_metrics) stats paths. Sink edges flag unresolvable dynamic calls (eval/computed-key) and are not resolution attempts — counting them against resolution quality was incorrect. The FP ratio still uses the full edge count. 2. Lift the minimum confidence for ts-native resolved edges from 0.3 → 0.5 (TS_NATIVE_CONFIDENCE_FLOOR). The proximity heuristic returns 0.3 for cross-module calls where no import-path evidence is available, but the native and WASM engines both perform actual name-based symbol lookup — stronger evidence than pure file-proximity. 0.5 (same-parent-directory level) is a conservative but correct floor. Sink edges (confidence=0.0) are explicitly excluded from the lift. The floor is applied: in-memory to allEdgeRows before batchInsertEdges (WASM and fallback paths); via SQL UPDATE in applyEdgeTechniquesAfterNativeInsert (native bulk-insert path); via SQL UPDATE in backfillEdgeTechniquesAfterNativeOrchestrator (native orchestrator path). Closes #1623
…nstructors Rust struct constructors (e.g. Import.new, FileSymbols.new) always have high call counts by design. Add isStructuralFalsePositive() to exclude any method named "new" in a .rs file from the false-positive warning list — pattern-based so no specific symbol names are hardcoded. Impact: 2 functions changed, 6 affected
… WASM backfill The native Rust engine uses the `ignore` crate with git_ignore(true) so it respects .gitignore and never processes gitignored files. The JS collectFiles walker has no gitignore awareness, so gitignored files such as crates/codegraph-core/index.js and index.d.ts (NAPI-RS generated) appeared in the expected-file set but not in the DB after a native build, triggering the spurious "Native orchestrator dropped N file(s) — likely a Rust extractor bug" WARN and an unnecessary WASM backfill on every fresh build. Fix: add queryGitIgnoredFiles() which runs `git check-ignore --stdin` on the candidate file list. detectDroppedLanguageGap() now filters the expected set through this check so gitignored files are never treated as native extractor failures. Falls back gracefully when git is unavailable or the directory is not a git repository. Closes #1626 Impact: 2 functions changed, 6 affected
Sorry, something went wrong.
| for (const line of output.split('\n')) { | ||
| const trimmed = line.trim(); | ||
| if (trimmed) ignored.add(trimmed); |
There was a problem hiding this comment.
Git output not normalized before set insertion
The paths fed into git check-ignore --stdin are already normalized to forward slashes via normalizePath, but the echoed-back lines are added to ignored with only .trim(). On Windows, certain Git distributions may echo paths with backslashes (e.g., crates\codegraph-core\index.js) even when given forward-slash input. If that happens, gitIgnored.has(r) will never match any path in expectedRaw, silently bypassing the entire filter and allowing the spurious WARN and WASM backfill to re-appear.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed — now applying normalizePath(line.trim()) instead of just line.trim() before inserting into the ignored set. Since normalizePath converts backslashes to forward slashes, this ensures the echoed-back paths match the forward-slash keys in expectedRaw even on Windows Git distributions that echo paths with backslashes.
Sorry, something went wrong.
| const output = execFileSync('git', ['check-ignore', '--stdin'], { | ||
| cwd: rootDir, | ||
| input: stdin, | ||
| encoding: 'utf-8', | ||
| // git check-ignore exits with 1 when none of the paths are ignored — | ||
| // that is not an error for our purposes. stdio: 'pipe' lets us capture | ||
| // stdout without swallowing stderr, and the try/catch handles the | ||
| // non-zero exit from execFileSync when ALL paths are non-ignored | ||
| // (exit code 1 from git check-ignore means "no matches"). | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }); |
There was a problem hiding this comment.
maxBuffer unset — silent filter bypass for large ignored sets
execFileSync defaults to a 1 MB stdout buffer. If a repo has a large number of gitignored files (roughly >10 000 paths at 100 bytes each), the output overflows and execFileSync throws with an error that is not exit-code 1. The catch block logs a debug line and returns an empty ignored set, silently reverting to the pre-fix behavior (spurious WARN + WASM backfill). Passing an explicit maxBuffer large enough prevents this.
| const output = execFileSync('git', ['check-ignore', '--stdin'], { | |
| cwd: rootDir, | |
| input: stdin, | |
| encoding: 'utf-8', | |
| // git check-ignore exits with 1 when none of the paths are ignored — | |
| // that is not an error for our purposes. stdio: 'pipe' lets us capture | |
| // stdout without swallowing stderr, and the try/catch handles the | |
| // non-zero exit from execFileSync when ALL paths are non-ignored | |
| // (exit code 1 from git check-ignore means "no matches"). | |
| stdio: ['pipe', 'pipe', 'pipe'], | |
| }); | |
| const output = execFileSync('git', ['check-ignore', '--stdin'], { | |
| cwd: rootDir, | |
| input: stdin, | |
| encoding: 'utf-8', | |
| maxBuffer: 100 * 1024 * 1024, | |
| // git check-ignore exits with 1 when none of the paths are ignored — | |
| // that is not an error for our purposes. stdio: 'pipe' lets us capture | |
| // stdout without swallowing stderr, and the try/catch handles the | |
| // non-zero exit from execFileSync when ALL paths are non-ignored | |
| // (exit code 1 from git check-ignore means "no matches"). | |
| stdio: ['pipe', 'pipe', 'pipe'], | |
| }); |
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed — added maxBuffer: 100 * 1024 * 1024 to the execFileSync options. This prevents the 1 MB default from overflowing on repos with large numbers of gitignored files, which would have caused execFileSync to throw a non-exit-code-1 error and silently revert to the unfiltered behavior.
Sorry, something went wrong.
Codegraph Impact Analysis2 functions changed → 6 callers affected across 4 files
|
Sorry, something went wrong.
- Apply normalizePath() to each echoed-back line before inserting into the ignored set, so backslash paths on Windows match the forward-slash keys in expectedRaw (prevents silent filter bypass on Windows Git). - Add maxBuffer: 100 MiB to execFileSync so repos with >10 000 gitignored files don't overflow the default 1 MB buffer and silently revert to unfiltered behavior. Impact: 1 functions changed, 4 affected
Sorry, something went wrong.
| // Rust workspace convention — contains only Rust source and NAPI-RS generated | ||
| // binding artifacts (index.js / index.d.ts) that produce false complexity readings. | ||
| 'crates', | ||
| ]), |
There was a problem hiding this comment.
Hardcoded crates exclusion affects all repos, not just this one
IGNORE_DIRS is a global setting consumed by every collectFiles walk against any repository this tool indexes. Adding 'crates' means any user repo that happens to have a directory named crates with TypeScript, Python, or other supported-extension source files will silently have those files dropped from the graph — no warning, no error, no way to opt out. The actual root-cause fix (queryGitIgnoredFiles) already handles this correctly: the NAPI-RS binding artifacts (index.js / index.d.ts) are gitignored, so they are filtered before being placed into expected. The 'crates' entry in IGNORE_DIRS is redundant for this repo and harmful for any other repo with a legitimately named crates directory containing indexable files.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed — removed 'crates' from IGNORE_DIRS in both src/shared/constants.ts and the mirrored Rust collect_files.rs. The queryGitIgnoredFiles filter already excludes the NAPI-RS binding artifacts via git check-ignore, so the global directory exclusion was redundant for this repo and harmful for any other repo with a legitimately named crates/ directory.
Sorry, something went wrong.
Impact: 63 functions changed, 156 affected
…repos The gitignore-based filter in queryGitIgnoredFiles already excludes the NAPI-RS binding artifacts (crates/codegraph-core/index.js / index.d.ts) from gap detection. Adding 'crates' to IGNORE_DIRS is therefore redundant for this repo and harmful for any other repo that has a legitimately named crates/ directory with indexable source files.
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Root cause
detectDroppedLanguageGap calls collectFilesUtil (JS walker, no gitignore) to build the expected set, then compares against the DB populated by the native engine (which respects gitignore). Any gitignored file is in expected but not in the DB → classified as a native extractor failure → WARN + WASM backfill.
Fix
Add queryGitIgnoredFiles() that runs git check-ignore --stdin on the candidate paths. detectDroppedLanguageGap now filters the expected set through this check so gitignored files are never treated as native extractor failures. Falls back gracefully (empty ignore set) when git is unavailable or the directory is not a git repo.
Test plan
Closes #1626