posts

Why agentic code migration requires a parity harness

Treating generative AI as an automatic drop-in converter for legacy COBOL or Fortran codebases usually backfires. Mistral recently documented migrating 40,000 lines of Fortran 77 reservoir simulation code over to C++. Their early run with autonomous agents did what experienced engineers would expect: it simply retyped Fortran in C++ syntax. The model preserved awkward GOTO loops, dumped shared data into global structs, and produced code that was just as hard to maintain as the original.

Getting useful results required building a test harness to verify that the old and new code produced identical math at every step. By exporting intermediate outputs from the legacy Fortran and comparing them directly against the C++ build, the team gave the models an objective ground truth. Paired with human review on module architecture, structured agents handling planning, coding, and testing delivered clean code. Left completely on their own, the agents stalled whenever numbers drifted.

AI can translate syntax, but it cannot untangle technical debt on its own. Migration requires checking for both syntax and structure. If an agent rewrites legacy logic in a new syntax without updating the architecture to modern patterns, you miss the benefits of the target language and just end up with bad code in a new stack.

Source: mistral.ai/news/legacy-code-modernization

← all posts