Skip to content

#4023: COBOL paragraph / branch coverage per program (CICS crucible, CardDemo, cobol4j) - #4027

Merged
squid-protocol merged 4 commits into
mainfrom
feat/4023-cobol-coverage
Sep 30, 2026
Merged

squid-protocol merged 4 commits into
mainfrom
feat/4023-cobol-coverage

Conversation

@squid-protocol

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

Copy link
Copy Markdown
Owner

Closes #4023. Part of #3989.

A proven port only proves the paths its scenarios run. This PR adds a tool that measures which paths those are, and uses it in the three places that run COBOL: the CICS crucible, the CardDemo equivalence cases, and the opensourcecobol4j (cobol4j) estate.

The tool: tests/tools/cobol_coverage.py

  • The COBOL is compiled with cobc -ftraceall and run with COB_SET_TRACE / COB_TRACE_FILE. GnuCOBOL then writes every paragraph and section entered, and every statement executed, with its line.
  • Paragraphs: the live paragraphs and sections a run entered, out of all the live ones. Dead code is listed apart. It comes from the engine's own reachability (procedure_units / reachable_units), so "nothing can reach it" and "no scenario reaches it" are never the same line.
  • Branches: IF true / false, each EVALUATE arm, and "no arm" when there is no WHEN OTHER. Branch points are found in the original source. The outcome is read from the statement that runs next.
  • HANDLE labels: whether each label named in HANDLE CONDITION / AID / ABEND was entered.
  • Translated code: a line of the compiled text maps back to the original through a difflib alignment. Lines rewritten in place are paired by similarity, so the CICS translator's own IFs are never counted. An IF whose arms can't be told apart by (line, verb) is listed as unresolvable, not guessed.
  • Engine checks: a unit the engine calls dead that a run entered is reported (dead_but_executed). So is a unit the engine does not read at all (unread).

Where it runs

  • CICS crucible: the cobol-stub side is traced.
    • docs/language_status/cics_crucible.md gets a COBOL coverage section. Each ported program carries its claim, e.g. PCCONF: "proven on 3 scenarios, covering 4/5 paragraphs and 6/14 branches". The section also lists the live code no scenario reaches, as scenarios to propose.
    • tests/cics_crucible/coverage.json holds, per passing scenario, what it executed. --ci fails when that is lost or gained until --update-baseline records it.
    • A port proof (--report-dir) carries the claim.
  • CardDemo (equivalence.py, batch and CICS): each run writes cobol/coverage.json. The report gives the claim when the run is proven, and "not proven; …" otherwise. For example, INTCALC is "proven on 1 run, covering 20/22 paragraphs and 46/86 branches", and ACCTVIEW is "proven on 5 scenarios, covering 30/32 paragraphs and 39/71 branches".
  • cobol4j: cobol_coverage.py autotest <at_extract cases> runs each case under GnuCOBOL. ${COMPILE} / ${COBJ} build traced modules, and java PROG runs them with cobcrun. On cobol_utf8 + jp-compat (250 cases): 116 ran, 16 skipped, 79 don't compile under GnuCOBOL (oc4j-only dialect), and 39 are compile-only.

Engine defect found

The trace shows paragraphs and sections that cobol_graveyard_finder does not read: Japanese / full-width names, and a paragraph named END-IPROC1. Filed as #4026 and logged as field-testing D036. They are reported as unread and left out of the counts. No pinned mainframe corpus has either shape.

Verification

  • cics_crucible.py --update-baseline then --ci on JDK 17: 94 pass / 37 fail / 0 unsupported, the same cells as main. baseline.json is unchanged, and the coverage ledger reproduces run to run.
  • The runner's tests pass, including EQUIVALENCE_E2E=1 (the fixture through every side, now with coverage and a port claim). The new test_cobol_coverage.py needs no Docker, and I ran it through plain pytest from another directory.
  • audit_check.py: all clear. field_testing.py check: valid.
  • CardDemo: INTCALC and ACCTVIEW proven, with claims. POSTTRAN has no committed port, so its Java side fails as it already does on main, and its report says "not proven".

Notes

  • Every COBOL run is now traced, which adds a trace file per task. tests/tools/cobol_coverage.py joins trial.py's HARNESS_PATHS (the frozen harness), since every equivalence run now goes through it.
  • Cross-repo: none. The crucible pin is unchanged. A future pin bump also commits coverage.json (docs/ecosystem.md is updated).

🤖 Generated with Claude Code

https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

squid-protocol and others added 2 commits September 29, 2026 19:41
…ucible, 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
…rt 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
Comment thread tests/tools/cics_crucible.py Fixed
Comment thread tests/tools/cics_crucible.py Fixed
Comment thread tests/tools/cobol_coverage.py Fixed
Comment thread tests/tools/cobol_coverage.py Fixed
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 2 commits September 29, 2026 20:58
… 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]>
… 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
@squid-protocol
squid-protocol merged commit 2237222 into main Sep 30, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the feat/4023-cobol-coverage branch September 30, 2026 11:37
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 crucible: COBOL paragraph/branch coverage per program, so a proven port says how much it proves

2 participants