Skip to content

Close resolution gaps and port missing dynamic-dispatch passes - #11

Merged
NianJiuZst merged 1 commit into
mainfrom
claude/close-resolution-gaps
Nov 1, 2026
Merged

NianJiuZst merged 1 commit into
mainfrom
claude/close-resolution-gaps

Conversation

@NianJiuZst

Copy link
Copy Markdown
Owner

Problem

Compared with upstream CodeGraph on the languages cgr supports, calls were left unresolved (or resolved to the wrong symbol) in several recurring shapes: Go interfaces that embed standard-library types, calls through Go struct fields holding functions, JS/TS aliases and ES5 prototypes, Rust generics, Deref and type aliases, and Python factories, cross-method fields and pytest fixtures. Ten upstream dynamic-dispatch synthesis passes relevant to these languages had no cgr counterpart.

Changes

Resolution

  • Go: embedded standard-library types join interface satisfaction (method table ported from upstream go-stdlib-methods.ts); other outside embeds are opaque, so only a type embedding the same one satisfies the interface. A project embed the kernel writes without its package (sandbox.Manager → Manager) now binds through the written qualifier. This also removes a false positive: a type with only Close no longer implements an interface embedding io.Reader.
  • TS/JS: calls through const x = y, export const alias = impl and object-literal members (api.run()) reach the real function (upstream alias-binding). ES5 constructors type their instances through prototype members, with util.inherits / Object.create / setPrototypeOf inheritance recorded as extends. declare module 'x' { … } blocks in script .d.ts files bind TypeScript imports of x.
  • Rust: generic parameters resolve through their trait bounds (where clauses included), and an unbounded parameter never matches a same-named project type. Member lookup looks through impl Deref targets, type X = Y aliases and Mutex / RwLock lock guards. self.field call chains are evaluated.
  • Python: factories returning different classes in different branches are typed by their nearest common base; self.x = self.make() types a field across methods; pytest fixture parameters (same file or a conftest.py above) take the fixture's return type.

Synthesis passes (all recomputed whole on sync)
go-func-field, go-grpc-stub-impl, gin-middleware-chain, const-alias, redux-thunk, rtk-query, test-request (Spring MockMvc / WebTestClient / TestRestTemplate / RestAssured → routes), kotlin-expect-actual, tauri-command (registered commands only, looked up per app) and rn-native-module (NativeModules.X.m() → Java/Kotlin @ReactMethod).

Incremental sync: Deref, type-alias and fixture facts take part in invalidation; a changed fixture re-resolves the Python files of its conftest.py directory, since pytest injects fixtures without an import.

Engine rule version 7, so existing indexes rebuild on the next sync. Segment format unchanged. Both READMEs list the new rules and what remains uncovered.

Validation

  • 13 focused resolver tests (crates/cg-resolve/tests/gap_closure.rs), each with positive cases and links that must not be made.

  • An incremental test (crates/cg-sync/tests/gap_closure.rs) edits both sides of every new link over 11 steps. Each step must equal a fresh full index without falling back to a full rebuild.

  • CGR_SYNC_SEQUENCES=6 CGR_SYNC_STEPS=100 cargo test --workspace --locked: 192 passed, 1 existing ignored.

  • cargo +1.99.0 clippy --workspace --exclude cg-kernel --all-targets -- -D warnings, cargo +1.89.0 check --locked, the CI rustfmt package list and scripts/smoke.sh all pass.

  • Real repositories, main vs this branch (edge sets diffed, added edges spot-checked against source):

    Repository Added Removed
    grpc-java 0 0
    rocketmq 0 0
    opencode 336 1
    codex (Rust) 348 0
    WeKnora (Go) 52 0

    The one opencode removal is a precision gain: Notifications.tui() moved from a type member to the real implementation. These comparisons caught two regressions before commit, both now covered by tests: qualified project embeds treated as opaque, and Rust type aliases blocking member lookup.

Notes for reviewers

  • Not yet re-measured against the pinned upstream oracle on Express / Gin / Tokio / Django, and no performance retest for engine 7.
  • Not covered: MyBatis XML, Angular templates, Vue/Svelte ecosystem stores and routers, React Native events and the Fabric/Expo native side, Tauri events, GoFrame. Python parameter-type flow is also not covered; upstream implements it for Ruby only.

🤖 Generated with Claude Code

Resolution, for the supported languages:
- Go: embedded standard-library types join interface satisfaction (method
  table ported from upstream) and other outside embeds are opaque; a project
  embed the kernel writes without its package binds through the qualifier.
- TS/JS: calls through `const x = y`, `export const alias = impl` and
  object-literal members reach the real function; ES5 constructors type
  their instances through prototype members and util.inherits /
  Object.create; `declare module 'x'` blocks in .d.ts files bind imports.
- Rust: generic parameters resolve through trait bounds (an unbounded one
  never matches a same-named project type); impl Deref targets, type
  aliases and Mutex/RwLock guards are looked through; self.field chains
  are evaluated.
- Python: branched factories are typed by their common base, self.x =
  self.make() types fields across methods, pytest fixture parameters take
  the fixture's return type.

Synthesis passes: go-func-field, go-grpc-stub-impl, gin-middleware-chain,
const-alias, redux-thunk, rtk-query, test-request (Spring MockMvc,
WebTestClient, TestRestTemplate, RestAssured), kotlin-expect-actual,
tauri-command and rn-native-module. All are recomputed whole on sync.

Incremental sync re-resolves on Deref, type-alias and fixture changes (a
changed conftest re-resolves the Python files below it). Engine rule
version 7; segment format unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NianJiuZst
NianJiuZst merged commit edb403e into main Nov 1, 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