← Resources

Change the Rule in the Documentation, Not the Code.

Key takeaways

  • One AI read the COBOL of AWS CardDemo and wrote documentation. A coding agent working through FlowX Platform MCP rebuilt the programs on FlowX.AI from that documentation alone. Every output record was compared with the legacy program, against answers frozen and timestamped before any build was scored.
  • We changed business rules only in the documentation. On the lead rule, all three rebuilds matched the edited legacy program on every record. Across six more rules, 16 of 18 rebuilds followed the change and none kept the old rule.
  • Rebuilt screens did not match the original until the documentation got better. With a screen specification derived from the source, two of three fresh builds of the whole application matched the legacy run on every scored unit. The third missed two units on one screen, so we do not claim full equivalence.
  • When the documentation leaves a rule out, an AI fills the gap from memory of public code. A private system offers no such memory, which makes the documentation the part of a modernization worth investing in.

A modernization is usually judged by reading: the new documentation, the new code, the test reports. Reading cannot tell you whether the new system computes what the old one did, record for record.

AI now produces both halves of a modernization. One agent reads legacy code and writes documentation. Another builds a new implementation from it. Both look convincing on the page. The question that decides whether a bank or an insurer can trust them is narrower and harder: run the old program and the new one on the same data, and do the outputs match?

We tested that on a mainframe application anyone can run, and wrote it up as the RECAST paper. This post is the story behind it: what we set out to show, the result we were after, the parts that did not work, and what changed when they did. Every number here is in the paper and traces to a file in the public repository.

1. The test

The subject is AWS CardDemo, open source (Apache-2.0): a sample credit-card application written for the mainframe, in COBOL. We started with its four nightly batch programs: interest calculation, transaction posting, statements and the daily transaction report, 649 to 1,154 lines each.

The pipeline has two agents and no human edits in between:

  • Document. One AI reads the COBOL and writes a wiki: record layouts, a data contract and the business rules.
  • Rebuild. A coding agent working through FlowX Platform MCP, the platform’s MCP server, rebuilds each program on FlowX.AI from the wiki alone. It has file tools and the platform, and no shell and no web. Each build starts in a fresh project, three builds per condition.
  • Compare. The legacy COBOL runs under GnuCOBOL with a pinned clock. Old and new run on the same five data sets, and a scorer compares every output record by its business key.
COBOL source4 batch programsGnuCOBOL 3.2pinned clock · the referencelegacy recordsgolden outputswikiagent-writtencoding agentFlowX Platform MCPrebuilt recordsFlowX.AI workflowsSAME FIVE DATA SETSevery recordby business keyanswers frozen 2026-10-24,hash timestamped
one wiki, one rebuild, every record compared with the legacy run

Two choices in the design carry most of the weight.

We measure a match with legacy, not correctness. CardDemo has defects, like any system that has run for a while. Its interest program never rewrites the last account, for example. A rebuild that fixes a defect differs from legacy, and we count it as a difference. Whether a migration should keep a legacy defect is a business decision. The study measures whether the rebuild matches, and whether it said in advance where it would not. A difference stated in the build’s written assumptions before scoring is flagged. Anything else is silent.

The answers were fixed before the results. The protocol, the scorer and the golden outputs were frozen on 24 October 2026, before any build was scored, and their hash was timestamped with OpenTimestamps and attested in a Bitcoin block. The study was then extended many times. Each amendment is dated, and the paper says which were timestamped before their builds and which rest on git commits alone. A reader does not have to trust our account of the order.

From the detailed wiki, every batch rebuild returned output on every data set. Interest calculation matched legacy on 98.99 to 99.03% of records, transaction posting on 100%, the daily report on 99.72 to 99.73% of report units, and statements on every statement in at least four of the five sets. What remained was legacy defects the rebuilds did not copy, or a choice at a card on which legacy stops with an abend, and all but one build had flagged them before scoring. A rebuild of one program cost a median of $3.46 in model usage at list price and took a median of 7.5 minutes.

2. Change one rule in the documentation

Matching a legacy program is the starting point. What a business actually asks of a modernized system is that it can change. So the test that leads the paper is a change request.

We edited one business rule in the wiki, written as the rule with no change marker, so the builder could not tell it had changed. We made the same edit in the COBOL and compiled it, which gave the reference answer. Three fresh builds from the edited wiki were then compared with the edited legacy program on every record.

The lead rule is in transaction posting: a purchase is over limit only beyond the credit limit plus 10%. We know of no public source that proposes it, which matters, because the model cannot have read it anywhere. All three rebuilds matched the edited legacy program on every record, on all five data sets. For scale, the unedited legacy program scores 91.1 to 92.3% against the new rule.

The second rule, rounding interest to the cent, is the contrast: CardDemo’s public tracker already proposes it, so memory could supply it. All three rebuilds followed it, at 98.99 to 99.03%. The one record that differs on each set is the last account, the legacy defect the rebuilds do not copy.

Then we registered six more rules across all four programs, none of which we found proposed in CardDemo’s public tracker or on the web in 44 searches. 16 of 18 rebuilds followed the change, and no rebuild kept the old rule. The two that did not follow differ on an unrelated address line on every statement, which they had flagged in advance, so they score 0 at record level even though the changed rule itself is right in both.

0%25%50%75%100%Round interest to the centCR1 · INTCALC3 of 3 · one legacy defectOver limit only beyond limit + 10%CR2 · POSTTRAN3 of 3 · every recordTen-year accounts pay rate − 2.00CR3 · INTCALC3 of 3 · one legacy defectAt most four purchases per cardCR4 · POSTTRAN3 of 3 · every recordPost the smallest amounts firstCR5 · POSTTRAN3 of 3 · every recordStatement total counts charges onlyCR6 · CREASTMT1 of 3 · 2 differ, flaggedDaily report leaves out interestCR7 · TRANREPT3 of 3 · total flaggedCredit-score band on the statementCR8 · CREASTMT3 of 3 · abend card flaggedunedited legacy, scored against the new rulerebuilds, mean of five sets
eight rule changes made in the documentation only; records equal to the edited legacy program, business view

This is the result we built the study around. A rule changed in plain language, in a document a business analyst can read, reached the running system, and a record-by-record comparison with the edited original confirmed it. Nobody touched the code of the rebuild.

3. Memory is the hidden variable

CardDemo is public, so a model may have seen its source during training. That raises an uncomfortable question about every number above: did the rebuild follow the documentation, or did it remember the program?

We tested it on the interest program. Every identifier was renamed and five values were changed, so that memory of the public source gives the legacy value and the documentation gives the new one. The disguised COBOL was the reference. Four groups of builds differed only in what they were given to build from:

050100disguised COBOLthe source itself100detailed wikithe full documentation99.004summary wikistops before the business rules99.004no wikirecord layouts and contract only2.396median of build means over five sets · three builds per group · interest program only
the ablation under disguise: what each specification is worth once memory of the public source stops helping

Built from the detailed wiki, the rebuild came within one point of a rebuild from the disguised source code: 0.996 points on the pre-registered figure. On one of the five data sets the gap was 0.01 over the limit, and the paper reports both readings. Without documentation the builds fell to about 2%: they recognised CardDemo, used the values they remembered, and the disguise made those values differ.

The summary wiki is the instructive part. It stops before the business rules section, and it scored exactly as well as the detailed wiki. The builds filled the missing rules from memory of the public program. We had registered a prediction that the detailed wiki would beat the summary by more than a point, and it was not supported.

Memory showed up in honesty too. In the main CardDemo arms, one rebuild that returned output differed from legacy silently. Under the disguise, four of six did. Part of what looks like a well-calibrated builder on public code is a builder that remembers.

