Repository navigation
PL/I record layouts, the PL/I COMMAREA and typed DTOs (#3720) - #3729
Merged
Merged
Conversation
New gitgalaxy/tools/cobol_to_cobol/pli_mapping.py maps a PL/I structure by
IBM's structure-mapping rules:
- the deepest minor structures first, each a unit paired left to right;
- the second element of a pair at its first aligned position, then the
first shifted toward it, so padding falls before the unit;
- ALIGNED / UNALIGNED inherited;
- bit strings bit-packed when unaligned;
- array strides rounded to alignment;
- element widths for CHAR / VARYING, BIT, FIXED DEC, FIXED BIN, FLOAT,
PICTURE, POINTER and ENTRY / LABEL variables (LP(32)).
It reproduces the Language Reference's worked example ("Offsets in final
mapping of structure A") exactly: all 23 offsets, 80 bytes, and the offset
of 4 from a doubleword boundary.
GalaxyIR:
- record_layout, _storage_spans, _elementary_bytes and _item_class use the
mapping for PL/I. Unaligned bit fields carry bit_offset / bits.
- LIKE borrows the base structure's members, from the program or its
%INCLUDE members.
- DSF: 1,744 of 1,792 structures laid out.
Entry points: the PL/I boundary records the external procedure and its
parameters (kind PROCEDURE, like COBOL's PROCEDURE DIVISION USING), for 1,471
DSF files.
The PL/I COMMAREA: program_interfaces basis `parameter`. It is the structure
BASED on the main procedure's pointer parameter, or the parameter itself when
that is a structure. It only applies to programs with CICS evidence: a batch
main procedure's parameter is its PARM. A COMMAREA not found is a
commarea_gap that names the %INCLUDE members the scan could not resolve
(file_data.raw_imports, now EngineFile.includes). On DSF, 386 programs get
KOM_OMR from P0019908 or P0019913, which the public repository lacks.
Java: PL/I fields carry `dialect: pli`, and java_type maps PL/I types:
- FIXED DEC(p,q) -> Integer / Long / BigDecimal;
- FIXED BIN -> Integer / Long;
- FLOAT -> Double;
- prefix-repeat pictures -> numeric types;
- BIT(1) -> Boolean;
- locators -> Long.
DTO and entity comments show the PL/I type and bit position. The record doc
says "PL/I structure". An entity column of unknown width takes the JPA default
instead of crashing.
The fix also corrects a pre-existing defect, D026 in field_testing.json: `PIC
'( 4)9'` was sized as 5 bytes, so both of DSF's COBOL CALLs into PL/I routines
mismatched. Both now pair with every length matching.
Follow-ups: #3727 (answer-key census of PL/I layouts, item 3 of #3720) and
#3728 (%INCLUDE inside a DECLARE).
Closes #3720
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
Contributor
…3720) Both golden-master legs are re-blessed (full-precision and zero-dependency, each run through the worktree engine). The only drift is the new "Entry Points" block on 11 PL/I files: the external procedure and its parameters, now recorded for PL/I. Also removes the unused _TYPE regex and _num helper from pli_mapping, which CodeQL flagged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
The engine used to treat "no attribute" and "an explicit ALIGNED" on a structure the same way. So a bit string under an ALIGNED structure stayed bit-packed: in IBM's example, U BIT(3) got 3 bits instead of its byte. The inherited alignment is now three-valued (ALIGNED / UNALIGNED / neither). Only when no enclosing structure says do strings and pictures default to unaligned and arithmetic to aligned. Found by the #3727 answer key, which states IBM's rule independently. Neither keyed corpus has a bit string under an ALIGNED structure, so their layouts are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
squid-protocol
added a commit
that referenced
this pull request
Sep 26, 2026
* PL/I record layouts, the PL/I COMMAREA and typed DTOs (#3720) New gitgalaxy/tools/cobol_to_cobol/pli_mapping.py maps a PL/I structure by IBM's structure-mapping rules: - the deepest minor structures first, each a unit paired left to right; - the second element of a pair at its first aligned position, then the first shifted toward it, so padding falls before the unit; - ALIGNED / UNALIGNED inherited; - bit strings bit-packed when unaligned; - array strides rounded to alignment; - element widths for CHAR / VARYING, BIT, FIXED DEC, FIXED BIN, FLOAT, PICTURE, POINTER and ENTRY / LABEL variables (LP(32)). It reproduces the Language Reference's worked example ("Offsets in final mapping of structure A") exactly: all 23 offsets, 80 bytes, and the offset of 4 from a doubleword boundary. GalaxyIR: - record_layout, _storage_spans, _elementary_bytes and _item_class use the mapping for PL/I. Unaligned bit fields carry bit_offset / bits. - LIKE borrows the base structure's members, from the program or its %INCLUDE members. - DSF: 1,744 of 1,792 structures laid out. Entry points: the PL/I boundary records the external procedure and its parameters (kind PROCEDURE, like COBOL's PROCEDURE DIVISION USING), for 1,471 DSF files. The PL/I COMMAREA: program_interfaces basis `parameter`. It is the structure BASED on the main procedure's pointer parameter, or the parameter itself when that is a structure. It only applies to programs with CICS evidence: a batch main procedure's parameter is its PARM. A COMMAREA not found is a commarea_gap that names the %INCLUDE members the scan could not resolve (file_data.raw_imports, now EngineFile.includes). On DSF, 386 programs get KOM_OMR from P0019908 or P0019913, which the public repository lacks. Java: PL/I fields carry `dialect: pli`, and java_type maps PL/I types: - FIXED DEC(p,q) -> Integer / Long / BigDecimal; - FIXED BIN -> Integer / Long; - FLOAT -> Double; - prefix-repeat pictures -> numeric types; - BIT(1) -> Boolean; - locators -> Long. DTO and entity comments show the PL/I type and bit position. The record doc says "PL/I structure". An entity column of unknown width takes the JPA default instead of crashing. The fix also corrects a pre-existing defect, D026 in field_testing.json: `PIC '( 4)9'` was sized as 5 bytes, so both of DSF's COBOL CALLs into PL/I routines mismatched. Both now pair with every length matching. Follow-ups: #3727 (answer-key census of PL/I layouts, item 3 of #3720) and #3728 (%INCLUDE inside a DECLARE). Closes #3720 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * field_testing: D026 fixed by #3729 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * Golden masters: PL/I entry points; drop unused pli_mapping helpers (#3720) Both golden-master legs are re-blessed (full-precision and zero-dependency, each run through the worktree engine). The only drift is the new "Entry Points" block on 11 PL/I files: the external procedure and its parameters, now recorded for PL/I. Also removes the unused _TYPE regex and _num helper from pli_mapping, which CodeQL flagged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * PL/I mapping: ALIGNED on a structure aligns its strings too (#3720) The engine used to treat "no attribute" and "an explicit ALIGNED" on a structure the same way. So a bit string under an ALIGNED structure stayed bit-packed: in IBM's example, U BIT(3) got 3 bits instead of its byte. The inherited alignment is now three-valued (ALIGNED / UNALIGNED / neither). Only when no enclosing structure says do strings and pictures default to unaligned and arithmetic to aligned. Found by the #3727 answer key, which states IBM's rule independently. Neither keyed corpus has a bit string under an ALIGNED structure, so their layouts are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * PL/I record layouts: answer key + blind census (#3727) A new answer-key field, `pli_layouts`, covers every PL/I structure, one unit per named elementary member: - `ROOT/NAME @offset+bytes`; - `@byte.bit+Nb` for a member off a byte boundary (an unaligned bit string). The key uses the key tool's own PL/I reader and its own statement of IBM's structure mapping. Rather than the engine's pairwise shifting, it takes the start residue whose padding (gap by gap) is least, which gives an independent oracle. It reproduces the Language Reference's Figure 12 exactly, and the UNALIGNED variant. The key skips, and records why, structures it cannot lay out: LIKE, UNION/CELL, REFER, AREA, and an %INCLUDE inside the DCL (#3728). The engine comparator leaves the same roots out. New `plilayouts` census suite in cross_verify_sections: full while a corpus holds 600 units or fewer, else a seeded sample covering every construct stratum (bit, varying, binary, decimal, picture, pointer, aligned, unaligned, defined, skipped), with recall files. Census, by 8 blind brief-only reviewers: - zopeneditor: 27/27 in full, cross_verified. - DSF: a 14-file sample, 309/309 units, 0 key errors, 95% upper bound 0.97%, sample_verified. One reviewer missed a structure at the end of a 2,139-line file. A fresh reviewer re-ran that batch and agreed 73/73. - Round-tripped through grade before launch: 336 units, 0 disagreements. Ledger: new field "PL/I layouts". The engine agrees with the key on every unit: DSF 6,694/6,694, zopeneditor 27/27. The key's independent statement of the rules also found an engine gap, fixed on #3729: ALIGNED on a structure must align its bit strings. Field testing registers "PL/I layouts" (introduced #3727, 6 development rounds), so it is open until fresh estates arrive. Closes #3727 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
squid-protocol
added a commit
that referenced
this pull request
Sep 26, 2026
…known (#3728) (#3737) * PL/I record layouts, the PL/I COMMAREA and typed DTOs (#3720) New gitgalaxy/tools/cobol_to_cobol/pli_mapping.py maps a PL/I structure by IBM's structure-mapping rules: - the deepest minor structures first, each a unit paired left to right; - the second element of a pair at its first aligned position, then the first shifted toward it, so padding falls before the unit; - ALIGNED / UNALIGNED inherited; - bit strings bit-packed when unaligned; - array strides rounded to alignment; - element widths for CHAR / VARYING, BIT, FIXED DEC, FIXED BIN, FLOAT, PICTURE, POINTER and ENTRY / LABEL variables (LP(32)). It reproduces the Language Reference's worked example ("Offsets in final mapping of structure A") exactly: all 23 offsets, 80 bytes, and the offset of 4 from a doubleword boundary. GalaxyIR: - record_layout, _storage_spans, _elementary_bytes and _item_class use the mapping for PL/I. Unaligned bit fields carry bit_offset / bits. - LIKE borrows the base structure's members, from the program or its %INCLUDE members. - DSF: 1,744 of 1,792 structures laid out. Entry points: the PL/I boundary records the external procedure and its parameters (kind PROCEDURE, like COBOL's PROCEDURE DIVISION USING), for 1,471 DSF files. The PL/I COMMAREA: program_interfaces basis `parameter`. It is the structure BASED on the main procedure's pointer parameter, or the parameter itself when that is a structure. It only applies to programs with CICS evidence: a batch main procedure's parameter is its PARM. A COMMAREA not found is a commarea_gap that names the %INCLUDE members the scan could not resolve (file_data.raw_imports, now EngineFile.includes). On DSF, 386 programs get KOM_OMR from P0019908 or P0019913, which the public repository lacks. Java: PL/I fields carry `dialect: pli`, and java_type maps PL/I types: - FIXED DEC(p,q) -> Integer / Long / BigDecimal; - FIXED BIN -> Integer / Long; - FLOAT -> Double; - prefix-repeat pictures -> numeric types; - BIT(1) -> Boolean; - locators -> Long. DTO and entity comments show the PL/I type and bit position. The record doc says "PL/I structure". An entity column of unknown width takes the JPA default instead of crashing. The fix also corrects a pre-existing defect, D026 in field_testing.json: `PIC '( 4)9'` was sized as 5 bytes, so both of DSF's COBOL CALLs into PL/I routines mismatched. Both now pair with every length matching. Follow-ups: #3727 (answer-key census of PL/I layouts, item 3 of #3720) and #3728 (%INCLUDE inside a DECLARE). Closes #3720 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * field_testing: D026 fixed by #3729 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * Golden masters: PL/I entry points; drop unused pli_mapping helpers (#3720) Both golden-master legs are re-blessed (full-precision and zero-dependency, each run through the worktree engine). The only drift is the new "Entry Points" block on 11 PL/I files: the external procedure and its parameters, now recorded for PL/I. Also removes the unused _TYPE regex and _num helper from pli_mapping, which CodeQL flagged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * PL/I mapping: ALIGNED on a structure aligns its strings too (#3720) The engine used to treat "no attribute" and "an explicit ALIGNED" on a structure the same way. So a bit string under an ALIGNED structure stayed bit-packed: in IBM's example, U BIT(3) got 3 bits instead of its byte. The inherited alignment is now three-valued (ALIGNED / UNALIGNED / neither). Only when no enclosing structure says do strings and pictures default to unaligned and arithmetic to aligned. Found by the #3727 answer key, which states IBM's rule independently. Neither keyed corpus has a bit string under an ALIGNED structure, so their layouts are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * PL/I record layouts: answer key + blind census (#3727) A new answer-key field, `pli_layouts`, covers every PL/I structure, one unit per named elementary member: - `ROOT/NAME @offset+bytes`; - `@byte.bit+Nb` for a member off a byte boundary (an unaligned bit string). The key uses the key tool's own PL/I reader and its own statement of IBM's structure mapping. Rather than the engine's pairwise shifting, it takes the start residue whose padding (gap by gap) is least, which gives an independent oracle. It reproduces the Language Reference's Figure 12 exactly, and the UNALIGNED variant. The key skips, and records why, structures it cannot lay out: LIKE, UNION/CELL, REFER, AREA, and an %INCLUDE inside the DCL (#3728). The engine comparator leaves the same roots out. New `plilayouts` census suite in cross_verify_sections: full while a corpus holds 600 units or fewer, else a seeded sample covering every construct stratum (bit, varying, binary, decimal, picture, pointer, aligned, unaligned, defined, skipped), with recall files. Census, by 8 blind brief-only reviewers: - zopeneditor: 27/27 in full, cross_verified. - DSF: a 14-file sample, 309/309 units, 0 key errors, 95% upper bound 0.97%, sample_verified. One reviewer missed a structure at the end of a 2,139-line file. A fresh reviewer re-ran that batch and agreed 73/73. - Round-tripped through grade before launch: 336 units, 0 disagreements. Ledger: new field "PL/I layouts". The engine agrees with the key on every unit: DSF 6,694/6,694, zopeneditor 27/27. The key's independent statement of the rules also found an engine gap, fixed on #3729: ALIGNED on a structure must align its bit strings. Field testing registers "PL/I layouts" (introduced #3727, 6 development rounds), so it is open until fresh estates arrive. Closes #3727 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * PL/I: an %INCLUDE inside a DECLARE is spliced in, or the layout is unknown (#3728) The scanner dropped an %INCLUDE inside a PL/I declaration, so a structure whose remaining members come from the member was laid out from the members before it alone. DSF's TRANHISTSEGM (`4 XSPERRE CHAR(1), %INCLUDE P0019940;`) read as a complete 39 bytes. Logged as D027. Scanner (mainframe_boundary): `, %INCLUDE M` (or SYSLIB(M)) inside a DCL now goes into copy_members on the item it follows, the column COBOL's COPY already uses; 879 on DSF. A member that opens with level-numbered items (a declaration fragment) has its items recorded with section `%INCLUDE`. Reader (galaxy_ir._pli_mapping): each structure is rebuilt in declaration order, with each member's fragment spliced in where it stands, then nested by level number as the compiler sees it. LIKE borrowing is kept. A member in the repository adds its items (`file` = the member, `copybooks`); a missing one leaves the width unknown and is named in `unexpanded`. The Java record doc says "%INCLUDE members not found" for PL/I, and the worklist files it under missing-layout. On the public corpora every in-DCL include names a member the repository lacks (DSF: 885 uses of 89 distinct members, none present). So expansion is exercised by a scanned fixture, and DSF gains honest unknowns (TRANHISTSEGM x2) plus a named member on one VSAM store record (INNT_RAPP: P0019956). Key fix (#3727 key): only `, %INCLUDE` marks an include. A `%SKIP` listing directive after a stray comma in R0017601's W001_DLI had been read as one. Its 8 units are now keyed, with a verification note, and the engine agrees. The ledger stays clean: engine = key on 6,702 / 6,702 DSF units. Verification: - ir_join_diff --rescan: only that DSF VSAM record changes. - Golden masters re-blessed (full and zero-dependency): B01's Copy Members. - DSF: 17/17 configs compile. - Snapshots: 0 differ. - Full suite passes. - Preflight passes. Closes #3728 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g * field_testing: D027 fixed by #3737 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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 #3720 (epic #3625). Follows #3721, which put PL/I programs into the pipeline.
Storage mapping (
pli_mapping.py)PL/I structures are mapped by IBM's structure-mapping rules.
Pairing:
Alignment:
bit_offset/bits.Widths: CHAR, VARYING (+2), BIT, FIXED DEC (p/2+1), FIXED BIN (1/2/4/8), FLOAT (4/8/16), PICTURE positions (prefix repeats, CR/DB), POINTER, ENTRY/LABEL variables (LP(32)).
Checked against IBM: the Language Reference's worked example ("Example of structure mapping", Figure 12) is reproduced exactly: all 23 offsets, 80 bytes, and the structure's offset of 4 from a doubleword boundary. The same declaration UNALIGNED gives 69 bytes, where the only padding is 5 bits after the
BIT(3).LIKE borrows the base structure's members, from the program or its
%INCLUDEmembers.DSF: 1,744 of 1,792 structures are laid out. The remainder are mostly
%INCLUDEinside a DECLARE, now #3728.The PL/I COMMAREA
parameter:program_interfaces("pli")uses the structureBASEDon the main procedure's pointer parameter (or the parameter itself, when that is a structure). This is the new basisparameter, and the existing caller-vs-declared rules (COMMAREA basis: a caller's record outranks a concrete declared LINKAGE DFHCOMMAREA of a different width #3688) apply unchanged.KOM_OMR) fromP0019908/P0019913, which the public repository does not contain. Instead of guessing,commarea_gapnames the%INCLUDEmembers the scan could not resolve. That covers 386 programs, usingfile_data.raw_imports, nowEngineFile.includes.BASEDon separate pointers, not fields of the record. So "keyed by one field" stays 0 by fact, not by a gap in the reader. Record widths are now known for 60 of 72 stores.Java
PL/I fields carry
dialect: pli.java_typemaps them:Other changes:
// ACCT_DEL: BIT(1), offset 7 bit 1, 1 bits.Defect fixed (D026)
PIC '( 4)9'was sized as 5 bytes, so both COBOL→PL/I CALL contracts on DSF (R001NRCO, R001NACO) mismatched. Both now pair with every length matching. The defect is logged infield_testing.json.Verification
ir_join_diff --base origin/main --rescan:includeskey on EngineFile.vsam_stores.java_target_matrix --scan: 17/17 configs compile on DSF and on zopeneditor.refraction_snapshot check: 0 differ on all 6 corpora.preflight --java: all gates pass, with the mypy gate re-run after the fix.Tests
tests/cobol_mainframe/test_pli_layouts.pycovers:Follow-ups
%INCLUDEinside a DECLARE.🤖 Generated with Claude Code
https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g