refactor: split hybridSearchData into keyword, vector, and merge steps#768
refactor: split hybridSearchData into keyword, vector, and merge steps#768carlos-alm merged 3 commits intomainfrom
Conversation
|
Claude finished @carlos-alm's task —— View job PR Review: Hybrid Search RefactoringTodo List
Root Cause AnalysisProblem Being Solved: The Why This Approach: Breaking down complex functions into smaller, single-responsibility functions is a proven refactoring technique that improves code maintainability, testability, and readability. The extracted functions ( Risk Assessment: ✅ LOW RISK - This is a pure refactoring with no behavioral changes, proper interface preservation, and comprehensive test coverage already exists. Backlog Compliance
Configuration & Test Review✅ No configuration changes detected - Only the implementation file was modified
Code Quality AssessmentStrengths ✅
Implementation Quality ✅
Potential Concerns (Minor)
Code Patterns ✅
Technical Deep DiveThe refactoring successfully decomposes the original 160+ line function into:
This decomposition dramatically improves the cognitive load while preserving all existing functionality and test coverage. Final Recommendation
The only reason this isn't 5 stars is that it's "just" a refactoring - while excellently executed, it doesn't add new functionality or directly address user needs. |
Greptile SummaryThis PR refactors Confidence Score: 5/5Safe to merge — pure structural refactor with no behavioral changes to the public API. All three extracted helpers faithfully reproduce the original logic. Interfaces promoted to module scope are unchanged. The removal of the dead typeof query === 'string' branch is a minor improvement, not a regression. No P0 or P1 findings. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant hybridSearchData
participant parseQueries
participant collectRankedLists
participant ftsSearchData
participant searchData
participant fuseResults
Caller->>hybridSearchData: query, customDbPath, opts
hybridSearchData->>hybridSearchData: loadConfig(), derive limit/k/topK
hybridSearchData->>hybridSearchData: openReadonlyOrFail → hasFtsIndex → close
alt FTS not available
hybridSearchData-->>Caller: null
end
hybridSearchData->>parseQueries: query string
parseQueries-->>hybridSearchData: string[]
hybridSearchData->>collectRankedLists: queries[], customDbPath, opts, topK
loop for each query q
collectRankedLists->>ftsSearchData: q, customDbPath, opts+limit
ftsSearchData-->>collectRankedLists: BM25 results
collectRankedLists->>searchData: q, customDbPath, opts+limit+minScore
searchData-->>collectRankedLists: semantic results
end
collectRankedLists-->>hybridSearchData: RankedItem[][]
hybridSearchData->>fuseResults: rankedLists, k, limit
fuseResults-->>hybridSearchData: HybridResult[] (RRF-scored)
hybridSearchData-->>Caller: { results }
Reviews (1): Last reviewed commit: "refactor: split hybridSearchData into ke..." | Re-trigger Greptile |
Summary
hybridSearchData(cognitive=38, MI=24.6, bugs=1.43) into keyword search, vector search, and result merge stepsTitan Audit Context
Changes
src/domain/search/search/hybrid.ts- Extract keyword/vector/merge sub-functions from hybridSearchDataTest plan