Skip to content

CICS transactions + COMMAREA / channels -> REST endpoints and DTOs (#3615) - #3636

Merged
squid-protocol merged 2 commits into
mainfrom
feat/txn-endpoints-3615
Sep 25, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feat/txn-endpoints-3615

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3615 (epic #3625). This is the first generator that builds from the verified skeleton (#3614, PR #3631).

What changes

For a program with CICS evidence, the controller is built from the skeleton instead of the generic per-program controller. CICS evidence means an entry transaction, an EXEC CICS resource, a COMMAREA contract or a container.

fact (skeleton section) generated
CSD TRANSACTION(x) PROGRAM(p) (entry_transactions) POST /api/v1/<p>/transactions/<x> → service.handleTransaction("x", body)
resolved LINK / XCTL into p (commarea_contracts), or no transaction enters p POST /link → service.handleLink(body)
GET / PUT CONTAINER (interface.containers) <P>ChannelIn / <P>ChannelOut DTOs; the transaction body when p has no COMMAREA, else POST /channel
COMMAREA layout (interface.commarea) the request / response DTO in dto.cics

How the COMMAREA layout is resolved (engine side, new GalaxyIR.program_interfaces()):

  1. The record the program's resolved LINK / XCTL / RETURN TRANSID callers pass it. If callers pass different records, the one most sites pass wins and the others become a TODO listing each alternative.
  2. Else the program's own fixed-length DFHCOMMAREA.
  3. Else no body, with a TODO giving the reason: a variable-length OCCURS … DEPENDING ON EIBCALEN area no caller pairs with, or no DFHCOMMAREA at all.

Traceability:

  • Every DTO field comment gives the COBOL name, PIC, usage, offset, width and source file.
  • Every class and endpoint names its CSD line or call site, and the field-testing status of the facts it rests on.
  • One DTO serves every program passed the same copybook record. A program that continues the copied record past its COPY gets its own class, since its layout differs: CardDemo's CARDDEMO-COMMAREA is 160, 194 or 218 bytes depending on the program.
  • The DTOs follow the target config: Lombok, plain class, or Java record.

Example (CardDemo):

    /** CICS transaction CA00 -> Coadm01c (CSD app/csd/CARDDEMO.CSD:327 group CARDDEMO). */
    @PostMapping("/transactions/CA00")
    public ResponseEntity<CarddemoCommarea> transactionCA00(@RequestBody CarddemoCommarea request) {
        return ResponseEntity.ok(coadm01cService.handleTransaction("CA00", request));
    }

    /** Program-to-program entry: XCTL at app/cbl/COSGN00C.cbl:231. */
    @PostMapping("/link")
    // CDEMO-FROM-TRANID: PIC X(04), offset 0, 4 bytes (app/cpy/COCOM01Y.cpy)
    private String cdemoFromTranid;

Coverage on the pinned corpora

corpus CICS programs with a COMMAREA DTO transaction endpoints COMMAREA / channel DTOs
CardDemo 25 21 26 14
CBSA 27 22 14 37
GENAPP 31 31 25 27
zECS 5 4 5 4
zOE, DSF 0 (batch) – – –

Compile

  • java_target_matrix.py --scan refactors against an engine scan, so the skeleton path gets compiled.
  • java-compile.yml now runs each corpus's configs twice: the generic path, then --scan.
  • Locally, all 13 configs compile via --scan on CardDemo, CBSA, GENAPP and zECS. zOE and DSF have no CICS programs and pass on the generic path.

Unchanged without a skeleton

  • With no skeleton, generate_service_skeleton and generate_java_dto output is byte-identical; the DTO renderer is only factored out.
  • refraction_snapshot.py check: 0 differ on all 6 corpora.
  • Full suite: 11545 passed.
  • ruff_audit.py --ci: clean.

Tests

tests/cobol_mainframe/test_cics_endpoints.py runs a real scan of a small CICS estate: a transaction, a LINK with a copybook COMMAREA, a channel program with a dotted container name, and a batch program. It covers:

  • the interface join: caller-record precedence, offsets, containers;
  • PIC → Java type mapping;
  • endpoints, DTOs and services end to end;
  • the target style reaching the new DTOs;
  • DTO sharing and de-duplication.

Not in this PR

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g

…3615)

A CICS program's controller is now built from the verified skeleton
(06_skeleton, #3614), replacing the generic per-program controller:
- each CSD transaction entering the program -> POST /transactions/<transid>
- a LINK / XCTL target, or a program no transaction enters -> POST /link
- GET / PUT CONTAINERs -> POST /channel, or the transaction body when
  the program has no COMMAREA

Engine side, GalaxyIR.program_interfaces() resolves each program's
COMMAREA layout, in this order:
- the record its resolved LINK / XCTL / RETURN TRANSID callers pass it
  (the most-passed wins; the rest are listed as alternatives);
- else its own fixed-length DFHCOMMAREA;
- else a stated gap.
It also resolves every GET / PUT CONTAINER with its INTO / FROM layout.
The skeleton carries this as a new `interface` section.

Java side, the COMMAREA and container records become DTOs in dto.cics.
- One class serves every program passed the same copybook record. A
  program that extends the copied record gets its own class.
- Every field comment gives the PIC, offset, width and source file, and
  every class and endpoint names the CSD line or call site it came from,
  plus the field-testing status.
- Where no layout resolved, the endpoint takes no body and a TODO says why.
- Services gain the handleTransaction / handleLink / handleChannel methods
  the endpoints call.
- The DTO renderer is factored out of generate_java_dto (output unchanged)
  so the lombok / plain / record styles apply to the new DTOs.

java_target_matrix.py gains --scan. The java-compile workflow runs every
corpus both ways. Locally, all 13 configs compile via --scan on CardDemo,
CBSA, GENAPP and zECS; zOE and DSF have no CICS programs and pass on the
generic path. Without a skeleton, output is unchanged: the refraction
snapshot shows 0 differ on 6 corpora.

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

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

CodeQL flagged a duplicate '9' in _EDITED's character class ([^9SVP()0-9]).
The class also had a real bug. The (n) repeat counts are stripped before
the check, so its 0-9 range only let editing digits through: PIC 9990,
whose 0 is an insertion zero (display text), was typed as a number. The
class is now [^9SVP], and tests pin 9990 / 9(3)0 as String and S9(10) as
Long.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
@squid-protocol
squid-protocol merged commit 34d6d8f into main Sep 25, 2026
36 checks passed
@squid-protocol
squid-protocol deleted the feat/txn-endpoints-3615 branch September 25, 2026 17:00
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.

Java conversion: CICS transactions + COMMAREA / channel contracts -> REST endpoints and request / response DTOs

2 participants