Skip to content

CICS facades: answer the own COMMAREA DTO where returned() converts by layout without loss (#4449 part 2) - #4529

Merged
squid-protocol merged 6 commits into
mainfrom
feat/4449-typed-facade-returned
Oct 6, 2026
Merged

squid-protocol merged 6 commits into
mainfrom
feat/4449-typed-facade-returned

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Part of #4449. Still open there: the comment's EC-BOUND-SUBSCRIPT suggestion (compile the COBOL side with -fec=EC-BOUND-SUBSCRIPT), not attempted here.

Draft. Part 2 of #4449 (part 1, the java-facade side, landed in #4455). Builds on main after #4490 (#4465) and #4524 (#4464).

Problem

#4427 made a CICS facade answer Object wherever a RETURN TRANSID its task can end in passes another class: COBOL passes bytes, and each program reads them through its own record. A deployment caller of those facades got an untyped answer. #4449 asks for the typed alternative: convert by layout in returned().

The design call

Converting by layout is lossless only when both records cut the bytes the same way. In every other case a typed answer would lose or invent data:

  • A wider record (CardDemo: COSGN00C's 160-byte CarddemoCommarea against COACTUPC's 1,033-byte COMMAREA) would be truncated. The caller would then pass the next transaction a COMMAREA missing the program's state.
  • A narrower record would be padded with bytes that were never passed (EIBCALEN is shorter).
  • The same width, cut differently would decode text bytes as numbers.

Conservative version (this PR): a facade answers the program's own DTO only where every other record its task can RETURN has the same partition: the same width, and each item at the same offset, width, PICTURE, USAGE, SIGN and OCCURS, with names ignored. In other words, the same COMMAREA under another program's names. Everywhere else the answer stays Object, as #4427 left it.

Generator (cobol_to_java_transaction_forge.py)

  • commarea_codec writes toCommarea() / static fromCommarea(byte[]) through CobolRecords, in the record charset. It writes them only into the DTOs that a facade converts between, so no other DTO changes. It writes none for a layout it cannot lay out exactly: unknown width, OCCURS, PL/I, COMP-1/COMP-2, or overlapping items (REDEFINES). An unset number is written as spaces and read back as null.
  • _plan_conversations keeps txn_response = own DTO when _reads_through holds, and records txn_converts. The facade Javadoc names the converted records. txn_request is unchanged: the in side stays Object where it was.

Runtime (CicsTask.returned)

  • The same class is returned as the same object, as before.
  • Another class is converted when both have the codec. A RETURN LENGTH is honoured.
  • A class with no layout, or fewer bytes than the target record, is refused by name. It is never guessed.

Harness (equivalence_cics.py)

The java-facade check accepts a converted answer when it has the same toCommarea bytes as task.returned(type). Before, it accepted only the identical object.

Effect on the estates

  • CICS crucible: 3 facades become typed.
    • pc-wizard: PCWIZ and PCCONF both COPY PCSTATE into their own WS-STATE, so PcwizWsState and PcconfWsState have the same partition.
    • pc-aid-menu: PCMENU answers PcmenuWsCa, converting from PcdetlWsCa.
    • The ports were resurfaced with port_surface.py crucible, with a resurfaced provenance event, and re-proven with evidence.py prove. All 4 pc-wizard and pc-aid-menu records are proven (PCWIZ 6/6, PCCONF 5/5, PCMENU 4/4, PCDETL 3/3), including the java-facade runs:
      • back-and-fix: PCCONF XCTLs to PCWIZ, whose RETURN passes a PcwizWsState, so PCCONF's facade converts.
      • PCMENU option 2: RETURN TRANSID(PC12) with PCDETL's record.
  • CardDemo, CBSA, GenApp: no change. No crossing in them is lossless. CardDemo's records differ in width (160 / 194 / 218 / 380 / 480 bytes), and the composite and OCCURS COMMAREAs have no exact layout. Their facades stay Object. The equivalence ports, facade_baseline.json and det_sweep_baseline.json are untouched.

The alternative (not implemented)

A typed bytes value: handleTransaction answers a generated Commarea (the bytes passed plus EIBCALEN), with <T> T as(Class<T>) converting by layout on demand.

  • For: lossless everywhere and typed at the call site. The caller passes the same Commarea on to whichever transaction the RETURN names.
  • Against: the REST/JSON surface becomes bytes (or base64) instead of a DTO. Every port's runTask would have to read task.commarea(..) through it. It changes the facade signature of every crossing program, so all 14 CardDemo façade ports would need re-proving.

Two narrower variants:

  • Truncate or pad to the own DTO. Typed, but lossy as described above.
  • Convert the in side too: handleTransaction(String, Own) takes any record with the same partition.

Either is a follow-up if the 4th-estate API wants it.

Found along the way (not changed here)

On main, port_surface.py equivalence --check already reports drift:

Resurfacing them means re-proving 14 cases, so it is left to its own PR.

Checks

  • New tests/cobol_mainframe/test_facade_layout_4449.py:
    • the planner: typed when lossless, and Object when the other record is wider, narrower, cut otherwise, or an OCCURS table;
    • the partition and codec rules;
    • the generated runtime and DTOs compiled with javac (plain classes and Java records): conversion, identity, and both refusals.
  • Updated: test_cics_conversation_4427.py (its fixtures now cut the records differently, to keep testing Object) and the refusal text in test_cics_runtimes.py.
  • The equivalence E2E facade tests (EQUIVALENCE_E2E=1) pass.
  • pr_gates.py: all 7 gates pass (lint, audits, secrets, xray, gauntlet, golden, suite).
  • pr_gates.py --ratchets: all 5 pass (ports, estate, fact-crosscheck, completeness, ground-truth).
  • Det sweep (proof_sweep.py --det-only --skip-db2): as expected, with det_sweep_baseline.json unchanged.
  • The mypy audit is clean under the latest mypy (2.4.0) in a fresh venv. Ruff is pinned at 0.16.0.
  • The 4 crucible records were re-proven on the final tree, after merging main (det: SEND CONTROL and terminal RECEIVE (INTO/SET/LENGTH/MAXLENGTH/NOTRUNCATE, LENGERR, EOC) (#4413) #4500, det: read continued apostrophe literals, "" inside literals, PROGRAM-ID without its period (#4523, #4462) #4526).

🤖 Generated with Claude Code

https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR

squid-protocol and others added 5 commits October 5, 2026 22:51
…y layout losslessly (#4449 part 2)

A facade whose task can RETURN another program's record keeps the program's own
DTO as its answer when every such record cuts the bytes exactly as its own does
(same width, offsets, PICTUREs, USAGEs); CicsTask.returned converts by layout
through generated toCommarea / fromCommarea codecs. Any other crossing keeps
Object (#4427): a typed answer would truncate, pad or misdecode it.

pc-wizard (PCWIZ, PCCONF) and pc-aid-menu (PCMENU) facades become typed; ports
resurfaced and re-proven. CardDemo / CBSA / GenApp unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR
@squid-protocol squid-protocol added enhancement New feature, sensor, or structural signature legacy-modernization COBOL refractor, dead-code extraction, and JCL forging priority: high Core feature broken, but workarounds exist testing Unit, integration, and E2E pipeline verification labels Oct 6, 2026
Comment on lines +214 to +215
"refused: the task RETURNed a java.lang.StringBuilder, not a com.acme.dto.contract.PcconfWsState "
"(no layout converts one into the other)",
Comment on lines +216 to +217
"refused: the task RETURNed a com.acme.dto.contract.PcwizWsState, not a com.acme.dto.contract.PcconfWsState: "
"20 bytes do not fill PcconfWsState's 30-byte record",
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, sensor, or structural signature legacy-modernization COBOL refractor, dead-code extraction, and JCL forging priority: high Core feature broken, but workarounds exist testing Unit, integration, and E2E pipeline verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants