Skip to content

Refraction graveyard finder: scope terminators as paragraphs, programs inlined as copybooks, same-directory-only COPY, no SECTION model #3203

Closed

Description

@squid-protocol

Found by the #3120 differential. x_ray_dead_code and its resolve_copybooks (gitgalaxy/tools/cobol_to_cobol/cobol_graveyard_finder.py) produce mostly false output on real code.

zopeneditor-sample CBSA
"dead paragraphs" reported 17 623
of which scope terminators (END-IF, END-EXEC, GOBACK, EXIT) 17 119
of which paragraphs of a different program inlined as a copybook 0 118
of which live by SECTION fall-through 0 165

Defects

  1. Scope terminators read as paragraphs. The pattern ^[ \t]{0,11}NAME\. accepts up to 11 leading blanks, which reaches into Area B, so END-IF. and GOBACK. become paragraphs. Every "dead paragraph" on zopeneditor is one of these.
  2. Programs inlined as copybooks. resolve_copybooks tries .cbl/.cob as copybook extensions in the program's own directory. COPY ACCTCTRL (the copybook lives in cobol_copy/) therefore inlines the program cobol_src/ACCTCTRL.cbl, often the program itself, and does it up to three passes deep. This happens in 18 of CBSA's 31 programs.
  3. Same directory only. Real layouts keep copybooks elsewhere (COPYBOOK/, cobol_copy/), so on both corpora 0 real copybooks are ever resolved. The orphaned-variable result is therefore computed without the copybook data layouts it exists to consider.
  4. Sequence-number fields. The patterns assume blanks in columns 1–6. R2 COPY SAM2PARM. (zopeneditor multiroot) and any sequence-numbered source are invisible.
  5. No SECTION model. X SECTION. headers are invisible, and paragraphs reached by fall-through inside a PERFORMed section are reported dead.

Downstream effect

dead_paras feeds extract_lineage masking and the microservice slicer, and orphaned_vars feeds the schema forge's ignore_vars. So these errors reach generated output.

The engine DB cannot replace this pass yet: its usage_status is a by-name test, filed separately. Details: docs/refraction_engine_differential.md D1–D3 (PR for #3120).

Activity

  1. added
    bug
    legacy-modernization
    on Sep 19, 2026
  2. squid-protocol commented on Sep 19, 2026

    @squid-protocol
    OwnerAuthor

    Measured against the new answer key (#3210, PR #3216) there's a worse consequence than the table above shows. On CBSA's BANKDATA.cbl, x_ray_dead_code marks the entry paragraph A010 dead. COPY ACCTCTRL / COPY CUSTCTRL resolve to the sibling programs (defect 2), and the inlined text changes which paragraph the graveyard takes as "first".

    extract_lineage then masks A010, which holds the program's only OPEN OUTPUT CUSTOMER-FILE. So BANKDATA's one output disappears even though the OPEN is single-mode (not the #3204 shape):

    A010 in forge dead: True
    extract_lineage(p, forge_dead)['outputs'] -> set()
    extract_lineage(p, set())['outputs']      -> {'VSAM'}
    

    Answer-key scores for this issue's field on CBSA: real dead logic is 10 units, and the forge finds 5 of them among 571 non-trivial claims (P 5/571 · R 5/10). A fix here can be scored directly with python tests/tools/cobol_answer_key.py score <cbsa clone> --key tests/cobol_mainframe/answer_key/cics-banking-sample-application-cbsa.json.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy-modernization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions