Inspiration
Every time a financial institution tries to modernize legacy COBOL with raw AI prompts, subtle fixed-point truncation bugs (PIC 9(7)V99 vs IEEE-754 floats), ON SIZE ERROR fallbacks, and unreachable "zombie" paragraphs silently break downstream ledgers. We wanted to resurrect 1985 mainframe engineering—IBM 3270 phosphor green terminals, 80-column Hollerith punch cards, EBCDIC Code Page 037, and COMP-3 packed decimals—and wire it directly into Kiro's Spec-Driven Development workflow so legacy code isn't just "rewritten," it is formally specified in EARS notation and mathematically proven equivalent before a single mainframe job retires.
What it does
- Executes Real COBOL-85 Deterministically: Parses both fixed-80 column card decks (
000100sequence tags + cols 73–80 deck labels) and free-format COBOL-85, executingDATA DIVISIONPICmasks, level-88 condition-names,COMP-3fields,COMPUTE ROUNDED,ON SIZE ERROR,DIVIDE ... REMAINDER,EVALUATE TRUE, andPERFORM VARYING/UNTIL/TIMES/THRUwith exactDecimal(Python) and scaledBigInt(10^12in browser JS) fixed-point math. - Visualizes Mainframe Internals Live: Renders authentic IBM 029 12-row Hollerith punch cards per source line, IBM CP037 EBCDIC hex bytes, and COMP-3 packed-decimal nibbles (
C/D/Fsign nibbles), plus an interactive step-by-step Exhumation Debugger inside a haunted IBM 3270 CRT web workstation (docs/index.html). - Audits Legacy Code Hygiene: Builds the paragraph Control-Flow Graph and Data-Flow matrix to detect unreachable Zombie Paragraphs, unused Ghost WORKING-STORAGE Fields, McCabe cyclomatic complexity, and Kahn's topological migration waves.
- Reverse-Compiles Legacy Code into Kiro Specs: Emits ready-to-use
.kiro/specs/<program>/bundles (requirements.mdin strictWHEN ... THE SYSTEM SHALL ...EARS syntax,design.mdwith Mermaidflowchart TDandPICData Dictionary, andtasks.mdwith topological build waves). - Proves 100% Migration Parity: Transpiles COBOL ASTs to clean modern Python (
decimal.Decimal) and JS, automatically mines numeric thresholds fromIF/EVALUATEpredicates, and runs a Differential Equivalence Oracle across boundary and fuzzed inputs.
How we built it (with Kiro)
- Specs (
.kiro/specs/): Engineered two formal Kiro feature specs (cobol85-resurrection-engineandears-spec-compiler-and-oracle) using EARS requirements (WHEN ... THE SYSTEM SHALL ...), Mermaid architecture diagrams, and Kahn wave-ordered task checklists before writing implementation code. - Steering (
.kiro/steering/): Combined always-on rules (product.md,tech.md,structure.md) with conditionalfileMatchsteering (python-engine.mdforsrc/necrobol/**/*.pyenforcing zero-floatDecimal, andweb-crt-ui.mdfordocs/**/*enforcing P31 phosphor contrast andBigIntfixed-point parity). - Hooks (
.kiro/hooks/): Configured 4v1lifecycle hooks—auto-runningunitteston Python saves, verifying Node.js vs Python cross-runtime parity on engine edits, blocking any accidental.kiroentry in.gitignorevia exit code2onPreToolUse, and auditing submission readiness onStop. - MCP (
.kiro/settings/mcp.json): Built a zero-dependency Stdio JSON-RPC 2.0 MCP server (necrobol.mcp_server) exposing 5 mainframe exhumation tools directly to Kiro.
Challenges we ran into
- Floating-Point Drift Across Browser & Python: JavaScript's
Numbercannot represent COBOL decimal arithmetic reliably (0.1 + 0.2). We engineered a10^12-scaledBigIntengine indocs/engine.jswith10^-8division truncation (ROUND_DOWN) and half-up rounding (ROUNDED) that matches Python'sdecimal.Decimalbit-for-bit. - Period-Terminated vs Block-Structured COBOL: Handling both classic 1980s period-terminated
IF/DISPLAYstatements and modernEND-IF/END-PERFORMdelimiters required careful lookahead soDISPLAY "NET PAY: $" WS-NET-PAY.never misclassifiedWS-NET-PAY.as a new paragraph header. - True COBOL Fallthrough Reachability: Distinguishing sequential top-level fallthrough from
PERFORM-called subroutine returns so unreachable trailing paragraphs (like999-LEGACY-TAPE-DUMPinLEDGER-RECON.cbl) are accurately flagged as Zombies.
Accomplishments that we're proud of
- Zero External Dependencies: Runs purely on Python 3.10+ stdlib and static vanilla ES2022/HTML/CSS (deploys directly to GitHub Pages with zero build step).
- 17/17 Unit + Cross-Runtime Node/Python Parity Tests Passing: Verified bit-exact output, EBCDIC, COMP-3, Hollerith, and CFG equivalence between Python and Browser JS.
- 196/196 Differential Equivalence Vectors Passed (100.0%): Proven across
LOAN-AMORT.cbl(49/49),PAYROLL85.cbl(52/52),LEDGER-RECON.cbl(46/46), andINVENTORY-EOQ.cbl(49/49).
What's next for NecroBOL
- Add
COPYBOOKresolution (COPY ... REPLACING), indexedVSAMfile I/O simulation, and direct AWS Mainframe Modernization Blu Age blueprint export from.kiro/specs/.
Built With
- cobol
- ears-specs
- github
- javascript
- kiro
- mcp
- python