Skip to content

COBOL: blank the numbered sequence area so split operands read the real target (#4300) - #4334

Merged
squid-protocol merged 1 commit into
mainfrom
fix/4300-cobol-sequence-area-operands
Oct 4, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/4300-cobol-sequence-area-operands

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #4300

What was broken

In fixed-format COBOL with a numbered sequence area (cols 1-6, e.g. ISPF NUMBER ON STD), a verb whose operand starts on the next line read that line's sequence number as the operand. The operand separators (\s+, [ \t\n]+) cross the newline, and Prism had blanked cols 73-80 (#4264) but not cols 1-6.

statement before after
PERFORM / 000900 INIT-PARA calls_out_to 000900 INIT-PARA
CALL / 001100 'SUBPGM1' 001100, no call_site_data row SUBPGM1, literal row
CALL / 001300 WS-PGM 001300, no row WS-PGM, identifier row (resolves to SUBPGM2)
GO TO / 001000 END-PARA. transfers_to 001000 END-PARA
COPY / 000600 CPYA. import 000600 CPYA

The fix

I took the first route in the acceptance criteria: the stream is blanked, not the separators. cobol_source_format.blank_sequence_area runs in Prism next to blank_identification_area, so every COBOL rule and reader downstream gets it.

It blanks the sequence area of fixed lines, offsets kept, only when the area is numbered: six letters/digits, at least one digit, no spaces, followed by a blank / - indicator. This matches the shape the per-reader _blank_sequence_fields helpers already assume. Those helpers are now no-ops on these lines.

What is left alone:

  • free and variable-format lines;
  • 02 DELTA (a level number in cols 1-6);
  • unnumbered areas;
  • a continuation - in col 7.

A debug line's col-7 D behind an all-digit area is blanked too (064000D PASS. → operand PASS). The engine already treated debug lines as code. Paragraph headers on debug lines (064100DDEBUG-LINE-TEST-03-A.) keep their names, because the cobol_sentence_start filter keeps PASS. there from becoming a header.

One follow-on fix was needed. Once those fields are blanked, a line that holds only sequence / identification fields (003100, or 340000 in cols 73-80) leaves the code stream. Prism's doc_loc = active_lines - coding_loc would then have counted it as documentation. The active-line count for COBOL now uses the same blanked text, so such a line counts as blank: it is neither code nor doc.

Evidence

  • REPRO4: MAIN-PARA.calls_out_to = [INIT-PARA, SUBPGM1, WS-PGM] (was [000900, 001100, 001300]). call_site_data gets the literal SUBPGM1 and identifier WS-PGM rows.
  • REPRO5: transfers_to = [END-PARA] and the COPY capture is CPYA.
  • NIST (language-crucible v1.7.0):
    • NC1344.2.cbl TEST-2 transfers_to is now [TST-21, TST-22] (was 038000), and the same holds at all 6 sites.
    • DB1024.2.cbl DEBUG-LINE-TEST-03 / -03-A / -04 now call PASS / FAIL / PASS (were 064000D / 064200 / 065400D).
    • DB1034.2.cbl likewise.
  • All units in the 628 COBOL/PL/I files, before vs after:
    • 44 files change, all NIST CCVS plus cobol-check LONGLINESANDNUMBERS.
    • Phantom callees: 5 removed (064000D, 064200 …), replaced by PASS/FAIL.
    • Phantom transfers: 6 removed (038000, 042900 …). 11 real ones were added; the extra five come from GO / TO split across lines that now match.
    • 248 unit spans got shorter: they no longer end on a trailing sequence-number-only line.
  • New tests: tests/core_engine/test_cobol_sequence_area_4300.py has 7 tests. They cover the verbatim REPRO4/5 (all 5 shapes plus call_site_data), the DB1024 debug-line operand and paragraph, the blanker's line-by-line rules (numbered / alphanumeric / continuation / debug / 02 DELTA / unnumbered / seq-only), free-format untouched, and the LOC accounting. Four of the five tests that existed before the LOC fix fail on main.

Golden-master diff (both legs regenerated: 4,657 diffs each, same shape)

All of it is on mainframe files except the layout/PageRank/Testing-Exposure ripple at the end.

  • Calls Out To / Fan In-Out / PageRank on 3 files: the DB1024/DB1034 PASS/FAIL edges.
  • Usage Status / Duplicate Logic (IX2184.2): the two INPUT-PROCESS paragraphs differed only by their sequence numbers. They now have identical bodies and are flagged duplicates (status 2).
  • Record Layout on 109 files: VALUE literals continued on the next line used to read as the sequence number ('007400', '015400'). They now read the real literal (' COMPUTED=', 'OFFICIAL COBOL COMPILER VALIDATION SYSTEM'). Continuation joins still carry their \n - remainder, as before, minus the number.
  • Data Moves (DB1024/DB1034): SUBTRACT on D debug lines is now read.
  • Type/Safety Bypasses (NC1344, +5): GO / TO split over two lines now matches.
  • Coding LOC on 124 files: sequence-number-only lines are no longer code. Global total_loc goes from 926,260 to 925,304. Documentation LOC changes in 1 file: COCRDUPC has a line holding only 340000 in cols 73-80, which is no longer counted as doc.
  • Indentation Style / Structural Space Indentations on 156 / 161 files: numbered lines now start with spaces, as unnumbered fixed-format files (e.g. CardDemo) always did. Indentation on numbered and unnumbered fixed files is now measured the same way. Before, a numbered file read as "Neutral / No Indentation".
  • Derived from the above: magnitude, control-flow ratio, cognitive density, fingerprint/drift/archetype and risk exposures for those files; NIST / cobol-check directory groups; global composition and health averages.
  • Non-mainframe: layout X/Z on 31 files, from the sector shift caused by the mainframe group magnitudes. PageRank moves on 10 files. Testing Exposure moves by ±0.01pp on 3 files, a corpus-relative normalization. No non-mainframe extraction changed.
  • pytest -m golden_crucible passes in both venvs.

Ground-truth ledger

ground_truth_ledger.py check is clean. The keyed corpora do not contain the split-operand shape, so there is no ledger change.

Local checks

  • tests/extraction, tests/core_engine, tests/cobol_mainframe: 13,162 passed
  • mypy_audit --ci, ruff_audit --ci (0.16.0), dead_key_audit --ci: nothing new

🤖 Generated with Claude Code

…al target (#4300)

In fixed-format source with a numbered sequence area (cols 1-6), a verb
whose operand starts on the next line read that line's sequence number:
`PERFORM` / `000900 INIT-PARA` recorded the callee 000900, a split GO TO
the transfer 038000, a split COPY the import 000600, and a split CALL
left no call_site_data row at all.

Prism already blanked cols 73-80 of fixed lines (#4264); it now also
blanks a numbered sequence area (six letters/digits with a digit, no
spaces) of fixed lines, plus a debug line's col-7 D behind an all-digit
area, for every COBOL rule and reader. Free and variable lines, and
unnumbered/level-number heads like `   02  DELTA`, are left alone. A line
holding only sequence/identification fields is blank, not documentation.

Golden masters regenerated in both legs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as ready for review October 4, 2026 16:14
@squid-protocol
squid-protocol merged commit 87c89f5 into main Oct 4, 2026
36 checks passed
@squid-protocol
squid-protocol deleted the fix/4300-cobol-sequence-area-operands branch October 4, 2026 16:14
squid-protocol added a commit that referenced this pull request Oct 4, 2026
…4341)

#4335 (answer-key extents, #4318) and #4334 (#4300, sequence-area
blanking) merged three minutes apart. #4335's ledger recorded 200
`engine_unit_end_counts_noncode_lines` entries against the engine
before #4334; with #4334 on main, 182 of them no longer reproduce
(units no longer end on sequence-number-only lines), so the ledger
gate on main failed with "0 new, 182 no longer reproducing".
Regenerated with `ground_truth_ledger.py update`: +0 -182, 0 untriaged.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

COBOL engine: a cols 1-6 sequence number is read as the operand when PERFORM / GO TO / CALL / COPY continues on the next line

1 participant