Skip to content

CardDemo COACCT01 / CODATE01: coverage reads cobc trace lines past a redundant period; MQ fault arms (Part of #6072) - #6828

Merged
squid-shepherd[bot] merged 7 commits into
mainfrom
churn/6072-20261027T2200Z
Oct 27, 2026
Merged

squid-shepherd[bot] merged 7 commits into
mainfrom
churn/6072-20261027T2200Z

Conversation

@squid-protocol

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

Copy link
Copy Markdown
Owner

Part of #6072.

What

CardDemo COACCT01 and CODATE01 showed every WHEN MQCC-OK / IF success arm after an MQ call as uncovered, although
the GnuCOBOL traces run them. The cause is trace-line drift in tests/tools/cobol_coverage.py's reading of
-ftraceall output, not the programs.

  • Root cause (measured in gitgalaxy-gnucobol:3): cobc does not count the newlines between a separator period
    and a following redundant period (a line whose code area is only .). Every later trace line reads that many lines
    early, until the end of a COPY statement resyncs the count. COACCT01 224-226 (PERFORM 8000-TERMINATION., blank,
    .) is the first occurrence, so every EVALUATE / IF after it landed on the wrong line and was never credited.
  • Fix: _traced_lines(compiled) builds the trace-line -> compiled-line map from the measured rule. LineMap.get
    translates a trace line through it first. Every caller goes through LineMap, so no caller changes.
  • Tests first: the new tests in tests/tools/test_cobol_coverage.py failed before the fix and pass after it. They
    cover blank / comment / adjacent / same-line / repeated / COPY-resync shapes, the negatives (a normal period, a .
    in a literal), and an end-to-end hits() case.
  • MQ failure arms: each case gets two new fault scenarios:
    • close-input-fails (MQCLOSE nth 1, 2009)
    • error-put-fails (MQPUT nth 1, 2051)
      The case notes' wrong "unterminated CALL" explanation is replaced.
  • z/OS probe c20-recursive-perform-returns (new, in docs/language_status/zos_probes.json): a recursive
    PERFORM that ends, in CardDemo's shape. Its expected output is measured in gitgalaxy-gnucobol:3: control returns
    to each PERFORM in turn. IBM leaves the result unpredictable, so a z/OS run that prints those lines MATCHES C20 and
    anything else DIFFERS.
  • Register C20 (new): a failed close PERFORMs 8000-TERMINATION while it is active, which is a recursive PERFORM.
    IBM says it "can cause unpredictable results". The oracle runs the nested range and returns, and the det runtime
    matches it.

Net branches (ladder_refresh, before = origin/main)

case paragraphs net branches before after
carddemo-coacct01 13/13 18.2% (6/33) 93.9% (31/33)
carddemo-codate01 13/13 21.4% (6/28) 92.9% (26/28)

Both cases are proven, on every scenario.

Facts checked

  • IBM Enterprise COBOL 6.4 LR (SC27-8713-03), "Basic PERFORM statement" (https://www.ibm.com/docs/en/SS6SG3_6.4.0/lr/ref/rlpsperf1.html):
    "A PERFORM statement must not cause itself to be executed. This constitutes a recursive PERFORM, which can cause
    unpredictable results."
  • cobc's redundant-period rule: measured by compiling probe programs with cobc -x -std=ibm -ftraceall in
    gitgalaxy-gnucobol:3 and reading the trace lines. The variants were blank lines, comment lines, adjacent lines,
    the same line, several occurrences and a COPY resync.
  • MQCLOSE / MQPUT fault reasons: they come from equivalence_mq.FAULT_REASONS (IBM MQ reason codes).
  • Class sweep: _traced_lines was run over every compiled program in the mainframe corpora, cics-crucible and
    estate-crucible. Only COACCT01.cbl and CODATE01.cbl have a non-empty correction, and every crucible file gives an
    empty one, so no other ledger and no cics_crucible baseline moves.

Sibling gaps

  • No other program has the redundant-period shift (class sweep above).
  • The same MQCLOSE recursion shape exists in both programs (the remaining slices below). I did not sweep other estates for it.

Remaining slices

  • COACCT01 585:OTHER, 608:OTHER; CODATE01 489:OTHER, 512:OTHER: the WHEN OTHER arms of a failed close of the
    reply or error queue.
    • They are not infeasible: a close can fail at runtime.
    • They are unstateable today. The input queue's open flag is never reset after its close, so the nested 8000
      re-closes it, gets 2019, takes WHEN OTHER again and recurses without end. cobc dies with rc=11 (SIGSEGV) and Java
      with StackOverflowError.
    • A scenario needs a model of what z/OS does when the stack runs out, or a fault plan that fails only the first
      close of a given queue and not the re-close.

Plan changes

  • The plan expected four sibling ledgers (acctupdate, adminmenu, adminmenu-generated, cotrtupc) to move. Measured,
    _traced_lines is empty for all four programs, so none moves.
  • The MQCLOSE arms are only partly modelled: nth 1 (the input close) is stated, and nth 2/3 are dropped for the
    reason above. The error-put arm was added. Register C20 was added as the 5th hand-written file, and its z/OS probe (needed by test_zos_probes for any ASSUMED entry) is a 6th, one over the brief's cap of 5.

Lessons for agents

  • cobc -ftraceall does not count the newlines between a separator period and a redundant .. Trace lines drift
    early until a COPY end, and cobol_coverage._traced_lines corrects for it.
  • audit_check.py's format check scans only gitgalaxy/ (SCAN_ROOT). Run ruff format --check on changed
    tests/ files directly.
  • Naming a test_* module, as a word, in a tests/tools module makes test_ground_truth_plan's closure "reach" it
    and fail. Keep test-module names out of tool docstrings.
  • A recursive PERFORM that never ends crashes both oracle and port (SIGSEGV / StackOverflowError). Don't write a
    scenario for it.

Gates

  • pr_gates --ratchets: 9 pass, 0 fail.
  • pr_gates --fast: 9/9. The first run failed affected in two places, both fixed now:
    • test_ground_truth_plan: a tool docstring named a test module.
    • The register audit and test_zos_probes: C20 lacked an IBM document number and a z/OS probe.
  • audit_check.py's format check scans only gitgalaxy/ (SCAN_ROOT). Run ruff format --check on changed
    tests/ files directly.
  • Naming a test_* module, as a word, in a tests/tools module makes test_ground_truth_plan's closure "reach" it
    and fail. Keep test-module names out of tool docstrings.
  • A recursive PERFORM that never ends crashes both oracle and port (SIGSEGV / StackOverflowError). Don't write a
    scenario for it.

Gates

  • pr_gates --ratchets: 9 pass, 0 fail.
  • pr_gates --fast: 8/9. affected failed on test_ground_truth_plan, because a tool docstring named a test
    module. I fixed that, and the test file now passes (96 passed together with test_cobol_coverage).
  • audit_check.py: all clear. ruff format --check on the changed tests/ files: clean. register.py --check: OK.
  • ladder_refresh.py carddemo-coacct01 carddemo-codate01: 2/2 proven (16 and 15 scenarios). The pin tests
    passed: 284 passed, 114 skipped.

Cross-repo: none.

🤖 Generated with Claude Code

@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 27, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review October 27, 2026 22:50
@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) October 27, 2026 22:50
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot merged commit b967ed0 into main Oct 27, 2026
82 checks passed
@squid-shepherd
squid-shepherd Bot deleted the churn/6072-20261027T2200Z branch October 27, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant