Skip to content

haskell func_start: hardcoded '< 2 lines' floor in _slice_by_indentation drops every abstract typeclass method signature #1435

Closed

Description

@squid-protocol

Summary

tests/tools/tree_sitter_accuracy_audit.py --lang haskell measures func_start recall at only
55.3% (52/94 real functions found in the language-crucible haskell corpus). Root cause,
confirmed via minimal repro and direct pipeline tracing (not the func_start regex itself, which
matches correctly): detector.py's _slice_by_indentation (Mode C, used for haskell/python/yaml
per #1266) has a hardcoded floor at line ~2469:

block = code[start_idx:end_idx].strip()
if not block or len(block.splitlines()) < 2:
    continue

Any Haskell function whose captured block is exactly ONE line gets silently dropped. This is
exactly the shape of an abstract typeclass method signature -- methodName :: Type, declared
inside a class ... where block with NO default implementation -- which is a ubiquitous,
idiomatic Haskell pattern, not an edge case.

Repro (confirmed both via minimal file and real corpus)

Minimal file:

module Foo where

class HasSyntaxExtensions a where
  getExtensions :: a -> Extensions

realFunc :: Int -> Int
realFunc x = x + 1

galaxyscope finds realFunc (2-line block: signature + equation) but silently drops
getExtensions (1-line block: signature only, no equation -- it's abstract).

Real corpus: language-crucible/data/haskell/pandoc/Options.hs's
class HasSyntaxExtensions a where \n getExtensions :: a -> Extensions (line 63) is dropped the
same way. Traced the full pipeline for this file: the raw func_start regex correctly matches
getExtensions at line 63 (verified via direct .finditer()), prism.py's shielding correctly
preserves the line in code_stream (verified byte-for-byte), so the < 2 floor in
_slice_by_indentation is the sole point of loss -- a full-pipeline scan of this single 459-line
file found exactly 1 function total (isEnabled) despite dozens of real signatures being
present and correctly regex-matched.

Note: the surrounding code (added for #1266, see the #1266 comment block right above this
check) already anticipated a RELATED but different failure mode -- a signature immediately
followed by its own equation clause getting truncated to just the bare signature line -- and
fixed that case by extending end_idx through the equation. But when there IS no equation at all
(the abstract-method case), there's nothing to extend to, and the unconditional < 2 floor drops
it regardless.

Suggested fix shape

Gate the floor to not apply for haskell (or lower it to < 1 for haskell specifically), since a
single-line match there is virtually always a real, legitimate typeclass method signature --
func_start's own regex already requires an explicit :: type-signature marker to match at all,
which is a strong enough signal on its own without also requiring 2+ lines. Something like:

if not block or (len(block.splitlines()) < 2 and lang_id != "haskell"):
    continue

Verify against tests/extraction/languages/test_haskell.py (must not regress existing cases) and
re-run python tests/tools/tree_sitter_accuracy_audit.py --lang haskell --regenerate to confirm
found_functions (currently 52) rises meaningfully without extra_functions (currently 26)
climbing in proportion -- watch specifically for whether this also lets through any single-line
false positive shape that wasn't previously reachable (the < 2 floor may have been incidentally
suppressing some other bug's false positives for other reasons, not just filtering real
single-line signatures -- worth a quick regression scan across the OTHER Mode C languages too,
python/yaml, even though the fix itself should be haskell-gated and not touch their behavior).

Scope note

This only affects func_start/args/class_start name-extraction accuracy (the extraction-
gauntlet pillar from epic #813), not GitGalaxy's risk-scoring rules, which are unaffected.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    priority: high
    on Aug 13, 2026
  2. 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: hightestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions