Skip to content

Fix jcl and m4 func_start recall: route to Mode A, not brace search - #1987

Merged
squid-protocol merged 3 commits into
mainfrom
fix/jcl-m4-mode-a-routing-1975
Aug 21, 2026
Merged

Fix jcl and m4 func_start recall: route to Mode A, not brace search#1987
squid-protocol merged 3 commits into
mainfrom
fix/jcl-m4-mode-a-routing-1975

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Same bug shape as dockerfile's own fix (#1976, merged): jcl and m4 have no ScopeParsingRegistry entry and no brace-delimited bodies at all, so they silently fell through to Mode_B_Braces in _function_slice -- which only produces a named function when a literal { happens to appear by coincidence within its search window.

  • jcl: func_start matches // <name> EXEC ... job-step lines -- JCL is fixed-column mainframe syntax with no brace concept anywhere.
  • m4: func_start matches define(...)/m4_define(...)/AC_DEFUN(...) etc. -- macro definitions are parenthesis-delimited with backtick/bracket quoting, not brace-delimited.

Evidence

Direct measurement (struct_func_start, the raw signal, vs. function_count, the named list actually reaching consumers), against the real language-crucible corpus:

Language Raw signal Named list (before) Recall
jcl 3 0 0%
m4 39 1 2.6%

Fix

Routes both to Mode A (_slice_by_labels), the same "greedy to the next func_start match" heuristic already proven for abap/cobol/fortran/assembly/dockerfile. Post-fix, both hit 100% recall in the local corpus (3/3, 39/39).

makefile was also flagged as a candidate in the same investigation but its corpus sample was inconclusive (only 1 real match total) -- deliberately left untouched, out of scope for this fix.

Verification

  • pytest across jcl/m4 extraction + strict tests, plus test_detector.py: 321 passed, 3 xfailed, 3 xpassed (pre-existing, unrelated).
  • ruff_audit.py --ci / mypy_audit.py --ci: clean against baseline.
  • Real corpus recall independently re-confirmed: jcl 3/3, m4 39/39.
  • crucible_check.py (full_precision + zero_dependency): real, expected drift in jcl/m4 files (new real functions captured, e.g. curl-sysconfig.m4's CURL_DARWIN_SYSTEMCONFIGURATION) plus global spatial-layout ripple across the corpus (a real function-count change in a directory group shifts the whole graph's spatial layout, confirmed the same pattern as prior sweep sessions); both golden masters re-blessed; final re-run: PASS/PASS.

