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): flag computed method assignments as unresolved

Lum1104b51e65cc63bc
diff --git a/tests/skill/understand/test_incremental_symbols.test.mjs b/tests/skill/understand/test_incremental_symbols.test.mjs
index 31aad9de..5551472a 100644
--- a/tests/skill/understand/test_incremental_symbols.test.mjs
+++ b/tests/skill/understand/test_incremental_symbols.test.mjs
@@ -142,6 +142,8 @@ describe('incremental symbol matching', () => {
['unextracted arrow method', 'class A { run = () => {}; }'],
['computed method', 'class A { ["run"]() {} }'],
['computed name fragments', 'class A { ["r" + "un"]() {} keep() {} }'],
+ ['computed method assignment', 'class A { keep() {} }; A.prototype["r" + "un"] = function() {};'],
+ ['escaped method assignment', String.raw`class A { keep() {} }; A.prototype.r\u0075n = function() {};`],
['escaped identifier', String.raw`class A { r\u0075n() {} keep() {} }`],
['escaped string method name', String.raw`class A { "r\u0075n"() {} keep() {} }`],
['moved method', 'class B { run() {} }'],
diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjs
index 03432d9e..93ab9ff9 100644
--- a/tests/skill/understand/test_prepare_incremental.test.mjs
+++ b/tests/skill/understand/test_prepare_incremental.test.mjs
@@ -251,10 +251,13 @@ describe('incremental symbol publication gate', { timeout: 30_000 }, () => {
expect(f.persisted()).toEqual(before);
});
- it('does not publish a missing method whose computed source name still denotes the old symbol', () => {
+ it.each([
+ ['declaration', 'export class Service { ["method" + "0"]() { return 1; } method1() {} }\n'],
+ ['assignment', 'export class Service { method1() {} }; Service.prototype["method" + "0"] = function() {};\n'],
+ ])('does not publish a missing method whose computed %s still denotes the old symbol', (_label, source) => {
const f = symbolFixture(2);
- const source = 'export class Service { ["method" + "0"]() { return 1; } method1() {} }\n';
- expect(Object.hasOwn(class { ['method' + '0']() {} }.prototype, 'method0')).toBe(true);
+ const result = new Function(source.replace('export ', '') + '\nreturn Service;')();
+ expect(Object.hasOwn(result.prototype, 'method0')).toBe(true);
writeProjectFile(f.root, 'src/a.ts', source);
commit(f.root, 'use a computed method name');
const before = f.persisted();
diff --git a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts
index b94231d9..ed168542 100644
--- a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts
+++ b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts
@@ -384,6 +384,10 @@ export class Greeter {
'class A { ["r" + "un"]() {} keep() {} }',
String.raw`class A { r\u0075n() {} keep() {} }`,
String.raw`class A { "r\u0075n"() {} keep() {} }`,
+ 'class A { keep() {} }; A.prototype["r" + "un"] = function() {};',
+ 'class A { keep() {} }; A.prototype[key] ||= function() {};',
+ 'class A { keep() {} }; ({method: A.prototype[key]} = obj);',
+ String.raw`class A { keep() {} }; A.prototype.r\u0075n = function() {};`,
]) {
const result = plugin.analyzeFileStrict("test.js", code);
expect(result.status).toBe("succeeded");
@@ -391,6 +395,8 @@ export class Greeter {
}
expect(plugin.analyzeFileStrict("test.js", String.raw`function keep(r\u0075n) { return r\u0075n; }`)
.hasUnresolvedNames).toBe(false);
+ expect(plugin.analyzeFileStrict("test.js", 'class A { keep() { return this["x" + "y"]; } }')
+ .hasUnresolvedNames).toBe(false);
});
});
diff --git a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts
index 07bcc80a..2f35156c 100644
--- a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts
+++ b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts
@@ -314,6 +314,23 @@ export class TreeSitterPlugin implements AnalyzerPlugin {
|| (methodName?.type === "string" && methodName.text.includes("\\"))) {
hasUnresolvedNames = true;
}
+ if (!hasUnresolvedNames && ["typescript", "javascript"].includes(langKey!)
+ && ["assignment_expression", "augmented_assignment_expression"].includes(node.type)) {
+ // Methods can also be installed through prototype/object writes.
+ // Inspect the entire target for destructuring and wrapped accesses;
+ // computed reads alone are not declaration evidence.
+ const target = node.childForFieldName("left");
+ const targets = target ? [target] : [];
+ while (targets.length > 0) {
+ const part = targets.pop()!;
+ if (part.type === "subscript_expression"
+ || (part.type === "property_identifier" && part.text.includes("\\"))) {
+ hasUnresolvedNames = true;
+ break;
+ }
+ targets.push(...part.namedChildren);
+ }
+ }
if (node.childCount === 0) leafTexts.add(node.text);
else pending.push(...node.children);
}
diff --git a/understand-anything-plugin/skills/understand/SKILL.md b/understand-anything-plugin/skills/understand/SKILL.md
index c892277c..5ed2676e 100644
--- a/understand-anything-plugin/skills/understand/SKILL.md
+++ b/understand-anything-plugin/skills/understand/SKILL.md
@@ -416,7 +416,7 @@ Before dropping dangling endpoints, merge records normalized edge candidates fro
Candidate endpoints use the current analysis's node and ownership descriptors before any baseline alias is applied: an ID reused by a different current symbol must keep its current meaning. During repair, incoming edges are deferred outside the ordinary retained batch until those original HEAD descriptors can be matched against replacement nodes, so temporary ID reuse cannot create a false edge during merge.
-A syntactically valid parse is insufficient to prove deletion when declaration names remain computed or escaped. The strict parser marks this uncertainty, and missing symbols remain `unknown` rather than being treated as deleted merely because their literal spelling is absent.
+A syntactically valid parse is insufficient to prove deletion when declaration names remain computed or escaped, including methods installed through computed prototype/object assignments. The strict parser marks this uncertainty, and missing symbols remain `unknown` rather than being treated as deleted merely because their literal spelling is absent.
Go receiver methods, Rust inherent impl methods, and C++ out-of-class definitions retain explicit type ownership and their own source ranges. Their duplicate entries in `classes[].methods` are reconciled without assuming the method body is inside the type declaration. Free functions with the same name stay distinct; unresolved receivers and Rust trait impl identities remain `unknown`. Receiver changes also affect structural fingerprints when the type declaration is in another file.