Skip to content

fix(scheme): _slice_by_braces checks dead lang_id "lisp", causing 100% recall loss - #1929

Merged
squid-protocol merged 2 commits into
mainfrom
fix/scheme-slice-by-braces-lisp-check
Aug 20, 2026
Merged

fix(scheme): _slice_by_braces checks dead lang_id "lisp", causing 100% recall loss#1929
squid-protocol merged 2 commits into
mainfrom
fix/scheme-slice-by-braces-lisp-check

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Closes detector.py's _slice_by_braces checks for dead lang_id "lisp", causing 100% function recall loss for scheme #1928. StructuralExtractor._slice_by_braces (Integration Mode B) chose its scope-delimiter characters via if lang_id == "lisp": -- but "lisp" has never been a real key in LANGUAGE_DEFINITIONS (only "scheme" is), so that branch was unreachable dead code in production. Every real scheme file fell through to the curly-brace default; since scheme is entirely parenthesis-delimited, the downstream scope-body search never found an opener and silently discarded every func_start match -- a 100% function-recall drop for the whole language, confirmed via the tri-comparison ledger's scheme/function/existence/agree[ctags]_vs[gitgalaxy] shape (92 occurrences).
  • GitGalaxy's own func_start regex was never the problem (confirmed matching 31/31 standalone against real corpus source), and prism.py's comment stripping was confirmed clean too -- the drop was isolated specifically to this delimiter-selection branch via a live-pipeline before/after proof.
  • Fix keys the delimiter choice off lexical_family == "recursive_block_lisp" (scheme's real value) instead of the dead lang_id string, so any future lisp-family language sharing this integration mode is covered automatically.
  • Also fixes test_detector_mode_b_lisp_family, which had been passing for the wrong reason: its mock language was literally named "lisp" (matching the dead check by construction) with a mock lexical_family value the old code never actually consulted.

Verification

  • Directly against the tri-comparison gatherer: scheme function recall goes from 0 to 58 real functions found across the corpus (ctags finds 92 total -- a smaller residual gap remains, tracked separately, not blocking this fix).
  • Confirmed via spot-checks (not just trusted) that the new 50-occurrence "GitGalaxy-alone" shape this fix surfaces is real, nested define forms ctags' scheme parser structurally misses (e.g. (module (create-bindings create-inits) (define (build-free-ref x) ...))) -- a genuine win, not a false-positive regression.
  • 108 scheme-specific tests + full tests/core_engine//tests/extraction/ suite green (6747 passed).
  • python tests/tools/crucible_check.py: full_precision PASS, zero_dependency PASS (after re-blessing golden masters for the real, expected output change on scheme/racket corpus files).
  • ruff_audit.py --ci / mypy_audit.py --ci / ruff format --check: clean (verified my specific edits are format-clean; a large pre-existing, unrelated formatting drift in test_detector.py was confirmed present even with my changes stashed out, and left untouched).

Test plan

  • Live-pipeline before/after verified directly (not just the regex in isolation)
  • New shape surfaced by the fix spot-checked against real source, confirmed legitimate
  • Golden master diff reviewed line-by-line, confirmed scoped to scheme + natural ripple
  • Full extraction/core_engine suite green
  • crucible_check.py differential scan clean (both venvs, post-reblessing)

🤖 Generated with Claude Code

…% recall loss

Closes #1928. StructuralExtractor._slice_by_braces (Integration Mode B)
chose its scope-delimiter characters via `if lang_id == "lisp":` -- but
"lisp" has never been a real key in LANGUAGE_DEFINITIONS (only "scheme"
is), so that branch was unreachable dead code in production. Every real
scheme file fell through to the curly-brace default; since scheme is
entirely parenthesis-delimited, the downstream scope-body search never
found an opener and silently discarded every func_start match -- a 100%
function-recall drop for the whole language, confirmed via
scheme/function/existence/agree[ctags]_vs[gitgalaxy] (92 occurrences).

GitGalaxy's own func_start regex was never the problem (confirmed
matching 31/31 standalone against real corpus source), and prism.py's
comment stripping was confirmed clean too -- the drop was isolated
specifically to this delimiter-selection branch via a live-pipeline
before/after proof (monkey-patching lang_id to "lisp" immediately
recovered real functions from the same input).

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

