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.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
fix(incremental): detect Ruby and Python runtime method installers
Lum11040658f0c55e8e
diff --git a/tests/skill/understand/test_incremental_symbols.test.mjs b/tests/skill/understand/test_incremental_symbols.test.mjsindex e0ba2ac5..a6bdb746 100644--- a/tests/skill/understand/test_incremental_symbols.test.mjs+++ b/tests/skill/understand/test_incremental_symbols.test.mjs@@ -18,6 +18,25 @@ const compare = (oldNodes, newNodes, oldSource, newSource) => compareFileSymbols);describe('incremental symbol matching', () => {+ it.each([+ ['rb', 'class A\n def run; end\nend\n', 'class A\n def keep; end\n define_method(("r" + "un").to_sym) { 1 }\nend\n'],+ ['rb', 'class A\n def run; end\nend\n', 'class A\n def keep; end\n send(:define_method, ("r" + "un").to_sym) { 1 }\nend\n'],+ ['py', 'class A:\n def run(self): pass\n', 'class A:\n def keep(self): pass\nsetattr(A, "r" + "un", lambda self: None)\n'],+ ['py', 'class A:\n def run(self): pass\n', 'class A:\n def keep(self): pass\ninstall = setattr\ninstall(A, "r" + "un", lambda self: None)\n'],+ ])('keeps runtime-installed %s methods unresolved', (extension, oldSource, newSource) => {+ const filePath = `src/a.${extension}`;+ const before = parser.analyzeFileStrict(filePath, oldSource);+ const after = parser.analyzeFileStrict(filePath, newSource);+ expect(before.status).toBe('succeeded');+ expect(after.status).toBe('succeeded');+ expect(after.hasUnresolvedNames).toBe(true);+ const previous = graph([node('A.run', { filePath, id: `function:${filePath}:A.run` })]);+ expect(compareFileSymbols(previous, graph([]), before, after).missing[0].status).toBe('unknown');+ const ordinary = parser.analyzeFileStrict(filePath, extension === 'rb'+ ? 'class A\n def keep; end\nend\n' : 'class A:\n def keep(self): pass\n');+ expect(compareFileSymbols(previous, graph([]), before, ordinary).missing[0].status).toBe('deleted');+ });+it.each(['ts', 'tsx', 'js', 'jsx', 'mts', 'cts', 'mjs', 'cjs'])('rejects computed assignment deletion evidence in .%s', extension => {const filePath = `src/a.${extension}`;const before = parser.analyzeFileStrict(filePath, 'class A { run() {} }');diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjsindex bdb9c1a0..4c667c2b 100644--- a/tests/skill/understand/test_prepare_incremental.test.mjs+++ b/tests/skill/understand/test_prepare_incremental.test.mjs@@ -232,6 +232,27 @@ afterEach(async () => {});describe('incremental symbol publication gate', { timeout: 30_000 }, () => {+ it.each([+ ['rb', 'class A\n def run; end\nend\n', 'class A\n def keep; end\n define_method(("r" + "un").to_sym) { 1 }\nend\n'],+ ['py', 'class A:\n def run(self): pass\n', 'class A:\n def keep(self): pass\nsetattr(A, "r" + "un", lambda self: None)\n'],+ ])('blocks publication of omitted runtime-installed %s methods', (extension, oldSource, newSource) => {+ const path = `src/dynamic.${extension}`;+ const f = symbolFixture(2, { [path]: oldSource });+ const previous = JSON.parse(f.persisted()[0]);+ const method = { ...f.methodNodes[0], id: `function:${path}:A.run`, name: 'A.run', filePath: path };+ previous.nodes.push(method);+ writeFileSync(join(f.dataDir, 'knowledge-graph.json'), JSON.stringify(previous));+ writeProjectFile(f.root, path, newSource);+ commit(f.root, 'install method dynamically');+ const before = f.persisted();+ expect(prepare(f.root, f.baseCommit).plan.filesToReanalyze).toContain(path);+ f.write('batch-1.json', { nodes: [previous.nodes.find(node => node.id === `file:${path}`)], edges: [] });+ expect(spawnSync(python, [mergeScript, f.root]).status).toBe(1);+ expect(f.read('incremental-symbol-report.json').files.find(file => file.filePath === path).missing[0].status).toBe('unknown');+ expect(spawnSync(process.execPath, [finalizeScript, f.root]).status).toBe(1);+ expect(f.persisted()).toEqual(before);+ });+it('reanalyzes changed Rust trait identities and blocks publication with unresolved receivers', () => {const path = 'src/method.rs';const f = symbolFixture(2, { [path]: 'impl TraitA for A { fn run(&self) {} }\n' });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.tsindex 9ca7280b..bc661637 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@@ -304,9 +304,26 @@ export class TreeSitterPlugin implements AnalyzerPlugin {);const isJavaScriptExtractor = extractor.languageIds.some(id => id === "typescript" || id === "javascript");const propertyDefinitionNames = new Set(["defineProperty", "defineProperties", "__defineGetter__", "__defineSetter__"]);+ const runtimeInstallers = new Set<string>();+ if (isJavaScriptExtractor) {+ for (const name of ["eval", "Function"]) runtimeInstallers.add(name);+ }+ if (extractor.languageIds.includes("ruby")) {+ for (const name of ["define_method", "define_singleton_method", "alias_method", "attr_accessor", "attr_reader",+ "attr_writer", "class_eval", "module_eval", "instance_eval", "class_exec", "module_exec", "instance_exec",+ "eval", "send", "public_send", "__send__"]) runtimeInstallers.add(name);+ }+ if (extractor.languageIds.includes("python")) {+ for (const name of ["setattr", "__setattr__", "__dict__", "exec", "eval", "type", "new_class"]) {+ runtimeInstallers.add(name);+ }+ }const pending = [tree.rootNode];while (pending.length > 0) {const node = pending.pop()!;+ // Name references also cover local aliases and dynamic dispatch. These+ // languages can install methods without any structural declaration.+ if (node.childCount === 0 && runtimeInstallers.has(node.text)) hasUnresolvedNames = true;if (isJavaScriptExtractor) {// Runtime property installers are not structural declarations. Mark// references as well as calls so local aliases/destructuring cannotdiff --git a/understand-anything-plugin/skills/understand/SKILL.md b/understand-anything-plugin/skills/understand/SKILL.mdindex 4af941ed..6bcd19bf 100644--- a/understand-anything-plugin/skills/understand/SKILL.md+++ b/understand-anything-plugin/skills/understand/SKILL.md@@ -420,6 +420,8 @@ A syntactically valid parse is insufficient to prove deletion when declaration nRuntime property-definition APIs (including `Object.defineProperty`, `Reflect`, and locally aliased property installers) and computed callees also make absence unconfirmed. The structural extractor does not evaluate runtime property creation; such evidence blocks automatic deletion confirmation even when the remaining declarations parse successfully.+The same conservative rule applies to Ruby method installers/dynamic dispatch (such as `define_method`, `alias_method`, `send`, and class evaluation), Python attribute/class installers (such as `setattr`, `__dict__`, and `type`), and dynamic code evaluation. References to these APIs can establish uncertainty even through local aliases; ordinary source-confirmed Ruby/Python method deletions remain supported.+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.When the report has `unresolvedFiles`, prepare exactly one repair: