Skip to content

Million-Token Mainframe Migration

Million-Token Mainframe Migration: COBOL to Java, proven byte for byte Banks and insurers still run their core money calculations on decades-old COBOL.

Core trick

Runs original COBOL and generated Java on identical data and diffs every output file byte for byte.

Tags

Description

Million-Token Mainframe Migration: COBOL to Java, proven byte for byte Banks and insurers still run their core money calculations on decades-old COBOL. Migrating it typically takes years and millions of dollars, and the hardest part isn’t translation but trust. Teams can’t prove the new code behaves exactly like the old, so migrations stall. This project uses Gemini 4 Argon to migrate three interdependent mainframe batch jobs from AWS’s open-source CardDemo credit-card system: posting daily transactions, calculating interest, and generating the transaction report. Argon reads the whole codebase, including programs and shared copybooks, in one context and writes the complete Java system in one long-output pass, keeping shared data layouts consistent across every file. A differential test harness then runs the original COBOL and the new Java on identical data and compares every output file byte for byte, along with console output and return codes. Argon matched all 7 outputs on its first pass with zero fixes, in 11 minutes, for about $1. A Gemini 3.8 Flash baseline translating file by file produced 0/7. It didn’t compile and created conflicting versions of the same data structures, even after a fix round. An engineer reviews the diff and test report before anything merges.
thealchemist135/gemini-hack-github★ 00 forksCOBOLCreated Oct 25, 2026 · last push Oct 25, 2026

README excerpt

# Million-Token Mainframe Migration: CardDemo COBOL -> Java with Gemini 4 Argon

Migrates three IBM mainframe batch jobs from AWS CardDemo (post daily transactions ->
calculate interest -> transaction report) from COBOL to Java, and proves equivalence by
comparing every output file byte for byte against the original COBOL run in GnuCOBOL.

## What's here
- `carddemo/app/` - original COBOL programs, copybooks, JCL and sample data (AWS CardDemo)
- `golden/` - reference outputs from running the COBOL in GnuCOBOL 3.1 (clock pinned to 2022-07-18 10:00)
  - POSTTRAN (CBTRN02C): 300 daily transactions -> 257 posted, 43 rejected
  - INTCALC (CBACT04C): 50 interest transactions, account balances updated
  - TRANREPT (CBTRN03C): 532-line transaction report
- `tools/make_golden.py` - compiles and runs the original COBOL in GnuCOBOL to produce `golden/`.
  Only needed to regenerate the reference; testing the Java needs just Python and a JDK.
- `migrate.py` - Argon whole-codebase migration, Flash file-by-file baseline, self-fix loop
- `difftest.py` - differential test harness (needs only Python + a JDK)

## Run it (Windows PowerShell, macOS or Linux)
Prereqs: Python 3.10+, JDK 17+ (`javac -version`), `pip install "google-genai>=2.3.0"`,
and a `.env` file here containing `GEMINI_API_KEY=...`

    python migrate.py whole --out out/argon        # Argon, one long-output pass
    python migrate.py perfile --out out/flash      # baseline (run in a second terminal)
    python difftest.py --impl 

Team