Skip to content

Fix #4003: CICS harness models the condition machinery (HANDLE/IGNORE CONDITION, RESP/NOHANDLE, HANDLE ABEND, PUSH/POP) - #4016

Merged
squid-protocol merged 3 commits into
mainfrom
fix/4003-conditions
Sep 29, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
fix/4003-conditions

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #4003
Part of #3989 (phase 3, lane B)

What

The stub runtime and translator now model CICS condition handling the way IBM's translator and runtime do.

  • Condition table: each level has a table (GGCHCND) that maps a condition, by DFHRESP code, to its HANDLE CONDITION label index, IGNORE (-1) or the default (0). The last HANDLE or IGNORE for a condition wins. IBM, IGNORE CONDITION: "until a HANDLE CONDITION command for the same condition is encountered".
  • Per command: RESP and NOHANDLE suspend the handlers (no transfer, no abend), while RESP/RESP2 and the EIB are still set. IBM, HANDLE CONDITION: "temporarily deactivated by the NOHANDLE or RESP option".
  • Resolution (GGCCOND), in order:
    1. The condition is IGNOREd: control continues.
    2. It has its own label.
    3. ERROR has a label. IBM, "Modifying default CICS exception handling": "If no HANDLE CONDITION command is active for a condition, but one is active for ERROR, control passes to the label for ERROR".
    4. The default action: an abend with the condition's AEIx code (the SPEC 6.2 table).
  • Transfer of control is a real COBOL GO TO <labels> DEPENDING ON GG-GOTO issued after the failing command, not a GOBACK.
    • The label list is every label named by the program's HANDLE CONDITION, HANDLE ABEND LABEL and HANDLE AID commands, in first-use order (handler_labels). This is IBM's translator's GO TO … DEPENDING ON DFHEIGDI.
    • COBOL fall-through and PERFORM-range return therefore work as written. hc-perform-range proves it.
  • HANDLE ABEND:
    • LABEL, CANCEL and RESET are modelled. PROGRAM is refused by name, because no crucible case uses it.
    • An abend, whether EXEC CICS ABEND or an unhandled condition, goes to the first active exit from its level upward. The exit is deactivated when it takes control. IBM, abend recovery: "starting at the logical level … proceeding to successively higher levels".
    • If the exit is at this level, control transfers by GO TO. If it is above, GG-GOTO is -1 and the program is left, ready for the LINK unwinding in CICS harness: LINK with by-reference COMMAREA and program levels (unlocks through 18 cobol-stub cells) #4004.
    • With no exit, or with ABEND CANCEL, the task terminates.
  • ASSIGN ABCODE returns the current code, or blanks when there has been no abend. Other ASSIGN options are refused by name.
  • PUSH/POP HANDLE: PUSH saves and suspends conditions, IGNOREs and the abend exit together. POP restores them, and raises INVREQ when nothing was pushed.
  • Program entry: each program names itself to the stub on entry (GGCPENT, injected after the PROCEDURE DIVISION header). That name is the exit's program in the ABEND event.
  • Stub ABEND event: ABEND abcode= cause= [condition=] outcome=exit|terminated [exit=PROG.LABEL]. The runner and the equivalence harness both read it.
  • Java (generated CicsTask): abendOnCondition(condition), abendToExit(abcode, cause, condition, program, label), abcode() (ASSIGN ABCODE) and abcodeFor(condition).
    • The ABEND event carries cause, condition, outcome and exit.
    • Only a terminating abend ends the task.
    • The Java driver ends a task as abend only on outcome: terminated.

Cells (side × status)

side before pass/fail/unsupported after
engine-facts 10 / 0 / 0 10 / 0 / 0
forge-compile 10 / 0 / 0 10 / 0 / 0
cobol-stub 2 / 1 / 34 6 / 1 / 30
java 0 / 37 / 0 0 / 37 / 0
  • hc-perform-range cobol-stub now passes all 4 scenarios:
    • three-items: an ITEMERR label inside the PERFORM range.
    • no-queue: QIDERR falls through the next paragraphs.
    • five-items: the handlers are reached by fall-through with no condition raised.
    • length-trap: LENGERR goes to the ERROR label outside the range.
    • The three post-loop ITEMERRs cover RESP, IGNORE, and a HANDLE that overrides the IGNORE.
  • hc-abend-link is now blocked only by translator: LINK (CICS harness: LINK with by-reference COMMAREA and program levels (unlocks through 18 cobol-stub cells) #4004).

Tests

  • Translator: GGCCOND and GO TO DEPENDING after a failing command, and none under RESP or NOHANDLE; HANDLE, IGNORE, ABEND LABEL/CANCEL/RESET, PUSH/POP, ASSIGN ABCODE and ABEND (GO TO then GOBACK); handler_labels; the program-entry injection; refusals of HANDLE ABEND PROGRAM, other ASSIGN options and unknown conditions.
  • test_cics_runtimes.py:
    • The stub, compiled with cc, is driven through the whole condition table: HANDLE/IGNORE/ERROR/default, PUSH/POP/INVREQ, exit deactivation, RESET, ABEND CANCEL and ASSIGN ABCODE.
    • A check that the stub's abend-code table equals the runner's.
    • CicsTask's abend API, run under javac.
  • End to end: the EQUIVALENCE_E2E=1 fixture run passes on every side. CardDemo account view (which uses HANDLE ABEND LABEL) still passes 9/9 events.

Generated output

CicsTask.java gains the abend API (intended). It is generated only for CICS transaction programs. No goldens change.

Audits: ruff, mypy and dead-key show no new findings. tool_regex_redos --ci is clean. Touched files are formatted.

🤖 Generated with Claude Code

Comment on lines +169 to +170
"{abcode=AEYH, cause=condition, condition=QIDERR, event=ABEND, exit={label=MAIN-ABEND, program=HCMAIN}, "
"outcome=exit}",
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 3 commits September 29, 2026 15:04
- HANDLE CONDITION / IGNORE CONDITION / ERROR as a per-level table in the
  stub (GGCHCND); RESP and NOHANDLE suspend it per command. A condition
  goes to its label, else ERROR's, else the default action (abend with its
  AEIx code). The last HANDLE or IGNORE for a condition wins.
- Transfer of control is a real GO TO <labels> DEPENDING ON GG-GOTO after
  the command, the labels being every one the program's HANDLE commands
  name (handler_labels), as IBM's translator's GO TO ... DEPENDING ON.
- HANDLE ABEND LABEL / CANCEL / RESET; an abend (EXEC CICS ABEND or an
  unhandled condition) goes to the first active exit from its level
  upward, deactivating it; with none (or ABEND CANCEL) the task terminates.
  ASSIGN ABCODE returns the current code. PUSH HANDLE suspends conditions,
  IGNOREs and the abend exit; POP restores them (INVREQ when empty).
- Each program names itself to the stub on entry (GGCPENT), for the exit's
  program in the ABEND event.
- CicsTask: abendOnCondition / abendToExit / abcode / abcodeFor; the ABEND
  event carries cause, condition, outcome and exit.

cobol-stub: hc-perform-range passes all 4 scenarios. hc-abend-link waits
only for LINK (#4004).

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 358935b into main Sep 29, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the fix/4003-conditions branch September 29, 2026 19:19
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.

CICS harness: condition machinery (HANDLE/IGNORE CONDITION, RESP/NOHANDLE, HANDLE ABEND, PUSH/POP HANDLE)

2 participants