Skip to content

Import resolver: a unique COPY / %INCLUDE candidate must be in the importer's language (part of #4265) - #4366

Merged
squid-protocol merged 1 commit into
mainfrom
fix/4265-copy-language-guard
Oct 4, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/4265-copy-language-guard

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #4265 (the cross-language resolver shape reported in the 2026-10-04 19:01 comment). Library resolution (H-0034) and REPLACING (H-0016) follow as their own PRs.

What was broken

The #3199 language rule for source-member imports (COBOL COPY, PL/I %INCLUDE, HLASM COPY) is that a member is source in the importer's language. _narrow_ambiguous enforced it only when several files matched. When exactly one file matched, the resolver took it whatever its language. In the crucible this drew 11 wrong edges:

  • lsp TEST.CBL COPY A / COPY B → hlasm/che4z_hlasm/A.hlasm, B.hlasm; testing_A.cpy COPY B → B.hlasm
  • DSF PL/I (6 programs) %INCLUDE DFHBMSCA → carddemo's COBOL DFHBMSCA.cpy
  • zopeneditor PSAM1LIB.pli → COBOL DATETIME.cpy and REPTTOTL.cpy

This is the same class as #3001 (Python import base64 → base64.c).

The fix

_resolve_by_name applies the language rule to the unique-candidate path too. There is one exception, declared in the language definition (cobol.py, new key source_members_generated_from: ("bms",)): a COBOL program may resolve to a BMS mapset, because the mapset's symbolic map is a COBOL copybook generated from it.

Why the exception is needed. Without it, estate-crucible regressed: copies went from 32 pass / 3 fail to 30 / 5, because CUSTINQ COPY CUSTMS and GULFINQ COPY GULFMS lost their edges.

  • Root cause: the real symbolic-map copybooks (CUSTMS.cpy, GULFMS.cpy) are excluded by the aperture as machine-generated. They are in excluded_artifacts and not in file_data. That leaves the mapset as the only CUSTMS.
  • What the key accepts: the mapset as an alternative.
  • Follow-up: the aperture exclusion is a separate defect, filed as Aperture excludes checked-in BMS symbolic-map copybooks as machine-generated #4365. It is not changed here.

The layouts change I saw during development (80 pass / 7 fail to 81 / 6): CUSTINQ WS-COMMAREA @11 lost its bytes: None failure. That was a side effect of dropping the BMS edge. With the edge, the copy files include a .bms that has no records. Without it, GalaxyIR's synthetic symbolic map (#3490) took over. With the exception in place, both the edge and the layout fail are back exactly as on main.

Evidence

Golden masters (both legs regenerated; same diff)

import_edges: exactly the 11 edges above are removed and none are added. Everything else is downstream graph math over those edges:

  • PageRank / blast radius (e.g. CRELIBS.jcl 12.847 → 12.823)
  • modularity 0.8344 → 0.8349
  • articulation points 199 → 196
  • popularity, drift and fingerprint files

pytest -m golden_crucible passes in both venvs.

Ground-truth ledger

update: no change. check: clean.

Estate-crucible v0.3.0

Identical to main: every channel count, horror and check line matches. H-0034 still FAILs; it is the library-resolution part, which comes next.

Local checks

tests/security_auditing, tests/cobol_mainframe, tests/extraction and tests/core_engine: 13,599 passed. mypy_audit / ruff_audit (0.16.0) / dead_key_audit --ci report nothing new.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo

…porter's language (part of #4265)

The #3199 language rule for source-member imports (COBOL COPY, PL/I %INCLUDE,
HLASM COPY) ran only when several files matched. A single match in another
language was taken. Examples: COBOL `COPY A` -> A.hlasm (che4z lsp fixtures),
DSF PL/I `%INCLUDE DFHBMSCA` -> carddemo's COBOL copybook, and zopeneditor
PSAM1LIB.pli -> COBOL DATETIME.cpy / REPTTOTL.cpy. This is the same class as
#3001's Python `import base64` -> base64.c.

A BMS mapset stays a valid COBOL member source (new language key
`source_members_generated_from`). Its symbolic map is a COBOL copybook
generated from it, so `COPY CUSTMS` may name CUSTMS.bms when the mapset is the
only CUSTMS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as ready for review October 4, 2026 22:44
@squid-protocol
squid-protocol merged commit 8c0ec52 into main Oct 4, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the fix/4265-copy-language-guard branch October 4, 2026 22:44
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.

1 participant