| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…core Native's call resolver seeded typed-receiver dispatch to an interface's qualified method node only when computeConfidence(callerFile, targetFile) >= 0.5, so callers many directories away from an interface declaration (e.g. BetterSqlite3Database in src/types.ts) got no edge at all. WASM never has this gap because resolveChaTargets resolves typed-receiver dispatch to concrete implementors unconditionally, independent of file proximity. Adds a BFS+RTA fallback tier mirroring cha.ts's buildChaContext/resolveChaTargets, using a flat CHA_TYPED_DISPATCH_CONFIDENCE (0.8) via a confidence_override out-param threaded through the two resolve_call_targets call sites. Fixes 6 of the native/wasm role-classification mismatches on this repo's own src/ build (55 -> 49); the rest are unrelated pre-existing gaps (tracked in #2062, #2139, #2235). docs check acknowledged: internal engine bug fix, no README/CLAUDE.md/ROADMAP changes needed.
Greptile SummaryThe PR adds a native typed-receiver CHA fallback when existing call-resolution tiers return no target, assigning resolved implementation edges a fixed confidence.
Confidence Score: 4/5The PR does not yet appear safe to merge because typed CHA dispatch can produce cross-module false edges and still omit inherited implementations. The global unqualified hierarchy, instantiation, and method indexes conflate unrelated same-named types, while dispatch searches only for methods declared directly on each instantiated descendant and never walks back to an inherited declaration. Files Needing Attention: crates/codegraph-core/src/domain/graph/builder/stages/build_edges.rs Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Call["Typed receiver call"] --> Existing["Existing resolution tiers"]
Existing -->|target found| EmitExisting["Emit existing target"]
Existing -->|no target| CHA["CHA BFS over implementors"]
CHA --> RTA{"Type is instantiated?"}
RTA -->|no| Descendants["Continue traversing descendants"]
Descendants --> CHA
RTA -->|yes| Lookup["Look up Class.method"]
Lookup --> EmitCHA["Emit edge at fixed confidence"]
Reviews (2): Last reviewed commit: "fix(native): add CHA typed-dispatch fall..." | Re-trigger Greptile |
Sorry, something went wrong.
| let list = implementors.entry(parent.as_str()).or_default(); | ||
| if !list.contains(&cls.name.as_str()) { list.push(&cls.name); } | ||
| } | ||
| if let Some(ref parent) = cls.extends { | ||
| let list = implementors.entry(parent.as_str()).or_default(); | ||
| if !list.contains(&cls.name.as_str()) { list.push(&cls.name); } | ||
| } | ||
| } |
There was a problem hiding this comment.
Global CHA names merge hierarchies
When unrelated modules reuse an interface or base-class name, this global simple-name map merges their implementors, and the fallback can emit call edges to methods in the wrong module, corrupting call-graph, impact, and role results.
Knowledge Base Used: Rust Native Core and the Native/WASM Bridge
Sorry, something went wrong.
| if ctx.cha_instantiated_types.contains(cls) { | ||
| let qualified = format!("{}.{}", cls, method_name); | ||
| if let Some(found) = ctx.nodes_by_name.get(qualified.as_str()) { | ||
| results.extend(found.iter().filter(|n| n.kind == "method")); | ||
| } |
There was a problem hiding this comment.
Inherited implementations remain unresolved
When an instantiated subclass inherits the called method without overriding it, this lookup checks only Subclass.method even though the node belongs to the declaring parent, causing the reachable call edge to remain missing.
Knowledge Base Used: Rust Native Core and the Native/WASM Bridge
Sorry, something went wrong.
|
Both flagged concerns are valid, but verified against the WASM source this PR mirrors (src/domain/graph/builder/cha.ts) — they're pre-existing characteristics already present identically in WASM, not new divergences introduced here: Issue 1 (global simple-name implementor map): buildChaContext in cha.ts builds the exact same flat, bare-name-keyed implementors map across every file in the build, with no import/module scoping — the Rust build_cha_implementors_map is a faithful mirror of that same structure. Same class of bug as #2062 (resolveThisDispatch cross-file same-named-class collision). Issue 2 (inherited methods not resolved): resolveChaTargets in cha.ts does the exact same direct qualified lookup (${cls}.${methodName}) with no walk up the extends chain for a method a concrete class inherits without overriding — the Rust resolve_cha_dispatch mirrors that same limitation. Since this PR's job is specifically to close the proximity-gate parity gap (native producing zero edges where WASM already produces some via unconditional CHA dispatch), fixing either of these unilaterally in the new Rust code only would make native more correct than WASM for this pattern — a new divergence in the other direction, which conflicts with this repo's dual-engine parity requirement. Filed both as a dual-engine follow-up: #2237. |
Sorry, something went wrong.
|
That's the right call, and the reasoning is sound. Both concerns are pre-existing cha.ts characteristics — fixing them unilaterally in the Rust mirror would introduce a new native-ahead-of-WASM divergence, which is the opposite of this PR's mandate. The parity-first constraint applies cleanly here. The confidence_override out-param approach, the BFS structure, and the RTA filter all faithfully mirror resolveChaTargets as-is. The 4 unit tests cover the exact edge cases that matter (distant interface, RTA filter, proximity-gate already-hit, multi-level BFS). #2237 is the right place for the dual-engine fixes. LGTM — the implementation is correct given the parity constraint. |
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Closes #1949.
Native's call resolver seeded typed-receiver dispatch (db.prepare() where db: BetterSqlite3Database) to the interface's own qualified method node only when computeConfidence(callerFile, targetFile) >= 0.5. For callers many directories away from the interface declaration (e.g. src/types.ts), that proximity check fails in both engines and no seed edge is ever created. WASM never has this gap because its CHA post-pass (resolveChaTargets in cha.ts) resolves typed-receiver dispatch to concrete implementors unconditionally, independent of file proximity — "file proximity is not meaningful for virtual dispatch confidence." Native's runPostNativeCha only expands an existing seed edge; it has no equivalent unconditional fallback.
This adds a BFS+RTA fallback tier to resolve_call_targets_core (crates/codegraph-core/src/domain/graph/builder/stages/build_edges.rs), tried only when the existing tiers found nothing and the receiver has a typeMap-resolved type:
Verification
Follow-up (filed, not fixed here)
The remaining 49 role mismatches are unrelated pre-existing gaps, diagnosed while verifying this fix:
Test plan