fix(native): CHA/RTA instantiation evidence lacks new_expressions - #2493
Merged
Conversation
Native engine's collect_cha_instantiated_types only sourced typeMap entries (confidence >= 0.9) as RTA instantiation evidence for CHA dispatch, unlike WASM/TS's collectInstantiatedTypes (cha.ts) which also unions every new_expressions entry regardless of assignment shape. A class instantiated ONLY via an object-literal property value or bare non-`this.` assignment never produced a confidence>=0.9 typeMap entry, so it was invisible to native's CHA/RTA filter even after #2139's dispatch-edge fix — WASM already handled this correctly. Adds new_expressions: Vec<String> to FileSymbols/FileEdgeInput, populated unconditionally in handle_new_expr (mirroring the TS extractor's newExpressions collection), and unions it into collect_cha_instantiated_types alongside the existing typeMap source. New fixture (ObjWorker.ts) instantiated only via an object-literal property value, verified via describe.each(['wasm','native']) that both engines now emit the CHA-expanded dispatch edge to it. docs check acknowledged: this is an internal RTA-evidence parity fix closing a narrow instantiation-evidence gap in one engine to match the other's already-correct, already-documented CHA+RTA behavior — no new feature, language, or architecture change, so README/CLAUDE/ ROADMAP do not need updates. Closes #2346 Impact: 3 functions changed, 4 affected
Contributor
Greptile SummaryThe PR brings native CHA/RTA instantiation detection into parity with the WASM engine by collecting every supported JavaScript/TypeScript
Confidence Score: 5/5The PR appears safe to merge, with the new native extraction and CHA/RTA evidence flow aligned with the existing WASM behavior. The added field is initialized and propagated through all native constructors and marshaling points, both engines use equivalent constructor-name extraction and recursive traversal, and the integration test covers the targeted missing-edge scenario. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Source["JavaScript / TypeScript source"] --> Extract["Native new-expression extraction"]
Extract --> Symbols["FileSymbols.newExpressions"]
Symbols --> Inputs["FileEdgeInput.newExpressions"]
Inputs --> RTA["CHA/RTA instantiated-type union"]
TypeMap["typeMap entries with confidence >= 0.9"] --> RTA
RTA --> Filter["Filter hierarchy dispatch candidates"]
Filter --> Edges["Persist CHA call edges"]
Reviews (1): Last reviewed commit: "fix(native): cha dispatch missing rta ev..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
collectInstantiatedTypes,cha.ts) unions typeMap entries (confidence >= 0.9) with every rawnew X()expression in the file (symbols.newExpressions), regardless of assignment shape.collect_cha_instantiated_types,build_edges.rs) only had the typeMap half — there was nonew_expressionslist on the Rust side at all. A class instantiated ONLY via a pattern that doesn't produce a confidence>=0.9 typeMap entry (e.g.new X()as an object-literal property value, or a bare non-this.assignment) was invisible to native's RTA filter and never got CHA-expanded dispatch edges, even though WASM correctly produced them for identical code.new_expressions: Vec<String>toFileSymbols/FileEdgeInput, populated unconditionally inhandle_new_expr(mirroring the TS extractor's existingnewExpressionscollection), and unioned intocollect_cha_instantiated_typesalongside the existing typeMap source — matchingcha.ts's union exactly.native-orchestrator.ts's DB-driven incremental path (buildChaRtaSet) already independently covers this via its own calls-edge query and does not go throughbuild_edges.rs, so it needed no changes (confirmed via investigation before implementing).Test plan
tests/fixtures/cha-dispatch/ObjWorker.ts— implementsIWorker, instantiated ONLY via an object-literal property value ({ w: new ObjWorker() }), never asconst x = new ObjWorker()tests/integration/phase-8.5-cha-dispatch.test.ts—describe.each(['wasm','native'])now asserts both engines emit the CHA-expandeddispatch → ObjWorker.doWorkedgecargo test --workspace: 1011 passedcargo fmt --check/cargo clippy --workspace --all-targets -- -D warnings: cleannpm run lintcleanCloses #2346