Skip to content

javascript: call-graph engine for the JavaScript front end - #466

Closed
swapnilpaliwal-sd wants to merge 15 commits into
mainfrom
javascript-engine
Closed

swapnilpaliwal-sd wants to merge 15 commits into
mainfrom
javascript-engine

Conversation

@swapnilpaliwal-sd

@swapnilpaliwal-sd swapnilpaliwal-sd commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Tracking #456. Implements #457, #458, #459, #460, #461, #462, #463, #464, #467; #465 lists what is left.

Draft on purpose: nothing here merges until the engine is code-complete and the held-out evaluation is settled. The branch is the integration point; this PR carries the running evaluation.

What this is

A call-graph engine for the JavaScript front end, under src/javascript/, with its oracle, scorer, evaluation harness and regression suite under test/javascript/.

JavaScript declares no types, so the engine is a may-analysis over values, not a type lookup: every expression, binding, parameter, property and return carries the set of values it may hold, a function, a class, an instance, a prototype, a module surface, an object literal, an array, or the platform, and a call site resolves through the callee's value. An untyped receiver produces nothing; the site is a declared unknown with its reason attached. src/javascript/README.md has the layer order and the decisions; PARSER-DEFECTS.md the six IR gaps the rules work around.

How it is measured

checker.getResolvedSignature from a ts.Program built with allowJs + checkJs over the project's own files, per site. Sites the compiler types as any (about half) enter no rate. Scoring is per site: EXACT / SOUND_SUPERSET / WRONG / MISSED over compiler-decided client→client sites; platform targets, implicit constructors, JSDoc-type targets and targets outside the IR are bucketed apart.

Results (production code, per-site, compiler-decided client→client)

Development corpus, 15 projects, 9,867 decided sites:

exact 0.988
recall (exact + sound superset) 0.996
precision 1.000 (WRONG = 0)
sound supersets 75, all of width 2–4
conservation loss 0 on every project
solve time ≤ 6 s per project

Held-out corpus, 4 projects, 9,649 decided sites, validation only, no rule was derived from it:

project decided sites exact recall precision solve
A 1,840 0.985 0.985 0.999 5 s
B 2,150 0.967 0.973 1.000 9 s
C 2,258 0.837 0.992 0.997 1 s
D 3,401 0.973 0.985 1.000 7 s
aggregate 9,649 0.942 0.984 0.999

The generalisation gap is 4.6 points of exact and 1.2 of recall, and it is almost entirely WIDTH on project C: 387 of its 404 non-exact sites are 2-wide sound supersets. WRONG is 8 sites in 9,649.

Project B is the one that did not terminate before #467: the fan cap took it from >40 minutes to 9 seconds with development rates unchanged to three decimals. A second, smaller merge point surfaced after it, a write through a @param {Object}-typed value landed on the ONE identity every such parameter shares, and is closed the same way (the platform's properties are not tracked).

What is deliberately not resolved

Sites the compiler types as any, 7,319 on the development corpus, 18,272 held-out, enter no rate. Platform targets (LIB_AMBIENT_OK 6,040 / 5,561) are classified from the value reached, not the syntax; the LIB_MISSED residue (562 / 547) is almost entirely string/number/promise methods on the result of a project call, which nothing here types (#465). A fan wider than --dispatch-cap is refused and declared (fan_capped), as in the other rule sets.

Regression suite

Eight hand-written cases, edges and compiler adjudication pinned; --bless cannot bless away a MISSED or WRONG line. test/javascript/run-tests.sh --oracle.

swapnilpaliwal-sd and others added 8 commits September 13, 2026 13:45
…callee resolution, call chain; tsc oracle and per-site scorer

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…types, member-named call/apply/bind, default-export recovery; oracle restricted to root files, JSX and type-only targets bucketed

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… exports/module.exports as the module's own surface

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…values called and constructed through their default export, computed-member this, name-matched default-export recovery

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…s, map, typed T[], for..of, patterns and iteration callbacks; typedef aliases; exports-member writes on the module.exports value

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…hains and literals classifies the site; an ambient alternative beside project targets; this.constructor; regression suite with seven cases; README and parser-defects log

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ldens blessed; PD-JS-5 known-missing

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…staged from source; case 08

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@swapnilpaliwal-sd swapnilpaliwal-sd added engine Resolution / call-graph engine rules enhancement New feature or request javascript JavaScript labels Sep 13, 2026
@swapnilpaliwal-sd swapnilpaliwal-sd self-assigned this Sep 13, 2026
…e not tracked; this bound at definition sites only

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
swapnilpaliwal-sd and others added 6 commits September 13, 2026 16:13
…ambient values

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…fan_capped), as in the other rule sets

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ntity per platform name is a global merge point

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…retired; the anonymous form still needs the modifier

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@swapnilpaliwal-sd
swapnilpaliwal-sd marked this pull request as ready for review September 14, 2026 01:04
@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor Author

Superseded by #472, the same engine rebased onto reshape (graph/ layout, in-repo parser, bundle adapter). Keep this one only if main is merged before reshape lands.

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor Author

Superseded by #472, which carried the same engine on the reshape layout and is now on main (21864ff). Closing without merge.

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

Labels

engine Resolution / call-graph engine rules enhancement New feature or request javascript JavaScript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant