Skip to content

detector.py's _slice_by_braces checks for dead lang_id "lisp", causing 100% function recall loss for scheme #1928

Closed

Description

@squid-protocol

Description

Found investigating tri-comparison ledger shape scheme/function/existence/agree[ctags]_vs[gitgalaxy] (92 occurrences).

gitgalaxy/core/detector.py's StructuralExtractor._slice_by_braces (Integration Mode B) chooses its scope-delimiter characters based on language:

opener, closer = "{", "}"
if lang_id == "lisp":
    opener, closer = "(", ")"

"lisp" has never been a real key in LANGUAGE_DEFINITIONS -- only "scheme" is registered. That means the parenthesis branch has been unreachable dead code in production for every real scan: lang_id is always "scheme", never "lisp", so every scheme file falls through to the curly-brace default. Since scheme is entirely parenthesis-delimited (no {/} anywhere), the downstream scope-body lookup never finds an opener, hits its if brace_idx == -1: continue bailout, and every single func_start match gets silently discarded -- a 100% recall drop for the whole language, independent of file content or corpus size.

This was never caught by tests/extraction/languages/test_scheme.py/test_scheme_strict.py because those test the func_start regex directly (which is correct in isolation), not the live _slice_by_braces integration path that actually turns regex matches into named function output -- the exact same "passes synthetic tests, fails on real corpus" gap this repo's tri-comparison-ledger-sweep skill has hit before (ABAP, cobol).

There was also a unit test (tests/core_engine/test_detector.py::test_detector_mode_b_lisp_family) asserting this mechanism works -- but it constructed a mock language literally named "lisp" (StructuralExtractor("lisp", MOCK_LANG_DEFS)), which happened to match the dead string check by construction, without ever exercising a real registered language. The mock's own lexical_family value ("lisp_style") was never consulted by the old code either, since the check was on lang_id, not lexical_family -- the test was passing for the wrong reason.

Steps to Reproduce

import sys
sys.path.insert(0, 'tests/tools')
from tri_comparison_gatherer import gather_language
results = gather_language('scheme')
print(sum(len(r.gg_funcs) for r in results))  # 0, despite dozens of real `(define (name ...))` forms

Confirmed directly (isolated by a dispatched investigation, 2026-08-20): prism.py's comment/code splitter is clean (raw (define count unchanged before/after), and func_start's own regex matches correctly when run standalone (31/31 hits on one corpus file) -- the drop happens specifically in _slice_by_braces's bracket-selection logic.

Suggested fix

Key the delimiter choice off the language's lexical_family (scheme's real value: "recursive_block_lisp") instead of a hardcoded lang_id string, so any future lisp-family language sharing this integration mode is covered automatically rather than needing its own hardcoded string.

Evidence

Full discrepancy record in docs/self_scan/tri_comparison_ledger.json, shape scheme/function/existence/agree[ctags]_vs[gitgalaxy].

Activity

  1. added
    bug
    testing
    core-engine
    on Aug 20, 2026
  2. added a commit that references this issue on Aug 20, 2026
    f1c0fd4
  3. added this to the v2.4.9 milestone on Aug 31, 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-enginetesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions