Repository navigation
Description
Setup: 0.9.17, uv, macOS, same Rails repo as #1634 / #1640 / #1666 / #1784.
First: the #1784 fix works exactly as specified. All 44 of our tracked .rake files now extract (81 nodes), helper classes and methods inside them get nodes, and their cross-file calls resolve. Thank you for the fast turnaround, and for applying the full seven-gate map.
Re-running our recall grading after the upgrade surfaced the next layer down. It is not a Ruby routing bug (it behaves identically in every language we probed), so filing it separately as a design/feature request.
The property: only calls made inside a definition context (a method, function, or class body) get a caller node. Code at the top level of a file, or inside a DSL block, has no enclosing definition, so its calls and constant references attach to nothing: no edge is emitted at all. The file node exists (and carries contains edges to any definitions), but nothing binds the file's top-level behavior to the things it uses.
Repro (five files, three languages):
# widget.rb
class Widget
def self.tally
42
end
end
# incontext.rb (control: same call, inside a method)
class Runner
def self.go
Widget.tally
end
end
# toplevel.rb
Widget.tally
# blockcall.rb (the Rake shape: plain Ruby, call inside a DSL block)
namespace :ops do
task fix: :environment do
Widget.tally
end
endPlus the same top-level pattern in Python (import widget; widget.tally()) and JS (import { tally } from './widget.js'; tally()).
graphify extract . --code-only yields 14 nodes, 7 edges. The control resolves perfectly: incontext_runner_go -[calls]-> widget_widget_tally. The other four callers (toplevel.rb, blockcall.rb, toplevel.py, toplevel.js) each get a file node and zero outgoing edges. The call site is byte-identical to the control; only the missing enclosing definition differs.
Why it matters on a real repo: rake task bodies are almost entirely task do ... end blocks. In a 13-entity blast-radius grading on our Rails repo (affected --depth 1 against comment-filtered grep ground truth, same method as #1784), 79 true dependents were rake files. Exactly 9 of them have edges today, the ones whose reference happens to sit inside a helper method: 11.4% recall, against 95.8% on .rb files. The same shape covers Rails initializers, db/seeds.rb, migration-adjacent backfill scripts, Python module-level wiring, and JS entry points. These are precisely the files a blast-radius query most needs to surface: ops and data-repair scripts that break silently when a class they use changes.
Proposal: when a call or constant reference has no enclosing definition, bind it to the FILE node as the caller. The file node already exists and already carries contains, so this adds outgoing calls / references edges to a node that is already the natural home for script-level behavior, and affected becomes complete for script-shaped code. Two softer landings if the full version feels too aggressive:
- gate it behind a flag or config key, since it changes what
affectedreturns on every corpus (in our view for the better, but it is a semantics change), or - start Ruby-only, where the pain concentrates (the Rake DSL, initializers, seeds), and extend later.
Happy to re-run our census + recall grading on whichever release this lands in, as before.
Activity
Rishet11 commentedon Jul 18, 2026
I have a fix for this on a branch, opening a PR against v8 shortly. Approach: a second walk over the file root with the file node as caller, emitting only direct calls edges (indirect dispatch and references keep their dedicated passes). Java is skipped since it has no top-level statements.
feat(extract): bind top-level / script-context calls to the file node…
test: add Ruby top-level and rake-task-block caller coverage for Grap…
fix(extract): attribute top-level calls to a per-file entry node (Gra…
test(extract): prove top-level calls reach graph.json, not just extra…