Skip to content

Fix #4011: dto_shape resolves a class by its package, not an arbitrary simple-name match - #4014

Merged
squid-protocol merged 1 commit into
mainfrom
fix/4011-dto-shape-fqn
Sep 29, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/4011-dto-shape-fqn

Conversation

@squid-protocol

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

Copy link
Copy Markdown
Owner

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

What changed

  • equivalence_cics.java_class_file(src, name, context=None) is new. It resolves a generated class the way Java does:
    • A qualified name (pkg.dto.contract.PcwizWsState) resolves by its path.
    • A simple name resolves from context, the file that names the class. It checks that file's single-type imports first, then its own package, then its on-demand (.*) imports.
    • With no context, it takes the only class of that name under src.
    • Two or more candidates with nothing to choose between them raise LookupError naming both paths. Before, next(rglob(...)) quietly took whichever came first, so entity/PcwizWsState won over dto/contract/PcwizWsState and the COMMAREA mapping came back empty.
  • dto_shape(src, cls, context=None) resolves cls through java_class_file. It resolves each part class (a composite COMMAREA's segments) from the DTO that declares it. A missing class raises LookupError instead of StopIteration.
  • run_java_cics now passes the service file as context. The COMMAREA class is the one the service imports.
  • tests/tools/cics_crucible.py drops its own path-based dto_shape copy (the workaround from #3989 phase 2: CICS crucible runner, baseline ratchet and CI #4000). It calls equivalence_cics.dto_shape with the fully qualified class name that the generated test reports.

Tests

  • test_a_dto_is_found_by_its_package_not_its_simple_name covers entity and contract DTOs with the same simple name. It checks:
    • lookup by qualified name, by the service's single-type import, and by an on-demand import;
    • a part class resolved from the DTO's package;
    • a bare ambiguous name raising, and a missing class raising.
  • The existing test_a_dtos_shape_is_read_from_its_comments (default package, no context) still passes.

Crucible cells

Before and after are identical. The runner already resolved the class by its full path, 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 #4013 (5c6d17f). 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.
  • With EQUIVALENCE_E2E=1, tests/cobol_mainframe/test_equivalence_cics.py and tests/cics_crucible pass 46 of 46. That includes the CardDemo account-view run end to end, which now goes through the service's import.
  • The ruff, mypy and dead-key audits show no new findings. ruff format is clean on the touched files. 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

…ary simple-name match

equivalence_cics.java_class_file resolves a generated class the way Java does:
a qualified name by its path; a simple name from the file that names it
(single-type imports, own package, on-demand imports); else the only class of
that name. Two candidates with nothing to choose between them raise
LookupError instead of quietly picking entity/PcwizWsState over
dto/contract/PcwizWsState. dto_shape and its part classes resolve through it,
run_java_cics passes the service as context, and the CICS crucible runner
drops its own path-based copy.

Part of #3989.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EC8FWfn3aPmsUPnRgKNVup
@squid-protocol
squid-protocol merged commit 81bdbd1 into main Sep 29, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/4011-dto-shape-fqn branch September 29, 2026 18:39
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: dto_shape finds a class by simple name and picks the wrong one

1 participant