Skip to content

Call resolver: choose Java overloads by argument count; ties are ambiguous (#3835) - #3840

Merged
squid-protocol merged 1 commit into
mainfrom
claude/optimistic-heisenberg-bta91d
Sep 26, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
claude/optimistic-heisenberg-bta91d

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #3835 (epic #3772).

The problem: when a Java class has several methods of the same name (overloads), the resolver linked any call to one of them to whichever came first in the file. Measured vs scip-java on gson (#3838), 1,653 of 1,923 confident wrong links were that arbitrary pick.

This is option B from the plan: choose the overload by argument count, and leave the call ambiguous when the count can't choose.

  • Detector (detector.py, language flag calls_out_arities, Java only): records the distinct argument counts each callee is called with.
    • _call_arity makes one bounded, linear pass with no regex.
    • Commas inside nested calls, lambdas, array initializers and generic type arguments (new HashMap<K, V>(, Map.<K, V>of() don't count.
    • A < comparison (f(i < n, x)) isn't mistaken for type arguments.
  • Persistence:
  • Resolver (call_resolver.py, OVERLOAD_LANGS = {"java"}), for a confident call whose target has same-named siblings on the same class in the same file:
    • exactly one overload declares that many parameters: a confident link to it. A caller that calls two overloads gets two links; it used to get one.
    • several overloads match, or none does (varargs, or no count recorded): the new ambiguous step overload. That's a row, never an edge, the same rule as every other ambiguous step.
    • a single definition ignores argument counts entirely, so varargs or a miscount never demote it.
  • Tools:
    • overload joins the scorer's ambiguous steps;
    • triage gets an ambiguous/overload hint;
    • explain_call handles several rows per callee, and shows argument counts and each definition's parameter count.

Results vs scip-java on gson (7,858 reference edges)

metric before after
confident precision (gated) 59.8% (4,778 judged) 92.7% (3,474 judged)
recall (gated) 36.3% 41.0%
resolution recall (gated) 38.7% 43.6%
strict precision (JDK calls counted wrong; not gated) 54.4% 82.9%
wrong links that are only an overload choice 1,653 0
external / unmapped_dst (not gated) 473 / 161 407 / 42

Ungated moves, and why:

The simulation run before any code, assuming perfect argument counts, predicted about 92% and about 41%. The measured result matches it.

Net change in the other languages: Python and TypeScript are unchanged to the decimal, as shown below. The change is Java-only by construction, and a guard test pins that.

Known limit: same-arity overloads (fromJson(String, Class) vs fromJson(Reader, Type)) stay ambiguous. Choosing between them would need argument types, which a regex engine doesn't have.

Type of change

  • Engine: detector, recorder, rehydrator and resolver, Java-scoped. Plus tooling and docs.

CI checklist

  • python tests/tools/audit_check.py: all clear; format clean
  • New tests:
    • test_call_arity_counts_top_level_arguments and test_detector_java_records_call_site_arities;
    • five resolver tests: choice by count, two links, ambiguous tie / no-match / no-count, single definition untouched, Java-only guard;
    • the persistence round-trip.
  • Tests run with plain pytest from /tmp

Differential Scan target

  • Crucible: crucible_check.py in zero-dependency mode passes with no re-bless. The golden masters don't change, since overload choice stays within one file and ambiguous rows don't feed the file graph.
  • Full precision: tiktoken's host is blocked in this environment, so CI's crucible-audit (full-precision) is the check for that half.

Verification

python tests/tools/callgraph_check.py --skip tree-sitter:

PASS     gate:java          precision 92.7% (3474) recall 41.0% resolution 43.6%  [baseline 59.8% / 36.3% / 38.7%]
PASS     gate:python        precision 99.8% (1806) recall 51.6% resolution 97.5%  [baseline 99.8% / 51.6% / 97.5%]
PASS     gate:typescript    precision 99.9% (1520) recall 57.1% resolution 73.7%  [baseline 99.9% / 57.1% / 73.7%]
PASS     tests              320 passed
PASS     crucible           mode zero
PASS     lint:ruff / dead-key / mypy / format

The Java baseline is regenerated to the new numbers. The docs (graph_accuracy.md, function_call_graph.md, README, roadmap), the miss-sweep skill's pattern table, and the coverage chart are updated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AbvXUJpva5XxxbssoKG9Jt


Generated by Claude Code

…guous (#3835)

The detector records, for java (language flag calls_out_arities), the distinct
argument counts each callee is called with (_call_arity: one bounded linear
pass; commas inside nested calls, lambdas, initializers and generic type
arguments do not count). It is persisted (function_data and
synthetic_unit_data.calls_out_arities, healed into old DBs) and rehydrated.

For OVERLOAD_LANGS (java), a confident call to one of several overloads on a
class now links to the overload declaring that many parameters -- one row per
overload the counts pick, so a caller of two overloads gets both -- and a count
that matches several overloads or none becomes the ambiguous step `overload`
(a row, never an edge).

vs scip-java on gson: confident precision 59.8% -> 92.7%, recall 36.3% -> 41.0%,
resolution recall 38.7% -> 43.6%, strict precision 54.4% -> 82.9%; no wrong link
is an overload choice any more. Python and TypeScript unchanged; zero-dependency
golden masters unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AbvXUJpva5XxxbssoKG9Jt
@squid-protocol squid-protocol added this to the Compiler call-graph comparison milestone Sep 26, 2026 — with Claude
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine core-engine Modifications to the central physics and parsing engine labels Sep 26, 2026 — with Claude
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit d8e6270 into main Sep 26, 2026
46 of 47 checks passed
@squid-protocol
squid-protocol deleted the claude/optimistic-heisenberg-bta91d branch September 26, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended behavior or logic failure in the engine core-engine Modifications to the central physics and parsing engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Call resolver: Java overloads -- a confident link goes to an arbitrary overload of the right method

2 participants