Implemented via a Gemini/agy dispatch from a fully diagnosed issue (root-caused and filed in the same session as #1976), independently re-verified end to end (diff read, tests/audits/recall/crucible_check all re-run from scratch, not just trusting the subagent's own self-report) before this PR.

Fixes #1975.

🤖 Generated with Claude Code

Same bug shape as dockerfile (#1976): jcl and m4 have no
ScopeParsingRegistry entry and no brace-delimited bodies at all, so
they silently fell through to Mode_B_Braces in _function_slice --
which only produces a named function when a literal { happens to
appear by coincidence within its search window.

jcl's func_start matches "// <name> EXEC ..." job-step lines -- JCL is
fixed-column mainframe syntax with no brace concept anywhere. m4's
func_start matches define(...)/m4_define(...)/AC_DEFUN(...) etc. --
macro definitions are parenthesis-delimited with backtick/bracket
quoting, not brace-delimited.

Confirmed via direct measurement (struct_func_start, the raw signal,
vs. function_count, the named list actually reaching consumers):
  jcl: 3 raw matches, 0 reached the named list (0% recall)
  m4:  39 raw matches, 1 reached the named list (2.6% recall)

Routes both to Mode A (_slice_by_labels), the same greedy-to-next-
match heuristic already proven for abap/cobol/fortran/assembly/
dockerfile. Post-fix: both hit 100% recall in the local corpus (3/3,
39/39). makefile was also flagged as a candidate in the same
investigation but its corpus sample was inconclusive (1 match total)
-- deliberately left untouched, not part of this fix's scope.

Verified against the full ~80-repo crucible corpus (both golden
masters re-blessed; drift is real function-count/structural-mass
changes in jcl/m4 files plus expected global spatial-layout ripple
across the corpus, not corruption elsewhere).

Fixes #1975.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Gemini 3.1 Pro <noreply@google.com>
@squid-protocol
squid-protocol enabled auto-merge (squash) August 21, 2026 01:46
…ting-1975

# Conflicts:
#	tests/golden_master_audit.json
#	tests/golden_master_zero_dep_audit.json
@squid-protocol
squid-protocol merged commit 5d01ef6 into main Aug 21, 2026
25 of 27 checks passed
@squid-protocol
squid-protocol deleted the fix/jcl-m4-mode-a-routing-1975 branch August 21, 2026 02:03
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

Severity Count
🔴 Critical 0
🟠 High 0
🟡 Medium 0
🟢 Low 0
ℹ️ Info 3

ℹ️ Info Findings

[checkov] Ensure that a user for the container has been created

File: /docs/language_status/dockerfile.md:1
Rule: CKV_DOCKER_3
Ensure that a user for the container has been created

[checkov] Ensure that HEALTHCHECK instructions have been added to container images

File: /docs/language_status/dockerfile.md:1
Rule: CKV_DOCKER_2
Ensure that HEALTHCHECK instructions have been added to container images

[checkov] Ensure the base image uses a non latest version tag

File: /docs/language_status/dockerfile.md:157
Rule: CKV_DOCKER_7
Ensure the base image uses a non latest version tag

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol added a commit that referenced this pull request Aug 21, 2026
…-shift

Second conflict round: #1987 (jcl/m4) landed on main right after the
first resolution, requiring another regenerate-and-rebless pass.

Also fixes a real, separate issue caught while investigating why
PR #1985/#1987 merged despite a failing ruff-audit CI check: #1972
(record_keeper.py's class_count fix, merged earlier and unrelated to
this PR) shifted 7 pre-existing baselined findings by a couple of
lines each -- tests/ruff_audit_baseline.json was never regenerated to
absorb that shift, so every PR's ruff-audit CI run since has been
reporting those 7 as spurious 'new' findings. Confirmed via
audit_check.py that all 7 are pure line-shifts (same file/code/
message, just moved), not real regressions, and regenerated the
baseline to absorb them. Verified against the exact CI-pinned ruff
version (0.16.0, not whatever floats on PATH locally).
squid-protocol added a commit that referenced this pull request Aug 21, 2026
* Add named class (build-stage) extraction for dockerfile

Dockerfile had no named class extraction at all: it wasn't in
_CLASS_START_NAMED_EXTRACTION_LANGS, so it fell back to the legacy
generic regex (class|struct|interface|trait|enum), which never
matches Dockerfile's FROM syntax at all -- correctly, since Dockerfile
has none of those keywords. Result: class_data stayed completely
empty for every Dockerfile scanned, even though struct_class_start
(the raw signal) correctly counted every real FROM line.

class_start's own regex previously captured only the literal keyword
FROM itself, not the build stage's real name -- extended it to an
alternation shape (matching the existing Fortran/Lua/ABAP convention
_resolve_class_start_match already documents): group 1 captures the
AS <alias> name when present, group 2 falls back to the bare base-image
reference for a stage with no alias (the file's final/default stage).
--platform=$VAR-style flags between FROM and the image reference are
skipped over. Added dockerfile to _CLASS_START_NAMED_EXTRACTION_LANGS,
and to the boundary-resolution skip condition alongside abap (same
#1907 rationale -- Dockerfile stages are never nested, and the brace
search would mistake ${VAR} template-substitution braces for a real
body opener).

Verified: class_data row counts now match struct_class_start exactly
(69/6/1/1 across the moby test corpus), with real stage names (base,
criu, xx, binary-dummy, ...) instead of the literal string "FROM"
repeated. ReDoS-probed the new regex directly (5000-char runs, deeply
nested continuations, huge flag/image tokens) -- all sub-millisecond.

One known, accepted side effect: THE LINEAGE EXTRACTOR (detector.py's
generic "any class_start match with 2+ groups treats group 2 as an
inheritance parent") doesn't know groups 1/2 here are alternation-
exclusive, not name-then-parent -- a bare FROM <image> (no alias)
sweeps the image reference into that file's parent_entity metadata.
This is a pre-existing, already-shipped pattern (fortran's own
class_start has the identical alternation shape and triggers the same
behavior for bare TYPE declarations today), not something this fix
introduces -- tracked as its own issue (#1983) for a future, more
alternation-aware fix to the shared extractor, not blocking here.

Fixes #1974.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Gemini 3.1 Pro <noreply@google.com>

* Regenerate golden masters against merged main (#1985 + dockerfile class fix)

* Regenerate golden masters (2nd merge-race) and fix ruff baseline line-shift

Second conflict round: #1987 (jcl/m4) landed on main right after the
first resolution, requiring another regenerate-and-rebless pass.

Also fixes a real, separate issue caught while investigating why
PR #1985/#1987 merged despite a failing ruff-audit CI check: #1972
(record_keeper.py's class_count fix, merged earlier and unrelated to
this PR) shifted 7 pre-existing baselined findings by a couple of
lines each -- tests/ruff_audit_baseline.json was never regenerated to
absorb that shift, so every PR's ruff-audit CI run since has been
reporting those 7 as spurious 'new' findings. Confirmed via
audit_check.py that all 7 are pure line-shifts (same file/code/
message, just moved), not real regressions, and regenerated the
baseline to absorb them. Verified against the exact CI-pinned ruff
version (0.16.0, not whatever floats on PATH locally).

---------

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Gemini 3.1 Pro <noreply@google.com>
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.

jcl and m4 (and possibly makefile) have the same Mode B brace-search func_start recall bug as dockerfile/abap/scheme

1 participant