diff --git a/gitnexus/src/core/ingestion/pipeline.ts b/gitnexus/src/core/ingestion/pipeline.ts index e840e4025..623fd51c9 100644 --- a/gitnexus/src/core/ingestion/pipeline.ts +++ b/gitnexus/src/core/ingestion/pipeline.ts @@ -1041,6 +1041,9 @@ async function runChunkedParseAndResolve( console.log( `🔍 Resolution cache: ${rcStats.cacheHits} hits, ${rcStats.cacheMisses} misses (${hitRate}% hit rate)`, ); + console.log( + `🔍 Fuzzy Lookups: ${rcStats.fuzzyCallCount} total, ${rcStats.fuzzyCallableCallCount} callable`, + ); } // ── Worker path quality enrichment: merge TypeEnv file-scope bindings into ExportedTypeMap ── diff --git a/gitnexus/src/core/ingestion/resolution-context.ts b/gitnexus/src/core/ingestion/resolution-context.ts index 0371c527d..da7908638 100644 --- a/gitnexus/src/core/ingestion/resolution-context.ts +++ b/gitnexus/src/core/ingestion/resolution-context.ts @@ -70,6 +70,8 @@ export interface ResolutionContext { getStats(): { fileCount: number; globalSymbolCount: number; + fuzzyCallCount: number; + fuzzyCallableCallCount: number; cacheHits: number; cacheMisses: number; }; diff --git a/gitnexus/src/core/ingestion/symbol-table.ts b/gitnexus/src/core/ingestion/symbol-table.ts index 96d0948db..086148f2f 100644 --- a/gitnexus/src/core/ingestion/symbol-table.ts +++ b/gitnexus/src/core/ingestion/symbol-table.ts @@ -114,7 +114,12 @@ export interface SymbolTable { /** * Debugging: See how many symbols are tracked */ - getStats: () => { fileCount: number; globalSymbolCount: number }; + getStats: () => { + fileCount: number; + globalSymbolCount: number; + fuzzyCallCount: number; + fuzzyCallableCallCount: number; + }; /** * Cleanup memory @@ -150,6 +155,10 @@ export const createSymbolTable = (): SymbolTable => { const classByName = new Map(); const classByQualifiedName = new Map(); + let fuzzyCallCount = 0; + + let fuzzyCallableCallCount = 0; + const CALLABLE_TYPES = new Set(['Function', 'Method', 'Constructor']); const add = ( @@ -267,10 +276,12 @@ export const createSymbolTable = (): SymbolTable => { }; const lookupFuzzy = (name: string): SymbolDefinition[] => { + fuzzyCallCount++; return globalIndex.get(name) || []; }; const lookupFuzzyCallable = (name: string): SymbolDefinition[] => { + fuzzyCallableCallCount++; if (!callableIndex) { // Build the callable index lazily on first use callableIndex = new Map(); @@ -317,6 +328,8 @@ export const createSymbolTable = (): SymbolTable => { const getStats = () => ({ fileCount: fileIndex.size, globalSymbolCount: globalIndex.size, + fuzzyCallableCallCount: fuzzyCallableCallCount, + fuzzyCallCount: fuzzyCallCount, }); const clear = () => { @@ -327,6 +340,8 @@ export const createSymbolTable = (): SymbolTable => { methodByOwner.clear(); classByName.clear(); classByQualifiedName.clear(); + fuzzyCallCount = 0; + fuzzyCallableCallCount = 0; }; return { diff --git a/gitnexus/test/unit/symbol-table.test.ts b/gitnexus/test/unit/symbol-table.test.ts index 95f79cfb8..bcb3df7e5 100644 --- a/gitnexus/test/unit/symbol-table.test.ts +++ b/gitnexus/test/unit/symbol-table.test.ts @@ -88,7 +88,12 @@ describe('SymbolTable', () => { describe('getStats', () => { it('returns zero counts for empty table', () => { - expect(table.getStats()).toEqual({ fileCount: 0, globalSymbolCount: 0 }); + expect(table.getStats()).toEqual({ + fileCount: 0, + globalSymbolCount: 0, + fuzzyCallCount: 0, + fuzzyCallableCallCount: 0, + }); }); it('tracks unique file count correctly', () => { @@ -484,7 +489,12 @@ describe('SymbolTable', () => { }); table.add('src/models.ts', 'User', 'class:User', 'Class'); table.clear(); - expect(table.getStats()).toEqual({ fileCount: 0, globalSymbolCount: 0 }); + expect(table.getStats()).toEqual({ + fileCount: 0, + globalSymbolCount: 0, + fuzzyCallCount: 0, + fuzzyCallableCallCount: 0, + }); expect(table.lookupExact('src/a.ts', 'foo')).toBeUndefined(); expect(table.lookupFuzzy('foo')).toEqual([]); expect(table.lookupFieldByOwner('class:User', 'address')).toBeUndefined(); @@ -497,7 +507,12 @@ describe('SymbolTable', () => { table.add('src/a.ts', 'foo', 'func:foo', 'Function'); table.clear(); table.add('src/b.ts', 'bar', 'func:bar', 'Function'); - expect(table.getStats()).toEqual({ fileCount: 1, globalSymbolCount: 1 }); + expect(table.getStats()).toEqual({ + fileCount: 1, + globalSymbolCount: 1, + fuzzyCallCount: 0, + fuzzyCallableCallCount: 0, + }); }); it('resets callableIndex so first lookup after clear rebuilds from scratch', () => {