Skip to content
Projets

Azure-Samples/Legacy-Modernization-Agents

Voir sur GitHub

À propos

AI-powered COBOL to Java Quarkus modernization agents using Microsoft Agent Framework. Automates legacy mainframe code modernization with intelligent agents for analysis, conversion, and dependency mapping.

IA et apprentissage automatique

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
+2
in 15 days
+3
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Project Starforge

Project Starforge - COBOL to Java/C# Migration

Project Starforge is the new name for Legacy Modernization Agents; the repository name and URLs are unchanged.

This open source migration framework was developed to demonstrate AI Agents capabilities for converting legacy code like COBOL to Java or C# .NET. Each Agent has a persona that can be edited depending on the desired outcome. The migration uses Microsoft Agent Framework with a multi-provider architecture supporting Azure OpenAI (Responses API + Chat Completions), GitHub Copilot (PAT or CLI-based SDK), and direct OpenAI to analyze COBOL code and its dependencies, then convert to either Java (Quarkus or Spring Boot) or C# .NET (user's choice).

Portal demo

The portal (./doctor.sh portal, http://localhost:5028) shows your estate, what the agents did, and what the parser saw. The recordings use the public Bank-of-Z sample; all demos with full descriptions are in Portal demo.

Estate Mission Control showing the Bank-of-Z estate

Estate Mission Control: every program, CICS transaction, API, DB2 table and data store in the estate, built deterministically from source with no model calls.

AST Explorer showing the Structure view and the Raw AST view

AST Explorer: the parsed structure of each COBOL program beside its source.

[!NOTE]

  • Structure view: expand a section and click a paragraph. The source jumps to it, and the Inspector shows its statement mix (MOVE, IF, PERFORM and so on).
  • Raw AST view: the parser's own nodes. Hover a node for its type, name and parser ID. Click a statement to see the exact COBOL the parser captured, or a paragraph to open its source range.
  • Why it matters: check for parse gaps before you convert. A statement missing from the AST was not parsed, so structure-based evidence (call graphs, readiness checks, structural context) cannot account for it. The conversion prompt still carries the source text, so a gap is a verification risk rather than proof the model never saw the line.

See AST Explorer.

Teach the parser: ./doctor.sh rekt-full, dialect teaching, AI Loop, Estate Mission Control and AST Explorer

Teach the parser (./doctor.sh rekt-full → teach-parser → ./doctor.sh portal): when an estate contains site-specific COBOL syntax, Starforge masks site names (W1, W2, …), asks your configured AI endpoint, verifies the candidate rule across the whole estate, re-parses to Full, loads Neo4j, and records the full audit trail in the AI Loop, Estate Mission Control and AST Explorer.

Converted Bank-of-Z running in a 3270-style terminal, then COBOL and Java side by side

The Bank-of-Z COBOL/CICS programs converted to Java Spring Boot and running, mapped 1:1 so each COBOL step can be traced to its Java equivalent.


Table of Contents


Quick Start

Prerequisites

Requirement Version Notes
.NET SDK 10.0+ Download
Docker Desktop Latest Must be running for Neo4j
AI Endpoint — Azure endpoint + az login, or GitHub Copilot copilot login, or API Key

On Windows, doctor.sh runs in Git Bash or WSL2; see Windows.

Step by step

flowchart TD
    A["1. ./doctor.sh setup<br/>Azure OpenAI or GitHub Copilot"]:::core --> B["2. Copy COBOL, copybooks,<br/>BMS, JCL into source/"]:::core
    B --> C["3. ./doctor.sh rekt-full<br/>parse + load graph · no model"]:::core
    C -->|"all programs read"| D["4. ./doctor.sh portal<br/>explore estate & readiness"]:::core
    C -.->|"if site syntax unread"| T["3b. Optional: ./doctor.sh teach-parser<br/>teach site COBOL words + re-parse"]:::opt
    T -.-> D
    D --> E["5. Pick programs<br/>Estate Mission Control / Convert Programs"]:::core
    E --> F["7. Highly recommended: tune prompts<br/>Prompt Studio in portal or Agents/Prompts/*.md"]:::rec
    E -.->|"standalone report"| R["6. Optional: ./doctor.sh reverse-eng<br/>business logic report"]:::opt
    R -.-> F
    F --> G["8. ./doctor.sh convert-only or ./doctor.sh run<br/>recommended: run with Copilot CLI"]:::core
    G --> H(["output/csharp or output/java<br/>review in the AI Loop"]):::done

    classDef core fill:#dbeafe,stroke:#1d4ed8,stroke-width:2px,color:#0f172a
    classDef rec fill:#dcfce7,stroke:#15803d,stroke-width:2px,color:#0f172a
    classDef opt fill:#fef3c7,stroke:#d97706,stroke-width:2px,stroke-dasharray: 5 3,color:#0f172a
    classDef done fill:#f1f5f9,stroke:#475569,stroke-width:2px,color:#0f172a

Flow color key: 🟦 Blue (solid) — Core required flow · 🟩 Green (solid) — Highly recommended before converting · 🟨 Amber (dashed) — Optional (run when needed).

Run every command from the repository root. Always use ./doctor.sh, not dotnet run: it checks prerequisites and starts the containers each step needs.

1. Configure the AI endpoint

git clone https://github.com/Azure-Samples/Legacy-Modernization-Agents.git
cd Legacy-Modernization-Agents
./doctor.sh setup

[!NOTE] GitHub Copilot: copilot login is part of setup. Install the Copilot CLI first (npm install -g @github/copilot). When setup asks how to authenticate, choose 1) Copilot CLI sign-in; it runs copilot login and you finish the sign-in in the browser. Setup then lists only the models your Copilot plan allows. If the sign-in fails or you cancel it, run copilot login yourself and run ./doctor.sh setup again. See Copilot sign-in.

The wizard asks for the provider, credentials, models and the Neo4j password, and writes them to Config/ai-config.local.env (git-ignored):

