Skip to content

fix(affected): walk the callers of the supertype member an overriding method overrides - #4331

Closed
rohit-jsfreaky wants to merge 2 commits into
Graphify-Labs:v8from
rohit-jsfreaky:fix/affected-overridden-callers
Closed

rohit-jsfreaky wants to merge 2 commits into
Graphify-Labs:v8from
rohit-jsfreaky:fix/affected-overridden-callers

Conversation

@rohit-jsfreaky

@rohit-jsfreaky rohit-jsfreaky commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #4330.

affected_nodes now treats a method's overridden members as stepping stones. When the walk reaches a method node, it finds the method's class (incoming method edge), that class's supertypes (inherits / extends / implements, transitively), and their same-named members, and walks those members' callers at the same depth. The overridden member itself is not reported (it did not change), unless a real edge reaches it too (a base overload calling the abstract member shares its node). It runs at query time: no new edges, no graph or cache change, every language with those edges (Java, TypeScript, Python, Kotlin, C#, ...).

This is class-hierarchy analysis: a caller bound to Base.m is listed for every override of m, since any of them can run there.

Type of change

  • Bug fix

Verification & Invariants

Invariant: a caller bound to a member that a method overrides is affected by that method, at the depth of a direct caller.

Against javac (callers of each overriding method that reach it only through the member it overrides, by file), 0.9.85 vs this branch, affected(method, depth=1):

project callers through the overridden member listed before listed after
jackson-core 1125 6 (1%) 707 (63%)
commons-io 637 0 (0%) 480 (75%)
jsoup 452 3 (1%) 298 (66%)
commons-lang 341 1 (0%) 160 (47%)

The rest are calls with no calls edge at all (receiver types graphify does not resolve yet), not the walk. TypeScript, callers of overridden members on graphify's own edges: TypeORM 1737 missed -> 0, NestJS 98 -> 0.

Cost, every method of the project as a seed, depth 2: jackson-core 0.01 -> 0.30 ms per query, jsoup 0.02 -> 0.12 ms, TypeORM 0.01 -> 0.14 ms; mean hits per seed 3.5 -> 6.3 / 4.2 -> 6.1 / 2.2 -> 3.7.

Python test suites, where a crash is inserted in a function and the failing test files are the truth (click 80 functions, flask 80, httpx 37): unchanged at depth 2; httpx at depth 50 33% -> 37% of failing test files found.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary (one function, query time only).
  • Added a regression test: tests/test_affected_overrides.py, 11 tests; 9 fail on 0.9.85; test_unrelated_same_named_method_is_not_walked and test_undirected_graph_is_unchanged pass on both (guards). test_recursive_overridden_member_is_a_caller_of_the_override pins that a self-recursive overridden member is reported. End-to-end on Java, TypeScript and Python extraction.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

Limitations: members are matched by label, so a same-named static method in a subclass (hiding, not overriding) and Java overloads sharing one node are walked too; an undirected graph has no supertype direction and is left as before.

How was this tested?

python -m pytest tests/test_affected_overrides.py -q        # 11 passed (on 0.9.85: 9 failed, 2 passed)
python -m pytest tests/test_affected*.py tests/test_js_dynamic_import_affected.py tests/test_indirect_dispatch.py -q   # 78 passed
python -m pytest tests -q                                    # run once with this PR and my other open PR (pytest fixture receivers) applied together: 3 failed, 7161 passed, 33 skipped; clean 0.9.85 on this machine: the same 3 failed, 7143 passed (test_3357_minimal_reproduction_no_config_emits_calls_edge and the two test_absolute_path_lookup_skips_getcwd), 0 new
python -m ruff check graphify/affected.py tests/test_affected_overrides.py   # All checks passed
pyright graphify/affected.py tests/test_affected_overrides.py   # 2 errors, same 2 as 0.9.85, 0 new

Graphify-specific checklist

  • I updated generated skill artifacts — not needed, no skill fragments touched.
  • I confirmed that AST/structural extraction remains deterministic.
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed that no API keys or local-only graph data are included.
  • I disclosed AI authorship in my commit messages.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B8gwEpjajiWHVW3c9smuKf

@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @rohit-jsfreaky. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 11, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 sampled, not proven).

Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.


Graphify review — findings

Makes affected_nodes follow method overrides, so changing a method also reports callers bound to the same-named member of any supertype its class transitively inherits, extends or implements (e.g. v.head() typed NodeVisitor when Printer.head changes). That supertype member is walked at the same depth as the override but reported only if a real edge also reaches it, so depth limits stay exact. The expansion needs edge direction, so undirected graphs get no override expansion and behave as before.

Worth a look

  • Recursive overridden member is reported as an affected hit via its own self-loop — graphify/affected.py:311 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 271 functions depend on the 35 functions this change touches.

Health — grade A; 5 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • main() — 103 callers, 3 callees (high)
  • dispatch_command() — 2 callers, 130 callees (high)
  • _run_cli() — 8 callers, 8 callees (high)
  • resolve_seed() — 12 callers, 4 callees (high)
  • test_poisoned_manifest_is_healed() — 0 callers, 6 callees (medium)

Verification — 271 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 85 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

12 of 368 test file(s) selected (3%) via static blast radius.

  • tests/test_affected_cli.py — impact
  • tests/test_affected_defines.py — impact
  • tests/test_affected_member_seed.py — impact
  • tests/test_affected_overrides.py — impact, changed-test
  • tests/test_corrupt_graph_json.py — impact
  • tests/test_indirect_call_nested_closure_shadow.py — impact
  • tests/test_indirect_dispatch.py — impact
  • tests/test_indirect_dispatch_assign_return.py — impact
  • tests/test_indirect_dispatch_getattr.py — impact
  • tests/test_js_dynamic_import_affected.py — impact
  • tests/test_js_dynamic_imports.py — impact
  • tests/test_scala_self_type.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Formal verification

No difference found (not proven): No behavior difference found in affected\_nodes (not a proof).

The verifier ran both versions of affected\_nodes on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

@rohit-jsfreaky

Copy link
Copy Markdown
Contributor Author

Recursive overridden member is reported as an affected hit via its own self-loop

Intended. A self-loop on Base.m is Base.m calling m on its own object, and for an Impl instance that call dispatches to Impl.m, so Base.m is a caller of the override, the same as a base overload calling the abstract member (the case the stepping-stone rule exists for: JsonParser.getBinaryValue() calling its own overload that ParserBase overrides, 124 such callers in jackson-core). Pinned in a27924f: test_recursive_overridden_member_is_a_caller_of_the_override (affected(Impl.m) == {Base.m: 1}).

@Graphify-Labs please re-review.

safishamsi pushed a commit that referenced this pull request Oct 11, 2026
…hod overrides (#4330)

Landed from PR #4331 (squashed, authorship preserved).
@safishamsi

Copy link
Copy Markdown
Member

Landed in 0.9.86 (now on PyPI) via an authorship-preserving cherry-pick, so your commit authorship is retained. Thank you, @rohit-jsfreaky!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: affected on an overriding method misses every caller that reaches it through the base or interface method

2 participants