From 0736bb23bcd22f7f60b262208fc1c7f519dcc77d Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Fri, 20 Mar 2026 12:28:22 +0000 Subject: [PATCH] fix(type-resolution): address Phase 14 enhancement code review findings 1. Replace fragile regex in buildExportedTypeMapFromGraph with extractReturnTypeName() for consistent generic unwrapping. 2. Fix gap detection precision: check upstream.has(binding.exportedName) instead of exportedTypeMap.has(binding.sourcePath) to avoid over-counting files that import only unrelated symbols. --- gitnexus/src/core/ingestion/call-processor.ts | 4 ++-- gitnexus/src/core/ingestion/pipeline.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gitnexus/src/core/ingestion/call-processor.ts b/gitnexus/src/core/ingestion/call-processor.ts index 0d2245965..adb63916a 100644 --- a/gitnexus/src/core/ingestion/call-processor.ts +++ b/gitnexus/src/core/ingestion/call-processor.ts @@ -104,8 +104,8 @@ export function buildExportedTypeMapFromGraph( if (!def) return; const typeName = def.returnType ?? def.declaredType; if (!typeName || typeName.length > MAX_TYPE_NAME_LENGTH) return; - // Extract simple type name (strip Promise<>, etc.) - const simpleType = typeName.replace(/^(?:Promise|Observable|Task|Future|CompletableFuture)\s*<\s*/, '').replace(/\s*>\s*$/, '') || typeName; + // Extract simple type name (strip Promise<>, etc.) — reuse shared utility + const simpleType = extractReturnTypeName(typeName) ?? typeName; if (!simpleType) return; let fileExports = result.get(filePath); if (!fileExports) { fileExports = new Map(); result.set(filePath, fileExports); } diff --git a/gitnexus/src/core/ingestion/pipeline.ts b/gitnexus/src/core/ingestion/pipeline.ts index 6db785356..71888192b 100644 --- a/gitnexus/src/core/ingestion/pipeline.ts +++ b/gitnexus/src/core/ingestion/pipeline.ts @@ -537,8 +537,9 @@ export const runPipelineFromRepo = async ( if (!imports) continue; let hasGap = false; for (const [, binding] of imports) { - // E1/E2: upstream file has variable bindings in exportedTypeMap - if (exportedTypeMap.has(binding.sourcePath)) { hasGap = true; break; } + // E1/E2: upstream file has a matching exported binding for this specific import + const upstream = exportedTypeMap.get(binding.sourcePath); + if (upstream?.has(binding.exportedName)) { hasGap = true; break; } // E3: upstream callable has a known return type in SymbolTable const def = ctx.symbols.lookupExactFull(binding.sourcePath, binding.exportedName); if (def?.returnType) { hasGap = true; break; }