graphify icon indicating copy to clipboard operation
graphify copied to clipboard

affected <Class> misses callers bound to the class's method nodes (post-#1634 granularity) — include member methods as reverse-traversal roots

Open krishnateja7 opened this issue 4 months ago • 3 comments

Enhancement request, follow-up to #1634 (verified working on 0.9.6 — this is about query-side traversal, not extraction). Generic across languages, though we hit it from Ruby.

Symptom

#1634 correctly binds Service.call to the def self.call method node when one exists — precise and the right choice. But affected <ClassLabel> traverses only:

Relations: calls, indirect_call, references, imports, imports_from, re_exports, inherits, extends, implements, uses, mixes_in, embeds

method / contains are (correctly, for forward noise reasons) not in that list — which means an inbound caller edge that lands on a method node of a class is unreachable when you query blast radius from the class. The more precisely #1634 binds, the fewer callers class-level affected sees.

Measured scale (our graph, 0.9.6)

  • 365 cross-file calls/references edges target Ruby method nodes.
  • For 89 of them, the caller has no parallel edge to the owning class/module node — those callers are invisible to affected <Class>.
  • That 89 is a lower bound on the general case: we run a Rails-truth sidecar that appends class→class edges for exactly this reason, and the pair-dedup means many would-be-missing pairs are already bridged by it. A stock install would miss more.

Concrete shape: Draft::SnapshotService here has a single inbound references edge on its class node, while callers of its class methods bind at method granularity — affected "SnapshotService" reports one node.

Ask

When the query root is a class/module node, include its member method nodes as additional traversal roots for the reverse direction — i.e., one contains/method hop outward from the root at query time, before the normal relation-filtered walk. That keeps method/contains out of the general traversal (no noise change anywhere else) while making affected <Class> see callers that #1634 binds at method level.

An alternative with the same effect: emit a low-weight rollup edge caller --calls--> Class alongside each caller --calls--> Class#method binding. The query-time hop is probably cleaner (no link inflation).

Environment

graphifyy 0.9.6 (uv tool), macOS, Rails repo as in #1666 (~11.8k nodes / ~19.8k links).

krishnateja7 avatar Jul 04 '26 20:07 krishnateja7

Done in 6631af7 (v8, ships in 0.9.7). Thanks for the precise framing — implemented exactly the query-time hop you proposed.

affected <Class> now seeds its reverse walk with the root's own member nodes (one method/contains hop outward) before the normal relation-filtered traversal. So a caller that binds to Class#method (as #1634 now does for Service.call -> def self.call) is reachable from the class. method/contains stay out of the general walk, so there is no forward-noise change anywhere else, and the seeded member nodes are not themselves reported as hits. Verified your shape: a caller of a class method now shows up in affected <Class>, and a downstream class discovered mid-walk does not get its methods expanded (only the root's).

safishamsi avatar Jul 05 '26 10:07 safishamsi

Thank you, the member-node reverse-seeding is exactly the query-time hop we hoped for. Same status as #1668: on 0.9.6 here, waiting on the 0.9.7 release to verify. This is the fix that decides how much of our class-level sidecar we can drop (we append class-to-class edges precisely because affected could not see method-bound callers), so I will re-run our 89-missing-caller measurement against 0.9.7 and confirm those sidecar rows become redundant. Will follow up with numbers.

krishnateja7 avatar Jul 05 '26 20:07 krishnateja7

Following up with the numbers I promised, measured on the 0.9.7 release against our Rails app.

Both fixes verified working end to end:

  • #1668: 9 mixes_in edges in our graph, and the exact example from that issue now lights up (affected SealedEntriesProtection returns RosterSnapshot [mixes_in]).
  • #1669: affected <Class> now returns method-bound callers. Spot check: affected SettleService went from empty to 8 callers (jobs, correction services, integration specs), which is exactly the class of results we were patching in by hand.

Redundancy measurement (our sidecar appends 938 class-level edges to work around what upstream could not express; we replayed your 0.9.7 depth-1 affected semantics, member seeding included, over upstream-only links):

  • Pre-0.9.7 semantics: 3 of 938 sidecar edges were redundant.
  • On 0.9.7: 247 of 938 are now redundant, and 241 of those are class-level call edges (241 of our 403 calls edges, about 60 percent). That is precisely the sub-source #1669 targeted, so the fix does what it says on real data.
  • What remains genuinely residual, in case it is useful for roadmap: constant reads/references between classes (279 of 283 of our references edges; upstream binds calls at method granularity but does not capture bare constant references like a Blueprint reading another Blueprint or a model constant), ActiveRecord association edges (194 of 196), and our ActionCable channel-to-frontend seam (56 of 56). Those categories have essentially zero upstream overlap today.

Net effect for us: the query-time hop removed the need for the majority of our class-level call patching without any graph noise, since the overlapping pairs just deduplicate at query time. Thanks for turning both of these around so quickly.

krishnateja7 avatar Jul 06 '26 03:07 krishnateja7