Skip to content

fix(typescript): resolve imported calls through scoped const aliases - #5614

Closed
rvitaliy wants to merge 2 commits into
Graphify-Labs:v8from
rvitaliy:fix/typescript-scoped-callable-aliases
Closed

rvitaliy wants to merge 2 commits into
Graphify-Labs:v8from
rvitaliy:fix/typescript-scoped-callable-aliases

Conversation

@rvitaliy

@rvitaliy rvitaliy commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Resolve an imported callable reached by a local const alias inside an indexed TypeScript callable. The existing import and export facts must identify a single target. The edge keeps the lexical caller and the actual call line, including a call inside an anonymous callback.

Closes #5613. Follow-up to #5594.

Type of change

  • Bug fix

Verification & Invariants

  • An alias from an indexed body cannot bind calls in a sibling scope. Shadowed, mutable, type-only, cyclic and ambiguous cases stay unresolved.
  • Full extraction and caller-only incremental extraction agree. A target-only change can require a forced rebuild under the existing JS/TS invalidation rules, which also apply to direct imported calls.
  • A real email persistence caller now links to the exported persistence function at its original call site.

How was this tested?

  • The scoped-alias regression fails on v8 with both full and incremental contexts. The focused extractor and architecture suites passed on Python 3.14 (223 tests), and the factory and typed receiver suites passed on Python 3.11 (41 tests).
  • Full Python 3.14 suite split across xdist (12,093 passed), the two worker-sensitive files without xdist (93 passed), and the serial group (282 passed).
  • ruff check ., git diff --check, and graphify update . passed. Pyright adds no diagnostics relative to v8.

Graphify-specific checklist

  • Verified lexical ownership and exact export resolution.
  • Reviewed the diff for credentials and generated graph files.
  • Disclosed AI assistance in the commit trailer.

Review follow-up

Use runtime module bindings to resolve scoped aliases. A local alias in an unrelated function and a type-only import cannot redirect the call. A same-named type and function keep the call when the indexed source location identifies the function declaration. The extractor's existing shared node ID can still hide the function when its same-named type comes first.

The updated branch passed 185 focused tests on Python 3.14 and six runtime-binding cases on Python 3.11. The full Python 3.14 suite passed with 12,474 tests. The installer and worker-sensitive tests ran without xdist after an intermittent installer fixture failed in the parallel run. The isolated installer test passed on both v8 and the updated branch. Ruff and graphify update . passed, and Pyright adds no diagnostics relative to v8.

@rvitaliy
rvitaliy requested a review from safishamsi as a code owner November 28, 2026 23:32
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @rvitaliy. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 28, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Nothing blocking · 5 possible issues to check · Merge confidence 5/5

5 possible issues to check · High impact

The change adds scoped TypeScript call resolution for const aliases of imported functions, including through runtime re-exports.

5 possible issues we couldn't confirm

They don't change the score.

What this review covered
  • We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
  • 5 of 5 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 6388 functions depend on this change
  • 5 functions became more coupled. Largest: extract() (1429 callers), _apply_symbol_resolution_facts() (8 callers), _collect_js_symbol_resolution_facts() (5 callers).
  • 658 of 658 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed ef17d29 · 5 earlier findings not re-checked

safishamsi added a commit that referenced this pull request Nov 30, 2026
Extractor accuracy (Swift #5641, Apex #5627, Python #5647, TypeScript
#5604/#5614/#5612, Bash caller-var #5602), GitHub Actions run-step
extraction (#5603), incremental correctness (#5634/#5638/#5636), symlink
and semantic-cache fixes (#5617/#5618), export/report hardening and perf
(#5643/#5644/#5645/#5646/#5619/#5620/#5621), and CLI/docs/skill/install
work (#5629/#5628/#5626/#5624/#5623/#5625/#5642/#5583). AST cache schema
59 to 60; Swift/Apex/Python/Bash/GHA inputs re-extract on first build.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Landed in v0.9.124 (just released to PyPI), cherry-picked with your authorship preserved so it shows under your name in the history. Thanks @rvitaliy for resolving imported calls through scoped const aliases — verified green in the full suite and, where applicable, smoke-tested against the published package. 🙏

@Komorebi-GZM

Copy link
Copy Markdown
Contributor

I'd like to take a follow-up on this: resolving calls through purely local function aliases (const persist = save, save declared in the same module) on top of your scope-resolution foundation, with the same fail-closed guards and no bare-name rewrite.

@rvitaliy
rvitaliy deleted the fix/typescript-scoped-callable-aliases branch December 1, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Calls through a local const alias disappear inside indexed TypeScript callables

3 participants