Skip to content

Call resolution Level 2: measure TypeScript against the compiler's type checker - #3761

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

squid-protocol merged 3 commits into
mainfrom
claude/optimistic-heisenberg-bta91d

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

The Level 2 call-resolution check (tests/tools/call_graph_resolution.py) only covered Python, scored against pyan3. This PR adds a typescript mode. It scores the engine's fcall_data links against the TypeScript compiler's own type checker, which knows which declaration each call and new resolves to.

  • tests/tools/ts_callgraph.js (new): builds a ts.Program from every .ts/.tsx file of a repo under its root tsconfig.json. It emits function defs, caller→callee edges, and external calls (resolved only to lib.d.ts/node_modules). The typescript version is pinned at 6.0.2 (TYPESCRIPT_VERSION). --ci warns if the installed version differs, and --regenerate refuses to run.
  • Corpus: the pinned typescript repo of tests/import_graph_corpus.json (zod), fetched by the existing import_graph_accuracy.py --fetch-only. language-crucible's TypeScript samples are flattened (28 files, one directory per repo), so no relative import would resolve.
  • Scorer: the pyan scorer is now a shared _score() over a RefGraph. Python numbers are unchanged: python --ci passes at the same baseline. TypeScript adds one verdict pyan cannot give. external means the engine linked a call that the checker resolves only outside the repo. It is reported as confident_strict_precision_pct, which is baselined but not gated yet.
  • graph-accuracy-audit.yml: npm install --global [email protected] plus a TypeScript gate step, using the same 0.5 pp tolerance.
  • Docs: docs/graph_accuracy.md gets a table row and a "Call resolution in TypeScript" section. docs/function_call_graph.md has updated limits.

zod results (tests/call_graph_resolution_typescript_baseline.json)

metric TypeScript (zod, tsc) Python (pyan3, for reference)
confident precision 99.6% (1,519 judged) 99.8% (1,806)
strict precision (external counted wrong) 96.3% (52 external) n/a
ambiguous precision 54.5% 66.7%
recall 56.9% 51.6%
resolution recall 73.7% 97.5%

The checker is a reference, not ground truth. It stays silent on any receivers and on package imports, because zod isn't npm installed. Those links count as unconfirmed, never wrong.

Engine defects this surfaced (filed, not fixed here — this PR is measurement-only)

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

  • python tests/tools/audit_check.py: ruff, format and dead-key are OK. mypy reports 4 findings, all in files this PR doesn't touch, from missing yaml stubs in the local env. ast-accuracy couldn't run because the local clone is shallow and has no v2.4.7 tag.
  • pytest tests/tools/test_call_graph_resolution_gate.py (run as plain pytest from an unrelated directory): 5 passed, including a live ts_callgraph.js fixture test that skips when node or typescript is absent.
  • Parsing/engine logic untouched, so crucible_check.py / tree_sitter_accuracy_audit.py don't apply.
  • CLI output schema unchanged.

Differential Scan target

N/A (no engine change).

Verification

$ 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 -- no gated python metric dropped beyond the baseline tolerance.
$ PYTHONPATH=$PWD python tests/tools/call_graph_resolution.py typescript --regenerate
| typescript | tsc | 99.6% (1519 judged) | 54.5% | 56.9% | 73.7% |
confident links tsc resolves outside the repo (not gated): 52; strict precision counting them wrong 96.3%; unmapped 224
$ cd /tmp && pytest -q .../tests/tools/test_call_graph_resolution_gate.py
5 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01AbvXUJpva5XxxbssoKG9Jt


Generated by Claude Code

…pe checker

call_graph_resolution.py only scored Python (vs pyan3). Add a `typescript`
mode that scores the engine's fcall links against the TypeScript checker's own
call resolution (new tests/tools/ts_callgraph.js, typescript pinned 6.0.2) on
the pinned typescript repo of tests/import_graph_corpus.json (zod) -- the
crucible's TypeScript samples are flattened, so no import would resolve.

The pyan scorer becomes a shared _score() over a RefGraph; python numbers are
unchanged (gate passes at the same baseline). The checker adds one verdict pyan
cannot: `external`, a confident link for a call it resolves only outside the
repo (`str.trim()` -> String.prototype.trim), reported as strict precision.

zod: confident precision 99.6% (1,519 judged), strict 96.3% (52 external),
recall 56.9%, resolution recall 73.7%. Baselined in
tests/call_graph_resolution_typescript_baseline.json and gated in
graph-accuracy-audit.yml.

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

… without one

The smoke suite failed on the runner's preinstalled global typescript, which is
now 7.x -- the native Go port, whose npm package exports no createProgram or
type checker. ts_callgraph.js crashed on `ts.sys.fileExists`. It now exits 3
with a message naming the fix ([email protected], what graph-accuracy-audit.yml
installs), and the fixture test skips unless the package on NODE_PATH has the
compiler API, and shows the script's stderr when it does fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AbvXUJpva5XxxbssoKG9Jt
The compiler reports SourceFile.fileName with forward slashes on every
platform, but the repo prefix came from path.resolve (backslashes on
Windows), so every file would read as outside the repo there. Normalise the
prefix, and fold case on win32.

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