Skip to content

Benchmark call-graph accuracy (#3332) + two resolver fixes it found - #3378

Merged
squid-protocol merged 2 commits into
mainfrom
feat/3332-call-graph-benchmark
Sep 23, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feat/3332-call-graph-benchmark

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

#3265 step 5. It publishes the first accuracy numbers for the call graph, and fixes the two resolver bugs those numbers exposed.

Level 1: callee-name extraction (tests/tools/call_graph_accuracy.py)

  • Method: the engine's calls_out_to against tree-sitter call nodes. The tree-sitter side names each callee by its rightmost identifier, attributes it to the innermost function, and applies the #3265 step 0: state the calls_out contract (what counts as a call) #3327 rules (constructors and macros count, recursion is dropped).
  • Scope: the pinned crucible, via one in-process scan. Only functions both sides find are scored; tree_sitter_accuracy_audit owns function detection.
  • Gate: the baseline is committed, and --ci fails a drop of more than 0.5 pp.
language functions precision recall
c 2,559 99.3% 95.7%
java 735 96.9% 96.9%
python 4,045 92.1% 89.7%
go 1,294 90.3% 92.2%
csharp 650 89.5% 97.2%
php 1,548 88.1% 98.3%
cpp 1,280 87.4% 93.4%
rust 1,774 84.9% 85.5%
typescript 2,847 80.7% 90.6%
javascript 619 78.4% 94.4%
ruby 338 89.8% 33.7%

Where the gaps come from (--samples N prints them):

Level 2: resolution correctness (tests/tools/call_graph_resolution.py)

Python vs pyan3. pyan3 is already in requirements, runs on the crucible's six repos, and gives 14.6k edges. It is a reference, not an oracle.

links agree wrong target unconfirmed precision
confident (graph edges) 1,500 62 406 96.0%
ambiguous (never edges) 61 10 41 85.9%

COBOL vs the hand-verified answer keys (mainframe_corpus.py fetch+scan): every confident PERFORM link must land on a real, live unit of the same program.

  • zopeneditor: 86/86
  • cbsa: 348/348

Two resolver bugs Level 2 found (each pinned by a test that fails before the fix)

  1. Shared class/program name. zopeneditor's SAM1.cbl and SAM1LIB.cbl both declare PROGRAM-ID SAM1, and SAM1LIB's own PERFORMs resolved into SAM1.cbl because the owner index kept one definition per name. It now keeps all of them and prefers the caller's own file, then the nearest. zopeneditor went 34.9% → 100%. The same fix covers two same-named classes in different packages.
  2. Untyped receiver with several candidate classes. In cython's Nodes.py, self.body.generate_execution_code() was marked confident because the caller's own file defines the method, on about 40 classes. It's now confident only when exactly one visible class defines the method, and receiver (ambiguous) otherwise.

Not in this PR

The full suite passes, the golden crucible is unchanged, and the ruff, mypy and dead_key audits are clean. Per CLAUDE.md, these are the first published numbers, and no README or badge claim is made here.

Closes #3332

🤖 Generated with Claude Code

squid-protocol and others added 2 commits September 23, 2026 12:52
#3265 step 5.

Level 1, tests/tools/call_graph_accuracy.py: precision/recall of each
function's calls_out_to against tree-sitter call nodes. It uses one crucible
scan and 11 C-style languages, with both sides following the #3327 contract.
The baseline is committed and --ci gates a drop of more than 0.5pp.
- Most languages score 85-99% on both precision and recall.
- Lost precision is #3359's keyword/annotation captures.
- Lost recall is #3361's built-in filter.
- ruby recall is 33.7% (paren-less calls; filed #3377).

Level 2, tests/tools/call_graph_resolution.py:
- python vs pyan3 on the crucible repos: confident links 96.0% precision /
  4.0% wrong-target; ambiguous links 85.9% / 14.1%. That 3.5x gap is the
  evidence for keeping ambiguous links out of the graph. Resolution recall is
  30.9% of the pyan edges whose name was extracted.
- COBOL vs the hand-verified answer keys: 434/434 confident PERFORM links land
  on a real, live unit of the same program.

Resolver fixes, each found by Level 2 and pinned by a test that fails before it:
- A class name shared by several files (zopeneditor's SAM1 and SAM1LIB both
  declare PROGRAM-ID SAM1) resolved to the first file's method. It now prefers
  the caller's own file, then the nearest. zopeneditor goes 34.9% -> 100%.
- An untyped receiver (`self.body.gen()`) was confident whenever a visible
  file defined the method, even on ~40 classes. It is now confident only when
  exactly one visible class defines it, and `receiver` (ambiguous) otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Runs call_graph_accuracy.py --ci on PRs that touch extraction, the tool or
its baseline, with the same pinned crucible and fork fallback as the
tree-sitter accuracy audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@squid-protocol

Copy link
Copy Markdown
Owner Author

Update: the token now has the workflow scope, so .github/workflows/call-graph-accuracy-audit.yml is pushed on this branch (ab38397). The Level-1 gate now runs on PRs that touch extraction.

@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 09a8b56 into main Sep 23, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the feat/3332-call-graph-benchmark branch September 23, 2026 17:06
@squid-protocol squid-protocol added this to the Compiler call-graph comparison milestone Sep 26, 2026 — with Claude
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.

#3265 step 5: benchmark call-graph accuracy (tree-sitter call tags + type-aware tools)

1 participant