Strangling the legacy system, one seam at a time

Big-bang rewrites overrun and get cancelled. We use comprehension agents, golden datasets and strangler-fig migration to retire legacy code safely, then run AI on the result.

ext-imp Research · 28 Nov 2026 · 8 min · Pillar 08

Every established business has a system nobody wants to touch. It runs something essential, such as policies, orders or billing. It was written decades ago, the people who understood it have retired or moved on, and every change request joins a queue measured in months. The board has been pitched a full replacement at least once. It was shelved on cost and risk, and the risk assessment was correct.

New ventures build their own version faster than they expect. They ship on whatever stack the first engineer chose, add AI features with prompts embedded in application code, and discover at scale that they have no evaluation suite, no tracing and no safe way to change model without breaking something. This year's prototype becomes next year's legacy system. The cure for both is the same: change in small, verified steps.

What breaks today

  • Big-bang rewrites fail. A full replacement has to reproduce years of undocumented behaviour before it can go live. Most overrun. Many are cancelled, leaving two systems to maintain.
  • Nobody knows what the system does. Business rules live in code paths, stored procedures and batch jobs. The documentation, if any, describes the system as it was intended to be.
  • Data is trapped. Operational databases feed analytics through nightly exports, so every AI initiative starts with a six-month data project.
  • AI features ship without evals. A model upgrade or prompt tweak silently degrades output quality, and the first signal is a customer complaint.
  • Security lags adoption. Prompt injection, data leakage through model calls, over-permissioned agents and staff using unsanctioned tools all arrive before the policy does.

How we solve it

Comprehension before change. Code comprehension agents parse the legacy codebase, whether COBOL, RPG, PL/SQL, VB6 or an early Java monolith, and build call graphs, data lineage and a map of batch dependencies. They then extract business rules into plain-language specifications, each linked to the exact source lines it came from. Your subject-matter experts review and correct those specifications. This step alone often justifies the engagement, because it is the first time in years that anyone has had an accurate description of what the system does.

Golden datasets. Before we change anything, we record real production inputs and outputs and build characterisation tests from them. These tests describe what the system does today, including its quirks. Some quirks are bugs. Some are business rules nobody remembers agreeing. The tests make both visible.

Strangler-fig migration. We place an API facade in front of the legacy system so that every request passes through a routing layer. Then we pick one seam, a single capability with clear inputs and outputs, and build a new service for it. Agent-assisted code generation speeds up that build, with every change reviewed by an engineer and covered by the golden tests. The new service runs in shadow mode: it receives live traffic, its results are compared with the legacy output, and every difference is investigated. When parity holds for an agreed period, the facade routes that capability to the new service. The legacy code path is retired. Then the next seam.

Change data capture into the Data fabric. In parallel, change data capture streams the legacy database into a lakehouse in near real time, with a semantic layer on top. Analytics and AI work can start against current data without waiting for the migration to finish.

LLMOps from day one. For every AI feature, ours or yours, we set up a model registry, versioned prompts, an evaluation harness that runs in CI, tracing of every call, cost per request, and fallback routing across the Model mesh. A model change ships only if it passes the evaluation suite.

Security in the Guardrails layer. Input filtering for prompt injection, PII redaction before any external model call, least-privilege tool permissions for every agent, a red-team test suite, and an audit log of every agent action.

The architecture

The facade is the hinge of the whole design. It lets old and new run side by side, lets us route a single customer segment or product line to the new service first, and gives us an instant rollback path. The Outcome meter reads routing logs to count how much real traffic the new services carry.

01
Legacy codebaseSource, schemas, job logs
02
Comprehension agentsRules, lineage, call graphs
03
Golden datasetsRecorded inputs and outputs
04
API facadeRoutes traffic per capability
05
New servicesBuilt and tested per seam
06
Shadow comparisonParity before cutover
07
CDC to lakehouseLive data for analytics and AI

Choosing the order of seams is a judgement call. We look for capabilities that change often, cause the most incidents or block the most valuable new work, and that have clear boundaries. Rating engines, pricing rules, document generation and notification services are frequent early candidates. Core ledgers usually go last.

Extend vs implement

Extend (legacy estate) Implement (new venture)
Starting point Decades-old core system Fast-built stack, prompts in code
First task Comprehension and golden datasets Eval harness and tracing in CI
Migration Strangler fig, seam by seam Modular boundaries from the start
Data CDC from legacy into the lakehouse Event-driven data model from day zero
Security Retrofit guardrails and permissions Guardrails layer before first agent

The outcome we get paid on

We meter modernisation on progress that is hard to fake:

  • Share of production traffic served by new services, read from facade routing logs.
  • Change lead time: days from an approved change request to production, for capabilities migrated so far.
  • Legacy run cost, including licences, hosting and specialist support.
  • For AI features: evaluation pass rate and cost per request.

Diagnose baselines change lead time and incident rates from your ticketing and deployment history over the past two to three quarters, and measures the current run cost. A target we often agree is moving the first two or three seams into production within two quarters, with change lead time for those capabilities falling from months to days. Guardrails govern every cutover: parity thresholds in shadow mode must be met, priority-one incidents must not rise above baseline, and every cutover has a tested rollback.

A composite example

A composite of engagements in UK specialist insurance, not a single firm. Picture an insurer writing niche commercial lines on a policy administration system built in RPG on a midrange platform, with rating logic spread across hundreds of programs and a handful of people who could safely change it.

Comprehension agents mapped the rating programs and extracted the rules into specifications that underwriters reviewed line by line. Several rules surprised them. Golden datasets came from a year of quotes. The first seam was the rating engine. The new service ran in shadow mode against every live quote, and differences were investigated until premiums matched to the penny or the difference was confirmed as a legacy bug the business chose to fix.

Mid-term adjustments became the second seam. Change data capture fed policy and claims data into the lakehouse, which let the pricing team run analyses that had previously waited for quarterly extracts. The midrange system is still running. It just does less every quarter.

If you have a system everyone is afraid to change, you do not need to replace it in one move. Talk to ext-imp about mapping your first seam.

Keep reading
Start here

Let’s put a meter on it.

A 30-minute call. We pick one metric, sketch the agents that would move it, and tell you honestly whether an outcome contract makes sense.