Skip to content

Fix JavaScript and TypeScript graph resolution gaps - #12

Merged
NianJiuZst merged 1 commit into
mainfrom
codex/js-ts-graph-resolution
Nov 2, 2026
Merged

NianJiuZst merged 1 commit into
mainfrom
codex/js-ts-graph-resolution

Conversation

@NianJiuZst

@NianJiuZst NianJiuZst commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Problem

The six-repository investigation found that tracked-but-ignored package manifests caused Zod workspace imports to be treated as external, and that JS/TS calls could target a same-named interface, a function from another closure, or a method on an unrelated receiver. Namespace imports forwarded through local exports were also lost, and the pinned TypeScript grammar reported errors for valid in/out variance annotations.

Changes

  • Discover Git-tracked ignored project manifests while continuing to honor explicit exclusions, built-in exclusions, depth and symlink boundaries. Invalidate the index when those manifests change or disappear.
  • Keep TypeScript type and value export spaces distinct, including aliases and namespace re-exports; do not use an interface or type alias as a runtime call target.
  • Preserve the exact node for a local function expression and preserve this/super in JS/TS call references. Avoid a unique-name guess for an unknown JS receiver. Restore a same-object this call only when its nearest function and the assigned target have matching object evidence; ordinary nested callbacks do not inherit it.
  • Recognize the bounded Express merge-descriptors factory pattern when the factory, returned object, exported application object, and assigned method agree. Reassignments, overrides, early exits and methods belonging to a different object stop the inference.
  • Recover the pinned grammar's unsupported variance annotations only after a failed parse, with a same-byte-length mask and the remaining parse timeout; use the original source for extraction, and keep the original error tree if the retry is not clean. Include the vendoring patch and bump the engine rules version.
  • Invalidate dependent references when factory evidence, assigned members or a re-exported import changes.

Validation

  • cargo test --workspace --locked with CGR_SYNC_SEQUENCES=6 CGR_SYNC_STEPS=100 passed locally.
  • cargo +1.99.0 clippy --workspace --exclude cg-kernel --all-targets --locked -- -D warnings, the CI formatting check, the end-to-end smoke script, and re-vendoring the pinned kernel plus its patches and comparing the result.
  • Temporary, uncommitted regression cases covered tracked ignored/deleted/excluded manifests; variance syntax and unrelated syntax errors; distinct TS type/value targets and namespace re-exports; separate same-name closures; this/super, nested callbacks, and unrelated receivers; proven Express applications versus reassignment, early return, method override, different objects, and replaced exports; and incremental versus fresh rebuilds after manifest, factory, member, and re-export edits.
  • In the real Express snapshot, examples/auth/index.js:21 still resolves app.use to lib/application.js::use; lib/application.js:222 no longer resolves router.use to it; examples/resource/index.js:14,15,21 no longer resolve this.get to an unrelated example. In Django's inlines.js, calls at lines 421–423 resolve to the functions at lines 382, 362 and 370 respectively.

The following is strict edge/site agreement with upstream codegraph d2e0389, not precision/recall against human-verified ground truth. Both versions saw the same indexed source paths and bytes (Express 142 files, Zod 523, Django 2,984). The Zod before/after runs also used the same Git checkout. The baseline is latest main 2e83569; its strict graphs for these three repositories are identical to the prior edb403e benchmark graphs. These are diagnostic graph comparisons, not a new performance benchmark.

Repository / edges Before precision / recall After precision / recall
Zod / all 91.77% / 61.84% 92.19% / 92.83%
Zod / calls 88.81% / 35.28% 91.52% / 93.27%
Express / all 58.76% / 88.35% 64.15% / 87.49%
Express / calls 49.26% / 85.70% 56.62% / 84.14%
Django / all 94.20% / 89.83% 94.21% / 89.82%
Django / calls 91.34% / 77.47% 91.38% / 77.43%

Zod's four TypeScript parse-error files dropped to zero in this snapshot. The lower Express agreement recall reflects the more conservative receiver rules; an upstream-only edge is not necessarily correct. Kotlin error-tree recovery and Go composite-literal calls identified separately in the investigation are outside this JS/TS-focused change.

@NianJiuZst
NianJiuZst merged commit 2c35e7a into main Nov 2, 2026
9 checks passed
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.

1 participant