Reverse engineering legacy code goes best in the order a senior engineer would choose: start with the screens people use, check the database for what is really stored, read the code for how it happens and treat every old document as a claim to test. Where two of those sources disagree, the disagreement is the finding.
This post follows that order on one module of Order Hub, a sample project used as illustration. It shows what an agent in the Analyze wing of an AI SDLC writes down, which questions it leaves open and what a person corrects before anyone plans a change.
01What dormant code cost one firm in 45 minutes
On 1 August 2012, Knight Capital's order router sent millions of unintended orders into the US stock market. The SEC's order against the firm counts about 4 million executions in 154 stocks, more than 397 million shares and a loss of over $460 million, all in roughly 45 minutes.
The cause was old code that had stayed on the production servers. A function called Power Peg had been retired from use in 2003 but remained callable. In 2005 the firm changed how a related safeguard worked and did not retest Power Peg afterwards. In 2012 a new feature reused the flag that once switched Power Peg on, with a plan to delete the old code. The update went to eight servers and missed one, and on that server the reused flag woke the old function.
The SEC also notes that the firm had no written protocol for accessing unused code on its production servers, and that 97 automated emails reading "Power Peg disabled" arrived before the market opened without anyone acting on them.
Each of those facts could have been found by reading the code and its history: the function still existed, the flag still reached it and the safeguard it relied on had moved. The case is from 2012, and it remains the clearest public record of what an unread corner of a system can cost. It is also why an AI SDLC starts with reading, before anyone writes a requirement.
02The order a senior engineer reads in
A senior engineer usually starts outside the code. The screens show what the system is used for today, the database shows which facts survived years of changes, the code explains how the work gets done and the old documents record what people once believed. Each layer answers one question, and the order runs from the layer most likely to be current to the layer most likely to be stale.
The fifth step produces the value. Thoughtworks describes the same idea for systems whose source code is missing: it reads the interface, the data, the integrations and the old documents as separate lenses and compares them. In its retailer case, descriptions from subject-matter experts were found to contradict observed behavior.
The Analyze wing assigns the same reading to three agents, all read-only. Anything they cannot verify is labeled as needing verification and given an owner.
03One module, read layer by layer
Asked a plain question, which states can an order be in, the four layers gave four different answers. The example is the orders module of Order Hub, the sample project, so every detail below is illustrative.
- Screens: the UI analyzer walks the Orders page with a test account and records tabs for All, New, Packed, Shipped and Returned. The order detail page has actions for packing and shipping, and none that moves an order to Returned.
- Database: the DB schema analyzer, connected read-only, finds a status column on the orders table that holds five distinct values in a sample: new, packed, shipped, cancelled and returned.
- Code: the reverse engineer reads the orders module and finds a status type with four values: new, packed, shipped and cancelled. Nothing in that module sets returned. A search of the repository finds one writer, a job in the warehouse integration that updates the column directly.
- Documents: the wiki page on the order lifecycle lists new, packed and shipped. It mentions neither cancelled nor returned.
Each layer describes a different part of the same system, and the gaps between them are where a change would go wrong.
04What the reconciliation shows
Placed side by side, the four lists produce two findings.
Returned is visible on screen and stored in the database, yet the orders code has no path that sets it and the wiki never mentions it. The only writer is the warehouse job. Cancelled is the mirror case: the code and the data know it, and the Orders page has no tab for it.
The agent does not pick a winner between layers. It writes each finding into the gaps and decisions log with the evidence behind it, labels what it could not verify and names an owner. An entry for the first finding reads like this:
A person can review a log like this in an afternoon, because each entry says what was seen, where it was seen and what is still unknown.
05What a person corrects afterwards
The agents end with a reviewed list of open items, and the client architect works through it at the gate that closes Analyze. In this example the two answers changed the documentation in different ways.
Returned was confirmed. The warehouse sets it when a parcel is scanned back in, and finance issues the refund by hand each week from an export. That second fact lived in a routine, so it appeared in no layer the agents could read. The entry now records the manual step, and a question goes forward to Plan: should the refund follow automatically?
Cancelled was a correction to the agents' own work. The missing tab had been flagged as unexplained, and the architect pointed to an admin screen that the test account could not open. The UI analyzer ran again with an admin account and captured that screen.
People supply three things that the layers cannot:
- Facts that live in routines, such as the weekly refund.
- Access the agents did not have, such as an admin account.
- Decisions about what the system should do next, which belong to Plan.
The gate checks the rest: the documentation reflects the system that really runs, unverifiable behavior is flagged and every open question has an owner. Plan reads the documentation only after a named person has signed it.
06Where Orlian fits
The Analyze wing is this reading, run on an existing system before Plan begins. Its three agents are read-only, they flag whatever they cannot verify and they hand the result to a named person to sign. Teams that need legacy code documentation for a system they are about to change get that signed picture as the first input to the AI SDLC. Plan then writes requirements against what exists and each requirement keeps a link to the finding it came from, along the red thread that runs from the first screen to the release.
In the sample project, the Returned finding would become one requirement about refunds and a later change to returns would start from the confirmed fact. The full lifecycle is described in What is an agentic SDLC?

