Skip to content

#4023 follow-up: prove error paths -- file / CICS fault injection on both sides of the equivalence harness - #4029

Merged
squid-protocol merged 1 commit into
feat/4023-cobol-coveragefrom
feat/fault-injection
Sep 30, 2026
Merged

squid-protocol merged 1 commit into
feat/4023-cobol-coveragefrom
feat/fault-injection

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Follow-up to #4023. Stacked on #4027, so it targets that branch. Retarget to main once #4027 merges.

Why

#4023's coverage showed that a CardDemo proof covered only the success path. Those programs are mostly error handling: file status checks, abends and RESP arms. The normal INTCALC run reached 46 of 86 branch outcomes. This PR injects the same fault on both sides at the same statement, and proves each fault run the same way as the normal run.

How

COBOL (GnuCOBOL) Java
batch file I/O tests/equivalence/faults/ggfault.c, preloaded in front of libcob's OPEN / CLOSE / READ / WRITE / REWRITE / DELETE / START. A planned statement sets its FILE STATUS and I/O exception, as libcob does for a real failure, and does nothing else generated CobolFiles (batch runtime): one call per COBOL I/O statement. It returns the status the COBOL would see (00/23/10/35), with the same plan and the same counting
abend ggabend.c is CEE3ABD: it records ABEND Unnnn generated CobolAbend.user(abcode, why)
CICS READ the stub (ggcics.c) reads faults.cfg: READ FILE NTH RESP RESP2 CicsTask.read(file, lookup) and withFaults
  • Faults: a case's faults (batch) or a scenario's faults (CICS). The CLI takes --faults all|none|NAME,....
  • When a fault run is proven:
    • both sides abend with the same code, or neither does and RETURN-CODE and every output are equal;
    • and the same faults fired on both sides, at least one. A fault that never fires tested nothing.
    • After an abend, outputs are not compared, because what an abended step leaves in its datasets is not defined.
  • Porting rules: an abend is CobolAbend.user; every batch I/O statement goes through CobolFiles, in program order; a CICS file READ goes through task.read, with every RESP arm ported.

Results

  • INTCALC (CBACT04C): 19 faults, and the port is rewritten onto CobolFiles.
    • The faults: every OPEN (35/37), every CLOSE, TCATBALF read error / early end / 9x status, account and xref not found, DEFAULT group missing, DISCGRP read error, REWRITE and WRITE errors.
    • All 20 runs are proven. Coverage goes from 20/22 to 22/22 paragraphs and from 46/86 to 82/86 branches.
    • The 4 outcomes left: one is unreachable (the loop exits first, the defect the port documents). Three are data gaps: one category balance per account, no zero rate, and no disclosure group that matches.
  • ACCTVIEW (COACTVWC): 6 fault scenarios: CXACAIX NOTOPEN, ACCTDAT NOTFND / IOERR, CUSTDAT NOTFND / DISABLED, and both not found.
    • The port's WHEN OTHER arms (WS-FILE-ERROR-MESSAGE) are now ported.
    • All 11 scenarios are proven, and branches go from 39/71 to 47/71. The screens show the real error text, e.g. File Error: READ on CXACAIX returned RESP 000000019 ,RESP2 000000000.
  • Negative check: a port that ignores the REWRITE status fails its fault run (ABEND: COBOL U0999, Java None).

Verification

  • Unit tests: tests/cobol_mainframe/test_equivalence_faults.py (plan format, selection, run judgement, CICS conditions, generated runtime and rules). With EQUIVALENCE_E2E=1 it also drives the GnuCOBOL shim and abend stub on a small program. The INTCALC e2e test now requires all 19 faults proven.
  • Test suites: tests/cobol_mainframe + tests/cics_crucible + the coverage tests: 1170 passed, 9 skipped (plain pytest, outside the repo).
  • CICS crucible --ci on this branch: cells (94/37/0) and the coverage ledger unchanged. CicsTask and the stub changed without effect.
  • Audits: audit_check.py all clear. trial.py check passes; the fault stubs join HARNESS_PATHS.
  • Proofs: equivalence.py run carddemo-intcalc and run carddemo-acctview both proven, on JDK 17.

Not in this PR

  • POSTTRAN still has no port, so its fault runs would have nothing to prove on the Java side.
  • CICS faults cover READ only, because READ is the command ACCTVIEW's gaps need. The plan format is written to take other commands.
  • The generated JCL runner doesn't yet turn a CobolAbend into a step ABEND for COND processing. It fails the job, which it already did for any exception.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

… on both sides of the equivalence harness

A proof only covered the success path. CardDemo's programs are mostly error handling (file status
checks, abends, RESP arms), and the normal run reaches about half their branches. A case's faults
now inject the same condition on both sides, at the same statement. Each fault run is proven like
the normal run.

- GnuCOBOL: tests/equivalence/faults/ggfault.c is preloaded in front of libcob's file I/O
  (OPEN / CLOSE / READ / WRITE / REWRITE / DELETE / START). A planned statement returns its FILE
  STATUS and I/O exception instead of running. ggabend.c is CEE3ABD: it records ABEND Unnnn.
- Java: the generated batch runtime gains CobolFiles (one call per I/O statement: the status the
  COBOL would see, plus the same plan and counting) and CobolAbend. CicsTask gains read(file, lookup)
  and withFaults. The CICS stub's READ reads the same plan.
