Repository navigation
Behavioural equivalence harness + CardDemo INTCALC vertical slice (#3624) - #3748
Merged
Merged
Conversation
) The harness (tests/tools/equivalence.py + equivalence_java.py) runs a COBOL program and the generated Java on the same recorded inputs, and diffs their outputs record by record, field by field, decimals exact. COBOL side: GnuCOBOL 3.1 (BDB indexed files) in a container (tests/equivalence/gnucobol.Dockerfile), -std=ibm -fsign=EBCDIC. - Each KSDS is loaded by a generated loader keyed like the program's SELECT, alternate keys included. - A generated driver passes the JCL PARM through LINKAGE, and COB_CURRENT_DATE pins the clock. - Each output (and each KSDS opened I-O) is unloaded. Java side: the generated project (target config h2), with the case's port overlaid, run by a generated JUnit test: - load each input through the entity's record codec into H2; - run the step's runBatch(dds, parm) with the clock pinned; - dump the outputs through the same codecs. The diff lays each record out with the answer key's copybook reader. `--generated-only` runs the stub as generated: the generator's own baseline. Generator additions the harness needs: - Record codecs: every VSAM entity gets fromRecord(byte[], Charset) / toRecord(Charset), field by field at the COBOL offsets, over a shared CobolRecords runtime (DISPLAY text, zoned decimal with its sign overpunched, COMP-3, COMP; stores follow MOVE: truncation, high-order loss). An entity it can't encode (OCCURS, COMP-1/2, PL/I) gets none, with the reason. This is also how REPRO-unloaded VSAM data migrates into the new database. - The step's PARM: job_flow STEP rows record the text EXEC PARM= passes (new job_flow_data.parm, rehydrated, EngineJobFlow.parm, job_steps "parm"), and runBatch is now runBatch(List<Dd> dds, String parm), each generated step passing its PARM. The vertical slice, CardDemo CBACT04C (job INTCALC, the interest calculator), is ported by hand onto the generated skeleton (tests/equivalence/carddemo-intcalc/port): - 100/100 records equal (ACCTFILE 50/50, TRANSACT 50/50), including S9(09)V99's extremes and truncation edges; - the generated stub scores 4/100. The case's category balances are CardDemo's keys with non-zero balances (the corpus ships zeros). The harness found a defect in the original: CBACT04C never adds the last account's interest to its balance. PERFORM UNTIL tests END-OF-FILE before each pass, so the EOF branch that updates the last account is unreachable. The port keeps the behaviour, documented at the spot; the one-line fix is a business decision. Verification: - ir_join_diff --rescan: only job_steps (the parm key). - Ledger clean; golden masters unchanged. - All 6 corpora compile on all 17 configs. - Full suite passes; preflight passes. - tests/cobol_mainframe/test_equivalence.py pins the harness's pure parts; the end-to-end run is opt-in (EQUIVALENCE_E2E=1: Docker + JDK). Closes #3624 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
Contributor
…sh_examples.py (#3624) CodeQL notes on #3748: - equivalence_java imported CASES back from equivalence (an import cycle); it now locates tests/equivalence itself, and a test pins that the two agree; - equivalence.py imported os without using it. New tests/tools/publish_examples.py regenerates the cobol_to_java_examples repository from the six pinned, answer-keyed corpora: - per example: the generated project (no build output, run timestamps blanked), PROVENANCE.md (source commit and licence, generator commit, commands) and scan_comparison.md (the source estate and the Java, scanned by the same engine); - the equivalence cases' reports (ported and as generated), their ports and how to reproduce; - a README whose numbers come from the generated trees; - a compile workflow, with actions pinned by SHA. A refresh is a pull request on that repository. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
…s (CodeQL, #3748) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
The generated examples, the equivalence port and its data are derived from third-party corpora (Apache-2.0, EPL-2.0, MIT), so publish_examples now: - copies each source's own LICENSE* / NOTICE* / COPYING* files beside what is derived from it (mainframe_corpus.excerpt's rule); - opens every generated Java file with a notice naming the source, its commit and licence, and that it was modified in generation (cobol-to-java --header; java_target_matrix.generate gains a `header`); - writes THIRD_PARTY_NOTICES.md (each directory's source and licence) and a trademark note; LICENSE (plain Apache-2.0) covers only the repository's own files. The equivalence case in this repository gets CardDemo's LICENSE and NOTICE, and its port opens with a notice. tests/equivalence/APACHE-2.0.txt is the plain licence text the examples repository's LICENSE uses. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3624, the last item of epic #3625.
Result
CardDemo CBACT04C (job INTCALC, the interest calculator), run as COBOL under GnuCOBOL and as the generated Java on the same inputs:
Every field matches, decimals exact. That includes S9(09)V99's extremes and the truncation edges: ±999,999,999.99, ±0.01, and a rate's cent boundary.
It found a defect in the original. CBACT04C never adds the last account's interest to its balance.
PERFORM UNTIL END-OF-FILE = 'Y'tests the flag before each pass, so the loop's EOF branch (ELSE PERFORM 1050-UPDATE-ACCOUNT) is unreachable. A first port that followed the evident intent scored 49/50 on ACCTFILE. The port now keeps the original behaviour and documents it at the spot; the one-line fix is a business decision.The harness (
tests/tools/equivalence.py,equivalence_java.py)tests/equivalence/gnucobol.Dockerfile, compiled-std=ibm -fsign=EBCDIC.COB_CURRENT_DATEpins the clock.h2) with the case'sport/overlaid, run by a generated JUnit test:runBatch(dds, parm)runs with the pinned clock;report.jsonandreport.md.case.json: the program, datasets with keys and copybooks, PARM, clock and notes. CardDemo ships every category balance as zero, so this case replaces them with varied ones on the same keys (documented in the case).Generator additions
Record codecs. Every VSAM entity gets
fromRecord(byte[], Charset)/toRecord(Charset), field by field at the COBOL offsets, over a sharedCobolRecordsruntime:This is also how REPRO-unloaded VSAM data migrates into the new database.
Step PARM. job_flow STEP rows record the text
EXEC PARM=passes: newjob_flow_data.parm, rehydrated,EngineJobFlow.parm, andjob_stepsparm.runBatchis nowrunBatch(List<Dd> dds, String parm), and each generated step passes its PARM (CBACT04C needsPARM-DATE).Verification
ir_join_diff --rescanchanges onlyjob_steps(theparmkey). The ledger is clean and the golden masters are unchanged.test_equivalence.pypins the decoder, the diff, the generated loader / driver / JUnit run, the codec kinds and expressions, and PARM parsing. The end-to-end run is opt-in (EQUIVALENCE_E2E=1, which needs Docker and a JDK).Next
Publishing: a script regenerates the
cobol_to_java_examplesrepo from the verified corpora, with this slice's report and a COBOL-vs-Java GitGalaxy scan comparison. That goes out as a PR to that repo.🤖 Generated with Claude Code
https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g