Índice do artigofaltam 6 min de leitura
Picture a distributor whose billing system has been running for more than a decade. The vendor no longer exists, the source code is lost, and nobody at the company can state the exact rule for late fees, interest and discounts. The problem shows up when someone decides to rewrite it: if the new version charges one cent differently, the boletos (Brazilian bank payment slips) stop matching the history and reconciliation becomes a headache. X-Apps, the software company that writes this blog, reproduced this situation in the lab, with a program built for the test, to see how far AI can go. It read the entire rule of the closed program, including the detail that changes one cent, and a battery of tests against the original checked that reading.
AI can already open a program like this and read what it does, but it also makes things up, and whoever approves the rewrite needs to know whether what it described is the real rule or a well-written guess.
This is a common problem. On GPSi, the inspection app used by Grupo GPS's field teams, X-Apps built the iOS version starting from an Android app with no source code and no documentation. There the technique was different, without the tool in this test: the team recorded every conversation between the Android app and the server, feature by feature, and that recording produced the specification, which stayed with the client.
The test: REA (Reverse Engineer Anything) against a closed program
REA is an open source tool that gives AI the instruments to open programs and delivers each conclusion with the evidence behind it. The October article about the tool covers the introduction and the legal side: before opening a third party's program, check in the license whether reverse engineering is allowed.
The program examined was written for the experiment. It imitates the billing module of an old management system and calculates how much to charge for a boleto paid late or early. The test was blind, meaning the investigator did not know the answer: one AI wrote the program with a rule of its own choosing, full of the kind of quirks that derail migrations, and sealed the code and the answer key in a folder. Another AI, Claude Code operating REA, received what a user would know: the inputs are amount, due date, payment date and customer category, and the output is the amount to charge. Of the program itself, it received only the compiled file, built in .NET, a common platform in Windows management systems.
The question was closed: what exactly is the rule that calculates the amount to charge for an invoice paid late or early?
- Seal the code and the answer key away from the investigator.
- Read the program without running it.
- Hypothesize, separating what the program shows from what is a guess.
- Test the rewrite against the original program, case by case.
- Check the answer key only at the end.
What came out of the reading in two minutes
Without running the program, REA listed in seconds every function in the file with the low-level instructions of each, the ones the computer executes. It does not return the program rewritten in a readable language: it was the AI that reassembled the calculation from the instructions, and the whole reading, up to the written specification, took about two minutes. The box is for those who want to see the evidence; the sentence after it says what it shows. It is the tool's output for the interest calculation, condensed to fit on screen:
Cobranca.Tit::CalcJ
IL_0000 ldarg.0
IL_0001 call System.Decimal::op_Explicit r8(System.Decimal)
IL_0006 conv.r8
IL_0007 ldsfld Cobranca.Tit::fatD : r8
IL_000c mul
IL_000d ldarg.1
IL_000e conv.r8
IL_000f mul
IL_0010 ldc.r8 100
IL_0019 mul
IL_001a call System.Math::Floor r8(r8)
IL_001f ldc.r8 100
IL_0028 divIn plain language, interest is calculated using an approximate number type and then truncated at the cent, without rounding. The AI noted the consequence right there: on some invoices, this truncation charges one cent less than the exact calculation.
The AI marked each statement as confirmed by the code or as a hypothesis, when it depended on the platform, such as default rounding. The recovered rule:
- A due date falling on a weekend moves to Monday to decide whether the payment was late, but interest counts from the original due date.
- Each customer category has a grace period, and category C has none; once past it, everything is charged from the due date.
- The late fee sends the half cent to the even number, so-called banker's rounding; the discount sends the half cent up.
- Simple daily interest, on the invoice amount for customer A and on amount plus late fee for B and C.
- Late fee and interest combined have a cap, a percentage of the amount.
- Small invoices pay a fixed surcharge instead of late fee and interest.
- Early payment earns a discount in two tiers, depending on the category, and C never gets one.
The specification, the document that describes the rule for whoever is going to rewrite it, includes the values. A summary of it, followed by cases run on the original program:
Grace period (days after adjusted due date): A = 3 | B = 1 | C = 0
Late fee: 2% of amount, half cent to even
Interest: 0.033% per day, simple, from original due date
base: A = amount | B and C = amount + late fee
computed as approximate number, truncated at the cent
Cap on late fee + interest: 20% of amount
Invoice below 30.00: fixed surcharge of 2.50
Early payment discount: 10 days or more A = 3%, B = 2%
5 to 9 days A = 1.5%, B = 1%
amount due date payment cat. charged
1000.00 2026-03-10 2026-03-13 A 1000.00 grace period
1000.00 2026-03-10 2026-03-25 A 1024.95 late fee and interest
1000.00 2026-03-10 2026-03-25 B 1025.04 interest on the late fee
1000.00 2026-03-14 2026-03-17 C 1021.00 due date on Saturday
29.99 2026-03-10 2026-03-20 C 32.49 small invoice
850.50 2026-03-20 2026-03-10 B 833.49 early payment
10000.00 2024-03-04 2024-06-13 A 10533.29 the interest centWhere the reading stopped and the test took over
The next step was to use the original program as the judge. The AI rewrote the rule using only the specification and built a battery of tests, which runs the old program and the rewrite with the same inputs and compares the answers.
The first round had 4,270 cases, some chosen to hit the edges of the rule, some randomly drawn. All but 24 matched on the first try, and in those the error was in the rewrite, which crashed with absurdly large values. The reading had left that corner as an open question, and in some of those cases the original program also aborts, without returning a value. No hypothesis about the business rule was disproved. In the second round, with the rewrite fixed and more cases, no discrepancy was left.
The last case in the box, a large invoice paid months late, has interest of R$ 333.30 (Brazilian reais) by the exact calculation. The old system charges R$ 333.29, because it does the calculation with an approximate number and truncates at the cent. The reading had already described this behavior, and the rewrite reproduced it from the start. The test did two things the reading does not do: it proved, case by case, that the rewrite returns the same amount as the old system, and it measured the cost of "fixing" the calculation. With the approximate calculation replaced by the exact one, the final battery flagged a discrepancy in 97 cases. In a real system, those would be boletos that no longer match the history.
Only at the end was the answer key opened, and every quirk hidden in the program was in the specification.
What this test does not prove
The program is small and was written for the test; a real system has rules that depend on a database, holidays and customer records. .NET keeps function names, even if abbreviated, and instructions that are easier to read, which makes it the favorable scenario; a program in C or Delphi, or deliberately obfuscated, takes much more work. The few minutes of the experiment are not a project timeline. It was a single run, without comparing cost against manual work. The extracted instructions were sent to the AI model's provider, because REA runs on the local computer and the AI does not; with a third party's program, that matters.
And what if the old system runs in the cloud, accessed through the browser? Then the tool only observes this side: the page, the programs the browser downloads and its conversations with the server. Version 6.9.0, published on November 12, added the comparison between the addresses these programs call and the recorded traffic, and the inventory of the document that describes the connection to other systems, when the company has that file. The code running on the vendor's server remains out of reach, and of the rules applied there you only see the result that comes back.
What this leaves for anyone about to modernize
What comes out of work like this is a document with the rule step by step, the evidence for each item and acceptance cases with the real output of the old system. The cases become the tests of the new system. For the first steps, there is the article on what to do when the vendor disappears and the system is still running.
One part the company can do on its own, before hiring anyone. Pick a critical rule, preferably the one that deals with money, and gather real input and output cases from the old system, such as boletos already paid with amount, due date, payment date and amount charged. Keep this material as the answer key before any rewrite.
AI reads the rule in minutes; what proves the rule is right is testing against the old system.
Sources: morluto/rea repository, README and version 6.9.0 release notes of November 12, 2026, checked on November 14, 2026. X-Apps experiment of November 14, 2026: test program in .NET 8, REA 6.9.0 operated by Claude Code, battery of 4,270 cases against the original program.





