refactor: decompose Rust build-pipeline process_file and match_js_type_map#1592
Conversation
… DEFAULTS docs check acknowledged
| // Engine selection: CODEGRAPH_ENGINE env always wins over config-file value. | ||
| if (process.env.CODEGRAPH_ENGINE !== undefined) { | ||
| const val = process.env.CODEGRAPH_ENGINE as 'auto' | 'native' | 'wasm'; | ||
| (config.build as Record<string, unknown>).engine = val; | ||
| } |
There was a problem hiding this comment.
The
CODEGRAPH_ENGINE value is cast to the union type without any runtime validation. If the variable is set to an unrecognized value (e.g. CODEGRAPH_ENGINE=typo), it will be written to config undetected and could silently cause the engine-selection logic downstream to behave unexpectedly. The CODEGRAPH_FAST_SKIP_DIAG path uses an explicit === '1' check, which is a safer pattern for this kind of single-source-of-truth override.
| // Engine selection: CODEGRAPH_ENGINE env always wins over config-file value. | |
| if (process.env.CODEGRAPH_ENGINE !== undefined) { | |
| const val = process.env.CODEGRAPH_ENGINE as 'auto' | 'native' | 'wasm'; | |
| (config.build as Record<string, unknown>).engine = val; | |
| } | |
| // Engine selection: CODEGRAPH_ENGINE env always wins over config-file value. | |
| if (process.env.CODEGRAPH_ENGINE !== undefined) { | |
| const val = process.env.CODEGRAPH_ENGINE; | |
| if (val === 'auto' || val === 'native' || val === 'wasm') { | |
| (config.build as Record<string, unknown>).engine = val; | |
| } else { | |
| debug(`applyEnvOverrides: ignoring unknown CODEGRAPH_ENGINE value "${val}" (expected auto|native|wasm)`); | |
| } | |
| } |
There was a problem hiding this comment.
Resolved — merged origin/main which brings in CODEGRAPH_ENGINE and CODEGRAPH_FAST_SKIP_DIAG test coverage from #1589. Additionally, the merge also brings in main's validation-with-warning for CODEGRAPH_ENGINE (the P2 finding itself): invalid values now log a warning and fall back to "auto" rather than being cast blindly.
Codegraph Impact Analysis23 functions changed → 27 callers affected across 4 files
|
Keep main's validation-with-warning for CODEGRAPH_ENGINE and the detailed JSDoc for config.build.engine referencing issue #1596.
|
Addressed Greptile finding: merged origin/main to pick up env-override test coverage for CODEGRAPH_ENGINE and CODEGRAPH_FAST_SKIP_DIAG (landed in #1589). The merge also brings in the validation-with-warning fix for CODEGRAPH_ENGINE (the P2 finding itself) — invalid values now warn and fall back to "auto". All 3126 tests pass locally. |
Summary
Mirrors the TS call-resolution decomposition (PR #1591) for the Rust native engine. Decomposes the highest-complexity Rust functions in the build pipeline.
process_file: cog 73→14, bugs 3.72→0.69 (81% reduction each)match_js_type_map: cog 122→thin dispatcher (~95% reduction)write_dataflowinpipeline.rs: extracted focused helperdo_insert_nodesininsert_nodes.rs: decomposedTitan Audit Context
Changes
crates/codegraph-core/src/domain/graph/builder/stages/build_edges.rs—process_filedecomposed into focused sub-functions;match_js_type_map→ thin dispatchercrates/codegraph-core/src/extractors/javascript.rs—match_js_type_maphelpers extractedcrates/codegraph-core/src/domain/graph/builder/pipeline.rs—write_dataflowextractedcrates/codegraph-core/src/domain/graph/builder/stages/insert_nodes.rs—do_insert_nodesdecomposedMetrics Impact
process_file(Rust): cog 73→14, bugs 3.72→0.69match_js_type_map(Rust): cog 122→dispatcher patternTest plan