diff --git a/gitnexus/src/core/kuzu/kuzu-adapter.ts b/gitnexus/src/core/kuzu/kuzu-adapter.ts index 78e48bf27..f39d15b0d 100644 --- a/gitnexus/src/core/kuzu/kuzu-adapter.ts +++ b/gitnexus/src/core/kuzu/kuzu-adapter.ts @@ -582,15 +582,16 @@ export const loadExistingGraph = async ( const fromId = str(row.fromId ?? row[0]); const toId = str(row.toId ?? row[1]); if (!nodeIdSet.has(fromId) || !nodeIdSet.has(toId)) continue; + // All relationships are regenerated by the incremental pipeline: + // CONTAINS (processStructure), IMPORTS/CALLS/EXTENDS/IMPLEMENTS + // (full import/call/heritage), MEMBER_OF/STEP_IN_PROCESS (communities/processes). + // Only keep DEFINES for unchanged nodes (File -> code element). const type = str(row.type ?? row[2]); - // Only keep DEFINES (intra-file, deterministic IDs, only re-created for changed files). - // Everything else is regenerated: - // - CONTAINS: by processStructure on all files - // - IMPORTS, CALLS, EXTENDS, IMPLEMENTS: by full import/call/heritage on all files - // - MEMBER_OF, STEP_IN_PROCESS: by community/process detection if (type !== 'DEFINES') continue; + // For DEFINES: use the canonical ID format to avoid duplicates with freshly parsed results + const canonicalId = `DEFINES:${fromId}->${toId}`; relationships.push({ - id: `${fromId}_${type}_${toId}`, + id: canonicalId, sourceId: fromId, targetId: toId, type: type as any,