Skip to content

call resolver (ts/js): only a binding is bare-callable; signatures are never targets (#3757, #3758, #3759) - #3767

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 #3757, fixes #3758, fixes #3759.

The three issues share a root cause. In TypeScript and JavaScript, only a declaration binds a name that a bare call can reach. The resolver couldn't tell a declaration from the other things the detector extracts as functions:

Detector: def_shape (typescript/javascript only)

_slice_by_braces records one of three values on each TS/JS function:

def_shape what can a bare call reach it?
binding function f, const/let/var f = … yes
member object-literal method f() {}, property f: () => …, x.f = () => …, class method no, only through its object
signature interface member, abstract method, overload signature never: no code runs

Recorder

  • New column: function_data.def_shape (TEXT, NULL outside TS/JS), plus a _heal_column for existing DBs.
  • Delta scans: the state rehydrator already copies every function_data column into the rehydrated function, so a delta scan resolves exactly as a fresh one does. There's a new test for that.
  • JSON reports: the audit JSON's function section uses a fixed key list, so the field doesn't appear in the golden masters.

Resolver (core/call_resolver.py)

Measured

zod, TypeScript Level 2 gate:

before after
confident precision 99.6% 99.9%
confident links wrong 6 1 (the remaining one is #3756's ctx.addIssue)
unmapped confident links (an end tsc has no function for) 216 10
strict precision (external counted wrong) 96.3% 96.6%
confident judged 1,527 1,520
recall 57.2% 57.1% (−0.1, within the 0.5 pp tolerance)
resolution recall 73.8% 73.7%
ambiguous precision (reported, not gated) 54.5% 32.1%

The ambiguous precision drop is expected. Calls that used to land confidently on an interface or abstract signature now fall through to the ambiguous receiver step. The real target is dynamic dispatch, which a heuristic can't know. Ambiguous rows are never graph edges, so no edge got worse.

The const Node cases, withChecks → clone and nullish/optional → optional now all agree with the checker.

Python pyan3 gate: unchanged, at 99.8% (1,806 judged) / 51.6% / 97.5%.

Type of change

  • Bug fix
  • New feature / language support
  • Parsing or engine logic (gitgalaxy/core/detector.py, language_standards.py, prism.py, or a per-language rule)
  • Docs, tooling, or CI only
  • Other (describe above)

CI checklist

  • ruff_audit.py --ci, dead_key_audit.py --ci: OK. ruff format (0.16.0) is clean on every touched file. mypy_audit.py --ci shows only the four findings present on main, from missing stubs in this environment, none in touched files.
  • Full suite: 11,714 passed. The one collection error was numpy/pandas/xgboost missing from the local interpreter. After installing them, test_security_auditor.py passes 15/15.
  • New tests:
    • test_call_resolver.py: 5, one per issue plus the Python guard and hoisting.
    • test_detector.py: def_shape classification for TS and JS; unset for C.
    • test_fcall_data.py: def_shape persists and rehydrates.
  • crucible_check.py --mode zero: PASS, no golden-master drift. Full-precision can't run in this environment, because the network policy blocks tiktoken's cl100k_base download. CI's crucible-audit (full-precision) is the check for that half.
  • tree_sitter_accuracy_audit.py --ci --all: all OK, 30 languages.
  • call_graph_resolution.py typescript --regenerate, which locks in the improvement, and python --ci, which is OK.
  • CLI output JSON schema: unchanged. def_shape is a DB column only.

Differential Scan target

https://github.com/colinhacks/zod (pinned in tests/import_graph_corpus.json)

Verification

$ PYTHONPATH=$PWD python tests/tools/call_graph_resolution.py typescript --regenerate
| typescript | tsc | 99.9% (1520 judged) | 32.1% | 57.1% | 73.7% |
confident links tsc resolves outside the repo (not gated): 52; strict precision 96.6%; unmapped 10
$ PYTHONPATH=$PWD python tests/tools/call_graph_resolution.py python --ci
| python | pyan3 | 99.8% (1806 judged) | 66.7% | 51.6% | 97.5% |
call_graph_resolution: OK
$ python tests/tools/crucible_check.py --mode zero
✅ zero_dependency: PASS
$ python tests/tools/tree_sitter_accuracy_audit.py --ci --all
tree_sitter_accuracy_audit --all: all OK.   (30 languages)
$ python -m pytest tests -n 8
11714 passed, 334 skipped, ... (1 collection error: numpy missing locally; 15/15 once installed)

🤖 Generated with Claude Code

https://claude.ai/code/session_01AbvXUJpva5XxxbssoKG9Jt


Generated by Claude Code

…e never targets (#3757, #3758, #3759)

The detector now records what each typescript/javascript definition is, as
function_data.def_shape:
  binding    `function f`, `const/let/var f = ...` -- the only shape a bare
             call can reach
  member     object-literal method, object property, `x.f = () => ...`
  signature  interface member, `abstract` method, overload signature (the
             terminator scan's bodyless `;`/#2278 case)
Other languages leave it NULL. The recorder persists it (plus a heal for old
DBs); the rehydrator already carries every column, so delta scans see it.

The resolver:
  - drops signatures from the definition index: no code runs there (#3757);
    an overloaded function now reaches its implementation;
  - keeps members out of the bare-call (`free`) set: `import { clone }` no
    longer loses to an object-literal `clone(def, params) {}` in a
    namespace-imported module (#3758);
  - among several same-file bindings in ts/js, a bare call takes the nearest
    one written before it, else the last (hoisting) -- `const Node = ...` per
    test callback (#3759). Python is left alone: a module-level redefinition
    is legal there and the last one wins at runtime.

zod (TypeScript Level 2 gate): confident wrong 6 -> 1 (the one left is
#3756), precision 99.6% -> 99.9%, unmapped 216 -> 10, recall 57.2% -> 57.1%
(within tolerance). Calls that used to land on signatures are now ambiguous
`receiver` rows, not edges: ambiguous precision 54.5% -> 32.1% (reported, not
gated). Baseline regenerated. Python gate unchanged (99.8% / 51.6% / 97.5%).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AbvXUJpva5XxxbssoKG9Jt
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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