- Porting rules: an abend is CobolAbend.user; every batch I/O statement goes through CobolFiles;
  a CICS file READ goes through task.read, with every RESP arm ported.
- The harness: faults in case.json (batch) or a scenario (CICS), --faults. A run is proven when
  both sides abend with the same code, or neither does and RETURN-CODE and outputs are equal, and
  the same faults fired (at least one).
- INTCALC: 19 faults, the port rewritten onto CobolFiles. All 20 runs are proven, and COBOL
  coverage goes from 46/86 to 82/86 branches and 20/22 to 22/22 paragraphs. The 4 outcomes left
  are data gaps or unreachable. ACCTVIEW: 6 fault scenarios, the port's WHEN OTHER arms ported,
  all 11 scenarios proven, and 39/71 -> 47/71 branches.

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

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit bf49442 into feat/4023-cobol-coverage Sep 30, 2026
2 checks passed
@squid-protocol
squid-protocol deleted the feat/fault-injection branch September 30, 2026 00:58
squid-protocol added a commit that referenced this pull request Sep 30, 2026
…CardDemo, cobol4j) (#4027)

* #4023: COBOL paragraph / branch coverage per program, for the CICS crucible, CardDemo and cobol4j

A proven port only proves the paths its scenarios run. tests/tools/cobol_coverage.py
says which ones those are. The COBOL is compiled with cobc -ftraceall and run with
COB_TRACE_FILE. Per program it reports the live paragraphs and sections entered, the
IF / EVALUATE outcomes taken, and the HANDLE labels entered. Dead code (the engine's
reachability: procedure_units / reachable_units) is listed apart from code no scenario
reaches. Branch points come from the original source, and a trace line maps back
through a difflib alignment, so the CICS translator's rewritten lines and its own IFs
are handled. An IF whose arms cannot be told apart by (line, verb) is listed as
unresolvable, not guessed.

- CICS crucible: the cobol-stub side is traced. The report has a COBOL coverage section
  with each ported program's claim ("proven on N scenarios, covering X/Y paragraphs and
  A/B branches") and the live code no scenario reaches (scenarios to propose).
  tests/cics_crucible/coverage.json holds what each passing scenario executes, and --ci
  ratchets it. A port proof (--report-dir) carries its claim.
- CardDemo (equivalence.py, batch and CICS): each run writes coverage.json, and the
  report gives the claim when proven.
- cobol4j: `cobol_coverage.py autotest` runs at_extract cases under GnuCOBOL with shims
  for ${COMPILE} / java.

The trace also shows units the engine's unit reader misses: non-ASCII names, and
paragraphs named END-... (#4026, field-testing D036). They are reported as "unread",
not counted.

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

* #4023: freeze cobol_coverage.py with the trial harness; tidy the report section

Every equivalence run now goes through tests/tools/cobol_coverage.py, so it belongs in
trial.py's HARNESS_PATHS with the rest of the frozen harness. The harness report's
coverage section no longer repeats a blank line.

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

* #4023 follow-up: prove error paths too -- file / CICS fault injection on both sides of the equivalence harness (#4029)

A proof only covered the success path. CardDemo's programs are mostly error handling (file status
checks, abends, RESP arms), and the normal run reaches about half their branches. A case's faults
now inject the same condition on both sides, at the same statement. Each fault run is proven like
the normal run.

- GnuCOBOL: tests/equivalence/faults/ggfault.c is preloaded in front of libcob's file I/O
  (OPEN / CLOSE / READ / WRITE / REWRITE / DELETE / START). A planned statement returns its FILE
  STATUS and I/O exception instead of running. ggabend.c is CEE3ABD: it records ABEND Unnnn.
- Java: the generated batch runtime gains CobolFiles (one call per I/O statement: the status the
  COBOL would see, plus the same plan and counting) and CobolAbend. CicsTask gains read(file, lookup)
  and withFaults. The CICS stub's READ reads the same plan.
- Porting rules: an abend is CobolAbend.user; every batch I/O statement goes through CobolFiles;
  a CICS file READ goes through task.read, with every RESP arm ported.
- The harness: faults in case.json (batch) or a scenario (CICS), --faults. A run is proven when
  both sides abend with the same code, or neither does and RETURN-CODE and outputs are equal, and
  the same faults fired (at least one).
- INTCALC: 19 faults, the port rewritten onto CobolFiles. All 20 runs are proven, and COBOL
  coverage goes from 46/86 to 82/86 branches and 20/22 to 22/22 paragraphs. The 4 outcomes left
  are data gaps or unreachable. ACCTVIEW: 6 fault scenarios, the port's WHEN OTHER arms ported,
  all 11 scenarios proven, and 39/71 -> 47/71 branches.


Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

Co-authored-by: Claude Opus 5.5 <[email protected]>

* #4023: each multi-line report string one parenthesised string (CodeQL implicit concatenation)

CodeQL's py/implicit-string-concatenation-in-list flagged four report paragraphs split over
several source lines inside a list (alerts 1205-1208). Each is now one parenthesised string, as
#3762 did for the porting rules. The generated text is unchanged: the crucible report regenerated
from the same results is byte-identical.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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