Skip to content

tree_sitter_accuracy_audit: haskell's _get_param_count never finds parameters (equation node's pattern list field is 'patterns', not 'parameters') #1505

Closed

Description

@squid-protocol

Summary

args_exact_match for haskell measures 31/81 (38.3%) in docs/self_scan/tree_sitter_accuracy_history.csv. Every sampled mismatch is real=0 got=N where GitGalaxy's own curried-arity count (N, from :: type-signature arrow counting -- see #1209) is correct -- the tool's tree-sitter ground truth is under-measuring.

Root cause

tests/tools/tree_sitter_accuracy_audit.py::_get_param_count looks for a field literally named parameters, which tree-sitter-haskell's real function-equation node never has.

Confirmed via a live parse of:

configureCommonState :: Foo -> Bar -> IO ()
configureCommonState a b = return ()

This produces TWO separate nodes typed "function" (haskell's grammar reuses this type name for two unrelated shapes, both already inside func_node_types = {"function"}):

  1. Inside the signature node: an arrow-chain type expression (Foo -> Bar -> IO ()) with fields parameter/arrow/result -- no name field, so _get_node_name correctly returns None for it and it's never added to real_funcs (no false-positive naming collision here, confirmed).
  2. The actual function equation (configureCommonState a b = return ()) with fields name (-> variable, resolves to "configureCommonState" correctly), patterns (-> a patterns node wrapping one variable child per parameter -- 2 in this example), and match.

_get_param_count never checks a patterns field at all, so it falls through every existing branch and returns 0 for every real haskell function equation regardless of true arity.

Reproduce: LANGUAGE_CRUCIBLE_PATH=/home/joe/nyx_projects/language-crucible python tests/tools/tree_sitter_accuracy_audit.py --lang haskell (no --ci) and read the "Sample args-count mismatches" section.

Suggested fix

Same shape as #1503/#1504 (this function's own precedent, plus the original #1339 whitelist-gap fix): when node.type == "function" and node.child_by_field_name("patterns") is not None, count that node's named children as the parameter count. Sample corpus (pandoc/App.hs) only exercises plain variable patterns in the cases checked so far -- verify against at least a wildcard (_) and a literal/constructor pattern (e.g. f 0 = ...) too, since those are also valid named children of a patterns node and should still count as one parameter each. Note this only fixes the ground-truth counter; it does not touch GitGalaxy's own arrow-counting args regex or _count_haskell_type_arrows in detector.py, which are already correct per the sampled mismatches (got already matches expected arity in every sample).

Out of scope

Do not touch anything related to func_start's equation-form detection (#1435/#1442, already closed) or the "Sample missing"/"Sample extra" func-name mismatches shown in the same audit run -- this issue is scoped to the args-counter only.

This only affects tests/tools/tree_sitter_accuracy_audit.py's own measurement accuracy (epic #1227/#1261), not GitGalaxy's actual args structural signature or risk scoring in any way.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    on Aug 13, 2026
  2. squid-protocol commented on Aug 14, 2026

    @squid-protocol
    OwnerAuthor

    Fixed by #1507 (haskell equation node's param list field is 'patterns', not 'parameters' -- _get_param_count now handles it, see tests/tools/tree_sitter_accuracy_audit.py line ~1282). Closing as already resolved -- found while triaging the sweep backlog, PR merged but issue was never auto-closed.

  3. added this to the v2.4.8 milestone on Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginepriority: mediumtestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions