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): recognize Ruby attr as a runtime method installer

Lum11040948ac150429
diff --git a/tests/skill/understand/test_incremental_symbols.test.mjs b/tests/skill/understand/test_incremental_symbols.test.mjs
index a6bdb746..6312c94d 100644
--- a/tests/skill/understand/test_incremental_symbols.test.mjs
+++ b/tests/skill/understand/test_incremental_symbols.test.mjs
@@ -20,6 +20,7 @@ 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 attr(("r" + "un").to_sym)\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'],
diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjs
index 4c667c2b..480e34f5 100644
--- a/tests/skill/understand/test_prepare_incremental.test.mjs
+++ b/tests/skill/understand/test_prepare_incremental.test.mjs
@@ -234,6 +234,7 @@ 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'],
+ ['rb', 'class A\n def run; end\nend\n', 'class A\n def keep; end\n attr(("r" + "un").to_sym)\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}`;
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 bc661637..eb13b613 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
@@ -309,7 +309,7 @@ export class TreeSitterPlugin implements AnalyzerPlugin {
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",
+ for (const name of ["define_method", "define_singleton_method", "alias_method", "attr", "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);
}