Repository navigation
Deterministic COBOL→Java ports: all 23 proven CardDemo programs translate with no model and prove - #4089
Merged
Conversation
…o GnuCOBOL on all 23 proven programs det/source.py expands COPY (REPLACING) and joins continued literals; det/layout.py parses the DATA DIVISION with tree-sitter's COBOL grammar and lays it out: sizes, offsets, OCCURS, REDEFINES (an 01 REDEFINES another shares its storage), usages, sign clauses, and the initial bytes from VALUE clauses. The test replaces each program's PROCEDURE DIVISION with a dump of every WORKING-STORAGE record and compares GnuCOBOL's bytes with the computed image: 23/23 programs identical. GnuCOBOL rules the oracle showed: a signed DISPLAY item without VALUE (and VALUE ZERO) is plain zero digits, but VALUE 0 is an overpunched positive zero; bytes only an oversized REDEFINES covers stay x'00'; numeric-edited items without VALUE are MOVE ZERO edited (left to the runtime). docs/language_status/det_port_design.md: the design and the runtime contract. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
…L), statement translator, batch/CALL boundary All 8 CardDemo batch and CALL programs translate with no holes and prove (fault runs included): CBACT02C CBACT03C CBCUS01C CBTRN01C CBTRN02C CBACT04C CBTRN03C CSUTLDTC -- 1,382 statements. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
…th no hole and prove A deterministic translator (gitgalaxy/tools/cobol_to_java/det) writes each program's Java onto its generated service -- no model -- and the equivalence harness proves it against GnuCOBOL, scenarios and fault runs included: batch 7 / CALL 1 / CICS 15 programs; 4,406 statements, 4,406 translated, 0 holes, 23 proven. - EXEC CICS onto the generated CicsTask: SEND / RECEIVE MAP through the screen view models, SEND TEXT, RETURN, XCTL, READ (UPDATE) / WRITE / REWRITE / DELETE / STARTBR / READNEXT / READPREV / ENDBR over the entities, HANDLE ABEND / CONDITION, ABEND, ASSIGN, ASKTIME / FORMATTIME, INQUIRE, WRITEQ TD; RESP / NOHANDLE / handler / default-abend precedence; the EIB and DFHAID; COMMAREA codecs from the contract DTOs' property comments. - The boundary comes from generator output only; where a program's own stub lacks a mapping, the estate's (each such inference written into the port's header). - Fixes the proofs found: unsigned numeric literals, abbreviated NOT relations and data-name objects, numeric DISPLAY -> alphanumeric moves (digit bytes as they are, GnuCOBOL-checked), DIVIDE intermediates, intrinsics. - Runtime matrix 299 cases equal to GnuCOBOL; tests/cobol_mainframe/test_det_translate.py runs without Docker. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
| from dataclasses import dataclass, field | ||
| from pathlib import Path | ||
|
|
||
| from gitgalaxy.tools.cobol_to_java.det import expr as E |
|
|
||
|
|
||
| def G_jstr(s: str) -> str: | ||
| from gitgalaxy.tools.cobol_to_java.det.gen import jstr |
| r = self.ref() | ||
| if r.name == "DFHRESP" and len(r.subscripts) == 1 and isinstance(r.subscripts[0], Ref): | ||
| # DFHRESP(condition): the condition's RESP value (IBM CICS TS) | ||
| from gitgalaxy.tools.cobol_to_java.det.cics import DFHRESP |
| from dataclasses import dataclass, field | ||
| from decimal import Decimal | ||
|
|
||
| from gitgalaxy.tools.cobol_to_java.det import expr as E |
| words = s.text.split() | ||
| if self.cics is None or len(words) < 2 or words[1].upper() != "CICS": | ||
| raise Untranslatable("EXEC " + (words[1] if len(words) > 1 else "")) | ||
| from gitgalaxy.tools.cobol_to_java.det.cics import CicsError |
| return it | ||
|
|
||
|
|
||
| def _value(node, src: bytes): |
| from dataclasses import dataclass, field | ||
| from typing import Any | ||
|
|
||
| from gitgalaxy.tools.cobol_to_java.det import expr as E |
| return out | ||
|
|
||
|
|
||
| def _when_object(p: str): |
Contributor
…ICS-only estates; CI audits tests/tools/det_survey.py translates every COBOL program of every corpus onto its generated service and compiles the port (translation, not correctness -- docs/language_status/det_survey.md): 123 programs: 105 translate (35 whole, 70 with holes), 18 refused; 13,973 / 14,981 statements (93.3%); 81 ports compile. First pass, as built for CardDemo: 7,192 / 7,457 statements reached, 65 refused, 29 compile. - Source: a copybook named like the program that COPYs it, PROCESS / CBL option lines, EXEC SQL INCLUDE as COPY (SQLCA shipped in IBM's layout), EXEC SQL DECLARE / obsolete IDENTIFICATION paragraphs / an empty section left out of the record parse, BMS symbolic maps generated where an estate does not check them in. - An estate with no generated batch package: a standalone DISPLAY / abend runtime, no batch members. - COACTUPC translates whole (1,415 statements): TEST-NUMVAL / TEST-NUMVAL-C (41 inputs equal to GnuCOBOL, test_det_funcs.py), VALUE lists with separator commas, SYNCPOINT ROLLBACK, a CALL to any estate service with a CALL entry, compareText. - The 23 proven CardDemo programs re-prove on this code. - mypy clean on the det package; dead-key audit allowlists the dynamically written COBOL phrase / CICS option keys. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
Comment on lines
+126
to
+127
| "Every COBOL program of each corpus translated onto its generated service and compiled against the " | ||
| "built estate. Translation only: a port is proven by its equivalence case (tests/tools/det_port.py).", "", |
|
|
||
| from gitgalaxy.tools.cobol_to_java.det import expr as E | ||
| from gitgalaxy.tools.cobol_to_java.det import layout as L | ||
| from gitgalaxy.tools.cobol_to_java.det import stmt as S |
| from gitgalaxy.tools.cobol_to_java.det import stmt as S | ||
|
|
||
| if TYPE_CHECKING: | ||
| from gitgalaxy.tools.cobol_to_java.det.cics import Cics |
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.
What
A deterministic translator (
gitgalaxy/tools/cobol_to_java/det) that writes a COBOL program's logic as Java onto the service GitGalaxy generates for it — no model involved — proven by the existing equivalence harness against GnuCOBOL.runBatch)handleCall)runTask)Proofs include every case's scenarios and fault runs (~400 runs in total).
How
det/layout.py): each record laid out and initialised as GnuCOBOL does —test_det_layout.py: 23/23 byte-identical.det/cobolrt, plain Java 17): MOVE / arithmetic / compare / class tests / STRING / UNSTRING / INSPECT / DISPLAY —test_cobolrt.py: 299 constructs byte-equal to GnuCOBOL.det/stmt.py,det/gen.py): tree-sitter's flat PROCEDURE DIVISION rebuilt into scopes; paragraphs as numbered methods with a PERFORM-THRU / GO TO dispatcher.det/program.py,det/cics.py): files, COMMAREA, screens and CICS commands converted through the generator's own entities, DTOs andCicsTask. The mapping comes only from generator output, never from a test case; where a program's own stub lacks one, the estate's — written into the port's header as Inferred.throw new Hole("line N: …"); none remain on these 23.Design, results and declared differences:
docs/language_status/det_port_design.md.Beyond the proven 23: every program of the six estates
tests/tools/det_survey.pytranslates every COBOL program of every corpus and compiles the port (translation, not correctness -- nothing outside CardDemo has equivalence cases). Details:docs/language_status/det_survey.md.What's left is named per line in each port: unresolved data references (288), CICS LINK (169) and other CICS commands not modelled yet; Db2 / IMS / pointers stay holes by design. COACTUPC (the program too big for a model) now translates whole -- 1,415 statements.
Declared, not covered by the proofs
Cobol.move(f12_ACCT_ID, …).Tests
tests/cobol_mainframe/test_det_translate.py: 13 parser tests, no Docker or corpus — run in CI.test_cobolrt.pyandtest_det_layout.pyneedEQUIVALENCE_E2E=1(Docker).python tests/tools/det_port.py run --all-proven --work DIRreproduces the table above.🤖 Generated with Claude Code
https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