Skip to content

Resolve Kotlin object/class qualified member calls across files - #3598

Closed
ayushcodes10 wants to merge 6 commits into
Graphify-Labs:v8from
ayushcodes10:fix-1698-kotlin-object-cross-file-calls
Closed

ayushcodes10 wants to merge 6 commits into
Graphify-Labs:v8from
ayushcodes10:fix-1698-kotlin-object-cross-file-calls

Conversation

@ayushcodes10

Copy link
Copy Markdown
Contributor

Summary

Fixes #1698.

A Kotlin call on an object or class qualified receiver (Config.load()) only resolved when the receiver's declaration lived in the same file. The gap sits at the intersection of three existing pieces of behavior:

Changes

  • Capture the receiver for Kotlin's two segment qualified navigation shape and thread it into raw_calls.
  • Add _resolve_kotlin_member_calls, mirroring the existing _resolve_kotlin_qualified_calls and the type_by_name / methods_by_type shape _resolve_swift_member_calls already uses: index Kotlin sourced classes and objects by bare name, resolve the receiver against that index, then look up the callee among that type's methods. Both steps bail on anything but exactly one candidate, the same god node guard every cross file resolver in this module already applies.
  • Register the new resolver for .kt / .kts files.

Test plan

  • New regression tests in tests/test_kotlin_grammar.py:
    • the issue's own cross file case now produces an EXTRACTED calls edge
    • the pre existing same file case is unaffected (negative control)
    • a receiver defined identically in two packages correctly yields no edge (god node guard)
  • Full suite: 5596 passed, 68 skipped, 2 deselected, no regressions.
  • python3 -m tools.skillgen --check: OK.

🤖 Generated with Claude Code

ayushcodes10 and others added 6 commits September 16, 2026 14:18
Toward issue 1698: a call like MessageHelper.isRoomClosed() has
exactly two navigation segments, so the existing fully qualified
prefix capture (which only fires at three or more segments) never
sees it, and the code deliberately never stamps member_receiver for
this shape either, since that would defer the in file bare name
lookup that already resolves the same file case correctly.

This adds the new variable with no behavior change yet; capturing
into it and threading it through to raw_calls lands in the next
commits.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Still toward issue 1698, still no behavior change: the variable is
computed but nothing reads it yet.

A capitalized two segment receiver (MessageHelper in
MessageHelper.isRoomClosed()) names an object singleton or a class or
companion member, statically unambiguous in source. Captured
separately from member_receiver so the existing in file bare name
lookup and its capitalized receiver deferral guard are untouched;
threading this into raw_calls for a dedicated cross file resolver
lands next.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Still toward issue 1698. Still no observable behavior change on its
own: nothing reads the new kotlin_object_receiver field yet, so
existing edges are unaffected. The resolver that consumes it lands
in the next commit.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Fixes issue 1698.

Mirrors _resolve_kotlin_qualified_calls just above it and the same
type_by_name plus methods_by_type shape _resolve_swift_member_calls
uses for its own type qualified case: index every Kotlin sourced
class or object by its bare name, resolve the receiver against that
index, then look up the callee among that type's methods. Both steps
bail on anything but exactly one candidate, the same god node guard
every cross file resolver in this module already uses.

Verified end to end: the issue's own cross file repro now produces an
EXTRACTED calls edge, the same file control case is unaffected, and
two objects sharing the same name in different packages correctly
produce zero edges instead of an ambiguous guess.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Covers three cases: the new cross file resolution (Config.load() called
from another file resolves to object Config), a same file control to
prove the existing in file resolution is unaffected, and an ambiguous
receiver defined in two packages that must yield no edge under the
exactly one candidate guard.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@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.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Resolves Kotlin Receiver.method() calls (object singletons and class/companion members) across files via the new _resolve_kotlin_member_calls pass, which matches the capitalized receiver to its declaring Kotlin type and the callee to a single method on that type, emitting an EXTRACTED calls edge. A receiver name matching 2+ declared types, or a method matching 2+ methods on the resolved type, produces no edge rather than a guess, and the pass only fires when the engine's in-file bare-name lookup already failed. Adds kotlin_object_receiver capture in _extract_generic (two-segment nav with a capitalized head) to tag those calls in raw_calls for the new resolver to claim.

Worth a look

  • Method label strip('()') mismatch when method has parameters in label — graphify/extract.py:4770 · 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 — 2472 functions depend on the 703 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 637 callers, 45 callees
  • new: _rebuild_code() — 123 callers, 53 callees
  • new: _extract_generic() — 18 callers, 29 callees
  • new: extract_js() — 85 callers, 4 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: dispatch_command() — 2 callers, 125 callees
  • new: extract_objc() — 27 callers, 9 callees
  • new: _get_extractor() — 26 callers, 6 callees
  • …and 40 more — each is listed as a finding

Verification — 2472 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: 2297 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

