Rewriting in the real world

blog

The mirage of fluent legacy translation

It's been fashionable lately to feed thousands of lines of COBOL, JCL, CICS, or PL/I into a frontier LLM and get back readable modern code: Java, C#, or tidied COBOL. It looks right, it compiles, and we can understand what is going on, at least relative to the originals.

But syntactic fluency and even semantic equivalence is not the same as operational equivalence: doing the same things correctly in the real world. Equivalence means the new system does the same things in the real world as the old one: the same balances, the same files, the same error handling, the same behavior on the odd input that arrives once a quarter. Anything less is a regression, and the business has learned the hard way that they do not want brand-new capabilities mixed with brand-new, breaking changes.

‍

Quirks make the system

When an expert reviews AI-generated code, the small defects are easy to spot. The harder ones might require an expert who can understand the combinations of rules and byzantine environmental conditions that made the original logic work. Unfortunately, you probably don't have enough reviewers. You likely do not have anyone with the relevant context to find those hidden problems. Mainframe systems encode decades of implicit business logic, strict state transitions, and high-stakes error handling that are hard for any human to fully understand.

Fast code generation doesn't remove the verification problem. In fact, it makes the problem worse. Delivering more unverified code, sooner, to the same small group of people who can make sure it's correct, makes the verification problem harder, and makes it less likely you will find those hidden quirks of behavior.

‍

The LLM looking glass

LLMs are not designed to have a causal model of the real world. They were designed for semantics and syntax: for generating texts which are internally consistent (working code) and based on a high-level goal (prompting and agent instructions).

Internal consistency is necessary, but not sufficient: that the code needs to compile is just the start. You also need the compiled code to do the right things in the world, and that is assessed based on how the living system behaves in the world, with all its upstream and downstream dependencies and internal processing.

Because LLMs work by probabilistic next-token prediction, they're not optimized to build a causal model of the real world. And when it comes to legacy systems, which have operated in the real world for years, if not decades, modernizing them requires a layer of data-driven deterministic verification to reach code which is sufficient to run in production.

‍

The anatomy of mainframe complexity

Mainframes are notoriously complex monoliths, and their complexity obfuscates the real-world behavior we need to preserve while making important new changes to the codebase during modernization. For example:

  • COBOL and PL/I: Procedural strictness, fixed-point arithmetic quirks, and deeply nested conditional logic. Dynamic call trees go beyond the static code, with schedulers and lookups that control files and tables.
  • JCL: Declarative sequencing, complex dataset concatenation, and tight coupling to system parameters.
  • CICS: Transactional processing, screen mapping, and non-linear state management.
  • Host environment: Compiler flags, runtime language options, sort defaults, resource definitions for CICS, storage for datasets, code pages, system exits, and so on.


Every mainframe carries a set of site-specific settings, and any of them can change behavior. COBOL compiler defaults, Language Environment runtime options, and sort defaults (DFSORT and others) are examples. So are CICS resource definitions, which decide which physical dataset a file name in the code points to, and with what permissions. None of these is guaranteed to appear in the source code a customer hands over for modernization.
‍

This results in two categories of risk:
‍

Technical risk. A minor omission in an error-handling paragraph (INVALID KEY, FILE STATUS checks) or an unmapped dataset attribute in a JCL script can trigger a production ABEND or silent data corruption. In a breakdown in data processing, data may need to be restored from backup (assuming it still exists) and the run attempted again. Or perhaps downstream dependencies don't receive their data, so their outbound feeds wait indefinitely until the system recovers.
‍

Business risk. Even in the case where there's no obvious breakdown, the system may keep running on bad data, without any flags, until a customer, supplier, or regulator notices something is amiss. Simplified, streamlined rules interact with other rules to produce system behavior. Running code hides the problems of inaccuracies, compounding the significance of the problem once it is found. You don't learn the implications of a change until customers and reputation are compromised. A simplified rule can violate a regulation or erode customer and brand trust, and catching these misses through human review (Your customers! Your integrated 3rd parties! Your regulators!) is untenable.

‍

The architectural ceiling of LLMs

It is tempting to assume that the astonishing progress that frontier models have made will solve this gap very soon. But while they're excellent at solving language problems, they aren’t designed to standalone solve problems described in real world behavior. That simply is a different problem than the one they are designed to solve.

LLMs lack an internal, causal representation of how code executes, how state evolves, or what consequences ripple through a multi-system architecture. This is an architectural limitation of LLMs, not a maturity lag. Adding parameters or widening context windows won't give a statistical transformer a semantic world model, so agents can't simply "solve" it.

Without a robust world model, an LLM can't autonomously verify its own omissions. It predicts plausible continuity, not real-world completeness or efficacy. Edge cases exist because of uncommon situations, and often were solved by “improper” fixes; both make these types of problems difficult for a system optimized for solving the normally-expected problem with the normally-best solution. For new capabilities from scratch, the normal problem and normal solution pairing is great. For avoiding key regressions on edge cases, it is a liability.

‍

Stochastic generation in production

Modern LLMs are great at producing code that compiles and looks "good". The reputational, regulatory, and bug-fixing danger sits in smoothing the complexity of a process If you are going to simplify business rules, you need to also ensure they are never subtly reinterpreted or dropped at the whim of the LLM.

Legacy systems rely on deterministic environmental states, powered by relational invariants across tightly coupled copybooks and working-storage sections. Unfortunately, stochastic generators frequently violate these relational invariants by treating localized code generation as an independent distribution. Without a world-model to influence the residual stream, local optimization (writing smooth code) overrides the global and convoluted behaviors that deliver correct results today.

‍

Data-driven deterministic verification

The fix is to give an LLM what it is otherwise missing: pragmatic feedback for when code is correctly behaving in the real world. Automated verification involves three pillars.
‍

  • Test vector generation. Automatically extract inputs and observed outputs from the legacy environment at scale, including edge cases. 
  • Symbolic execution. Map legacy ASTs and modern outputs into verification engines, using rigorous formal semantics to prove functional equivalence.
  • Deterministic harnesses. Run automated assertion checks that compare old mainframe execution paths against the modernized runtime at the boundary level, allowing for changes to the code without breaking non-negotiable contracts with the real world.


Generating code at scale that is right depends on a tight feedback loop at the most granular levels, where deltas can be captured.

‍

Engineering for meaningful change

Mainframe modernization is an engineering problem of exactness, not creative generation. Creativity is well suited and generally safe when it comes to additive new capabilities. Creativity needs to be measured with robust verification when key outcomes can’t be compromised: be creative in letting the code look significantly better, but verify you haven’t broken the key behavior and outcomes. Cavalier omissions of expected or required behaviors, not to mention the traceability required in many regulated industries, can violate customer trust and spark compliance investigations.

More training and more parameters won't give LLMs a world model that they can truly understand. Similarly, the success of AI-assisted migration won't be measured by how fast an LLM writes code. Rather, it will be measured by how rigorously deterministic verification frameworks can constrain, test, and prove its output. The more creative you want the new code to be compared with the old, the more critical that testing becomes.

When nothing is lost, everything is possible.

‍

Footnote

Leave a comment

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
0 Comments
Author Name
Comment Time

ReplyCancel
Delete
Author Name
Comment Time

ReplyCancel
Delete

You might like

Go up