Repository navigation
fix(extract): resolve Java/Kotlin imports and calls across the JVM (#4874) - #4879
Deepjyoti-Sarmah wants to merge 5 commits into
Conversation
|
Thanks for the pull request, @Deepjyoti-Sarmah. 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. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 2 changed function(s) (1 sampled, not proven, 1 not verified).
Formal verification. PR-changed functions: 1/2 verified (0 proven, 1 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: \_resolve\_kotlin\_member\_calls (vacuous: never exercised).
Graphify review — findings
Adds a JVM-wide resolution pass, _resolve_jvm_references, that indexes Java and Kotlin type nodes by package-qualified name and repoints imports, inherits, extends, implements and references edges to the declaring class. This lets Kotlin reach Java classes and Java reach Kotlin classes, and it only repoints when the written name matches exactly one sourced type. Ambiguous or unmatched names are left as they were, and the pass keeps the file-level import edge while adding a class-level one, so the duplicate-import risk lands on the Kotlin resolver that runs afterwards. Widens the Kotlin member-call class index to cover any JVM source file instead of just .kt/.kts, so Kotlin calls can bind to Java static methods. A class name that was previously unique to Kotlin can now collide with a Java class and become ambiguous. Adds tests/test_4874_jvm_resolution.py, which builds the issue's four-file Java/Kotlin project and checks that imports, inheritance and affected reach the class nodes, with controls for external imports, same-named classes across packages, and non-JVM definitions.
Worth a look
- Import edges are duplicated when the Kotlin import resolver runs after the JVM pass —
graphify/extract.py:6980· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
- Kotlin member-call class index now includes Java classes, making previously-unique Kotlin classes ambiguous —
graphify/extract.py:7807· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 3381 functions depend on the 362 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1055 callers, 63 callees
Verification — 3381 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: 3126 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
222 of 470 test file(s) selected (47%) via static blast radius.
tests/test_4874_jvm_resolution.py— impact, changed-testtests/test_affected_overrides.py— impacttests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_blade_extractor.py— impacttests/test_build.py— impacttests/test_builtin_global_type_refs.py— impacttests/test_c_include_resolution.py— impacttests/test_cache.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_cjs_module_extension.py— impacttests/test_cobol_extractor.py— impacttests/test_cpp_method_declarations.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cpp_template_type_params.py— impacttests/test_cpp_type_alias.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_language_call_resolution.py— impacttests/test_cross_repo_external_call_guards.py— impacttests/test_cross_repo_member_calls.py— impacttests/test_csharp_call_site_generic_args.py— impacttests/test_csharp_delegate_declarations.py— impacttests/test_csharp_enum_members.py— impacttests/test_csharp_field_generic_args.py— impacttests/test_csharp_foreach_loop_variable.py— impacttests/test_csharp_generic_callsites.py— impacttests/test_csharp_interface_dispatch.py— impacttests/test_csharp_member_calls.py— impacttests/test_csharp_member_chain_calls.py— impacttests/test_csharp_member_nodes.py— impacttests/test_csharp_object_creation.py— impacttests/test_csharp_overloads.py— impacttests/test_csharp_partial_classes.py— impacttests/test_csharp_tuple_type_refs.py— impacttests/test_csharp_type_resolution.py— impacttests/test_csharp_underscore_collisions.py— impacttests/test_csharp_var_call_return_type.py— impacttests/test_csharp_verbatim_interpolation.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_duplicate_annotation_edges.py— impacttests/test_ejs_extractor.py— impacttests/test_elixir_defdelegate.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_keyword_def_calls.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_erlang_extractor.py— impact- … and 172 more
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.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.9.5 (2026-07-02) (lines 1367-1390): references changed symbolsLogger
Formal verification
Could not verify: Could not verify \_resolve\_kotlin\_member\_calls.
The verifier did not have enough to check \_resolve\_kotlin\_member\_calls, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous
No difference found (not proven): No behavior difference found in extract (not a proof).
The verifier ran both versions of extract 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.
· 1 more finding(s) on lines outside this diff (see the check run).
|
Landed in v0.9.100, now on PyPI (pip install graphifyy==0.9.100). Java and Kotlin imports, extends/implements and member calls resolve across files and languages. Thanks for the fix, @Deepjyoti-Sarmah. |
Summary
Java and Kotlin share package names, class names, and call sites. Graphify built its cross-file type index from one extension at a time, so each language could not see the other:
This PR builds one JVM-wide package and type index and uses it before the shared call-evidence pass runs. That gives imports, inheritance, references, and member calls one place to resolve the same namespace.
Closes #4874.
What does this PR do?
_jvm_package_name,_jvm_imports_by_file, and_resolve_jvm_referencesingraphify/extract.py.(package, type name).affected <File>still reaches importers._resolve_kotlin_member_callsaccept JVM receiver types instead of only.ktand.ktsfiles.Type of change
Evidence
Before:
affected "Logger"returned onlyJavaUser.java.affected "BaseScreen"returned onlyKotlinUser.kt.After:
The regression suite is 9 tests:
Full suite:
Verification & Invariants
The invariant: if a Java or Kotlin file imports a type that exists in the scanned corpus, and exactly one sourced declaration matches the written package and type name, the edge must reach that declaration node. If the candidate is missing or ambiguous, the reference stays unresolved.
0.9.97(0a8cd4e1) before changing code.The exact FQN is the only key used. Source-less stubs are not candidates, and two candidates produce no edge. That keeps these existing behaviours:
org.springframework.stereotype.Componentdoes not bind to a localComponent.a.Loggerandb.Loggerare separated by the import package.No AST cache schema changes. Resolution runs on every extraction, so a full rebuild is enough to heal an existing graph.
Known limitations:
package.Outer.Inneryet.per_fileresults. Unchanged JVM declarations still need to be added throughresolution_context_nodesfor warm updates to resolve exactly like a cold build.How was this tested?
The CLI output matches the expected result in #4874.
Merge Danger
Door: two-way. Reverting the branch restores the previous edges, and no persisted schema or cache format changes.
Blast Radius: resolver. Mixed Java/Kotlin repositories get new class-level edges. Single-language repositories and non-JVM languages keep their existing behaviour.
A graph built before this change may keep its old edges until a full rebuild. A warm
--updateis not guaranteed to repair it.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.