Repository navigation
Fix haskell clause-splitting in tri-comparison's tree-sitter walk - #1865
Merged
Merged
Conversation
_walk_tree_sitter listed every matching tree-sitter node with no consolidation, so a Haskell function written as multiple pattern-match clauses (idiomatic style -- toJSON instance methods, guard-clause helpers, etc.) counted as multiple distinct occurrences of one name. Confirmed via the ledger's own toJSON example: 5 clause-nodes at consecutive lines in one Options.hs instance block, where GitGalaxy and ctags each correctly report 1. This is the same bug tree_sitter_accuracy_audit.py's measure() already fixed once (#1614-1616) -- this module wrote its own simpler walk instead of reusing that closure and silently reintroduced it. Ported the same fix: consecutive func-type sibling nodes sharing a name (interleaved `comment` nodes don't break the run) collapse into the first occurrence only. Verified: haskell's raw tree-sitter function count drops from 275 to 146 (GitGalaxy's own count is 148), and the ledger's tree_sitter-only-vs-[ctags,gitgalaxy] shape (91 occurrences) no longer reproduces. Regenerated the full ledger and chart across all 45 languages with tree-sitter-language-pack + a locally-built universal-ctags -- no other language's entries were affected. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
Resolved without needing a fresh investigation -- two from source already read earlier in this same effort, one from a doc comment already sitting in ctags_reader.py: - agree[gitgalaxy]_vs[ctags,tree_sitter] (2): mixed verdict, read individually. getExtensions is a real instance method both other tools structurally can't see; extensionEnabled is a genuine GitGalaxy false positive (misreads a guard-clause call as a definition). - args agree[none]_vs[gitgalaxy,tree_sitter] (9): one systematic cause, point-free/eta-reduced equations -- GitGalaxy counts true signature arity, tree-sitter counts only the aligned clause's explicit patterns. Same shape as Claim 1, not an engine defect. - class agree[gitgalaxy,tree_sitter]_vs[ctags] (16): not a real discrepancy at all -- ctags_reader.py already documents CTAGS_CLASS_KINDS["haskell"] = set() on purpose, no class-shaped ctags kind exists for this language. The remaining 2 unvalidated haskell shapes (ctags-alone existence, ctags-misses-real existence) are still open -- under investigation. Co-Authored-By: Claude Sonnet 5 <[email protected]>
agree[ctags]_vs[gitgalaxy,tree_sitter] (103 occurrences): dispatched agent investigation, all 10 sampled cases are ctags-side artifacts, no GitGalaxy/tree-sitter defect. Three causes: multi-clause double-tagging (ctags tags every pattern-match equation as a separate occurrence, GG/TS correctly anchor to the first clause only), keyword-as-identifier misparsing (class/where/pattern), and a value-vs-function kind collapse ctags' Haskell parser can't express (GitGalaxy and tree-sitter's own audit tooling both independently make the same correct distinction, per #1312/#1566). Full evidence in the ledger verdict. 5 of 8 haskell shapes now validated. 1 remaining under investigation. Co-Authored-By: Claude Sonnet 5 <[email protected]>
agree[gitgalaxy,tree_sitter]_vs[ctags] (69 occurrences): dispatched agent investigation confirms all 10 sampled misses -- and by cross-check against further non-sampled instances, plausibly all 69 -- are locally-scoped definitions (instance methods, where-clause helpers, let-bound names in do blocks), never top-level. ctags' Haskell parser has no layout-rule/scope awareness and only tags column-1 equations; it correctly handles multi-clause definitions when they're top-level (expandFilterPath/writeFnBinary/writerFn all tag fine), so this is a pure scope gap distinct from the clause-splitting bug fixed earlier. GitGalaxy and tree-sitter both correct; nothing to fix in this repo. Added a doc addendum to ctags_reader.py alongside its existing Haskell notes so this is documented at the source, not just in the ledger. All 8 haskell ledger shapes are now resolved: 5 validated (real findings, all confirming GitGalaxy/tree-sitter correctness against ctags-side limitations, plus one genuine GitGalaxy false-positive and one documented point-free-arity distinction), 3 stale/no-longer- reproducing (artifacts of the clause-splitting bug fixed earlier in this PR, kept as history per the ledger's own lifecycle). Regenerated chart.svg reflects the cleared asterisks. Co-Authored-By: Claude Sonnet 5 <[email protected]>
3 tasks done
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
tests/tools/tri_comparison_gatherer.py::_walk_tree_sittercounted every matching tree-sitter node with no consolidation, so a Haskell function written as multiple pattern-match clauses (idiomatic style) counted as multiple distinct occurrences of one name -- e.g.toJSONwritten as 5 clauses in oneOptions.hsinstance block read as 5 separate functions, where GitGalaxy and ctags each correctly report 1.tree_sitter_accuracy_audit.py'smeasure()already fixed once (tree_sitter_accuracy_audit: haskell ground truth counts each pattern-match clause as a separate real function, deflating measured func_start recall from ~94% to 50.5% #1614-1616); this newer module wrote its own simpler walk instead of reusing that closure and silently reintroduced it. Ported the same fix: consecutive func-type sibling nodes sharing a name (interleavedcommentnodes don't break the run) collapse into the first occurrence only.docs/self_scan/tri_comparison_ledger.jsonanddocs/self_scan/tri_comparison_chart.svgacross all 45 languages (tree-sitter-language-pack + a locally-built universal-ctags) so the committed artifacts reflect the fix.Verification
haskell/function/existence/agree[tree_sitter]_vs[ctags,gitgalaxy]shape (91 occurrences) no longer reproduces; 3 haskell shapes total went stale, all clause-splitting artifacts, none deleted (kept per the ledger's own "never delete, mark still_reproduces: false" lifecycle).ruff_audit.py --ciandmypy_audit.py --ci: no new findings beyond baseline.Test plan
tri_comparison_chart.py --languages haskell --writebefore/after the fix, confirmed thetoJSONexample collapses from 5 clause-nodes to 1 per real instance via direct source inspection (Options.hslines 171-174 and 190-192, two separateinstance ToJSONblocks).tri_comparison_chart.py --all --writerun across all 45 languages, diffed the ledger to confirm only haskell (and one unrelated pre-existing perl entry) changed.ruff_audit.py --ci/mypy_audit.py --ciclean against baseline.🤖 Generated with Claude Code