Repository navigation
Description
Summary
tests/tools/tree_sitter_accuracy_audit.py's _get_param_count (the tree-sitter ground-truth
arity counter used by args_exact_match) has a counted_types whitelist that was built around
JS-family grammars (identifier/assignment_pattern/array_pattern/object_pattern/
rest_pattern) plus C-family parameter_declaration. It was extended once for rust (#1319,
gated to rust's two node types only, with an explicit comment claiming "no other NODE_MAPS
language's parameter children use these type names") but never audited against the rest of
NODE_MAPS -- turns out that claim was wrong, and the same false-"real=0" defect shape #1319 fixed
for rust alone was silently deflating measured args_exact_match for 11 languages:
| language | real per-param node type(s) not in whitelist |
|---|---|
| csharp | parameter (shared with scala, NOT rust-specific as the old comment claimed) |
| scala | parameter |
| java | formal_parameter |
| apex | formal_parameter |
| typescript | required_parameter, optional_parameter |
| php | simple_parameter, variadic_parameter, property_promotion_parameter |
| ruby | optional_parameter, splat_parameter, hash_splat_parameter, block_parameter (plain identifier was already covered) |
| go | variadic_parameter_declaration (plain parameter_declaration was already covered) |
| swift | no "parameters" field at all -- function_declaration/init_declaration have bare parameter nodes as flat siblings, not wrapped in any field or wrapper node |
| dart | no "parameters" field at all -- function_signature wraps an unfielded formal_parameter_list containing formal_parameter children |
| matlab | no "parameters" field and no C-style declarator -- function_definition wraps an unfielded function_arguments child containing plain identifier children |
Confirmed via language-crucible for each, e.g. csharp's
GetParseDiagnostics(CancellationToken cancellationToken = default) measured real=0 against
GitGalaxy's correct got=1 pre-fix; every affected language showed this same "real=0 regardless
of actual signature" pattern in --lang <x>'s verbose mismatch samples.
Impact (measured against language-crucible, args_exact_match / args_comparable)
| language | before | after |
|---|---|---|
| csharp | 119/571 (20.8%) | 535/571 (93.7%) |
| java | 81/233 (34.8%) | 222/233 (95.3%) |
| apex | 34/38 (89.5%) | 38/38 (100%) |
| scala | 109/499 (21.8%) | 481/499 (96.4%) |
| typescript | 379/1566 (24.2%) | 1484/1566 (94.8%) |
| php | 484/1701 (28.5%) | 1700/1701 (99.9%) |
| swift | 16/92 (17.4%) | 84/92 (91.3%) |
| dart | 243/526 (46.2%) | 454/526 (86.3%) |
| ruby | 85/117 (72.6%) | 89/117 (76.1%) |
| go | 298/817 (36.5%, stale local baseline) | 731/817 (89.5%) |
| matlab | 1/23 (4.3%) | 22/23 (95.7%) |
Zero regressions confirmed across every other NODE_MAPS language (rust, kotlin, objective-c,
powershell, javascript, c, cpp, css, fortran, zig, solidity, tcl, perl, haskell) -- c and cpp
even improved slightly as a side effect (1606→1609, 991→1004) since a couple of their real-world
samples happened to use the newly-added node types too.
Note: this is a ground-truth measurement fix, not necessarily a GitGalaxy product-accuracy fix
args_exact_match measures GitGalaxy's OWN _count_top_level_args/args regex output against
tree-sitter as ground truth. This fix corrects the ground truth side -- in most sampled cases
GitGalaxy's own counter was already returning the right number (e.g. GetParseDiagnostics above:
GitGalaxy's got=1 was correct all along, real=0 was the bug). Whether any GENUINE GitGalaxy
args-counting defects remain is now measurable for the first time across these 11 languages, and
should be triaged as a separate follow-up once this ground-truth fix lands (see below).
Residual mismatches after this fix (follow-up triage, not fixed here)
Skimmed the post-fix mismatch samples for csharp/typescript/swift -- the largest remaining gaps
(e.g. swift's Session.swift::request real=1 got=8, typescript's crConnection.ts::constructor
real=2 got=4) all traced to the tool's own already-documented SCOPE limitation: same-named
function/method overloads within one file collide in both tree-sitter's walk and GitGalaxy's
function_data table (each keeps only one row per name per file), so the reading is an artifact
of the measurement methodology, not a new counting bug -- confirmed via grep that all three
sampled cases are legitimate method overloading (multiple classes/overloads sharing a name in the
same file), not a novel defect shape.
Two smaller, apparently genuine, single-language gaps were also noticed in passing (not chased
here, flagging for separate issues if worth pursuing):
- dart: a couple of real single-line signatures measured
got=0from GitGalaxy's ownargs
regex (e.g.editable_text.dart::userUpdateTextEditingValue) -- narrow, not obviously
cross-language. - c: very long/multi-line signatures with the return type on its own line above the function name
(e.g.cpython/compile.c::_PyCompile_EnterScope) measuredgot=0-- also narrow, C's overall
args accuracy is already 96%+.
Fix
tests/tools/tree_sitter_accuracy_audit.py's _get_param_count: extend the base counted_types
whitelist with the newly-confirmed node type names above (safe to add unconditionally -- none
collide with any other NODE_MAPS language's existing per-parameter node names), and add
swift/dart/matlab-specific branches for the three no-field shapes. Baselines regenerated for all
11 affected languages.
Activity
fix(tests): _get_param_count node-type gaps deflated args_exact_match…
fix(tree_sitter_accuracy_audit): args ground-truth counter missing so…