fix(python): avoid false ambiguity for aliased module imports - #2429
fix(python): avoid false ambiguity for aliased module imports#2429hopstreax wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR modifies the module-matching logic in _resolve_python_member_calls within graphify/extract.py. The condition for matching imported modules against a resolution key now prefers an alias match when the module has an alias entry, and otherwise falls back to comparing the module stem key. A new test is added in tests/test_extract.py covering the case where two imported modules share the same filename stem (one aliased, one not) to check that both calls resolve to their respective files.
No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1403 functions depend on the 465 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 360 callers, 29 callees
Verification — 1403 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: 1275 function(s) in the blast radius were not formally verified this run
· 1 more finding(s) on lines outside this diff (see the check run).
Summary
Fixes #2428.
Fix Python member-call resolution when multiple imported modules share the same filename stem but one of them is imported with an alias.
Previously, aliased imports were still matched by their module stem during
_resolve_python_member_calls. This could incorrectly introduce ambiguity when another imported module shared the same stem, causing validcallsedges to be skipped.For example:
The resolver incorrectly treated both
pkg.serviceandother.serviceas candidates for the receiverservice, even though Python only bindsother.servicetoother_service.Root Cause
The resolver matched imported modules using:
This allowed an aliased import to continue matching by its original module stem, creating false ambiguity whenever another imported module shared that stem.
Fix
Update
_resolve_python_member_callsso that:This aligns the resolver with Python's name-binding semantics while preserving existing behavior for non-aliased imports.
Tests
Added a regression test covering the following scenario:
from pkg import servicefrom other import service as other_serviceother_service.ping()service.register_user()The test verifies that both
callsedges are emitted.Additionally: