Skip to content

#3830: the equivalence oracle is no more lenient than COBOL - #3853

Merged
squid-protocol merged 1 commit into
mainfrom
fix/3830-strict-numbers
Sep 27, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/3830-strict-numbers

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3830 (epic #3819).

Why

The equivalence harness is the oracle behind every "the Java port equals COBOL" claim, and it was more lenient than COBOL in two ways:

  • Number parsing: decode_field parsed DISPLAY numerics with int(), which accepts spaces, +, _ and non-ASCII digits. So " 12" equalled "0012", and ١٢ read as 12.
  • Value-only comparison: the diff compared decoded values only, so a C vs F COMP-3 sign nibble, or −0 vs +0, passed as equal even though the output files differ and a later program may test the sign.

What

  • Strict decoding:
    • DISPLAY digits must be ASCII 0-9 once the sign is resolved;
    • COMP-3 digit nibbles must be 0-9, with an a-f sign nibble;
    • anything else is <invalid …>, as a COBOL NUMERIC test would say.
  • Separate signs: a latent bug found along the way. SIGN IS LEADING/TRAILING SEPARATE fields only decoded because int() happens to accept a leading +/-; a trailing sign read as invalid. The flag now travels from the copybook layout to the decoder, which reads the sign byte at either end.
  • Byte-level differences: a field with the same value but different bytes is now a difference, marked "raw": true and shown as hex. The Markdown report labels it "(bytes; same value)". The CICS harness passes the separate-sign flag too.

Verified

  • New tests cover:
    • " 12", +012, 1_2, Arabic-Indic digits and bad COMP-3 nibbles are invalid;
    • a separate sign is read at either end;
    • C vs F and −0 vs +0 are raw differences, shown in the report.
  • Proven ports re-run end to end under the strict oracle, all still equal byte for byte: CBACT04C on CardDemo data, CBACT04C on generated edge-case inputs, and the COACTVWC CICS account view.
  • The whole mainframe suite passes, and the mypy and ruff audits are clean.

Note for running the end-to-end proofs locally: set JAVA_HOME to a JDK 17 and GITGALAXY_MAINFRAME_CORPORA to a checkout's .mainframe_corpora.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g

decode_field read a DISPLAY numeric with int(), which takes spaces, `+`, `_` and non-ASCII
digits: "  12" equalled "0012". The diff compared decoded values only, so a C vs F sign
nibble or -0 vs +0 passed as equal though the files differ.

- decode_field: DISPLAY digits must be ASCII 0-9 after the sign is resolved; COMP-3 nibbles must
  be 0-9 with an a-f sign; anything else is <invalid ...>, as a NUMERIC test would say
- SIGN IS SEPARATE: the flag now travels from the copybook layout to the decoder, which reads the
  `+`/`-` byte at either end -- it had only worked because int() takes a leading sign (a
  trailing one read as invalid)
- diff_records: same value, other bytes is a difference, marked "raw" and shown as hex;
  report_markdown labels it "(bytes; same value)"
- the CICS harness passes the separate-sign flag too

Proven ports re-run end to end under the strict oracle (EQUIVALENCE_E2E=1, JDK 17): CBACT04C,
CBACT04C on generated inputs, and the COACTVWC CICS view all still equal. Mainframe suite green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
@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 d37558b into main Sep 27, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the fix/3830-strict-numbers branch September 27, 2026 00:55
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.

Harness numeric comparison is lenient: int() accepts spaces, + and _; sign nibble and ±0 not compared

1 participant