Skip to content

Deterministic COBOL→Java ports: all 23 proven CardDemo programs translate with no model and prove - #4089

Merged
squid-protocol merged 4 commits into
mainfrom
feat/det-port
Oct 1, 2026
Merged

squid-protocol merged 4 commits into
mainfrom
feat/det-port

Conversation

@squid-protocol

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

Copy link
Copy Markdown
Owner

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.

programs statements translated holes proven
batch (runBatch) 7 1,355 1,355 0 7
CALL (handleCall) 1 27 27 0 1
CICS (runTask) 15 3,024 3,024 0 15
all 23 4,406 4,406 0 23

Proofs include every case's scenarios and fault runs (~400 runs in total).

How

  • Storage is bytes (det/layout.py): each record laid out and initialised as GnuCOBOL does — test_det_layout.py: 23/23 byte-identical.
  • Statements call a runtime (det/cobolrt, plain Java 17): MOVE / arithmetic / compare / class tests / STRING / UNSTRING / INSPECT / DISPLAY — test_cobolrt.py: 299 constructs byte-equal to GnuCOBOL.
  • Control flow (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.
  • Boundaries (det/program.py, det/cics.py): files, COMMAREA, screens and CICS commands converted through the generator's own entities, DTOs and CicsTask. 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.
  • Anything untranslated becomes 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.py translates 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.

programs translate statements translated ports compile
first pass (as built for CardDemo) 123 58 7,192 / 7,457 29
after source handling + Db2 includes 123 105 13,973 / 14,981 (93.3%) 81

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

  • Indexed files are ordered by EBCDIC key (the generator's choice); the harness's files are ASCII-ordered. CardDemo's keys sort the same either way.
  • Keyed lookups scan the repository (exact for any key, slow on big files).
  • The output is faithful, not idiomatic: byte-level 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.py and test_det_layout.py need EQUIVALENCE_E2E=1 (Docker).
  • python tests/tools/det_port.py run --all-proven --work DIR reproduces the table above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

squid-protocol and others added 3 commits October 1, 2026 17:51
…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):
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

…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 thread tests/tools/det_survey.py
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
@squid-protocol
squid-protocol merged commit 097c849 into main Oct 1, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the feat/det-port branch October 1, 2026 23:50
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.

2 participants