fix(parity): gate astTypeMap lookup with Object.hasOwn#1041
Conversation
The AST-store visitor looked up `astTypeMap[node.type]` with plain bracket
notation. When tree-sitter emits a node type that collides with an
Object.prototype member — Haskell sum-type constructors are reported as
node type `constructor` — the lookup walks the prototype chain and
returns `Object.prototype.constructor` (the Object() function). The
function then lands in the astNodes row's `kind` field and the row
fails to structured-clone across the worker boundary, surfacing as
"function Object() { [native code] } could not be cloned" and skipping
the file entirely.
Every Haskell file containing `Left`, `Right`, `Just`, etc. was being
silently dropped, which is what dragged the resolver from
precision=1.0/recall=0.333 in v3.9.4 to 0/0 in v3.9.6. With the gate in
place the four expected truePositives in the Haskell fixture come back
and the metrics restore to the v3.9.4 baseline.
Closes #1039
|
Claude finished @carlos-alm's task —— View job Reviewing PR: fix(parity): gate astTypeMap lookup with Object.hasOwnTodo List:
Phase 1: Root Cause Analysis ✅Problem Being Solved: The AST-store visitor in Why This Approach: The fix uses
Risk Assessment: ✅ LOW RISK - This is fixing a genuine bug, not masking symptoms. The approach is minimal, targeted, and preserves existing behavior for valid lookups while preventing prototype pollution issues. Phase 2: Configuration Change Detection ✅✅ No configuration changes detected. This PR only modifies:
No biome/linting rules, test timeouts, coverage thresholds, build config, or TypeScript settings modified. Phase 3: Test Integrity Analysis ✅✅ Test changes are appropriate and strengthen validation:
Phase 4: Code Quality Review ✅Implementation Quality:
Potential Issues:
Code Style: Phase 5: Backlog Compliance Assessment ✅Root Cause AnalysisProblem Being Solved: Critical bug where Haskell files with constructor nodes ( Backlog Compliance
Critical ConcernsNone identified. This is a textbook example of a surgical bug fix. Final Recommendation
|
Greptile SummaryThis PR gates the Confidence Score: 5/5Safe to merge — targeted one-line guard with a clear root-cause explanation and passing test suite. The fix is minimal and correct: No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Walker as AST Walker
participant Visitor as ast-store-visitor
participant Map as astTypeMap (plain object)
participant Worker as Worker boundary (structured-clone)
Walker->>Visitor: enterNode(node{type:"constructor"})
Note over Visitor: Before fix
Visitor->>Map: astTypeMap["constructor"]
Map-->>Visitor: Object.prototype.constructor (function)
Visitor->>Worker: structured-clone(row{kind: Object()})
Worker-->>Visitor: ❌ DataCloneError — function could not be cloned
Walker->>Visitor: enterNode(node{type:"constructor"})
Note over Visitor: After fix (this PR)
Visitor->>Map: Object.hasOwn(astTypeMap, "constructor")
Map-->>Visitor: false → return early
Note over Visitor: Node skipped cleanly, no clone attempted
Reviews (1): Last reviewed commit: "fix(parity): gate astTypeMap lookup with..." | Re-trigger Greptile |
Codegraph Impact Analysis2 functions changed → 9 callers affected across 3 files
|
Summary
astTypeMap[node.type]with plain bracket notation; tree-sitter node typeconstructor(Haskell sum-types:Left,Right,Just, …) walked the prototype chain toObject.prototype.constructor, dropping theObject()function into the astNodes row'skindfield.function Object() { [native code] } could not be cloned, skipping every Haskell file containing constructors and dragging the resolver from 100%/33% precision/recall in v3.9.4 to 0%/0% in v3.9.6.Object.hasOwnso prototype-derived members never leak into the result. Restores the four expected truePositives in the Haskell fixture; metrics return to the v3.9.4 baseline (precision=1.0, recall=0.333).The
KNOWN_REGRESSIONSentries stay until v3.9.7 benchmark data is captured (matching the established pattern for the other 3.9.6 entries).Closes #1039
Test plan
npx vitest run tests/benchmarks/resolution/resolution-benchmark.test.ts— all 170 pass; Haskell now parses 4/4 files (was 2/4).precision=1.000 (4/4),recall=0.333 (4/12)— matches v3.9.4 baseline.npx vitest run tests/parsers/ tests/integration/ast.test.ts tests/engines/ast-parity.test.ts— 493 pass, no regressions.npx vitest run tests/benchmarks/regression-guard.test.ts— 17 pass.