feat: add normalizeSymbol utility for stable JSON schema#267
Conversation
Add normalizeSymbol(row, db, hashCache) that returns a consistent 7-field symbol shape (name, kind, file, line, endLine, role, fileHash) across all query and search commands. Update queryNameData, fnDepsData, fnImpactData, explainFunctionImpl, listFunctionsData, rolesData, whereSymbolImpl in queries.js and searchData, multiSearchData, ftsSearchData, hybridSearchData in embedder.js to use normalizeSymbol. Update SQL in listFunctionsData, rolesData, iterListFunctions, iterRoles, _prepareSearch, and ftsSearchData to include end_line and role columns. Export normalizeSymbol from index.js. Add docs/json-schema.md documenting the stable schema. Add 8 unit tests and 7 integration schema conformance tests. Impact: 13 functions changed, 33 affected Impact: 14 functions changed, 42 affected Impact: 13 functions changed, 21 affected
|
Claude finished @carlos-alm's task —— View job PR Review: normalizeSymbol utilityTodo List:
Root Cause AnalysisProblem Being Solved: This PR addresses the lack of a consistent symbol schema across different query and search commands. Previously, different commands returned symbol objects with varying field structures, making it difficult for API consumers to reliably process results. The Why This Approach: The approach is well-justified:
Risk Assessment: Low risk. This is primarily a refactoring that standardizes existing functionality without changing core behavior. Configuration Changes✅ No problematic configuration changes detected. No linting rules were relaxed, test thresholds lowered, or build configurations modified. Test Integrity✅ Strong test coverage:
Code Quality Analysis✅ Strengths
|
Summary
normalizeSymbol(row, db, hashCache)utility that returns a consistent 7-field symbol shape (name,kind,file,line,endLine,role,fileHash) across all query and search commandsqueryNameData,fnDepsData,fnImpactData,explainFunctionImpl,listFunctionsData,rolesData,whereSymbolImplin queries.js to usenormalizeSymbolsearchData,multiSearchData,ftsSearchData,hybridSearchDatain embedder.js to usenormalizeSymboldocs/json-schema.mddocumenting the stable schemaSplit from #261 — this PR contains only the normalizeSymbol feature.
Test plan
npm testpassesfileHashcache prevents redundant DB lookups (unit test)endLineandrolewithoutfileHash(by design)