JournalReading a legacy system the way a senior engineer would
Agentic SDLC

Reading a legacy system the way a senior engineer would

Kiran AbrahamFounding Principal Engineer, Orlian
Published
Reading time
6 min
Topic
Agentic SDLC
In short
  • 01In 2012 dormant Power Peg code woke on one missed server and cost Knight Capital over $460 million in about 45 minutes.
  • 02A senior engineer reads screens, then data, then code, then old documents, and treats each disagreement as a finding.
  • 03Asked which states an order can be in, the screens, database, code and wiki of one module gave four different answers.
  • 04The agent picks no winner: each gap goes into a log with its evidence, what is still unverified and a named owner.
  • 05The client architect confirmed Returned, corrected Cancelled and added a fact no layer held: a weekly manual refund.
  • 06Orlian's read-only Analyze agents hand Plan a signed picture of the existing system before anyone writes a requirement.

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.

Four layers are read separately, then reconciled and signed
  1. 1 · The screens people useUI analyzer · what is the system used for?
  2. 2 · The database underneathDB schema analyzer · what survives in the data?
  3. 3 · The source codeReverse engineer · how does the work happen?
  4. 4 · The old documentsReverse engineer · what did people believe?
  1. 5 · Reconcile the layersTwo layers disagree: the gap is a findingUnverifiable behavior is flaggedEvery open question gets an owner
  2. A written picture of what existsEvery uncertainty flagged, with an owner
  3. A person confirms itClient architect signs before Plan reads it
Reading order · 4 layers, 1 reconcile step, 1 gate

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Only the screens and the data know about Returned
NewPackedShippedCancelledReturned
Screens (tabs)foundfoundfoundnot foundfound
Database (values found)foundfoundfoundfoundfound
Code (status type)foundfoundfoundfoundnot found
Wiki (lifecycle page)foundfoundfoundnot foundnot found
Value found in this layerValue not found in this layer
Order states by layer · 4 layers, 5 states, 1 gap highlighted (illustrative)

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:

Gaps and decisions log
### Open item 4: order status ReturnedObserved: Returned appears on the Orders page and in the orders.status column. The orders module cannot set it. One job in the warehouse integration writes it by direct update.Not found: any document that describes Returned, or what should follow it.Needs verification: who owns the Returned state and what happens to a returned order.Owner: client architect

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.

A person’s answer turns two open items into recorded facts
Before the review
Returned: needs verificationSeen: no code path sets itOwner: client architect
Cancelled: needs verificationSeen: no tab on the Orders pageOwner: client architect
After the review
Returned: confirmedSet when the warehouse scans a parcel back inRefunds are issued by hand each week
Cancelled: correctedUsed on an admin screen the test account could not open; screen now captured
The same two log entries before and after the client architect’s review (illustrative)

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?

Filed underAgentic SDLC
Written by

Kiran Abraham

Founding Principal Engineer, Orlian. Kiran works with engineering teams on reading existing systems before they change them, from the first screen and table through to the code underneath.

The Journal, by email

Get the next field note in your inbox.

We write when we have something worth reading: the method behind the platform, and what we learn delivering with it.

You're on the thread.

Thank you for your interest. The next field note will land in your inbox the moment it's written. We'll send updates, never noise.

That didn't go through. Check the email address and try again, or write to us at hello@orlian.ai.

One email per field note. No noise, and you can unsubscribe anytime.