Skip to content

Call resolver: follow barrel re-exports (__init__.py, index.ts) — Python resolution recall 72% → 90% - #3689

Merged
squid-protocol merged 1 commit into
mainfrom
claude/resolver-reexports
Sep 25, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
claude/resolver-reexports

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

A Level 2 (call-graph resolution, epic #3265) improvement found by breaking down where the resolver loses pyan3's edges on language-crucible's Python repos.

Problem. The biggest single loss was tie (308 edges): the engine had the callee name, but ended up with several equally plausible definitions. The typical case is from fastapi import Depends in a test:

  • The import edge lands on fastapi/__init__.py, a barrel that only re-exports: from .param_functions import Depends as Depends.
  • The resolver's import step finds no Depends defined in the barrel.
  • So the call falls through to a repository-wide name search, where the Depends function and class tie.

Fix (gitgalaxy/core/call_resolver.py, _with_reexports):

  • When a file imports a barrel (__init__.py, or index.{js,ts,tsx,jsx,mjs,cjs,mts}), it can also see the files that barrel imports. Barrels importing barrels are followed at most 2 hops.
  • Only barrels are expanded. Importing an ordinary module still does not make that module's own imports visible, which keeps "everything imports everything" out.
  • No new resolution step and no schema change: these links resolve through the existing import step.

Type of change

  • Bug fix
  • Parsing or engine logic (gitgalaxy/core/call_resolver.py)

Measured: call_graph_resolution.py python (pyan3 reference, language-crucible)

metric before after
confident precision 98.7% (1,277 judged) 99.4% (1,567 judged)
edge recall (share of pyan's edges linked confidently) 36.1% 44.6%
resolution recall (pyan edges whose callee name the engine extracted) 71.8% 90.2%

tests/call_graph_resolution_baseline.json is regenerated. pyan3 is a reference, not ground truth: "wrong" means pyan links the same caller to a different function of that name.

Golden masters

Both fixtures re-blessed with crucible_check.py --mode both --update --yes. The 48 differences per fixture were all reviewed; the count is below the 50-line display cap, so none were hidden. They're all downstream of fastapi calls that now land on the defining module:

file direct downstream / Popularity Rank
fastapi/param_functions.py 2 → 92 (every Depends(...) in the tests)
fastapi/applications.py 1 → 44 (FastAPI(...))
fastapi/routing.py 6 → 13
fastapi/datastructures.py 7 → 11
fastapi/exceptions.py 28 → 32
fastapi/background.py 1 → 3

The remaining differences follow from those:

  • corpus-wide Composition Fit z-scores in other languages (a global distribution, so any file's shift moves every z-score);
  • network_macro (avg path length, modularity, assortativity);
  • three forensic top lists.

Tests

tests/core_engine/test_call_resolver.py adds four tests:

  • a barrel re-export becomes an import link;
  • an ordinary module does not re-export its imports;
  • nested barrels are followed two hops;
  • a TypeScript index.ts barrel is followed.

Verification

$ pytest tests/                                               -- 11408 passed, 334 skipped, 0 failed
$ PATH=.venv/bin:$PATH python tests/tools/audit_check.py      -- all clear (ruff, mypy, dead-key, ast-accuracy)
$ python tests/tools/call_graph_resolution.py python --regenerate
$ python tests/tools/crucible_check.py --mode both --update --yes   -- 48 differences each, reviewed above

A sibling PR (constructor calls → constructor method) also touches call_resolver.py and both golden masters. Whichever merges second needs a golden-master re-bless.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr


Generated by Claude Code

…e import step

`from fastapi import Depends` resolves to fastapi/__init__.py, which only
re-exports Depends from param_functions.py, so the import step found no
definition and the call fell to a repository-wide name search (a tie). A
caller that imports a barrel file now also sees what the barrel imports, at
most two barrel hops deep; importing an ordinary module still does not make
its imports visible.

call_graph_resolution.py python (pyan3, language-crucible): confident
precision 98.7 -> 99.4 (1277 -> 1567 judged), recall 36.1 -> 44.6,
resolution recall 71.8 -> 90.2. Baseline regenerated.

Golden masters (both): 48 values, all downstream of fastapi links that
now land on the defining module -- param_functions.py direct downstream
2 -> 92, applications.py 1 -> 44, routing.py 6 -> 13 -- plus the corpus-wide
Composition Fit z-scores, network macros and forensic top lists they move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
@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 3fcb768 into main Sep 25, 2026
31 checks passed
@squid-protocol
squid-protocol deleted the claude/resolver-reexports branch September 25, 2026 22:35
squid-protocol pushed a commit that referenced this pull request Sep 25, 2026
…tructors

Kept both test sections in test_call_resolver.py; took main's side for the
resolution baseline and golden masters, then regenerated them with both
changes: call_graph_resolution.py python -> confident precision 99.3%
(1687 judged), recall 48.0%, resolution recall 90.2%. Golden masters move
4 values each (network_macro, one forensic top list).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
@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.

2 participants