Skip to content

Fix #4010: layout_fields expands a nested COPY instead of shifting later fields - #4013

Merged
squid-protocol merged 1 commit into
mainfrom
fix/4010-layout-nested-copy
Sep 29, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/4010-layout-nested-copy

Conversation

@squid-protocol

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

Copy link
Copy Markdown
Owner

Fixes #4010
Part of #3989 (phase 3, lane A)

What changed

  • equivalence_common.layout_fields expands each COPY member. in the file before it lays out a record. It looks each member up in the new copy_dirs argument; by default that is the file's own directory, then the corpus. Nesting goes up to 8 levels. With the COPY expanded, the fields after it keep their offsets: CALINK's WS-AFTER-FLAG lands at offset 100, not 0.

  • Failing loudly. A new LayoutError(ValueError) is raised when:

    • a COPY that resolves nowhere sits inside the chosen record. The record runs from its own line to the next 01/77, section header or division header.
    • a COPY has REPLACING, which is not modelled.
    • the named record does not exist. Before, this was an IndexError.

    An unresolved COPY outside the record, such as COPY DFHAID. before it or in LINKAGE, is still harmless.

  • tests/tools/cics_crucible.py drops its expand_copies workaround and the temporary copy of each layout source. case_context now calls layout_fields(..., copy_dirs=<case copy dirs> + <DFH stand-ins>) and turns a LayoutError into a CaseError. It no longer takes a work argument.

Tests

  • test_layout_fields_expands_a_nested_copy_so_later_fields_keep_their_offsets covers a CALINK-shaped record with a two-level nested COPY, the explicit copy_dirs and the default search.
  • test_layout_fields_fails_loudly_on_a_copy_it_cannot_expand covers an unresolved COPY inside the record (raises), unresolved COPYs outside it (fine), a missing record, and REPLACING.
  • The existing runner test (test_layouts_inline_copy_members_so_later_fields_keep_their_offsets) now runs through layout_fields itself.

Crucible cells

Before and after are identical. The runner already worked around this bug, so this PR moves the fix into the harness and adds no cells. The baseline and report are unchanged.

On the first base (d650001), results.json was byte-for-byte the same before and after, with 20 pass, 12 fail and 62 unsupported. The branch is now rebased on #4002 (e804642). There --ci measures 22 pass, 38 fail and 34 unsupported, and the non-passing cells match the committed baseline cell for cell.

Verification

  • cics_crucible.py --ci is green.
  • The tests/cobol_mainframe/test_equivalence*.py suites with EQUIVALENCE_E2E=1 pass 58 of 58, including the CardDemo intcalc, acctview, generated-inputs and environments end to end. tests/cics_crucible with E2E also passes.
  • The ruff, mypy and dead-key audits show no new findings. ruff format is clean on the touched files. The two new regexes are anchored matches and time linearly on adversarial inputs. The engine and forge are untouched, so no golden masters change.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol force-pushed the fix/4010-layout-nested-copy branch from 0b6b7ee to 2897ddb Compare September 29, 2026 18:01
…ter fields

equivalence_common.layout_fields now expands every COPY in the file before
laying a record out, with members looked up in copy_dirs (default: the file's
own directory, then the corpus). A COPY that resolves nowhere inside the chosen
record, or any COPY ... REPLACING, raises LayoutError instead of returning a
shifted layout. The CICS crucible runner drops its expand_copies workaround and
passes its copy directories (the case's, then the DFH stand-ins).

Part of #3989.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EC8FWfn3aPmsUPnRgKNVup
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.

Equivalence harness: layout_fields drops a nested COPY silently and shifts later fields

1 participant