For a modernization program this is the most practical finding in the paper. Your system is not public. No model has read your COBOL, so nothing will fill the gaps in its documentation. On a private codebase, the quality of the documentation is the quality of the migration.

4. Where it did not hold

Batch programs read files and write files. Screens are harder: navigation, function keys, validation order, messages, paging. We registered a test of four online screens (sign-on, main menu, account view and bill payment), rebuilt three times from the wiki and scored against the original. With no real mainframe online system available, we scored them on a stand-in we wrote from the vendor’s documentation, and the paper is explicit that this is our own reading.

On the two registered payment cases, the bill payment wrote the same file records as legacy in all three builds. Screen content, account-view data, browser behaviour and the end-to-end chain each failed in all three. The screens differed from the original.

Then we registered the whole base application: 17 online programs, a date utility and 11 batch programs, rebuilt three times from one 234-page wiki at $35.62 to $37.67 and 69 to 75 minutes per build. The screens that move money wrote the same records as legacy in all three builds. The other six registered checks did not hold in any of them: not every screen was reachable, at most one screen program per build was free of silent differences, and list paging, the browser check, the chain from screens into batch, and the export and import round trip all differed.

So version 1.0 of the paper reports that the target claim, batch to working screens with both checked against the original, was not met. We published it that way.

5. Fix the documentation, not the build

The whole-application builds showed where the wiki was too thin. It described what the programs compute. It said much less about what a screen shows, in which order it validates, and what message appears on which key.

So we wrote a screen specification derived from the COBOL source, and changed nothing else about the approach:

  • One page per online program, 17 in all: layout, labels, field widths, messages, keys, navigation, validation order, paging and file effects.
  • Pages for the batch programs whose printed lines the wiki left out.
  • A catalogue of 150 legacy defects, each of which a build may reproduce or flag, and a list of places where the wiki and the source disagree.
  • Build rules: how precisely to match legacy, the platform conventions a build must follow, and checks the build runs on its own work before it finishes.

Every statement cites the COBOL source by file and line. We developed these inputs over a series of fresh builds. Between builds only the written inputs changed, and no built application was ever edited by hand.

On the last development build, the screens matched the legacy run on all 54 screen cases, apart from three units at limits of the test instrument. Every batch case matched, all four chains from screens into batch carried through, and the browser check passed 60 of 60 steps. It took 2 hours 11 minutes and $67.96. That build is exploratory and in-sample: the inputs were developed against the same cases that score them, so it shows the inputs can carry a build to the legacy result, not that they will. The scores moved with the documentation, which is the paper’s thesis applied to a whole application. It still had to be tested.

6. The confirmatory test

On 16 November 2026 we froze the inputs, every one by its hash, and registered the test before the first build: three fresh builds of the whole base application, each in one session, scored with the same instruments. A build passes only if all five conditions hold. Full equivalence with the legacy run is claimed only if all three builds pass.

2 of 3fresh builds matched the legacy application on every scored unit: 38,298 of 38,298, excused units aside
Build 1Build 2Build 3Online: every scored unit, 54 cases2 unitsAll 17 programs reachedBrowser: 60 steps, 9 casesBatch: 23 cases and the round tripEnd to end: 4 pairsBuild passesnoyesyes
the confirmatory test, pre-registered: five pass conditions per build, whole base application, FlowX Platform MCP

All three builds finished in one session, with no stop and no resume. Builds 2 and 3 passed all five conditions. Every scored unit equalled legacy, 38,298 of 38,298, once the units the rule set aside in advance are left out. Those are 29 units resting on two catalogued legacy defects that every build flagged as deliberate deviations before any case ran, and 2 units the test instrument cannot reach.

Build 1 passed four. On the card list, when the user presses PF8 again on the last page, legacy changes its message from NO MORE RECORDS TO SHOW to NO MORE PAGES TO DISPLAY. Build 1 kept the first message. It had stated that it reproduced this legacy behaviour, so under the rule fixed in advance those two units count against it. It is a silent difference: the build said it followed legacy and did not.

