Skip to content

Tree-sitter accuracy audit: node maps for crystal, erlang, nim, julia, r and fsharp - #9201

Merged
squid-protocol merged 2 commits into
mainfrom
treesitter-nodemaps-6
Nov 24, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
treesitter-nodemaps-6

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

What this does

language-crucible v1.8.0 (merged, pin bumped in #9162) added data for ten languages. This maps six of them in the tree-sitter accuracy audit so their function extraction is measured against tree-sitter: crystal, erlang, nim, julia, r, fsharp. Ada is separate (#9154). Elixir, ocaml and hcl are not mapped (below).

Each map follows GitGalaxy's own definition of a function in that language (its func_start rule), not a guess. First measurements:

language functions found recall extra precision args exact
crystal 393 of 400 98.2% 43 90.1% 345 of 393
erlang 494 of 547 90.3% 4 99.2% 412 of 494
nim 666 of 809 82.3% 113 85.5% 572 of 666
julia 422 of 981 43.0% 5 98.8% 280 of 422
r 441 of 449 98.2% 14 96.9% 441 of 441
fsharp 120 of 262 45.8% 6 95.2% 113 of 120

The low rows (julia, fsharp, part of nim) are real engine gaps, not mapping problems: see #9200, which I filed as one consolidated issue with isolated repros (one-line definitions are not extracted; an Erlang function after a -spec containing a record is dropped; Nim operator procs are unnamed).

How each language is read (decisions worth checking)

  • crystal: method_def, not the bodiless abstract_method_def. The grammar splits a setter's = off (def name=(v) reads as name), so the name is rebuilt. macro and a column-0 fun are not modelled by the grammar and read as engine-only.
  • erlang: the engine cleaves at the clause-ending period, so a function is a whole form: clauses joined by ; count once, f/0 and f/1 ending in . count twice. The grammar wraps each clause in its own fun_decl, so a clause counts only if the previous form did not end in ;.
  • nim: every routine, forward declarations included (the engine rule needs no body, unlike its Ada rule). Anonymous proc (x) stays out.
  • julia: a function block plus a call-shaped short-form assignment (f(x) = ...), not macros. Short forms are in the reference because the engine's own rule lists them; I did not narrow the reference to hide the gap.
  • r: a function is named only by the assignment around it. The grammar tags the function keyword as the node's name field, so the generic lookup would return the word "function".
  • fsharp: a let with a function_declaration_left and a member with an args field; values and properties stay out.
  • Classes: mapped for crystal and erlang only. The detector's named class extraction is a per-language allowlist ([TIER 1] Class detection is 0% across apex/csharp/fortran/solidity despite near-perfect function detection #1264) that none of these six is on, so the class numbers for crystal and erlang score the generic fallback (Crystal's class HTTP::Client reads as HTTP). The other four have no class map, like lua, shell and tcl; julia and fsharp therefore show "N/A | 0.0%" in the summary table, as lua does.

Read before merging

  • Baselines were generated in the CI-matched environment (tree-sitter-language-pack 1.24.0 from ci/requirements/treesitter.txt, the full-precision venv), after Tree-sitter accuracy audit: measure Ada (97.8% recall, 96.8% precision) #9154 showed that the self-scan venv gives different numbers. I did not run it in CI yet.
  • A bug I introduced and caught: my first Julia branch in _get_node_name caught every function_definition and returned None when there was no Julia signature, which silently broke Python and R. It is now gated on a signature child, and a test pins that python names are untouched. --all --ci over all 36 baselined languages passes in the CI-matched environment; the 30 existing baselines did not move.
  • Not mapped: elixir (every definition is a generic call, the same problem as scheme), ocaml (functions are let_bindings told apart only by parameters), hcl (no function definitions). The detection baseline has not been regenerated for the new languages; that would lift their coverage on the sheets and is a separate small step.
  • Second commit regenerates docs/language_sheets. Besides the six new function rows, C, C++, JavaScript, Kotlin and TypeScript change because main's call-graph baselines moved since the sheets were generated.
  • Ada (Tree-sitter accuracy audit: measure Ada (97.8% recall, 96.8% precision) #9154) and this PR both add entries to NODE_MAPS and _get_node_name; they should merge cleanly but whichever lands second may need a trivial rebase.

Checked

  • pytest tests/tools/test_tree_sitter_accuracy_nodemaps.py tests/tools/test_language_sheets.py: 20 passed
  • tree_sitter_accuracy_audit.py --all --ci (CI-matched env): 36 checked, all OK
  • ruff_audit.py --ci, doc_refs_audit.py --ci: no new findings
  • Not run: CI on the PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_018srRvhLsKhsTZmCyX36Qem

squid-protocol and others added 2 commits November 24, 2026 09:26
…, r and fsharp

language-crucible v1.8.0 added data for these languages, so the audit can now measure
their function extraction against tree-sitter. Each map follows GitGalaxy's own
definition of a function in that language (its func_start rule), not a guess:

- crystal: a `def` (method_def) and not a bodiless `abstract def`; a setter's `=` is rebuilt (the grammar
  splits it off); parameters from the `params` field. `macro` and a column-0 `fun` are not modelled by the
  grammar and read as engine-only.
- erlang: the engine cleaves at the clause-ending period, so a function is a whole form: clauses joined by
  `;` count once (named from the first), `f/0` and `f/1` ending in `.` count twice.
- nim: every `routine` (proc/func/method/iterator/template/macro/converter), forward declarations included
  because the engine rule needs no body; anonymous `proc (x)` stays out.
- julia: a function block and a call-shaped short-form assignment (`f(x) = ...`), not macros; the name is
  the callee's last identifier. The branch applies only to nodes with a Julia `signature`, so python/c/matlab
  `function_definition` nodes are untouched (a test pins this).
- r: a function is named only by the assignment around it (`f <- function`, `=`, `<<-`, backticks, `obj$f`);
  the grammar tags the `function` keyword as the node's name field, so the generic lookup is bypassed.
- fsharp: a `let` with a function_declaration_left and a member with an `args` field; values and
  properties stay out.

Classes are mapped for crystal and erlang only; the other four have none (like lua/shell/tcl), because the
detector's named class extraction is a per-language allowlist (#1264) none of them is on.

First measurements (functions): crystal 98.2% recall / 90.1% precision, erlang 90.3% / 99.2%, nim 82.3% / 85.5%,
julia 43.0% / 98.8%, r 98.2% / 96.9%, fsharp 45.8% / 95.2%. Baselines were generated in the CI-matched
environment (tree-sitter-language-pack 1.24.0 from ci/requirements/treesitter.txt, full-precision venv).
All 36 baselined languages pass --all --ci there; the 30 existing baselines did not move.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRvhLsKhsTZmCyX36Qem
…nim, julia, r, fsharp)

Generated by tests/tools/language_sheets.py --write from the committed baselines. Besides the six
new function rows, C, C++, JavaScript, Kotlin and TypeScript change because main's call-graph
baselines moved since the sheets were last generated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRvhLsKhsTZmCyX36Qem
@squid-protocol
squid-protocol marked this pull request as ready for review November 24, 2026 14:27
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 7c1aa2e into main Nov 24, 2026
123 checks passed
@squid-protocol
squid-protocol deleted the treesitter-nodemaps-6 branch November 24, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant