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

  1. Executes Real COBOL-85 Deterministically: Parses both fixed-80 column card decks (000100 sequence tags + cols 73–80 deck labels) and free-format COBOL-85, executing DATA DIVISION PIC masks, level-88 condition-names, COMP-3 fields, COMPUTE ROUNDED, ON SIZE ERROR, DIVIDE ... REMAINDER, EVALUATE TRUE, and PERFORM VARYING/UNTIL/TIMES/THRU with exact Decimal (Python) and scaled BigInt (10^12 in browser JS) fixed-point math.
  2. 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/F sign nibbles), plus an interactive step-by-step Exhumation Debugger inside a haunted IBM 3270 CRT web workstation (docs/index.html).
  3. 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.
  4. Reverse-Compiles Legacy Code into Kiro Specs: Emits ready-to-use .kiro/specs/<program>/ bundles (requirements.md in strict WHEN ... THE SYSTEM SHALL ... EARS syntax, design.md with Mermaid flowchart TD and PIC Data Dictionary, and tasks.md with topological build waves).
  5. Proves 100% Migration Parity: Transpiles COBOL ASTs to clean modern Python (decimal.Decimal) and JS, automatically mines numeric thresholds from IF/EVALUATE predicates, 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-engine and ears-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 conditional fileMatch steering (python-engine.md for src/necrobol/**/*.py enforcing zero-float Decimal, and web-crt-ui.md for docs/**/* enforcing P31 phosphor contrast and BigInt fixed-point parity).
  • Hooks (.kiro/hooks/): Configured 4 v1 lifecycle hooks—auto-running unittest on Python saves, verifying Node.js vs Python cross-runtime parity on engine edits, blocking any accidental .kiro entry in .gitignore via exit code 2 on PreToolUse, and auditing submission readiness on Stop.
  • 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 Number cannot represent COBOL decimal arithmetic reliably (0.1 + 0.2). We engineered a 10^12-scaled BigInt engine in docs/engine.js with 10^-8 division truncation (ROUND_DOWN) and half-up rounding (ROUNDED) that matches Python's decimal.Decimal bit-for-bit.
  • Period-Terminated vs Block-Structured COBOL: Handling both classic 1980s period-terminated IF/DISPLAY statements and modern END-IF/END-PERFORM delimiters required careful lookahead so DISPLAY "NET PAY: $" WS-NET-PAY. never misclassified WS-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 (like 999-LEGACY-TAPE-DUMP in LEDGER-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), and INVENTORY-EOQ.cbl (49/49).

What's next for NecroBOL

  • Add COPYBOOK resolution (COPY ... REPLACING), indexed VSAM file I/O simulation, and direct AWS Mainframe Modernization Blu Age blueprint export from .kiro/specs/.

Built With

Share this project:

Updates

Submission history