Skip to content

COBOL engine: a COPY of a member holding its own 01 records is folded into the copy_members of the 01 above it (layout bytes None / merged records) #4330

Closed

Description

@squid-protocol

Problem

copy_members on a data entry lists every COPY between the entry and the next level number (mainframe_boundary.py, copy_window, ~l.1075-1084). A COPY of a member that holds its own 01 records therefore gets attached to the 01 above it whenever it directly follows that 01's own COPY. GalaxyIR.record_layout then expands those records as children of the 01. If the member is outside the estate (a CICS- or Db2-supplied copybook such as DFHAID), the layout's bytes becomes None. If the member resolves, the record gets fields that belong to another record.

IBM: a level-01 entry in copied text begins a new record, so the copied member's 01 ends the record above it.

Evidence

  • estate-crucible v0.1.0 (Epic: estate-crucible -- a synthetic mainframe estate whose answer key is generated with it #4317), keyed: estate/apps/CUST/cobol/CUSTINQ.cbl:11-14:
           01  WS-COMMAREA.
               COPY CUSTCOMM.
               COPY CUSTMS.
               COPY DFHAID.
    copy_members is CUSTCOMM,CUSTMS,DFHAID; the key has CUSTCOMM. CUSTMS (a BMS symbolic map) and DFHAID each start with an 01. The layout of WS-COMMAREA is bytes: None (key: 50).
  • Minimal reproducer, main 25f9233. copy_members of WS-AREA = CPYAREA,CPYREC; expected CPYAREA:
           IDENTIFICATION DIVISION.
           PROGRAM-ID. CPYFOLD.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  WS-AREA.
               COPY CPYAREA.
               COPY CPYREC.
           PROCEDURE DIVISION.
           MAIN-PARA.
               MOVE SPACES TO AREA-NAME REC-KEY
               GOBACK.
    CPYAREA.cpy:
               05  AREA-NAME          PIC X(20).
               05  AREA-CODE          PIC 9(4).
    CPYREC.cpy:
           01  REC-RECORD.
               05  REC-KEY            PIC X(8).
               05  REC-DATA           PIC X(40).

Impact

COPY DFHAID. / COPY DFHBMSCA. / a symbolic map right after a COMMAREA or work-area COPY is a very common CICS shape. Each case loses that record's layout (COMMAREA contracts, vsam_files key positions, generated DTOs) or merges two records into one.

Acceptance criteria

  • A COPY whose resolved member's first data entry is an 01 (or 77) is not a member of the entry above it. When the member is outside the estate, the reader does not guess: the first COPY stays with the entry, and the later ones are recorded as section-level copies (not on the 01).
  • Reproducer: WS-AREA.copy_members = CPYAREA, and the layout of WS-AREA is 24 bytes.
  • estate-crucible: CUSTINQ WS-COMMAREA data_items and layouts checks pass.

Related: #3355 (copy_members), #4303 (same-line COPY), #4265 (copybook resolution in the wild), #4317 (planted as H-0010 from v0.2.0).

Found by: estate-crucible v0.1.0 scorecard (#4324).

Activity

  1. added
    bug
    core-engine
    legacy-modernization
    on Oct 4, 2026
  2. added 2 commits that reference this issue on Oct 4, 2026
  3. added
    scope:sweep
    era:2
    on Oct 16, 2026
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

    bugcore-engineera:2legacy-modernizationpriority: mediumscope:sweep

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions