Skip to content

COBOL engine: copybook resolution in the wild (REPLACING-generated names, search-path order, same-named members) #4265

Closed

Description

@squid-protocol

Problem

Engine facts do not follow COPY ... REPLACING, and member lookup is by bare name/file stem with no library (SYSLIB) ordering or collision handling.

Evidence (file:line, origin/main)

  • gitgalaxy/core/data_moves.py:53-55: names a COPY ... REPLACING would produce "are not resolved by the reader (record_data keeps the copybook's own names)"; the ingestion checklist records this as an engine limit.
  • gitgalaxy/tools/cobol_to_java/det/source.py:~113-117: the translator expands REPLACING (_replacing, _replace), but resolves a member as the first dir x extension match by name only; no library qualifier ordering, no collision report. So the two sides already disagree on REPLACING.
  • gitgalaxy/core/mainframe_boundary.py:~1064: copy members are recorded by name only (copy_members).

Impact on a real estate

Production estates generate record names via REPLACING (prefix tags) and keep several libraries with same-named members (test vs prod, per-application). Facts then carry the wrong names, or silently bind to the wrong member.

Acceptance criteria

  • Engine record/data-move facts resolve REPLACING-generated names (or flag them unresolved explicitly)
  • Configurable library search order (SYSLIB-style) and COPY x OF/IN lib honoured
  • Same-named members in different libraries are reported as a collision, not silently first-wins
  • Tests for each of the three

Out of scope

The translator's own expansion (works today); copybook formats other than COBOL.

Found during: 2026-10-03 COBOL engine/translator audit

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    core-engine
    legacy-modernization
    priority: high
    on Oct 3, 2026
  2. squid-protocol commented on Oct 4, 2026

    @squid-protocol
    OwnerAuthor

    Two more shapes of this issue (estate-crucible horrors H-0016 and H-0034):

    H-0034 also cascades into 6 other checks (the layouts that use WS-SHARED-DATE).

    Found by estate-crucible v0.2.0 (#4317); planted in squid-protocol/estate-crucible, scored by tests/tools/estate_crucible.py on main (#4337 has the full scorecard). The horror flips to pass when this is fixed.

  3. squid-protocol commented on Oct 4, 2026

    @squid-protocol
    OwnerAuthor

    Another shape for this issue, found while fixing #4303 (PR #4350): the import resolver's language guard (_narrow_ambiguous) only restricts a source-member import to the importer's own language when there are several candidates. A single candidate in another language is still taken, so a COBOL COPY A resolves to A.hlasm.

    Fix: apply the same language guard to the unique-candidate path. This is the same class as the cross-language edge fixed in #3001 (Python import base64 → C base64.c).

  4. added 6 commits that reference this issue on Oct 4, 2026
  5. 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

    core-engineenhancementera:2legacy-modernizationpriority: highscope:sweep

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions