fix(resolver): apply confidence filter to static receiver fallback#1427
Conversation
The direct qualified-name fallback in resolveByMethodOrGlobal was the only resolution path that did not apply computeConfidence >= 0.5, risking false edges from distant files in polyglot projects with name collisions. Closes #1398
|
Claude finished @carlos-alm's task —— View job PR Review: fix(resolver): apply confidence filter to static receiver fallback
Root Cause AnalysisProblem Being Solved: The Why This Approach: The fix adds the same confidence guard that already exists at every other call site in the same function (lines 123, 155, 188, 196, 215). This is the correct repair — it restores internal consistency rather than introducing new heuristics. The threshold Risk Assessment: Low. The change is additive (adds a filter, never changes resolution order) and is guarded only in the Phase 2: Configuration Change DetectionNo linting rules relaxed, no timeouts raised, no coverage thresholds changed, no TypeScript flags disabled. Clean. Phase 3: Test IntegrityTests are strictly additive (30 new lines, 0 deletions from existing test logic). The two new test cases in
Both cases are mathematically grounded against Phase 4: Code QualityThe code change is exactly one concept applied consistently: - .filter((n) => n.kind === 'method' || n.kind === 'function');
+ .filter(
+ (n) =>
+ (n.kind === 'method' || n.kind === 'function') &&
+ computeConfidence(relPath, n.file, null) >= 0.5,
+ );No concerns. The guard is correctly placed inside the One minor observation: Backlog Compliance
Final Recommendation |
Greptile SummaryThis PR closes a gap in
Confidence Score: 5/5Safe to merge — the change is a one-line guard addition that brings the typeName typed-method path in line with every other resolution path in the function, validated by two targeted unit tests. The fix is minimal and surgical: a single filter predicate added to the one byName call that lacked it. All other resolution paths in resolveByMethodOrGlobal already applied the same guard, so the change is consistent with established patterns. The new tests confirm both the pass (same-directory) and filter (distant-file) cases, and the existing test suite exercises the surrounding logic. No regressions are expected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[resolveByMethodOrGlobal] --> B{call.receiver?}
B -- yes --> C[effectiveReceiver + typeMap lookup]
C --> D{typeName resolved?}
D -- yes --> E["byName - typeName.method\nfilter: kind=method AND confidence >= 0.5\nNEW in this PR"]
E --> F{typed found?}
F -- yes --> G[return typed]
F -- no --> H["protoEntry alias\nfilter: confidence >= 0.5"]
H --> I{typeName set?}
I -- no --> J["direct qualified lookup\nfilter: kind=method/fn AND confidence >= 0.5"]
J --> K{direct found?}
K -- yes --> L[return direct]
K -- no --> M["compositeEntry pts\nfilter: confidence >= 0.5"]
I -- yes --> M
D -- no --> I
B -- "no / this / self / super" --> N["exact byName\nfilter: confidence >= 0.5"]
N --> O{exact found?}
O -- yes --> P[return exact]
O -- no --> Q["same-class fallback\nfilter: kind=method AND confidence >= 0.5"]
Q --> R[return result or empty]
style E fill:#90EE90,stroke:#2d6a2d
Reviews (8): Last reviewed commit: "Merge branch 'main' into fix/static-rece..." | Re-trigger Greptile |
Codegraph Impact Analysis1 functions changed → 15 callers affected across 5 files
|
…ethodOrGlobal (#1427) The typeName lookup (typeMap-resolved receiver) was the only remaining byName call in resolveByMethodOrGlobal without a computeConfidence >= 0.5 guard. Apply the same filter to close the gap and add two unit tests covering the same-dir (pass) and distant (filtered) cases.
|
Addressed Greptile's feedback: added |
|
Resolved merge conflict with main: tests/unit/call-resolver.test.ts had a conflict between this PR's typeName-branch confidence filter tests (#1398) and the bare-call JS/TS module-scope guard tests (#1407) added on main. Both test suites are preserved in the resolution. All 12 unit tests pass locally. |
|
Fixed the PR description: corrected the branch name from |
Summary
resolveByMethodOrGlobal(if (typeName)branch,call-resolver.ts) was the onlybyNamecall in the function that did not applycomputeConfidence(relPath, n.file, null) >= 0.5, leaving it open to false-positive edges from distant files in polyglot projects where two unrelated classes share a method namecomputeConfidence(relPath, n.file, null) >= 0.5guard that every otherbyNamecall in the function already applies; all resolution paths inresolveByMethodOrGlobalare now consistently guardedCloses #1398
Test plan
npx vitest run tests/unit/call-resolver.test.ts— 12 tests passnpx vitest run tests/integration/issue-1372-csharp-static-receiver.test.ts— 2 tests pass (same-dir cross-file static calls unaffected, confidence 0.7)npx vitest run tests/benchmarks/resolution/resolution-benchmark.test.ts— benchmark suite passes (C# benchmark all 3 static edges preserved)