refactor: remove dead WASM call-AST extraction and pre-3.2 edge shim#686
refactor: remove dead WASM call-AST extraction and pre-3.2 edge shim#686carlos-alm merged 13 commits intomainfrom
Conversation
…sitor Call sites are already captured in FileSymbols.calls during extraction and stored as graph edges — the separate `call` entries in ast_nodes were written but never queried. This removes ~100 lines of call-specific subtree walking logic (walkSubtree, walkCallArguments, collectNode, extractCallName) and the call_expression entry from JS/TS astTypes.
The supplementReceiverEdges fallback was added for native binaries older than 3.2.0 that didn't emit receiver or type-resolved method-call edges. Current version is 3.5.0 — all published binaries handle receivers natively. Removes ~70 lines of dead compat code.
|
Claude finished @carlos-alm's task —— View job Root Cause AnalysisProblem Being Solved: Removing genuinely dead code - WASM call AST extraction that duplicated already-captured call site data, and a compatibility shim for native binaries older than 3.2.0 (current is 3.5.0). Why This Approach: Call sites are already captured in Risk Assessment: Low risk. This is pure dead code removal with no behavioral changes. The functionality remains available through existing pathways (call edges, native receiver handling). Backlog Compliance
Technical AnalysisPhase 1: Root Cause Verification ✅
Phase 2: Configuration Changes ✅
Phase 3: Test Integrity ✅
Phase 4: Code Quality ✅
Phase 5: Architecture Compliance ✅
Critical ConcernsNone identified. This is a clean dead-code removal. Final Recommendation
This is exactly the kind of refactoring that keeps codebases healthy - removing code that has outlived its purpose without breaking anything. |
Greptile SummaryThis PR removes two pieces of dead code (−170 lines) and wires up three new native bulk-insert fast paths for complexity, CFG, and dataflow. Dead-code removals:
New native bulk-insert paths (complexity, CFG, dataflow):
Minor findings (P2):
Confidence Score: 5/5Safe to merge — dead-code removals are clean and new fast paths degrade gracefully to the existing JS fallback. All findings are P2. One is a theoretical mixed-engine inconsistency only on an unusual partial-failure path; the other is a name-resolution tiebreaker that may already be intentional. Neither affects correctness on the happy path. Dead-code removals are well-scoped, test suite is updated, and the 'call' filter handles the native binary transition period. src/features/complexity.ts (partial-insert fallback), src/features/dataflow.ts (global name resolution) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Build Pipeline] --> B{Engine?}
B -->|native| C[NativeDatabase napi-rs]
B -->|wasm / auto fallback| D[WASM / JS path]
C --> E{bulkInsertComplexity?}
E -->|yes, all defs have native complexity| F[Native bulk insert\nINSERT OR REPLACE]
E -->|no / partial failure| G[JS WASM fallback\nre-parse all files]
F -->|inserted == rows.length| H[return]
F -->|inserted < rows.length| G
C --> I{bulkInsertCfg + allNative?}
I -->|yes| J[deleteCfgForNode via BetterSqlite3\nthen bulkInsertCfg via napi-rs]
I -->|no| K[JS WASM CFG visitor]
J --> L[return]
C --> M{bulkInsertDataflow?}
M -->|yes, all files have symbols.dataflow| N[resolveNode local to global\nbulkInsertDataflow]
M -->|needsJsFallback = true| O[JS WASM dataflow visitor]
N --> P[return]
D --> Q[ast-store-visitor\nnew / throw / await / string / regex only\ncall_expression REMOVED]
Reviews (3): Last reviewed commit: "fix(ast): filter native call AST nodes b..." | Re-trigger Greptile |
…dataflow Add three new NativeDatabase methods (bulk_insert_complexity, bulk_insert_cfg, bulk_insert_dataflow) that write pre-computed Rust analysis results directly to SQLite via rusqlite, bypassing better-sqlite3 JS round-trips. Wire native fast paths in complexity.ts, cfg.ts, and dataflow.ts that try the rusqlite bulk insert first, falling back to better-sqlite3 when native data is unavailable. Update README with a table explaining what Rust handles on the native path end-to-end.
block_stmt.execute() returns Result<usize>, not Result<()>
Extract shared patterns from 9 language extractors into 4 reusable
helpers in helpers.ts, reducing per-language boilerplate by ~30 lines:
- findParentNode: replaces 6 findParent*/findCurrentImpl functions
- extractBodyMembers: replaces 5 body-iteration patterns for enums/structs
- stripQuotes: replaces inline .replace(/"/g,'') across 3 extractors
- lastPathSegment: replaces inline .split('.').pop() across 6 extractors
Net: +77 helper lines, -159 extractor lines = -82 lines total.
The matched Set was a deduplication guard left over from the removed manual walkSubtree logic. The DFS framework visits each node exactly once, so the guard never fires. Removing it eliminates a no-op allocation.
The WASM visitor no longer extracts call AST nodes (removed in this PR), but the native engine and the symbols.calls fallback path still inserted them. This broke the build-parity test. Remove call kind insertion from both the native bulk-insert filter and the WASM symbols.calls path. Call AST nodes were dead — never queried by any feature or command.
…nto refactor/remove-call-ast-wasm-fix
This reverts commit 03ebe9f.
…tave/codegraph into refactor/remove-call-ast-wasm-fix
|
Addressed Greptile's feedback and fixed CI failures:
|
The engine.ts check `!Array.isArray(symbols.astNodes)` skips the WASM visitor when native provides astNodes. If native only produced call entries (now dead), the array was non-empty but contained only filtered- out kinds, causing the WASM visitor to be skipped and no AST nodes to be stored. Filter call entries early so the WASM visitor runs when no non-call entries remain.
…ST nodes Move the call-kind filter from setupVisitors (which only runs for files with _tree) to the top of runAnalyses so it applies to all files including native-parsed ones. Add AST needs to ensureWasmTreesIfNeeded so WASM trees are created when native astNodes were cleared. Also remove unused nativeProvidedAstNodes variable and fix formatting.
Summary
callAST node extraction from WASM visitor — call sites are already captured inFileSymbols.callsduring extraction and stored as graph edges. Thecallentries inast_nodeswere written but never queried by any DB query, feature, or command. DeletesextractCallName,walkSubtree,walkCallArguments,findChildByKind,collectNode, and thecall_expressionentry from JS/TSastTypes. (~100 lines)supplementReceiverEdgeswas a JS fallback for native binaries older than 3.2.0 that didn't emit receiver edges. Current version is 3.5.0; all published binaries handle receivers natively. (~70 lines)Net: −170 lines of dead code.
Test plan
npm installto build grammars)