Provider Choose in setup Then sign in
Azure OpenAI / Azure AI Foundry Endpoint and deployment names; Entra ID (recommended) or an API key az login
GitHub Copilot (GHCP) GitHub Copilot SDK; the wizard lists the models your licence can use copilot login, or a fine-grained token with Copilot Requests in COPILOT_GITHUB_TOKEN

[!IMPORTANT] Sign in before you run anything that calls a model. The framework takes its token from your local sign-in; it does not prompt for one.

  • Azure (Entra ID): add --tenant <id> to az login if the resource is in another tenant. Your account needs the Cognitive Services OpenAI User role on the resource. See az login authentication.
  • GitHub Copilot: use the Copilot CLI's copilot login, not gh. Classic ghp_ tokens do not work, and the account needs a Copilot licence. ./doctor.sh setup records the choice as COPILOT_AUTH. See Copilot sign-in.

Without a valid sign-in (or an API key in Config/ai-config.local.env), conversion and reverse engineering fail on the first model call. rekt-full, estate and jcl call no model and need no sign-in.

2. Copy your COBOL into source/

[!IMPORTANT] The clone does not contain your estate. Copy your files into source/ before scanning, and again whenever they change: COBOL programs (.cbl), copybooks (.cpy, and Db2 DCLGEN members as .dcl), Db2 CREATE TABLE DDL (.sql, .ddl, or inside JCL), BMS maps (.bms), CICS definitions and JCL jobs (.jcl) with their procedures and INCLUDE members (.proc, .prc, .inc). Subfolders are fine; each top-level folder of source/ is treated as its own estate. Set JCL_SOURCE_FOLDER for an external JCL library.

cp -r /path/to/your/cobol/* source/

No estate at hand? Start with the bundled demo: cp -R samples/quickstart source/quickstart. It is a small MIT-licensed batch estate that Starforge reads fully. The demo guide also explains how to copy IBM Bank-of-Z and AWS CardDemo from their own repositories.

3. Scan the source

./doctor.sh rekt-full                 # parse every program, then load the graph into Neo4j
./doctor.sh rekt-full --parallel 4    # parse 4 programs at once (large estates)

rekt-full calls no model and needs no sign-in. It parses COBOL with Starforge, the .NET parser in Parser/ (no Docker for the parse), extracts JCL facts, records each program's parse fidelity, lists copybooks that are referenced but missing (output/rekt/missing-copybooks.txt), and loads everything into Neo4j. Each program prints one progress line with stage times and an estimate of the time left.

No settings are needed to understand an estate. Each estate's CICS definitions (*.csd, or YAML with resourceDefinitions:), Db2 table declarations and IDCAMS VSAM definitions are found automatically, and the documented IBM services (Language Environment, IMS, Db2) and screen-key/BMS meanings are built in. The parse prints one Found: line per estate showing what it used. The REKT_* settings only override this; see Configuration and Explicit platform replacement contracts.

Option Effect
--parallel N (or REKT_PARSE_JOBS=N) Parse 1–16 programs at once. 2–4 is a good choice. Results are identical to a sequential scan
./doctor.sh rekt-parse / rekt-ingest Run only the parse half or only the Neo4j load
./doctor.sh rekt-status Neo4j, graph and parse output status
REKT_VERBOSE=true Also stream the parser's own output (normally kept in output/rekt/**/*.parse.log)
./doctor.sh teach-parser Teach Starforge your site's own COBOL words with your own AI endpoint; asks once per estate before sending, then saves only rules that pass their check (--review to decide each step). See Teach the parser
REKT_NO_BMS_MAPS=true Do not generate symbolic map copybooks from BMS mapsets

Unchanged programs are skipped as (cached), so a rerun after a small change takes minutes. Add any missing copybooks to source/ and run rekt-full again before converting. See Parse first: rekt-full.

3b. Optional: teach site-specific COBOL syntax (./doctor.sh teach-parser)

./doctor.sh teach-parser report       # preview unread site-specific words (sends nothing)
./doctor.sh teach-parser              # teach rules automatically after one-time estate consent
./doctor.sh teach-parser --review     # review and approve each proposed rule step by step

Skip this step if rekt-full already read your programs as Full (the bundled quickstart, Bank-of-Z and CardDemo samples need no taught rules). If your estate uses site-specific macros, library includes or custom precompiler verbs that leave programs Partial, rekt-full offers to run teach-parser before loading Neo4j—or you can run ./doctor.sh teach-parser at any time. Starforge masks site identifiers (W1, W2, …), asks your configured AI endpoint, verifies each candidate rule across the entire estate, saves passing rules locally in Config/starforge-dialect.local.json, and re-parses. See the demo recording above and Teach the parser.

4. Explore the code in the portal

./doctor.sh portal                    # http://localhost:5028

🛰 Estate Mission Control maps every program, transaction, table and data store; AST Explorer shows what the parser saw for each program; Convert Programs lists programs by parse fidelity with their call closure. See Portal.

5. Pick the programs to convert

  • Estate Mission Control → ✂️ Carve-out plan: click a cluster and press 📦 Stage slice. The panel lists the programs, what they call and what is missing from source/, and gives the exact command. 🔁 Send to AI loop starts the conversion from the portal instead.
  • Convert Programs: tick programs and copy the generated convert-only command.
  • Terminal: ./doctor.sh estate prints the wave plan; ./doctor.sh estate C01 prints one cluster and its command.

6. Optional: reverse engineer the business logic

./doctor.sh reverse-eng                              # every program in source/
./doctor.sh reverse-eng --program ORDMAIN.cbl,ORDDATE.cbl   # only the selected programs

This optional standalone step explains the estate before you convert (./doctor.sh run runs it automatically as part of a full migration). CobolAnalyzerAgent and BusinessLogicExtractorAgent read each program and write output/reverse-engineering-details.md: the business purpose, use cases, business rules and a glossary, with technical details per program. Nothing is converted. The results are also saved to Data/migration.db, so you can:

  • read them in the portal (each run card has 🔬 RE Results) and ask questions with Ask the Report;
  • reuse them in a later conversion: ./doctor.sh convert-only asks whether to load the saved results from the last reverse-engineering run over the same source folder (answer Y).

