Skip to content

COBOL forge: fixed-format reader ignores cols 73-80 sequence numbers, dropping paragraphs (142 on carddemo) #3244

Closed

Description

@squid-protocol

Surfaced by the refraction differential (#3211) once it was pointed at a third corpus.

Symptom

On aws-mainframe-modernization-carddemo, the forge's paragraph reader misses 142 real paragraphs that both the engine and the answer-key drafter find. Reproduce:

python tests/tools/mainframe_corpus.py fetch aws-mainframe-modernization-carddemo
python tests/tools/refraction_differential.py --corpus aws-mainframe-modernization-carddemo
# -> 142 UNEXPLAINED  <prog>  paragraph/db  <NAME>

Root cause

carddemo uses traditional right-margin sequence numbers in cols 73-80, e.g. in COPAUA0C.cbl:

       1200-SCHEDULE-PSB.                                               08490000

cobol_graveyard_finder._UNIT_HEADER ends with \.[ \t]*$, so the trailing 08490000 (cols 73-80) makes the header line fail to match, and the paragraph is dropped. COPY_PATTERN almost certainly has the same blind spot on such lines.

This is the right-margin twin of #3203 defect 4, which taught the reader to tolerate a cols 1-6 sequence field (_SEQ_AREA) but never the cols 73-80 area. zopeneditor-sample and CBSA have zero col-73 lines, which is exactly why the defect never showed until carddemo. The engine and the answer-key drafter both truncate at col 72, so only the forge is affected.

Fix

Strip the fixed-format sequence area (cols 73-80, and the col-7 indicator / cols 1-6 already handled) before matching headers and COPYs — i.e. read Area A..B (cols 8-72) as cobol_answer_key.Source and _code_area already do, rather than anchoring the header regex to physical end-of-line.

Impact

Drops paragraphs -> corrupts the forge's unit inventory, dead-code reachability, and lineage for any program using right-margin sequence numbers (very common in real mainframe source). Blocks a clean carddemo answer key.

Part of the CICS modernization epic #3122.

Metadata

Metadata

Assignees

No one assigned

    Labels

    legacy-modernizationCOBOL refractor, dead-code extraction, and JCL forging

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions