Repository navigation
Description
What
Found while chasing the remaining ~1.4% args_exact_match gap after #1524/#1525 fixed python's
node-type undercounting (63.0% → 98.6%). The rest of the gap is a different, more fundamental
methodology issue in measure() (tests/tools/tree_sitter_accuracy_audit.py), not language-specific.
For each file, the tree-sitter walk builds real_funcs: dict[str, int] keyed by function name:
def walk(node):
if node.type in func_node_types:
name = _get_node_name(node)
if name:
real_funcs[name] = _get_param_count(node, lang) # <-- last occurrence winsand the GitGalaxy side does the mirror-opposite:
for r in gg_funcs:
gg_args_by_name.setdefault(r["func_name"], r["args"]) # <-- first occurrence winsWhen a file has multiple functions/methods sharing the same name — extremely common in Python
(__init__/__new__/__call__ across different classes in the same file, @property/@x.setter
pairs sharing a name) — the two sides silently compare unrelated functions: whichever one
tree-sitter walked last against whichever one GitGalaxy's SQL query returned first.
Confirmed concretely: language-crucible/data/python/numpy/core.py defines shape, mask, and
recordmask each 2× (property getter/setter pairs on different classes) and outer 2× (a method
and an unrelated module-level function). cython/Nodes.py has 14 separate __init__ methods
across different node classes.
Impact
This is NOT python-specific — any NODE_MAPS language can have repeated method names within one
file (any OOP language with multiple classes sharing method names: toString, __init__,
constructors, etc.). It also isn't limited to args_exact_match: metrics["real_functions"] += len(real_funcs) and the found/missing/extra set arithmetic all key off the same
collapsed-by-name dict/set, so func_recall/func_precision are also quietly undercounting real
occurrences whenever names repeat within a file, not just args comparability.
Suggested direction (not a full design, needs its own pass)
Something that preserves per-occurrence identity instead of collapsing to one dict entry per name
-- e.g. pairing same-named occurrences positionally (by walk order vs. SQL row order, both of
which should roughly track file order) rather than keeping only first/last, or keying by
(name, ordinal_occurrence) on both sides. Whichever approach, the found_functions/
extra_functions/missing_functions set-based metrics need the same fix, not just
args_comparable/args_exact_match, since they share the same root cause.
Scoped out of #1524/#1525 deliberately -- that PR only widened the per-parameter node-type
whitelist and left this pairing issue alone, since it's a bigger cross-language measurement
redesign, not a mechanical whitelist gap.
Activity