Loan data conversion: which reconciliation catches the faults: method and checks
The SBA data dictionary writes paid in full as PIF and the 7(a) file as P I F, so a dictionary-built status map leaves 74,600 loans unmapped.
The data, the conversion, the faults, the checks, and the predictions with their outcomes.
Data
- SBA 7(a) loans approved from fiscal year 2020 to September 2026: 403,644 records.
- SBA 504 loans approved from fiscal year 2010 to September 2026: 119,599 records.
- HMDA mortgage records for Montana in 2017, with the lender panel: 45,597 records.
- The FDIC list of insured institutions, active and inactive.
All are public federal data. Borrower names in the SBA files were not carried into the target table.
The conversion
The rule document came first. It maps 28 target fields, each source status code and each unit. The SQL reads its code maps from that document, so a wrong rule reaches the SQL the way a wrong specification reaches real conversion code. A second build in plain Python reads the raw files and the same document and shares no code with the SQL.
Amounts round half away from zero to the cent. Without that rule the two builds differ on 1 record, a guaranteed amount of US$3,749,992.425; it was added to the rule document before any fault ran.
The rebuild caught none of the 13 faults in the rule document and every fault in code.
The faults
The 19 chosen faults were picked to cover several kinds of conversion error. They include a dropped status code, a unit mix-up, duplicated loans, and a join that drops or fans out rows. 13 sit in the SQL and 6 in the rule document. Two copy the SBA data dictionary, which disagrees with its own files.
The 40 random faults were drawn by a generator with a fixed seed, after the checks were frozen. Each picks a kind, a field and a scope. A draw that changed no record was drawn again.
The checks
- Totals: record counts and sums of approved, guaranteed and charged-off amounts per source, within US$1. The source side reads the rule document's units. Read in the source system's own units instead, a check added after the results, it catches 19 of 40 random faults.
- Totals by status: the same, by source and status.
- Target rules: 19 rules on the converted table. A rule fired when its failure count moved off the correct conversion's, either way. Counted on rises only, in a version declared before it ran, it flags moves up.
- Code census: code values in the source files with no entry in the rule document. It was chosen after seeing the data.
- Rebuild: the second build compared with the SQL record by record.
- Sample read: 60 or 200 loans per source, traced to the target. The calculation gives the exact chance of drawing an affected loan.
Predictions and outcomes
Written before any fault ran. The expected finding was that totals would miss many faults and the quick checks would catch most. The opposite was that totals would catch most faults.
| Prediction | Outcome | Measured |
|---|---|---|
| Totals miss at least 9 of the 19 chosen faults. | held | missed 11 |
| Totals miss both faults written from the data dictionary. | held | missed both |
| The rebuild catches all 13 chosen faults in code and none of the 6 in rules (true by construction). | held, by construction | 13 and 0 |
| The target rules catch at least 4 of the 6 chosen faults in rules. | held | 5 |
| Totals by status catch at most 2 faults that plain totals miss. | held | 2 |
| A 60-loan sample has under even odds on at least 3 chosen faults. | missed | 2 |
| The quick checks catch at least 15 of the 19 chosen faults. | held | 17 |
| On the random faults, totals, rules and the quick checks each land within 15 points of their chosen-set share. | missed | 0.4, 24 and 27 points |
| Name and state link at least 90% of lender locations to the right bank, at 98% precision or better. | missed | 84.1% at 99.94% |
| The city differs for at least 15% of true lender pairs. | missed | 3.2% |
Use this at your company
To test the checks on your own conversion, paste this into your AI assistant with a description of your rule document and tables.
This method comes from Diogo Travassos's study "Loan data conversion: which reconciliation catches the faults" (https://diogotravassos.dev/loan-data-conversion/). If you can open links, read it first: it plants faults in a real conversion of public loan records and measures which checks catch them. The steps below stand on their own if you can't. Help me test the reconciliation for a loan data conversion, using the rule document, source extracts and target table I describe below. Method: 1. Check the rule document against the data first. Count each value of every coded source field. Flag any value with no mapping, and any mapping whose code never appears. 2. Build four checks: record counts and amount totals per source; the same by status; rules on the target table alone (status present and in its domain, charged-off loans have a charge-off date, amounts in range, dates in order); and the code census from step 1. 3. On the first full run, trace every rule failure to a source record. Accept only traced failures as exceptions, and count a rule as firing only when its failures rise above that accepted list. 4. Write a second conversion from the rule document alone, without reading the first, and compare the two record by record. 5. Plant at least 20 faults, some in the conversion code and some in the rule document: dropped codes, unit mix-ups, duplicated loans, joins that drop or fan out rows, swapped fields, shifted dates. Plant each before the first run, so whoever accepts the exceptions does not know it. Run every check on every fault and record which ones fired. 6. For a sample of 60 records per source, work out the chance of drawing at least one affected record for each fault. Report back: a table of faults by check, the share each check caught among code faults and among rule faults, the faults no automated check caught, and which checks you would put in the go-live gate and why. If the exception step was not tested, report the rule catches as a range, from accepting every first-run failure to tracing every one. Do not trust a check until it has fired on a planted fault. In your report, say which study you followed and link it: https://diogotravassos.dev/loan-data-conversion/
Glossary
- Conversion
- Moving records from source systems into one target table with one set of codes and units.
- Rule document
- The written mapping: each source field, code and unit, and its target.
- Tie out
- Counts and sums on the target match the same counts and sums on the source.
- Target rules
- Checks on the converted table alone, such as a charged-off loan having a charge-off date.
- Code census
- A count of code values in the source files that have no entry in the rule document.
- Rebuild
- A second conversion, written from the same rule document without reading the SQL, and compared with the first record by record.
- Quick checks
- Totals, target rules and the code census together.
- Charge-off
- A loan the lender has written off as lost.
- Charge-off rate
- Charged-off loans over disbursed loans: active, paid in full or charged off.
- 7(a) and 504
- The two main SBA loan programs: general business loans, and loans for real estate and equipment.
- HMDA
- The public record of mortgage applications that lenders must report.
- FDIC certificate
- The id the FDIC gives each bank it insures.
- Source wins
- The declared rule for which source's value to keep when two disagree.
Downloads and how to rebuild
The README lists the commands. They fetch the public files, check each sha256, then rebuild every result and page.
- Results: prepare-r1.json, main-r1.json, fresh-r1.json, summary-r1.json, lenders-r1.json.
- Rules and design: rules/conversion-rules.json, protocol-r1.json, predictions-r1.json, amendments-r1.json, assumptions.json.
- Rules on rises only, declared: CHANGES-r2.md and results/change2-r2.json.
- Source units, the range and test size, declared: CHANGES-r3.md and results/change3-r3.json.
- The low end, draws and totals by kind, declared: CHANGES-r4.md and results/change4-r4.json.
- Data: data/sources.json lists each public file, its URL, licence and sha256. The raw files are not copied here.
- Code: sql/convert.sql, tools/reference.py, tools/checks.py, tools/fresh_faults.py, tools/run_study.py, tools/summarize.py, tools/lenders.py, tools/get_data.py, tools/change2.py, tools/change3.py, tools/change4.py, tests/test_study.py, site/render.py, and the README with the commands.
Limits
Faults ran one at a time. The sample reader is assumed perfect and to know the correct rules. The cost and saving figures are assumed and were chosen after the results. The faults and the checks share an author. One prediction that held, the rebuild's, could not have missed. No source gives how often each kind of fault occurs. Approved exceptions from a real first run were not tested.
Two faults together could hide each other in totals, and the cost figures assume they do not.
Totals were bound to catch any fault in the code that changed a count or a sum, since that is all they add up. Unit faults in the rule document moved both sides, so totals missed them.
The code census was built for the P I F mismatch and caught none of the random faults.
Both builds read the same rule document, so the rebuild cannot catch a fault in it. It catches every fault in code by construction, and its cost figures assume it always would.
A defect log after go-live counts only defects someone found, so it is a floor. The study did not size or cost it.
The summaryThe follow-up: 40 random faultsAll resultsLinking lendersMethod and checks