Inspiration

Decades of critical banking, payroll, and ledger logic still run on 1960s–1980s COBOL-85 mainframes. Rewriting these programs in modern languages often introduces subtle floating-point drift on cent boundaries, sign-nibble bugs in COMP-3 packed decimals, or ROUNDED truncation mismatches. COBOLGhost resurrects legacy COBOL-85 batch programs inside a zero-install retro CRT workstation and mathematically proves that the transpiled TypeScript replacement matches the original mainframe execution down to every decimal digit.

What it does

  • Browser-Native COBOL-85 VM: Executes IDENTIFICATION, DATA, and PROCEDURE divisions directly in the browser with support for PIC 9, PIC S9, PIC 9V99, COMP-3 packed decimals, PERFORM ... VARYING, IF/ELSE, COMPUTE, ADD/SUBTRACT/MULTIPLY/DIVIDE, and ROUNDED arithmetic.
  • IBM 3270 Green-Phosphor CRT Telemetry: Live editable source deck, PERFORM call-graph AST spectrogram, CRT console output, and a live hex COMP-3 register inspector (plus optional Web Audio CRT ambience).
  • AST-to-Strict-TypeScript Transpiler: Generates clean, deterministic, fixed-point strict TypeScript directly from the COBOL-85 AST—preserving exact PIC scaling and ROUNDED semantics.
  • Property-Based Equivalence Oracle: Runs 100 randomized fast-check inputs simultaneously through both the COBOL-85 VM and the transpiled TypeScript module, verifying bit-exact output and register equivalence.
  • Local Stdio MCP Server: Ships mcp/cobol-ghost-mcp.mjs exposing 4 tools (cobol_inspect_ast, cobol_run_vm, cobol_transpile_ts, cobol_verify_equivalence) for agentic mainframe archaeology.

How we built it

COBOLGhost is built as a static single-page application using React, TypeScript, and Vite, deployed to GitHub Pages with zero runtime backend dependencies. Under the hood, a custom COBOL-85 lexer, recursive-descent parser, AST evaluator VM, and TypeScript code generator share a unified fixed-point integer-scaling core. We paired this with Vitest and fast-check for property-based verification, and wrapped the engine in a standard stdio Model Context Protocol (MCP) server (mcp/cobol-ghost-mcp.mjs).

How we used Kiro

The entire architecture was spec-driven and automated with Kiro (.kiro/ tracked at repository root):

  • Specs (.kiro/specs/cobol-resurrection/): requirements.md, design.md, and tasks.md define EARS acceptance criteria, formal correctness properties (P1–P3), and an end-to-end implementation checklist.
  • Steering (.kiro/steering/): product.md, tech.md, and structure.md enforce exact decimal scaling, zero-dependency browser VM execution, and deterministic TypeScript codegen.
  • Hooks (.kiro/hooks/): verify-on-save.json and spec-pbt-guard.json automate TypeScript typechecking, Vite bundling, and fast-check property-based test verification.
  • Custom Agent & MCP (.kiro/agents/mainframe-archaeologist.json, .kiro/settings/mcp.json): Configures the Mainframe Archaeologist agent and wires node mcp/cobol-ghost-mcp.mjs over stdio so Kiro workflows can inspect ASTs, execute COBOL programs, transpile to TypeScript, and run the equivalence oracle directly via MCP tools.

Challenges & Accomplishments

The hardest challenge was guaranteeing zero drift between COBOL-85 fixed-point semantics and JavaScript numbers: accurately modeling PIC 9V99 integer scaling, ROUNDED half-up behavior, and odd/even COMP-3 packed-decimal nibble sign encoding (C/D/F) without floating-point errors. Achieving 100-run differential equivalence across randomized inputs for every invariant—inside both Vitest and the interactive browser oracle—was our proudest milestone.

What's next

  • Expanding COBOL-85 dialect coverage with COPY copybook resolution and OCCURS tables.
  • Indexed FD file I/O emulation with virtual VSAM datasets in the browser.
  • Batch JCL runner pipelines for multi-step mainframe job resurrection.

Built With

Share this project:

Updates

Submission history