Repository navigation
fix(detector): a COBOL paragraph's ENTRY ... USING is its parameter declaration and belongs inside its args window (#2863) - #2864
Merged
Conversation
…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]>
Contributor
This was referenced Sep 7, 2026
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.
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_endextends 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:hit_vector, the block's own rule tally, saw the clause all along. The bounded per-functionargsfield — the oneavg_func_argsaverages (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_argswas 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 leadingENTRYstatements only, treating blank lines as transparent.Only
ENTRY— the narrowness is the point, not cautionI measured what a wider window would actually pick up. Over the crucible corpus, 158 paragraphs carry a
USING/RETURNINGsomewhere inside their greedy Mode A block, and not one of them is a parameter declaration:CALL … USINGPROCEDURE DIVISION USINGXML PARSE … RETURNINGCALLcontinuation lines, and aMOVE "USING OPERANDS"string literalWidening 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_REis anchored to the line's first token, soCALLcan 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:
prismblanks comment lines in place to preserve line numbering, so a banner comment between a paragraph label and itsENTRY— 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
crucible_check.pyPASS on both venvs, zero diff. The real corpus contains noENTRY … USINGat 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.main, which plants the construct):avg_func_args0.0 → 0.6923 (9 of 13 paragraphs declare one operand).audit_check.pyall clear (ruff 70-finding baseline + format clean, mypy 2-error baseline, dead-key, ast-accuracy).test_cobol_paragraph_entry_using_is_inside_the_args_window_2863pins 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_operandsreaches the per-function path; a comment-separatedENTRY) and what must stay out of reach (CALL … USINGat 0; a non-leadingENTRYat 0). Confirmed it fails onmain(got 0) and passes here.Corpus
No re-bless owed —
verify_language.py cobolpasses unchanged (81 assertions), because this moves a derived metric and no planted manifest count. That is why this PR does not carryrosetta: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_argslands 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 noENTRY, 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