Skip to content

fix(detector): a COBOL paragraph's ENTRY ... USING is its parameter declaration and belongs inside its args window (#2863) - #2864

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2863-cobol-entry-args-window
Sep 7, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/2863-cobol-entry-args-window

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #2863.

COBOL is the one Mode A language whose parameter declaration cannot sit on the label's own line. A paragraph name is terminated by its own period, so the ENTRY 'PARA-NAME' USING <linkage-item> that declares the paragraph's alternate entry point is necessarily a separate statement on the next line.

_mode_a_args_window_end extends a label's args-search window only across the language's line-continuation marker, and cobol correctly has none — its fixed-format continuation is a column-7 indicator on the continuing line, not a trailing marker on the line before. So the window was exactly the label line and the declaration always fell one line outside it. The symptom was one function record disagreeing with itself:

PROBE-GLOBALS: args=0   hit_vector.args=1

hit_vector, the block's own rule tally, saw the clause all along. The bounded per-function args field — the one avg_func_args averages (signal_processor.py ~L589) — read 0.

The gap was total, not marginal: not one of the 10,155 paragraphs across the 570-file language-crucible COBOL corpus had a nonzero per-function args count. avg_func_args was structurally 0 for the language.

The fix

cobol routes to a new _cobol_args_window_end, which extends the window from the label line across leading ENTRY statements only, treating blank lines as transparent.

Only ENTRY — the narrowness is the point, not caution

I measured what a wider window would actually pick up. Over the crucible corpus, 158 paragraphs carry a USING/RETURNING somewhere inside their greedy Mode A block, and not one of them is a parameter declaration:

count construct what it is
123 CALL … USING an invocation — passes arguments to a subprogram, does not declare the paragraph's own
26 PROCEDURE DIVISION USING the program-level linkage, swallowed by a preceding label's greedy block
3 XML PARSE … RETURNING a statement clause
6 CALL continuation lines, and a MOVE "USING OPERANDS" string literal

Widening this window to the block — the unbounded behaviour #1973/#2483 removed — would manufacture 158 wrong per-paragraph parameter counts to fix nothing. _COBOL_ENTRY_STATEMENT_RE is anchored to the line's first token, so CALL can never match it; the distinction is structural rather than incidental.

Blank lines are transparent for a concrete reason

Not for symmetry with the fortran branch: prism blanks comment lines in place to preserve line numbering, so a banner comment between a paragraph label and its ENTRY — ordinary COBOL house style — reaches the scan as an empty line. Stopping on it would make the measurement depend on whether the author commented the paragraph.

Verification

  • Golden masters: crucible_check.py PASS on both venvs, zero diff. The real corpus contains no ENTRY … USING at all, so no real-world count moves and the 158 correctly-unattributed clauses stay unattributed — a provable zero-diff on real COBOL, not an unreviewed bless.
  • keyword-rosetta shell (corpus main, which plants the construct): avg_func_args 0.0 → 0.6923 (9 of 13 paragraphs declare one operand).
  • Full pytest suite green — 8,156 passed, 0 failed. audit_check.py all clear (ruff 70-finding baseline + format clean, mypy 2-error baseline, dead-key, ast-accuracy).
  • New regression test test_cobol_paragraph_entry_using_is_inside_the_args_window_2863 pins both halves — what must now be reached (1 operand; 3 operands, which also proves fix(cobol): globals drops WORKING-STORAGE header (#2805); args counts operands not clauses (#2804) #2830's _count_cobol_using_operands reaches the per-function path; a comment-separated ENTRY) and what must stay out of reach (CALL … USING at 0; a non-leading ENTRY at 0). Confirmed it fails on main (got 0) and passes here.

Corpus

No re-bless owed — verify_language.py cobol passes unchanged (81 assertions), because this moves a derived metric and no planted manifest count. That is why this PR does not carry rosetta:rebless-owed.

keyword-rosetta owes a ledger change instead, which I'll open right after this merges: retire cobol-entry-args-outside-mode-a-window (its gap is fixed) and replace it with a live entry for the residual, per GATING.md's rule that a retired entry explains nothing.

avg_func_args lands at −30.8% against the 1.0 median rather than green, and that residue is honest morphology already priced in #2804: main.cbl's four paragraphs carry no ENTRY, and giving them one measures api 1 → 5 (screened), trading a planted, scored column to move a derived one.

Related: #2804 (parent), #2830 (the operand-count fix this completes), #1973 / #2483 (why the bound exists).

🤖 Generated with Claude Code

…eclaration and belongs inside its args window (#2863)

COBOL is the one Mode A language whose parameter declaration cannot sit on
the label's own line. A paragraph name is terminated by its own period, so
the `ENTRY 'PARA-NAME' USING <linkage-item>` that declares the paragraph's
alternate entry point is necessarily a SEPARATE statement on the next line.

`_mode_a_args_window_end` extends a label's args-search window only across
the language's line-continuation marker, and cobol correctly has no marker
(its fixed-format continuation is a column-7 indicator on the CONTINUING
line, not a trailing marker on the line before). So the window was exactly
the label line, and the declaration always fell one line outside it. The
symptom was a single function record disagreeing with itself:

    PROBE-GLOBALS: args=0   hit_vector.args=1

`hit_vector` -- the block's own rule tally -- saw the clause all along;
the bounded per-function `args` field, which `avg_func_args` averages
(signal_processor.py ~L589), read 0. COBOL `avg_func_args` was therefore
structurally 0: not one of the 10155 paragraphs in the 570-file
language-crucible COBOL corpus had a nonzero per-function args count.

cobol now routes to `_cobol_args_window_end`, which extends the window from
the label line across LEADING `ENTRY` statements only, treating blank lines
as transparent.

Only ENTRY, and that narrowness is the point rather than caution. Over the
crucible corpus, 158 paragraphs carry a `USING`/`RETURNING` somewhere inside
their greedy Mode A block and NOT ONE is a parameter declaration:

    123  CALL ... USING          an invocation -- passes arguments to a
                                 subprogram, does not declare the paragraph's
     26  PROCEDURE DIVISION USING  the program-level linkage, swallowed by a
                                 preceding label's greedy block
      3  XML PARSE ... RETURNING   a statement clause
      6  CALL continuation lines, and a MOVE "USING OPERANDS" literal

Widening this window to the block -- the unbounded behaviour #1973/#2483
removed -- would manufacture 158 wrong per-paragraph parameter counts to fix
nothing. `CALL` cannot match `_COBOL_ENTRY_STATEMENT_RE`, which is anchored to
the line's first token, so that distinction is structural rather than
incidental.

Blank lines are transparent for a concrete reason, not for symmetry with the
fortran branch: `prism` blanks comment lines in place to preserve line
numbering, so a banner comment between a paragraph label and its `ENTRY` --
ordinary COBOL house style -- reaches the scan as an empty line. Stopping on
it would make the measurement depend on whether the author commented the
paragraph.

Verification:
- Golden masters: `crucible_check.py` PASS on both venvs, zero diff. The real
  corpus contains no `ENTRY ... USING` at all, so no real-world count moves and
  the 158 correctly-unattributed clauses stay unattributed -- a provable
  zero-diff on real COBOL.
- keyword-rosetta shell (corpus main, which plants the construct):
  `avg_func_args` 0.0 -> 0.6923 (9 of 13 paragraphs declare one operand).
- `audit_check.py` all clear; full pytest suite green (8156 passed).

Corpus: no re-bless owed -- `verify_language.py cobol` passes unchanged (81
assertions), because this moves a derived metric and no planted manifest
count. keyword-rosetta owes a LEDGER change instead: retire
`cobol-entry-args-outside-mode-a-window` and replace it with a live entry for
the residual. `avg_func_args` lands at -30.8% against the 1.0 median rather
than green, and that residue is honest morphology already priced in #2804:
main.cbl's four paragraphs carry no `ENTRY`, and giving them one measures
api 1 -> 5 (screened), trading a planted scored column to move a derived one.

Closes #2863.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants