From 97cfbbec88605d638c74931f41d7a1f907161e9c Mon Sep 17 00:00:00 2001 From: slugb0t Date: Thu, 4 Jun 2026 00:21:05 -0700 Subject: [PATCH] fix: :bug: skip self-referential edges in Nuxt auto-import emission --- .../ingestion/languages/typescript/scope-resolver.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gitnexus/src/core/ingestion/languages/typescript/scope-resolver.ts b/gitnexus/src/core/ingestion/languages/typescript/scope-resolver.ts index 49a7532b3..2ab17bdce 100644 --- a/gitnexus/src/core/ingestion/languages/typescript/scope-resolver.ts +++ b/gitnexus/src/core/ingestion/languages/typescript/scope-resolver.ts @@ -214,6 +214,11 @@ const typescriptScopeResolver: ScopeResolver = { const emittedImports = new Set(); const emittedCalls = new Set(); + // Skip source files: a file cannot auto-import its own exports. + // Without this guard the content scanner would match each exported + // function's own name inside its definition body and emit a self-loop. + const selfPath = filePath; + CALL_RE.lastIndex = 0; let m: RegExpExecArray | null; while ((m = CALL_RE.exec(content)) !== null) { @@ -223,8 +228,9 @@ const typescriptScopeResolver: ScopeResolver = { const { exportName, sourceFile } = entry; - // Skip when the file already has an explicit import from this source. - if (explicitImports.has(sourceFile)) continue; + // Skip when the file already has an explicit import from this source, + // or when the file IS the source (a file cannot auto-import itself). + if (explicitImports.has(sourceFile) || sourceFile === selfPath) continue; // Emit one IMPORTS edge per (caller, sourceFile) pair. if (!emittedImports.has(sourceFile)) {