Also fixes tests/core_engine/test_detector.py::test_detector_mode_b_lisp_family,
which had been passing for the wrong reason: its mock language was
literally named "lisp" (matching the dead check by construction) with a
mock lexical_family value ("lisp_style") the old code never actually
consulted. Updated the mock to scheme's real lexical_family value so the
test now validates the actual production mechanism.

Verified directly against the tri-comparison gatherer: scheme function
recall goes from 0 to 58 real functions found across the corpus (ctags
finds 92 total -- a smaller residual gap remains, tracked separately, not
blocking this fix; confirmed via spot-checks that the 50-occurrence
GitGalaxy-alone shape this fix newly surfaces is real nested `define`
forms ctags' scheme parser structurally misses, not a false-positive
regression).

Re-blessed both golden master fixtures for the resulting real, expected
output change on the scheme/racket corpus files (function counts,
risk/topology numbers that depend on them) -- see CONTRIBUTING.md-style
explanation in this message; diff reviewed and confirmed scoped to
scheme + natural global-aggregate ripple, no unrelated language affected.

144 core_engine/extraction tests pass (108 scheme-specific), full suite
green (6747 passed), crucible_check.py clean on both venvs after
re-blessing, ruff/mypy/format clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol added a commit that referenced this pull request Aug 20, 2026
…#1930)

Investigates and validates the entire m4 tri-comparison ledger backlog
plus scheme's original recall-gap shape, via the tri-comparison-ledger-
sweep skill:

- m4/function/existence/agree[ctags]_vs[gitgalaxy] (79): clean ctags-side
  limitation, not a GitGalaxy defect -- every sampled occurrence is a real
  AC_DEFINE/AC_DEFINE_UNQUOTED autoconf helper call (emits a C
  preprocessor #define at build time), not an M4 macro definition. ctags'
  M4 parser heuristically over-tags these as function definitions; noted
  in ctags_reader.py alongside the existing C RICHCMP_WRAPPER precedent.
- m4/function/existence/agree[gitgalaxy]_vs[ctags] (1): real GitGalaxy
  false positive (func_start captured the AC_DEFUN keyword itself as a
  function name), fixed in PR #1927.
- m4/class/existence/agree[gitgalaxy]_vs[ctags] (4): real GitGalaxy false
  positive -- m4's class_start is None but detector.py's class-extraction
  fallback doesn't check that, so it matches raw C struct declarations
  embedded as text inside autoconf feature-test macro arguments. Filed as
  #1925 (broader gap, 18 other class_start=None languages not yet
  checked), not fixed in this sweep.
- scheme/function/existence/agree[ctags]_vs[gitgalaxy] (92): confirmed
  catastrophic GitGalaxy engine defect (100% function recall loss for the
  whole language), root-caused and fixed in PR #1929. A smaller residual
  gap remains post-fix (58/92 found) and a new, legitimate GitGalaxy-alone
  shape it surfaces (real nested `define` forms ctags' parser misses) is
  left unvalidated for a future sweep pass.

Also filed #1926 (yacc: both real corpus files silently excluded by
statistical_auditor.py's anomaly sweep, likely an n=2 degenerate-cohort
Z-score issue -- not root-caused to the exact triggering check, flagged
for follow-up).

Regenerated tri_comparison_chart.svg and tri_comparison_points_of_interest.md;
diff confirmed scoped to m4 (asterisks fully cleared) and scheme (0->58/92,
still asterisked since the residual gap is real and not yet fully closed).

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…races-lisp-check

# Conflicts:
#	tests/golden_master_audit.json
#	tests/golden_master_zero_dep_audit.json
@squid-protocol
squid-protocol merged commit f1c0fd4 into main Aug 20, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/scheme-slice-by-braces-lisp-check branch August 20, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant