Skip to content

PL/I: an %INCLUDE inside a DECLARE is spliced in, or the layout is unknown (#3728) - #3737

Merged
squid-protocol merged 9 commits into
mainfrom
feat/pli-dcl-include-3728
Sep 26, 2026
Merged

squid-protocol merged 9 commits into
mainfrom
feat/pli-dcl-include-3728

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #3728 (epic #3625). Follows #3733 (merged).

The defect (D027)

The scanner dropped an %INCLUDE that sits inside a PL/I declaration. So a structure whose remaining members come from the included member was laid out from the members before it alone. For example, DSF's TRANHISTSEGM (4 XSPERRE CHAR(1), %INCLUDE P0019940;) read as a complete 39 bytes. The error was silent.

Fix

Scanner:

  • , %INCLUDE M (or SYSLIB(M)) inside a DCL is now recorded in copy_members on the item it follows, the column COBOL's COPY already uses. That's 879 on DSF.
  • A member that opens with level-numbered items is a declaration fragment, and its items are recorded with section %INCLUDE.

Reader (_pli_mapping): each structure is rebuilt in declaration order, with fragments spliced in where they stand, then nested by level number (LIKE borrowing is kept):

  • Member in the repo: its items join the structure (file = the member; the member is listed under copybooks).
  • Member missing: the width is unknown, and the member is named in unexpanded.

Java: the record doc says "TODO: %INCLUDE members not found…" for PL/I, and the migration worklist files it under missing-layout.

On the public corpora

Every in-DCL include names a member the repository lacks: on DSF, 885 uses of 89 distinct members, none present. So expansion is proven by a scanned fixture (splice, nesting under an array member, missing member). DSF itself gains:

  • honest unknowns: TRANHISTSEGM ×2, previously a silently truncated 39 bytes;
  • a named member on one VSAM store record (INNT_RAPP: P0019956).

Answer-key fix (from #3727)

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. The engine agrees: 6,702 / 6,702 DSF units, and the ledger is clean.

Verification

  • Blast radius: ir_join_diff --rescan changes only that DSF VSAM record. Snapshots show 0 differ.
  • Golden masters: re-blessed on both legs, through the worktree engine. The only drift is B01's Copy Members: P0019921.
  • Compile: DSF 17/17 configs.
  • Suite and gates: full suite and preflight pass. The field-testing log has D027.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g

squid-protocol and others added 8 commits September 26, 2026 07:46
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
…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
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
…us-3727

# Conflicts:
#	docs/language_status/cics_field_testing.md
…known (#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
…3728

# Conflicts:
#	docs/language_status/cics_field_testing.md
#	gitgalaxy/standards/fact_channel_confidence.json
#	tests/cobol_mainframe/answer_key/dsf.json
#	tests/cobol_mainframe/ground_truth_ledger.json
#	tests/tools/cobol_answer_key.py
@squid-protocol squid-protocol changed the title Feat/pli dcl include 3728 PL/I: an %INCLUDE inside a DECLARE is spliced in, or the layout is unknown (#3728) Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 7ef2884 into main Sep 26, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the feat/pli-dcl-include-3728 branch September 26, 2026 13:18
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.

PL/I: %INCLUDE inside a DECLARE is not expanded into the structure

1 participant