283 of 283 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/test_affected_cli.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_agents_platform.py — full-run-safety
  • tests/test_analyze.py — full-run-safety
  • tests/test_anthropic_custom_endpoint.py — full-run-safety
  • tests/test_antigravity_install.py — full-run-safety
  • tests/test_apm_fallback_version.py — full-run-safety
  • tests/test_architecture_doc.py — full-run-safety
  • tests/test_astro_extraction.py — impact, full-run-safety
  • tests/test_astro_import_ids.py — impact, full-run-safety
  • tests/test_atomic_canvas_export.py — full-run-safety
  • tests/test_atomic_version_stamp.py — full-run-safety
  • tests/test_atomic_writes.py — full-run-safety
  • tests/test_backend_env_isolation.py — full-run-safety
  • tests/test_backend_extras.py — full-run-safety
  • tests/test_benchmark.py — full-run-safety
  • tests/test_benchmark_raw_graph.py — full-run-safety
  • tests/test_build.py — impact, full-run-safety
  • tests/test_build_merge_dedup_scope.py — full-run-safety
  • tests/test_build_merge_hyperedges_and_prune.py — full-run-safety
  • tests/test_build_merge_shrink_guard.py — full-run-safety
  • tests/test_builtin_global_type_refs.py — impact, full-run-safety
  • tests/test_cache.py — full-run-safety
  • tests/test_callflow_html.py — full-run-safety
  • tests/test_cargo_introspect.py — full-run-safety
  • tests/test_carried_hyperedge_remap.py — full-run-safety
  • tests/test_case_sensitive_resolution.py — impact, full-run-safety
  • tests/test_charmap_encoding.py — full-run-safety
  • tests/test_chunking.py — full-run-safety
  • tests/test_cjs_module_extension.py — impact, full-run-safety
  • tests/test_claude_cli_backend.py — full-run-safety
  • tests/test_claude_md.py — full-run-safety
  • tests/test_cli_broken_pipe.py — full-run-safety
  • tests/test_cli_export.py — full-run-safety
  • tests/test_cli_help.py — full-run-safety
  • tests/test_cluster.py — full-run-safety
  • tests/test_codebuddy.py — full-run-safety
  • tests/test_community_hub_labels.py — full-run-safety
  • tests/test_community_labels_skill.py — full-run-safety
  • tests/test_confidence.py — full-run-safety
  • tests/test_corrupt_graph_json.py — full-run-safety
  • tests/test_cpp_nested_and_cli.py — impact, full-run-safety
  • tests/test_cpp_objc_cross_file_calls.py — impact, full-run-safety
  • tests/test_cpp_preprocess.py — full-run-safety
  • tests/test_cross_extension_reexport_self_cycle.py — impact, full-run-safety
  • tests/test_cross_language_call_resolution.py — impact, full-run-safety
  • tests/test_cross_repo_external_call_guards.py — impact, full-run-safety
  • tests/test_cross_repo_member_calls.py — impact, full-run-safety
  • tests/test_cross_repo_shared_types.py — full-run-safety
  • tests/test_csharp_call_site_generic_args.py — impact, full-run-safety
  • … and 233 more

non-code file(s) changed (CHANGELOG.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (CHANGELOG.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests

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

Could not verify: Could not verify \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, 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: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set

· 48 more finding(s) on lines outside this diff (see the check run).

@ayushcodes10

Copy link
Copy Markdown
Contributor Author

Re: "Method label strip('()') mismatch when method has parameters in label" (graphify/extract.py:4770)

Checked this directly: every callable node label in the codebase, across all languages including Kotlin, is built from a hardcoded f".{name}()" template with literal empty parens (engine.py lines 2354, 2436, 2487, 4946) — never real parameter text. Confirmed by running the extractor on fun record(m: Money) { } (a method with a parameter): the label comes out as .record(), not .record(m: Money). tests/test_kotlin_grammar.py on this branch independently confirms the same convention throughout (.load(), .help(), .f(), .go(), .checkout(), .total() — always empty parens).

So .strip("()") on ".record()" correctly yields ".record", matching the wanted bare name. No fix needed here — false positive.

safishamsi added a commit that referenced this pull request Sep 18, 2026
…follow-up)

#3598 resolves Kotlin object/class-qualified member calls across files. Adds
two regression tests the PR omitted:

- a `companion object` member call (`Service.create()`), pinning the #2565
  enclosing-class attribution the resolver relies on;
- an incremental-rebuild test routed through the real watch._rebuild_code, so
  it actually exercises the context builder's allow-list carrying _callable_class
  + method edges (a hand-fed resolution_context_nodes list would bypass exactly
  the path that silently regressed in sibling PRs).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.64 (on PyPI). Cherry-picked with authorship preserved so it shows under your GitHub contributions. Thanks @ayushcodes10! (Added companion-object + real-incremental regression tests on merge.)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kotlin: cross-file calls to object (singleton) members produce no calls edges — same-file resolution works

2 participants