The confirmatory test, per build
Build 1Build 2Build 3
Passes all five conditionsno: 2 units on one screenyesyes
Scored units equal to legacy, excused units left out38,296 / 38,29838,298 / 38,29838,298 / 38,298
Browser steps60 / 6060 / 6060 / 60
Cost at list price$53.83$48.88$61.21
Agent time1 h 37 min1 h 47 min2 h 06 min

The registered claim needed three of three. Two passed, so we do not claim full equivalence. What we can say is narrower and, we think, more useful: from a written description derived from the source, fresh builds reproduced a whole mainframe application, screens and batch together, to the point where two of three matched every scored unit and the third missed two units of one screen.

What we do not claim

  • Scale. Four batch programs of 649 to 1,154 lines, 50 accounts, five data sets and three builds per condition, then one sample application of 17 screens and 11 batch programs. A bank’s portfolio is orders of magnitude larger.
  • Platform. CardDemo ran on GnuCOBOL, not on a mainframe, and the online reference is a stand-in we wrote from the vendor’s documentation, not a real online system.
  • Correctness. We measure whether a rebuild behaves like the legacy program, defects included, not whether either is right.
  • Independence. This is FlowX.AI testing its own platform. That is why the protocol was timestamped before the results and why the data, scorers and steps to rerun the scoring are public.
  • One builder. The paper reports FlowX Platform MCP. The protocol also registered a second builder, which the paper summarises in an appendix. Nothing is pooled across the two.

7. What it means for a modernization program

Three things carry over from a sample application to a real one.

The documentation becomes the control surface. In this study the business rules lived in a document a person can read and review. Changing the rule there was enough to change the running system, and the change could be checked against the original. That moves a modernization away from a one-time translation of code toward a system whose behaviour is described, reviewed and changed in plain language, with the platform holding the result.

Check by running, not by reading. A record-by-record comparison against the legacy run caught what a review would miss: a message that changes on the second key press, a total that counts the last amount twice, a field legacy leaves blank. The comparison is what turned “looks right” into a number someone else can verify.

Invest in the description. When the documentation was thin, the rebuild either fell back on memory or differed from legacy. When it got better, the rebuild got better, without a single hand edit to the built application. On a private codebase there is no memory to fall back on, so the description is where the effort pays off. We made a related argument about the mainframe itself in an earlier post: the systems stay, and the logic on them has to become changeable.

The full method, every table and the confirmatory test are in the RECAST paper (version 1.0, PDF; full report version 1.1, PDF). The code, data and scorers are on GitHub.

Glossary

A few terms from the study, in plain words.

TermWhat it means here
COBOLThe programming language most mainframe business systems are written in.
Batch programA program that runs on a schedule, usually overnight, reading files and writing files: interest, posting, statements, reports.
GnuCOBOLAn open-source COBOL compiler. We ran the legacy programs with it, off the mainframe, to get the reference outputs.
WikiThe documentation one AI wrote from the COBOL: record layouts, a data contract and the business rules.
FlowX Platform MCPThe FlowX.AI platform’s MCP server, through which a coding agent creates and runs workflows on the platform.
EquivalenceThe share of output records equal to the legacy program’s, matched by business key. A match with legacy, not a measure of correctness.
Flagged / silentA difference the build stated in advance is flagged. One it did not state is silent.
Change requestOne business rule edited in the wiki only, with the same edit made in the COBOL to give the reference answer.
DisguiseA copy of a program with every name changed and some values altered, so that memory of the public source no longer gives the right answer.
Pre-registrationFixing the questions, the scoring and the pass rules before the results exist, and timestamping them so the order can be checked.
Confirmatory testA test whose inputs and pass rule were frozen before its builds ran, as opposed to the exploratory builds used to develop the inputs.
Screen specificationPages derived from the COBOL source describing what each screen shows and does, with every statement traced to a file and line.
Next

Modernize from the description, and check every record.