Before any model call, the run reads the Starforge parser evidence in output/rekt/. Programs whose evidence is missing or older than the source are parsed first, the same way ./doctor.sh rekt-parse does (set RE_PARSER_STEP=off to skip this). The report then gets a Parser Facts (Starforge) section built without a model: program inventory with read status, the CALL / LINK / XCTL map, data access (SQL tables, files, copybooks), CICS transactions and BMS screens, JCL jobs, platform contracts and gaps. Each fact is marked parser or AI-inferred; parser facts win over the AI dependency map, and BusinessLogicExtractorAgent gets each program's parser facts in its prompt. If no evidence can be read or made, the run continues with AI-only analysis and the report says so.

Reusing them is off by default, because converters given only a summary tend to skip paragraphs; the COBOL source and the REKT facts always take precedence over the report. See Reverse engineering reports and Business logic persistence.

7. Tune the agent prompts (highly recommended)

[!IMPORTANT] Editing the prompts before converting is highly recommended. Default prompts produce clean baseline Java or C#, but tuning them to your target architecture—package/namespace structure, Domain-Driven Design conventions, naming rules, logging, persistence and error handling—substantially improves first-pass output and reduces manual rework.

Each agent's instructions live in Agents/Prompts/*.md. You can customize them in two ways:

  • Prompt Studio in the portal (./doctor.sh portal): open Prompt Studio to inspect, edit, AI-enhance and quality-score each agent prompt interactively before launching a run.
  • Direct Markdown edits: edit Agents/Prompts/*.md in your editor or with GitHub Copilot.
Agent Prompt file
COBOL analysis CobolAnalyzer.md
Business logic (reverse engineering) BusinessLogicExtractor.md
Java / C# conversion JavaConverter.md / CSharpConverter.md
Large programs (chunked) ChunkAwareJavaConverter.md / ChunkAwareCSharpConverter.md
Dependency mapping DependencyMapper.md

Keep the ## SECTION: headings and placeholders such as {{CodebaseProfile}}; they are filled in at run time. See Customizing agent behavior.

8. Convert

[!TIP] Recommended: run ./doctor.sh convert-only or ./doctor.sh run through GitHub Copilot CLI (copilot). Launching conversion inside an interactive Copilot CLI session gives you live supervision and control—if a preflight check blocks a program, a provider rate-limits or times out, or a compile/parity gate flags a gap, Copilot can inspect assisted-conversion-plan.md, compile-status.json, conversion-parity.json and Logs/, explain what happened, and help adjust prompts or rerun targeted slices without losing context.

# The whole estate in source/
./doctor.sh run --language CSharp                          # reverse engineering + conversion + portal
./doctor.sh convert-only --language Java                   # conversion only

# Selected programs
./doctor.sh convert-only --language Java --program ORDMAIN.cbl --dry-run    # preview the selection, no model call
./doctor.sh convert-only --language Java --program ORDMAIN.cbl,ORDDATE.cbl
./doctor.sh convert-only --language CSharp --program orders/cbl/ORDMAIN.cbl --include-callees --clean-output

# A JCL job and every program it runs
./doctor.sh run --job NITEJ001 --language CSharp
Option Effect
--language CSharp / Java Target language; --java-framework Spring or Quarkus for Java
--program A.cbl,B.cbl Convert only these programs (repeat or comma-separate; use the path under source/ when two programs share a name)
--include-callees Also convert every program the selection calls, directly or indirectly. The call closure comes from the REKT scan, so it follows every CALL branch through the estate; the portal must be running
--job NAME Convert the programs a JCL job runs and generate the job; their callees are added when the portal is running
--dry-run Show what would be converted without calling a model
--clean-output Write into an empty output folder

Copybooks are always carried in by the programs that COPY them. Output goes to output/<language>/<run>/ with compile-status.json, conversion-parity.json and a migration report; the 🔁 AI Loop tab shows each model call, retry and quality gate. See Working with generated output and the doctor.sh command reference.

Which programs are sent to the AI. Before any model call, the conversion gate reads the parser evidence and gives each selected program one label. This default mode is called assisted:

Label Meaning What happens
Verified The parser proved every dependency: copybooks, callees, files, Db2 tables, CICS and MQ. Converts as usual.
Converted with assumptions Everything can be read, but some behaviour is not known. Examples: a valid CICS command without a contract yet, a file or transaction missing from the CSD, a dynamic CALL, a Db2 table with no DDL, or a callee that is not converted. Converts. Each unknown operation becomes a call to a generated boundary interface, and the code marks it with // ASSUMPTION:. The AI must not invent that behaviour. The run is never reported as Verified.
Blocked The program cannot be converted safely: unreadable code, a missing copybook, an EXEC CICS command IBM does not define, or evidence that does not match the source. Not sent to the AI. The plan says what is wrong, where, why, and how to fix it. A blocked callee does not block its callers.
Skipped: low confidence More than 12 assumptions, or more than half of its procedure lines touch unknown behaviour. Not sent. Listed for a person to check.

./doctor.sh and the CLI print the counts and the top block reasons; assisted-conversion-plan.md and the migration report list every assumption and block. A later run converts only programs that are new or whose label, assumptions, source or evidence changed; unchanged programs are skipped and their earlier output is copied into the new run (--reconvert-all converts everything again). --dry-run shows the labels, counts and top reasons without a model call. --dependency-mode strict (refuse the run if any program is not Verified), draft and partial remain available. See Dependency eligibility.

Getting started covers Windows, Copilot sign-in details, manual setup without the wizard, the folder layout and what a run generates.


doctor.sh commands

Which command to run first (blue = core, green = highly recommended, amber dashed = optional):

flowchart TD
    S["./doctor.sh setup<br/>AI provider and passwords"]:::core --> SRC["Copy COBOL, copybooks, JCL<br/>into source/"]:::core
    SRC --> REKT["./doctor.sh rekt-full<br/>parse and load the graph · no model"]:::core
    REKT --> P["./doctor.sh portal<br/>explore, pick programs"]:::core
    REKT -.->|"unread site words"| TP["Optional: ./doctor.sh teach-parser<br/>teach site COBOL words + re-parse"]:::opt
    TP -.-> P
    P --> PS["Highly recommended: Prompt Studio<br/>or edit Agents/Prompts/*.md"]:::rec
    P -.->|"standalone report"| RE["Optional: ./doctor.sh reverse-eng<br/>business logic report"]:::opt
    RE -.-> PS
    PS --> C["./doctor.sh convert-only<br/>tip: run with Copilot CLI"]:::core
    PS -->|"all in one"| RUN["./doctor.sh run<br/>reverse-eng + convert + portal<br/>tip: run with Copilot CLI"]:::core
    REKT -.->|"no model"| EST["Optional: ./doctor.sh estate / jcl"]:::opt

    classDef core fill:#dbeafe,stroke:#1d4ed8,stroke-width:2px,color:#0f172a
    classDef rec fill:#dcfce7,stroke:#15803d,stroke-width:2px,color:#0f172a
    classDef opt fill:#fef3c7,stroke:#d97706,stroke-width:2px,stroke-dasharray: 5 3,color:#0f172a
Command What it does Calls a model?
./doctor.sh Health check: verifies prerequisites and configuration No
./doctor.sh setup Interactive setup wizard: AI provider, credentials, models and local services No (only lists models)
./doctor.sh rekt-full Parses COBOL with Starforge, extracts JCL facts and loads both into Neo4j. Run before converting No
./doctor.sh teach-parser (Optional) Teaches Starforge site-specific COBOL words/macros using masked excerpts and estate-wide verification (report, --review, list, remove, share) Only teach-parser / run
./doctor.sh portal Launches the web portal only (http://localhost:5028), including Estate Mission Control and Prompt Studio Only for chat / Prompt Studio
./doctor.sh estate [C01] Slices and migration waves from the source alone; with a cluster ID, its convert-only command No
./doctor.sh jcl Jobs from the JCL alone: what each job still needs No
./doctor.sh reverse-eng (Optional) Reverse engineering: business purpose, use cases, rules and glossary per program in output/reverse-engineering-details.md, saved to the database for the portal and for reuse in conversion; launches the portal. Accepts --program Yes
./doctor.sh convert-only Conversion only (--program, --job, --include-callees, --dry-run, --java-framework Spring). Recommended to run via Copilot CLI Yes
./doctor.sh run Full migration: reverse engineering → convert → launch portal. Recommended to run via Copilot CLI Yes

See doctor.sh command reference for every option: interactive prompts, speed profiles, parallel parsing, several estates in one source/, JCL, partial conversion and --reuse-re.


How it fits together

What runs where

flowchart LR
    subgraph HOST["Your machine"]
        direction TB
        DOCTOR["doctor.sh"]
        CLI["Migration CLI (.NET)<br/>agents · estate-graph · graph-ingest<br/>jcl-facts · jcl-jobs<br/>compile gate: dotnet build"]
        HELPERS["Scan helpers (same .NET CLI)<br/>rekt-preprocess · rekt-evidence<br/>rekt-diagnostics · doctor-report<br/>ai-loop-check · rekt-activity"]
        GUARD["Helper guard<br/>tools/lib/lma-cli.sh"]
        WEB["Portal · McpChatWeb<br/>localhost:5028<br/>+ MCP server child process"]
        PRE["Preprocess + Starforge parse<br/>(bash, .NET)"]
        FILES[("source/ · output/<br/>Data/migration.db")]
        LOGS[("Logs/doctor-helpers.log<br/>scan helper-crashes.log")]
        DOCTOR --> PRE
        DOCTOR --> CLI
        DOCTOR --> WEB
        DOCTOR --> GUARD
        PRE --> GUARD
        GUARD --> HELPERS
        GUARD -.->|crash| LOGS
    end

    subgraph DOCKER["Docker"]
        direction TB
        NEO[("cobol-migration-neo4j<br/>REKT + dependency graph · :7687")]
    end

    subgraph CLOUD["Model provider"]
        direction TB
        AOAI["Azure OpenAI /<br/>AI Foundry"]
        GHCP["GitHub Copilot SDK"]
    end

    CLI <--> FILES
    CLI -->|parse graph, REKT facts, dependencies| NEO
    WEB <--> FILES
    WEB --> NEO
    CLI ==>|prompts| CLOUD
    WEB ==>|chat| CLOUD
  • Everything but the model runs locally. Source code leaves the machine only inside the prompts sent to the provider you configured.
  • One Neo4j instance (:7687) holds both the REKT graph (parse trees and control flow) and the migration graph (dependencies found during a run). Every node is keyed by its run, so runs and scans sit side by side without overwriting each other. The port and container name can be changed in Config/ai-config.local.env.
  • The portal runs on the host (./doctor.sh portal). docker-compose.yml also has a portal service if you want it in a container. See Docker containers.
  • Estate Mission Control and jcl need neither a model nor Docker.
  • No Python. The prerequisites are the .NET SDK, Docker and Bash. Every helper doctor.sh and tools/*.sh call is a command of the same .NET CLI.

Where data and graphs live

Store Location What it holds Used by
Estate Dependency Graph In memory (EstateGraphService); CLI export at output/estate/estate-graph.json Between-file architecture built deterministically from source/ + output/rekt/: programs, copybooks, CICS transactions, BMS maps, Db2 tables, VSAM datasets, JCL jobs, hubs, Louvain clusters and carve-out waves Estate Mission Control, ./doctor.sh estate, Portal Chat, MCP (get_estate_graph)
Estate Readiness Snapshot output/rekt/estate-readiness.json (@repo/ portable stamps) Stamp-validated Assisted and Strict readiness (Verified, Converted with assumptions, Blocked, Skipped: low confidence) written by rekt-parse / rekt-full; falls back to full SHA-256 verification if any source, copybook, contract, rule or evidence file changes Estate Mission Control, Portal Chat, MCP (get_estate_readiness)
Neo4j Graph Docker volume graph_data (bolt://localhost:7687) Inside-file statement and control-flow graph (ASTNode parse trees, FOLLOWED_BY and JUMPS_TO CFG edges, DataStructure fields, JclNode job/step/DD nodes) plus per-run migration dependency graphs (CobolFile, DEPENDS_ON) AST Explorer, Dependency Graph tab, conversion REKT context, Portal Chat, MCP (get_ast_cfg_graph)
SQLite Run Store Data/migration.db (SqliteMigrationRepository) AI reverse-engineering and conversion run metadata (runs, metrics, cobol_files, analyses, dependencies, copybook_usage, business_logic, spec_* tables) and smart-chunking --resume state (chunk_metadata, signatures, type_mappings, forward_references) Run selector, RE Results, --reuse-re, --resume, Portal Chat, MCP

Agent flowchart

Seven agents call the model; everything between them is deterministic code. A conversion moves through the chart top to bottom:

flowchart TD
  CLI[["doctor.sh run / convert-only / reverse-eng<br/>or Portal: Send to AI loop"]]
  FACTS["REKT program facts, copybooks,<br/>call contracts (no model)"]

  subgraph RE_PHASE["Reverse engineering (optional)"]
      ANALYZER["CobolAnalyzerAgent<br/>structure and logic"]
      BIZ["BusinessLogicExtractorAgent<br/>use cases, rules, glossary"]
  end

  subgraph DEP_PHASE["Dependencies"]
      MAPPER["DependencyMapperAgent<br/>CALL / COPY / file / SQL"]
  end

  subgraph CONVERT_PHASE["Conversion"]
      CONVERTER["JavaConverterAgent / CSharpConverterAgent<br/>chunk-aware for large programs"]
      OGUARD["Output guard (no model)"]
      CGATE{"Compile gate<br/>dotnet build / mvn compile"}
      CREPAIR["Compile repair<br/>CompileRepairAgent (C#),<br/>ParityRepairAgent (Java)"]
      PSCORE{"Parity score (no model)"}
      PREPAIR["ParityRepairAgent"]
  end

  SQLITE[("SQLite<br/>Data/migration.db")]
  NEO4J[("Neo4j")]
  OUT["output/{language}/{run}/"]

  CLI --> FACTS --> ANALYZER --> BIZ
  ANALYZER --> SQLITE
  BIZ --> SQLITE
  FACTS --> MAPPER --> NEO4J
  SQLITE --> CONVERTER
  NEO4J --> CONVERTER
  CONVERTER --> OGUARD --> CGATE
  CGATE -->|errors| CREPAIR --> CGATE
  CGATE -->|builds| PSCORE
  PSCORE -->|gaps| PREPAIR --> PSCORE
  PSCORE --> OUT
  1. Facts first. The selected programs' REKT parse results, copybooks and call signatures are collected without a model. They become the ground truth every agent receives.
  2. Reverse engineering (run and reverse-eng): CobolAnalyzerAgent describes each program's structure and logic, and BusinessLogicExtractorAgent turns that into use cases, business rules and a glossary. Both are stored in SQLite; --reuse-re reuses them in later runs.
  3. Dependencies: DependencyMapperAgent records CALL, COPY, file and SQL relationships in Neo4j.
  4. Conversion: the Java or C# converter agent writes the target code, splitting large programs into chunks. The output guard rejects empty, truncated or placeholder answers before anything is written.
  5. Compile gate: the output is built (dotnet build or mvn compile). Compiler errors go to a repair agent file by file, for at most CompileGate.MaxRepairRounds rounds; a round that makes things worse is undone, and a file whose repair was rejected or undone is tried again in the next round, told why.
  6. Parity: a deterministic check compares procedures, fields, calls and SQL in the output with the COBOL. ParityRepairAgent fills the gaps it finds, and a fix is kept only if the re-measured score improves.
  7. Report: results land in output/<language>/<run>/ (compile-status.json, conversion-parity.json, migration report), and the 🔁 AI Loop tab shows every call, retry and gate, with a progress bar for the step that is running (for example compile repair round 2 of 5, or parity program 12 of 55).

See Architecture for agent inputs and outputs, storage and data flow.

Teach the parser flowchart

Starforge does not guess what a site's own COBOL words mean (for example a custom SITELOG verb or site EXEC block). Programs that use one stay Partial. Teach the parser asks your own AI endpoint what such a word is, then Starforge writes the rule itself, checks it against the whole estate and keeps it only if it passes (watch the recording). The AI never edits the parser or your code, and rules stay on your machine.

flowchart TD
  subgraph FIND["1 · Find (no model)"]
      PARSE[["./doctor.sh rekt-parse / rekt-full<br/>Starforge parse"]]
      PARTIAL{"Places Starforge<br/>could not read?"}
      DONE(["All programs Full"])
      REPORT["Group places by problem and word<br/>teach-parser report · sends nothing"]
      MODE{"STARFORGE_TEACH"}
      OFF(["off: list places and the command"])
  end

  subgraph ASK["2 · Ask your AI"]
      CONSENT{"Agreed for this estate<br/>and this endpoint?<br/>(asked once)"}
      STOP(["No: nothing is sent"])
      REDACT["Build the excerpt<br/>site names → W1, W2 …<br/>comments and literal text removed"]
      ENDPOINT["ParserTeachAgent → your AI endpoint<br/>set by ./doctor.sh setup<br/><b>only step that leaves your machine</b>"]
      CAT{"AI's category"}
  end

  subgraph KEEP["3 · Check and keep (no model)"]
      FIX(["source-error / missing-copybook<br/>no rule: fix the source or add the copybook"])
      GAP["parser-gap<br/>no rule: local note for the Starforge team"]
      SHARE(["share id: you choose to post a<br/>checked, anonymised GitHub issue"])
      RULE["Starforge builds the rule itself<br/>copyAlias · statement · notProgram"]
      CHECK{"Parse the whole estate with the rule:<br/>fixes every place in the group<br/>and changes nothing else?"}
      DROP(["Rule dropped"])
      SAVE[("Config/starforge-dialect.local.json<br/>git-ignored · SHA-256 in parse output")]
      REPARSE(["Parse again: those programs<br/>move from Partial to Full"])
  end

  subgraph SEE["Evidence in the portal"]
      JOURNAL[("output/teach-parser/run/teach.json")]
      USAGE[("output/.metrics/usage/teach.jsonl")]
      LOOP["🔁 AI Loop · Teach parser session<br/>excerpt, answer, check, decision"]
      TOKENS["Token usage · Teach parser<br/>tokens, model, AI service"]
  end

  PARSE --> PARTIAL
  PARTIAL -->|no| DONE
  PARTIAL -->|yes| REPORT --> MODE
  MODE -->|off| OFF
  MODE -->|"auto (default) / review"| CONSENT
  CONSENT -->|no| STOP
  CONSENT -->|"yes (review: per group)"| REDACT --> ENDPOINT --> CAT
  CAT --> FIX
  CAT --> GAP --> SHARE
  CAT -->|"dialect-rule / not-cobol"| RULE --> CHECK
  CHECK -->|no| DROP
  CHECK -->|"yes (review: you confirm)"| SAVE --> REPARSE

  CHECK -.-> JOURNAL
  ENDPOINT -.-> USAGE
  JOURNAL -.-> LOOP
  USAGE -.-> TOKENS

For architects

Question Answer
What leaves the machine? One excerpt per group, only after you agree for that estate and endpoint. Site names are replaced by W1, W2, …; comments and literal contents are removed. It is still your code's structure, so your endpoint's own data terms apply.
Which AI is asked? The endpoint and model set by ./doctor.sh setup (Azure OpenAI, OpenAI or GitHub Copilot) and its chat model. A different endpoint asks for agreement again.
What can the AI change? Nothing directly. It only picks a category, the rule kind and where a statement ends. Starforge builds the rule from what it found itself and keeps it only if the estate-wide check passes.
What is kept? Rules in Config/starforge-dialect.local.json, agreement in Config/starforge-teach-consent.local.json (both git-ignored). Every parse records the rules' SHA-256, so results show which rules they were made with.
What is shared? Nothing on its own. teach-parser share <id> writes a note checked against your estate's names; posting it is your choice.
What does it cost? One call per group of places with the same problem and word, with a seven-line excerpt. Text answered before is not sent again, and a run stops after two failed calls in a row. There is no per-run call limit; teach-parser report shows the groups first.
How is it audited? Each run writes output/teach-parser/<run>/teach.json (what was sent, what the AI said, the check, the decision), shown in the 🔁 AI Loop as Teach parser. Each model call is logged with tokens, model and AI service in output/.metrics/usage/teach.jsonl, shown in Token usage as Teach parser.

For developers

Piece Where
Command (report, run, list, remove, share, forget) Cli/TeachParserCommand.cs, Cli/TeachParser.cs
Model call (AgentBase: retries, AI Loop events) Agents/ParserTeachAgent.cs
Agreement, run record, notes, reused answers Cli/TeachConsent.cs, Cli/TeachJournal.cs, Cli/TeachNotes.cs, Cli/TeachAnswers.cs
Rules read by every parse Parser/Starforge.Cobol/Dialect/DialectRules.cs (STARFORGE_RULES picks another file)
After-parse trigger (STARFORGE_TEACH) doctor.sh
Portal views McpChatWeb/Services/TeachRunActivity.cs (AI Loop), McpChatWeb/Services/TokenUsageReader.cs (Token usage)

Commands, what is sent and returned, the check, cost, undo and troubleshooting: Teach the parser.

Docker containers

Docker is required only for Neo4j (cobol-migration-neo4j), which stores the Starforge AST/CFG/JCL graph and per-run dependency graphs. Starforge (Parser/), ./doctor.sh, the migration agents and ./doctor.sh portal all run natively on your host machine by default—there is no parser, Java or Python container.

docker-compose.yml defines two services (plus .devcontainer/ for optional VS Code Dev Container development):

Container / environment Role Required? Ports (host → container) Volumes / mounts How it is started
cobol-migration-neo4j (neo4j:5.15.0 + APOC + Graph Data Science) Graph database. Stores both the Starforge AST/CFG/data/JCL graph written by ./doctor.sh rekt-full (graph-ingest) and the per-run migration dependency graph written during conversion, isolated by run-scoped UIDs. Read by the AST Explorer, Dependency Graph tab, Portal Chat, MCP (get_ast_cfg_graph) and conversion REKT context. Yes for rekt-full, AST Explorer and Neo4j graph views (Estate Mission Control, rekt-parse, estate and jcl work without it) 127.0.0.1:7474 → 7474 (HTTP Browser), 127.0.0.1:7687 → 7687 (Bolt) Named volumes graph_data → /data, graph_logs → /logs, graph_import → /var/lib/neo4j/import; tmpfs at /var/lib/neo4j/run Automatically by ./doctor.sh rekt-full / rekt-ingest, or manually via docker compose up -d neo4j. ./doctor.sh setup pre-pulls the image.
cobol-migration-portal (built from root Dockerfile: aspnet:10.0 + /app/web + /app/cli) Optional containerized web portal + MCP host. Serves McpChatWeb (Estate Mission Control, AST Explorer, AI Loop, Token usage, Prompt Studio, Chat with your service, Ask the Report) and the embedded MCP server without installing the .NET runtime on a shared VM or demo host, reaching Neo4j at bolt://neo4j:7687. Optional (./doctor.sh portal runs the exact same portal natively on the host by default) 5028 → 5028 Bind-mounts Data/, Logs/, Config/, source/, output/, Agents/Prompts/ and contracts/ under /app (REPO_ROOT=/app); ships tools/system-copybooks/ inside the image docker compose up -d portal (after ./doctor.sh setup creates Data/, Logs/ and Config/).
.devcontainer/ (separate from docker-compose.yml) Optional VS Code Dev Container. Full workstation container with .NET 10 SDK, Java + Maven, Node.js, Azure CLI, GitHub CLI and Docker-in-Docker. Optional Forwarded by VS Code Mounts the repository workspace VS Code Reopen in Container (see .devcontainer/README.md).
  • Host vs portal container: ./doctor.sh portal on the host is the default workflow because host runs have direct access to your .NET 10 SDK (dotnet build compile gate), Java + Maven (mvn compile gate) and interactive az login / copilot login credentials. The cobol-migration-portal image uses the lightweight mcr.microsoft.com/dotnet/aspnet:10.0 runtime (no SDK or JDK/Maven), making it well suited for hosting the read/explore/Prompt Studio/Chat/MCP portal over already-scanned source/ and output/ folders or API-key-authenticated runs.
  • Volume names: Docker prefixes volumes with the compose project name (the checkout folder name, for example <folder>_graph_data).
  • Password: NEO4J_PASSWORD in Config/ai-config.local.env is required. Neo4j stores the password in graph_data on first start and ignores later changes; ./doctor.sh reports a mismatch.
  • Starting containers directly with docker compose: docker compose does not auto-load Config/ai-config.local.env for variable substitution, so source it first:
    set -a; source Config/ai-config.local.env; set +a
    docker compose up -d neo4j          # start only Neo4j (standard host workflow)
    docker compose up -d portal         # start Neo4j + containerized portal on :5028
    
    ./doctor.sh handles this automatically whenever a command needs Neo4j.
  • Who needs Neo4j running: run, convert-only and reverse-eng use Neo4j when it is reachable but do not start it; without it they continue with SQLite and file-backed parser evidence. Without Neo4j the portal shows the Neo4j status dot red and the AST Explorer cannot load AST/CFG nodes.
  • Corporate NuGet feed for Dockerfile builds: Dockerfile restores from nuget.org unless a git-ignored NuGet.Config exists in the repository root, in which case dotnet restore --configfile NuGet.Config uses only your configured feed/proxy.
  • Status & legacy container cleanup: ./doctor.sh rekt-status checks Neo4j, graph node counts and parse outputs; docker compose ps lists active containers. If an older checkout left a stopped cobol-rekt container in docker ps -a, remove it with docker rm <name>.

Running a second checkout side by side

Two checkouts on one machine would both claim the default names and ports. Give the second one its own values in its Config/ai-config.local.env:

NEO4J_CONTAINER="cobol-migration-neo4j-second"
NEO4J_HTTP_PORT="7475"
NEO4J_BOLT_PORT="7688"
PORTAL_CONTAINER="cobol-migration-portal-second"   # only for the portal container
MCP_WEB_PORT="5029"                                # the portal's port

doctor.sh reads these values and passes them to docker compose. Neo4j and the portal must use the same ports:

  • The CLI, the MCP server (dotnet run -- mcp) and the portal's Neo4j reader (RektNeo4j) resolve ApplicationSettings__Neo4j__*, NEO4J_URI, NEO4J_BOLT_PORT, NEO4J_USER and NEO4J_PASSWORD from environment variables first and fall back to Config/ai-config.local.env. The portal's Neo4j status dot also probes the HTTP port from NEO4J_HTTP_PORT (default 7474), and MCP_WEB_PORT selects the listener port (default 5028).
  • ./doctor.sh portal exports NEO4J_BOLT_PORT, NEO4J_HTTP_PORT, MCP_WEB_PORT and ApplicationSettings__Neo4j__* automatically. Start the portal this way when running two checkouts side by side.
  • If you start the portal directly with dotnet run --project McpChatWeb on custom ports, export NEO4J_HTTP_PORT and MCP_WEB_PORT (or ASPNETCORE_URLS) so the HTTP health dot and listener match your second checkout. The dot's tooltip names the address it tried and how to fix it.

How rekt-full and a conversion work inside, storage and the agents: see Architecture.


Portal

./doctor.sh portal (or the end of ./doctor.sh run) opens the portal at http://localhost:5028. Its tabs show the dependency graph, Estate Mission Control, the AI Loop, token usage, modernization intelligence, the AST Explorer, Convert Programs, the Program Explorer and missing copybooks. Chat with your service (POST /api/chat) and the MCP server (dotnet run -- mcp) query Estate Mission Control readiness, the Estate Dependency Graph (EstateGraphService) and the Neo4j AST/CFG/JCL graph (RektNeo4j) automatically—even before any AI conversion run—alongside SQLite run history and reverse-engineering reports. The tabs and chat views that read parse results need ./doctor.sh rekt-full first.


Configuration

File Purpose Git Tracked?
Config/appsettings.json All settings - models, chunking, Neo4j, output paths Yes
Config/ai-config.env.example Copy source for your local config Yes
Config/ai-config.local.env Your secrets - API keys, endpoints No (gitignored)

Estate data stays local. Source, output, logs and estate-specific rules are git-ignored, and a pre-commit guard blocks estate names. Run tools/check-no-estate-data.sh --install-hook once per clone. See Keeping estate data private.

Values load in the order appsettings.json → ai-config.local.env → environment variables; later values override earlier ones. See Configuration reference for key settings, Neo4j and sizing parallel jobs to your model quota.


Troubleshooting

./doctor.sh               # Check configuration
./doctor.sh test          # Run system tests
./doctor.sh chunking-health  # Check chunking setup
Issue Solution
Neo4j connection refused, or the portal's Neo4j dot is red Load Config/ai-config.local.env (set -a; source Config/ai-config.local.env; set +a), then run docker compose up -d neo4j. If you moved its ports, start the portal with ./doctor.sh portal so it uses the same ones; see Docker containers. The dot's tooltip names the address it tried
Azure API error Check Config/ai-config.local.env credentials or run az login
No output generated Ensure COBOL files are in source/
Portal won't start, or opens on another port The portal uses port 5028 unless MCP_WEB_PORT is set in Config/ai-config.local.env; remove that line so every checkout uses 5028. ./doctor.sh portal stops whatever listens on that port before it starts
A scan or command reports Internal helper crashed A .NET helper threw an unhandled exception. The stack trace is in Logs/doctor-helpers.log and, for scans, in helper-crashes.log beside scan.json. Run ./doctor.sh to check prerequisites, then rerun
Build fails with MSB3923 Failed to download file … github-copilot-…tgz, or setup says Could not fetch user-specific models The network blocks the GitHub release the Copilot SDK downloads its CLI from. doctor.sh falls back to your installed Copilot CLI automatically; for plain dotnet commands, see Building behind a download block
rekt-full stops with Source identity collisions prevent safe staging The parse reads copybooks by name from one folder, so it stops only when two copybooks share a name, differ, and a COPY or INCLUDE uses that name. The message lists the copies and the files that use them. Rename one copy, or move the estate you are not parsing out of source/. Copies with the same text, or that nothing uses, are staged and reported as a note

Documentation

Document Contents
Getting started Prerequisites, Windows, AI providers and Copilot sign-in, manual setup, folder layout and generated files
doctor.sh command reference Every doctor.sh command and option, rekt-full, JCL, partial and draft conversion, speed profile
Configuration reference Configuration loading, key settings, Azure OpenAI, Neo4j, quota and the parallel jobs formula
Architecture Inside rekt-full and a conversion, hybrid SQLite/Neo4j storage, agent pipeline and responsibilities, data flow
Portal Portal tabs, Estate Mission Control screenshots, AST Explorer, Convert Programs, demo recordings
Customizing agent behavior Prompt templates per agent, DDD example, service-oriented Spring output
File splitting and naming Split strategies, naming conversion, Spring and source-isolated partial conversion
Estate Mission Control and the AI Loop Deterministic clusters, carve scores, waves, stamp-validated readiness snapshot, chat/MCP graph tools and per-run model activity
Dependency Health & Semantic Flow Explorer Deterministic parse-fidelity, topology and JCL chain surfaces for deciding conversion order; assisted (default), strict and draft dependency eligibility
Ask the Report Portal chat answering from SQLite, readiness, the estate and Neo4j graphs, or a selected reverse-engineering report, plus saved chats
Reverse Engineering Process Architecture Reverse engineering reports, sample output, glossary, process flow and database schema
Legacy Modernization Flow How a run moves from COBOL through reverse engineering to generated code
Smart Chunking & Token Strategy Architecture Automatic chunking, full diagrams, constants reference and complexity scoring
Smart Chunking: Deep Technical Documentation Chunking pipeline, consistency mechanisms and database schema in depth
Ordered chunk output assembly How chunk-aware converters' continuation fragments are assembled and accepted
Speed Profiles TURBO/FAST/BALANCED/THOROUGH env var overrides and complexity scoring
Conversion Parity Validation Deterministic check that generated code represents the COBOL it came from, with per-axis coverage and a configurable threshold
Working with generated output Run folders, compile gate and what generated code needs before it builds and runs
Source decoding and generated output ownership Source encoding policy and per-target-path ownership of generated files
JCL job facts Deterministic JCL parser: procedures, symbols, conditions, Db2 runs and dataset lineage across jobs
Jobs generated from JCL Each JCL job as a .NET job (C#) or Spring Batch job (Java) that runs the converted programs under the JCL's conditions
CA IDMS programs What Starforge reads in IDMS programs, the dictionary copybooks you must supply, and how REKT is called for them
Bundled system copybooks Clean-room MIT SQLCA.cpy and SQLDA.cpy parser inputs supplied when the source has none, with provenance
Explicit platform replacement contracts Replacing a platform service explicitly, without redistributing its SDK copybooks
Teach the parser Teaching Starforge site words with your own AI endpoint; rules stay local
Demo guide The bundled quickstart estate, and how to copy IBM Bank-of-Z and AWS CardDemo for a demo
Bank-of-Z source corrections Corrections applied to the Bank-of-Z demonstration estate
Keeping estate data private Git ignores, the pre-commit guard and local estate rules
Azure AD / Entra ID Authentication Guide Keyless auth setup
Building behind a download block Building when the network blocks the Copilot CLI download
Validation and portal integration plan Proposed plan for integrating validation and portal work (not yet executed)
Spec-Driven Code Generation A considered approach, deferred and not implemented; kept for the reasoning rather than as a description of the tool
Dev container The VS Code development container
Changelog Version history

Workflows

Workflow / Agent Trigger Description
Documentation Updater Push to main Checks documentation completeness and reports gaps via issues or PR comments
Documentation Audit Weekly schedule Performs a full audit of project documentation for accuracy and completeness
Test Enhancer On demand Agentic workflow that analyzes the codebase and proposes improvements to test coverage
Branch Reviewer On demand (Copilot CLI) Reviews branch changes, summarizes commits, and detects breaking changes vs. main
Cross-platform checks Pull requests touching scripts or code, push to main, on demand Runs on Ubuntu and on Windows under Git Bash: shell scripts must parse and use LF endings; exercises doctor.sh platform helpers, JCL discovery, REKT preprocessing scripts and portal process control

Acknowledgements

Collaboration between Microsoft's Global Black Belt team and Bankdata. See blog post.

License

MIT License - Copyright (c) Microsoft Corporation. See LICENSE and THIRD-PARTY-NOTICES.md.

Explorer des projets similaires

Chargement…