Repository navigation
Fix #595: Strict parsing tests for m4 structural signatures - #766
Merged
Merged
Conversation
Adds strict positive/negative, ambiguity-sweep, and ReDoS regression coverage in tests/core_engine/test_language_standards_strict.py for all 31 non-None m4 structural signatures (41 tests). Found and fixed 1 real bug (Engine Rule 12: Comment-Style Completeness), affecting 3 rules. Real bug found and fixed: dead_code, doc, and ownership were all anchored ONLY on `dnl`, but GNU M4's actual default lexer-level comment delimiter is `#`-to-newline (confirmed in the shared line_exclusive family table in gitgalaxy_config.py, which prism.py uses to carve the comment stream for every line_exclusive language -- `dnl` is a separate, macro-level discard-to-newline mechanism, distinct from the lexer-level `#` comment). Verified against the real language-crucible corpus (curl/gnucobol configure.ac): `#` comments are as common as, or more common than, `dnl` ones in real Autoconf files, including realistic `# FIXME:`/`# Copyright` lines. Checking only `dnl` silently missed the dominant real-world style. Widened all three rules to accept both `dnl[ \t]+` and `#[ \t]*` prefixes. Also covers the issue's known ambiguity pattern (func_start vs macros -- confirmed no false collision, m4's macro-*definition* keywords are structurally distinct from its C-preprocessor-hook-configuration keywords) plus 5 intentional double-classifications found via a systematic token-overlap sweep across all rule pairs (api/macros on AC_DEFINE, cleanup/state_mutation on popdef, cleanup/test on AT_CLEANUP, dependency_injection/structural_boundaries on AC_REQUIRE, doc/ownership on AC_COPYRIGHT), a lexical-family check confirming no block-comment-family confusion (m4 is line_exclusive), and a ReDoS scaling sweep (2000-32000, all ~2x per doubling, confirming no catastrophic backtracking). Golden master fixtures regenerated via tests/tools/crucible_check.py --update; diff confirmed confined entirely to m4/curl and m4/gnucobol corpus entries (verified programmatically -- no other repo's parsed-file section changed), and the "Commented-out Code" count increase in both is the expected direct effect of the dead_code fix now detecting previously- invisible #-prefixed commented macros. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #518, closes #595.
Adds strict positive/negative, ambiguity-sweep, and ReDoS regression coverage in
tests/core_engine/test_language_standards_strict.pyfor all 31 non-Nonem4structural signatures (41 tests). Found and fixed 1 real bug (Engine Rule 12:
Comment-Style Completeness), affecting 3 rules.
Real bug found and fixed
dead_code,doc, andownershipwere all anchored ONLY ondnl, but GNU M4'sactual default lexer-level comment delimiter is
#-to-newline -- confirmed in theshared
line_exclusivefamily table ingitgalaxy_config.py({"delimiters": ["#", "<#", "#>", "=begin", "=end", ";", "dnl", "%", "#|", "|#"]}), whichprism.pyuses tocarve the comment stream for every
line_exclusivelanguage.dnlis a separate,macro-level discard-to-newline mechanism, distinct from the lexer-level
#comment.Verified against the real
language-cruciblecorpus (curl/gnucobolconfigure.ac):#comments are as common as, or more common than,dnlones in real Autoconf files(88-106
#lines vs 128-265dnllines per file), including realistic# FIXME:/# Copyrightlines actually present in the corpus. Checking onlydnlsilently missed the dominant real-world style. Widened all three rules to accept both
dnl[ \t]+and#[ \t]*prefixes.Also covered
func_startvsmacros) -- confirmed no falsecollision: m4's macro-definition keywords (
m4_define/define/AC_DEFUN/...) arestructurally distinct from its C-preprocessor-hook-configuration keywords
(
AC_DEFINE/...). Also a ReDoS check onfunc_startagainst a long macro-shaped run.across all rule pairs (not just the known cross-language ones):
api/macrosonAC_DEFINE,cleanup/state_mutationonpopdef,cleanup/testonAT_CLEANUP,dependency_injection/structural_boundariesonAC_REQUIRE, anddoc/ownershiponAC_COPYRIGHT.line_exclusive, no native block syntax -- a stray/* */-shaped sequence, which canlegitimately appear as literal embedded C output, doesn't trigger
dead_code/doc).func_start's structural exclusion ofdnl/#-commented lines (its own^[ \t]*anchor can't tolerate either prefix, a stronger guarantee than relying on prism.py's
stream separation alone).
unbounded-looking quantifier -- all showed ~2x time per doubling (linear), not the
~4x signature of catastrophic backtracking.
Verification
pre-PR, includes
test_prism.py)ruff format --checkclean;python tests/ruff_audit.py --ci-- no new findingsbeyond baseline
guidestar_lens.py, untouched by this PR(pre-existing drift, confirmed via
git statusscope)python tests/tools/crucible_check.pyagainst the locallanguage-crucible corpus -- real diff found in both venvs, confined entirely to
m4/curlandm4/gnucobolcorpus entries (verified programmatically: no otherrepo's parsed-files section changed). The "Commented-out Code (Dead Logic)" count
increase in both (curl: 0->4, gnucobol: 0->1) is the expected direct effect of the
dead_codefix now detecting previously-invisible#-prefixed commented macros.Fixtures regenerated via
crucible_check.py --updateand re-verified clean (PASS)in both venvs.
🤖 Generated with Claude Code