chore(fsharp): align npm grammar with cargo at v0.3.0#1165
Conversation
The WASM engine pulled tree-sitter-fsharp 0.1.0 from npm while the native engine used 0.3.0 from crates.io. The two versions diverged in how they parse type signatures in .fsi files: 0.1.0 emits `function_type` nodes for `a -> b` types, while 0.3.0 wraps every signature in `curried_spec` with `arguments_spec` children for function shapes. The F# extractor was forced to detect both shapes simultaneously, which is fragile — future grammar churn could silently desync further. * package.json now installs tree-sitter-fsharp from the ionide v0.3.0 GitHub tarball (npm has no 0.3.0 release; ionide is the upstream the cargo crate also tracks). Lockfile pins via SRI hash. * Both extractors now check only `curried_spec` → `arguments_spec`, removing the dead `function_type` branch from each. docs check acknowledged: README's F# row already covers .fs/.fsx/.fsi and the user-facing language count is unchanged; the grammar version is an internal implementation detail. Closes #1161
|
Claude finished @carlos-alm's task —— View job PR Review: chore(fsharp): align npm grammar with cargo at v0.3.0Todo List:
Root Cause Analysis ✅Problem Being Solved: Grammar version skew between npm and cargo versions of tree-sitter-fsharp. The WASM engine was using an older grammar version while the native Rust engine was already on v0.3.0, causing potential parsing inconsistencies. Why This Approach: Legitimate fix. Updates npm dependency to match the cargo version (v0.3.0) and removes compatibility workaround code that was bridging the grammar differences. This eliminates dual-shape detection that was only needed when engines used different grammar versions. Risk Assessment: Low risk. This is a proper alignment fix, not symptom hiding. The removal of legacy Configuration Change Detection ✅Dependency Changes:
No High-Risk Changes Detected: No linting rules disabled, test timeouts increased, TypeScript strict mode changes, or build configuration modifications. Test Integrity Check ✅Test Files: Both F# test files remain unchanged with no assertions weakened. Code Quality Review ✅TypeScript Changes: Clean removal of legacy dual-shape detection in Rust Changes: Matching cleanup in Architecture: This properly addresses the CLAUDE.md principle: "Both engines must produce identical results. If they diverge, the less-accurate engine has a bug — fix it, don't document the gap." Potential Issues: None. The changes are straightforward grammar version alignment with proper test coverage. Backlog Compliance Assessment ✅Zero-dep: ✓ — Changes existing tree-sitter dependency to newer version. No new runtime deps added. Foundation-aligned: ✓ — Fully compliant. Addresses P1 (keeps graph current without breaking changes), maintains dual-engine architecture (P2), and eliminates engine divergence that violated the "identical results" requirement. Problem-fit: 3/5 — This is infrastructure maintenance that prevents engine divergence issues. Doesn't directly address the core AI agent orientation problem but maintains system reliability. Breaking: No — Grammar update is internal implementation detail. User-facing language support and API remain unchanged. Tier: 1 (Zero-dep ✓ + Foundation-aligned ✓) Critical ConcernsNone. This is a well-executed maintenance fix. Final Recommendation
|
Greptile SummaryThis PR aligns the WASM engine's F# grammar version with the native (cargo) engine by pinning
Confidence Score: 5/5Safe to merge — the change removes dead code that was unreachable once both engines shared the v0.3.0 grammar, and the package bump is mechanically straightforward. The simplification in both the TypeScript and Rust extractors correctly preserves the existing No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["value_definition node"] --> B["first child == 'val'?"]
B -- No --> Z["return / ignore"]
B -- Yes --> C["findChild(node, 'value_declaration_left')"]
C -- not found --> Z
C -- found --> D["findChild(declLeft, 'identifier_pattern')"]
D -- not found --> Z
D -- found --> E["extract identifier name"]
E --> F["findChild(node, 'curried_spec')"]
F -- not found --> G["hasFunctionType = false"]
F -- found --> H["scan curried children for 'arguments_spec'"]
H -- found --> I["hasFunctionType = true"]
H -- not found --> G
G --> J["emit kind: 'variable'"]
I --> K["emit kind: 'function'"]
Reviews (3): Last reviewed commit: "docs(fsharp): explain tree-sitter-fsharp..." | Re-trigger Greptile |
| @@ -162,7 +162,7 @@ | |||
| "tree-sitter-dart": "^1.0.0", | |||
There was a problem hiding this comment.
GitHub tarball pin has no semver upgrade path
Because the npm registry has no 0.3.0 release, the tarball URL is the right choice here. Worth noting: unlike ^0.x.y semver ranges, npm update will never touch this entry — upgrading to a future release (e.g. 0.4.0) requires a manual URL edit in both package.json and package-lock.json. A short comment in package.json would help future maintainers know why the tarball form was chosen instead of a registry reference.
There was a problem hiding this comment.
Fixed — added a docblock to src/extractors/fsharp.ts explaining (a) why the tarball form is used (no v0.3.0 on npm), (b) that the cargo crate uses the same version, and (c) that upgrading requires a manual URL edit in both package.json and package-lock.json because npm update won't touch this entry. Put it in the extractor docblock rather than package.json since pure JSON doesn't support comments and a _comment field would be non-standard for this repo.
Codegraph Impact Analysis2 functions changed → 4 callers affected across 2 files
|
adcaf40
into
fix/1114-fsharp-signature-grammar
Summary
tree-sitter-fsharpto v0.3.0 (installed from the ionide GitHub tarball — npm has no 0.3.0 release) so the WASM engine matches the cargo crate the native engine already uses.handleValueDefinition/handle_value_definition(both engines) — only the v0.3.0 shape (curried_spec→arguments_spec) is checked. The legacy v0.1.0function_typebranch was dead under both engines once they shared a grammar.Why this lives on top of #1162
The dual-shape detection was introduced in #1162 as a parity workaround. This PR is stacked on
fix/1114-fsharp-signature-grammarso the cleanup lands as soon as that PR merges. Base will be reparented tomainif #1162 merges first.Test plan
npx vitest run tests/parsers/fsharp.test.ts tests/parsers/fsharp-signature.test.ts— 9 passedcargo test --lib extractors::fsharp(codegraph-core) — 3 passednpx vitest run tests/parsers tests/integration— 587 passednpx vitest run tests/benchmarks/resolution— 205 passed (F# resolution fixture included)tree-sitter-fsharp.wasmandtree-sitter-fsharp_signature.wasm(v0.3.0): all node kinds consumed by the extractor are present, no ERROR nodes for the standard fixtures.Closes #1161