Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

fix(incremental): preserve inbound edges through targeted repairs

Lum1104f230fbb7c60b
diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjs
index fb52a943..1c34be77 100644
--- a/tests/skill/understand/test_prepare_incremental.test.mjs
+++ b/tests/skill/understand/test_prepare_incremental.test.mjs
@@ -247,6 +247,8 @@ describe('incremental symbol publication gate', { timeout: 30_000 }, () => {
f.write('batch-7-part-2.json', { nodes: [otherFunction, obsolete], edges: [
{ source: otherFile.id, target: otherFunction.id, type: 'contains', direction: 'forward', weight: 1 },
{ source: otherFunction.id, target: obsolete.id, type: 'calls', direction: 'forward', weight: 1 },
+ { source: otherFunction.id, target: f.methodNodes[0].id, type: 'calls', direction: 'forward', weight: 0.8 },
+ { source: f.methodNodes[0].id, target: otherFunction.id, type: 'calls', direction: 'forward', weight: 0.5 },
] });
expect(spawnSync(python, [mergeScript, f.root]).status).toBe(1);
run(process.execPath, [retryScript, f.root], f.root);
@@ -261,7 +263,9 @@ describe('incremental symbol publication gate', { timeout: 30_000 }, () => {
const retained = f.read('batch-0.json');
expect(retained.nodes.find(node => node.id === otherFunction.id)?.summary).toBe(otherFunction.summary);
expect(retained.nodes.some(node => node.filePath === 'src/a.ts')).toBe(false);
- expect(retained.edges.some(edge => edge.target === obsolete.id)).toBe(false);
+ expect(retained.edges.some(edge => edge.target === obsolete.id)).toBe(true);
+ expect(retained.edges.some(edge => edge.source === otherFunction.id && edge.target === f.methodNodes[0].id)).toBe(true);
+ expect(retained.edges.some(edge => edge.source === f.methodNodes[0].id)).toBe(false);
expect(retained.edges.some(edge => edge.target === otherFunction.id)).toBe(true);
for (const batch of retry.batches) f.write(`batch-${batch.batchIndex}.json`, {
nodes: [f.fileNode, f.classNode, ...(outcome === 'success' ? f.methodNodes : [f.methodNodes[0]])], edges: [],
@@ -275,6 +279,8 @@ describe('incremental symbol publication gate', { timeout: 30_000 }, () => {
expect(graph.project.gitCommitHash).toBe(head);
expect(graph.nodes.find(node => node.id === otherFunction.id)?.summary).toBe(otherFunction.summary);
expect(graph.nodes.some(node => node.id === obsolete.id)).toBe(false);
+ expect(graph.edges.some(edge => edge.target === obsolete.id)).toBe(false);
+ expect(graph.edges.find(edge => edge.source === otherFunction.id && edge.target === f.methodNodes[0].id)?.weight).toBe(0.8);
} else {
expect(merged.status).toBe(1);
expect(finalized.status).toBe(1);
diff --git a/understand-anything-plugin/skills/understand/prepare-symbol-retry.mjs b/understand-anything-plugin/skills/understand/prepare-symbol-retry.mjs
index 70331273..ac7e43fd 100644
--- a/understand-anything-plugin/skills/understand/prepare-symbol-retry.mjs
+++ b/understand-anything-plugin/skills/understand/prepare-symbol-retry.mjs
@@ -73,7 +73,11 @@ async function main() {
.map(node => node.id));
const retained = {
nodes: assembled.nodes.filter(node => !removedIds.has(node.id)),
- edges: assembled.edges.filter(edge => !removedIds.has(edge.source) && !removedIds.has(edge.target)),
+ // Other files are not reanalyzed. Preserve their current inbound edge
+ // candidates until replacement nodes exist; merge resolves their endpoints
+ // and drops candidates whose targets were actually removed. Only outgoing
+ // edges from the affected files need regeneration by the retry analyzer.
+ edges: assembled.edges.filter(edge => !removedIds.has(edge.source)),
};
// Persist the attempt BEFORE mutating batches: a crash must not buy another