aft_callgraph: resolve Python cross-file and function-local imports (#1126)

AF
10h ago
+931-33

Public issue #1126 (and the details the same reporter gave in #1130): aft_callgraph callers returned a bare "0 callers" for a Python function called from another file through from mod import func, while same-file and TypeScript calls resolved.

What changes:

  • Python import bindings now resolve cross-file calls for top-level and function-local from mod import func, package-relative imports, aliases, and import mod; mod.f().
  • An unrelated function with the same name is never bound.
  • When some callers were found but there are also unresolved calls with the queried name, caller and impact results now say so, using the approved warning. The zero-caller warning already on main is unchanged.
  • The call-graph build output version moves to v22 (one rebuild per project), and the active-view producer to v13.

Tests: callgraph_python_imports_resolve_without_same_name_fallback and the integration callgraph tests cover each import form, the negative same-name case and a TypeScript control; the warning sentence is pinned byte for byte, with singular, plural and capped variants in library tests. Remote Linux 12-core runs plus Windows compile passed for the worker; CI is the gate here.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes Python cross-file caller resolution in aft_callgraph so from mod import func, relative and aliased imports, and import mod; mod.f() calls are attributed to the imported target instead of returning "0 callers."

  • Resolves import bindings lexically per call scope; an unrelated same-named function is never bound, and local definitions shadow imports.
  • When callers are found but matching unresolved same-name call sites remain, callers and impact answers now disclose the bounded unresolved count.
  • Bumps the call-graph build output to v22 and the producer to v13, so projects rebuild once.
  • Adds subc startup-phase tracing and attach-failure diagnostics that report child exit status and stderr.