Prove It or Page Me: Fixing Bad Data Only When the Source Agrees A developer with fifteen years of data engineering experience released DataRanger, an open-source Python tool that repairs data-quality problems only when a fix can be proven against source-system control totals, otherwise routing the incident to a human. In a built-in demo on version 0.9.0, the tool processed 35 incidents, fixing 18, clearing 9 as false alarms, and escalating 8 for manual review, producing an HTML dashboard plus CSV and JSONL audit files while leaving the original table untouched. Here is a small problem that has cost me more evenings than I like to admit. Two rows land in a payments table with the same payment ID. One says 112.31. The other says 62.31. A cleanup job deletes one of them, or these days an AI agent does. The duplicate alert clears. The dashboard goes green. Which amount did it keep? If nobody can answer that, the fix was a guess. I spent fifteen years moving data for banks, retailers and healthcare companies, and the bugs that hurt most were never the loud ones. They were the quiet fixes that made every check pass and left the wrong number behind. In this tutorial we will plant that exact problem in a small table, along with two others, and use DataRanger, an open-source tool I built, to fix what can be proven and hand back what cannot. It runs on your laptop in about five minutes. You need Python and nothing else: no account, no API key, no warehouse. Most data-quality tools stop at telling you something is wrong. DataRanger tries to fix it, under one rule: apply a fix only when it can be proven against the source. Otherwise, call a person. The proof comes from control totals. Your source system knows how many payments it sent each day and what they added up to. That small table of counts and sums is the referee. For each problem it finds, DataRanger does four things: Install it and run the built-in demo: pip install dataranger dataranger demo The demo patrols a sample payments table with planted problems. On version 0.9.0 it prints: 35 incidents: 18 fixed, 9 checked and left alone, 8 for you. Report: dataranger-demo/dashboard.html Open dataranger-demo/dashboard.html in a browser. That one line is the whole idea in miniature: some fixes were proven and applied, some alerts turned out to be nothing, and eight were handed to a person. Every incident ends in one of three places. | Outcome | What it means | |---|---| | Fixed | A fix was tried on a copy and the result matched the source's totals. | | Checked and left alone | An alert fired, but the data already agrees with the source. No change was needed. | | For you | Nothing could be proven. A person decides, with the evidence in the report. | The report folder holds four files: dashboard.html : the page you just opened. incidents.csv : one line per incident, with the decision. audit.jsonl : every fix that was considered, and why one was chosen or none was. fixed version.csv : the proposed corrected table. Your original is untouched. Now break a table yourself A demo you did not build is easy to distrust, so let's make our own. Save this as make data.py . It creates a month of payments, then a second copy with three problems planted in it. python import numpy as np, pandas as pd rng = np.random.default rng 7 days = pd.date range "2026-11-01", periods=30, freq="D" customers = pd.DataFrame {"customer id": f"C{i:03d}" for i in range 50 } rows = for day in days: for in range 40 : rows.append { "payment id": f"P{len rows :05d}", "customer id": rng.choice customers "customer id" , "booking date": day.date , "channel": rng.choice "web", "store" , "category": rng.choice "grocery", "fuel", "travel" , "amount": round float rng.uniform 5, 200 , 2 , } source = pd.DataFrame rows what the source system really holds loaded = source.copy what the pipeline loaded, with three problems def on day : return loaded "booking date" == days day - 1 .date 1. Nov 12: one payment arrives twice, and the first copy has the wrong amount. bad = loaded on 12 .head 1 .copy bad "amount" += 50 loaded = pd.concat bad, loaded , ignore index=True 2. Nov 20: five payments are loaded twice, identical copies. loaded = pd.concat loaded, loaded on 20 .head 5 , ignore index=True 3. Nov 25: three payments never arrive. loaded = loaded.drop loaded on 25 .head 3 .index customers.to csv "customers.csv", index=False source.to csv "source payments.csv", index=False loaded.to csv "payments.csv", index=False print len source , "rows in the source,", len loaded , "rows loaded" Run it: python make data.py 1200 rows in the source, 1203 rows loaded The first problem is the one from the opening. Payment P00440 is now in the table twice, once at 112.31 and once at 62.31. The wrong copy comes first, so a cleanup that keeps the first row it sees will keep the wrong amount. Control totals come from the source, never from the table being checked. One command builds them: dataranger totals --facts-file source payments.csv --out control totals.csv \ --date booking date --segment channel --amount amount 90 control-total rows for 30 day s written to control totals.csv. Use them with patrol's --manifest-file. dataranger patrol --facts-file payments.csv --ref-file customers.csv \ --manifest-file control totals.csv --key payment id --reference customer id \ --date booking date --segment channel --category category --amount amount 3 incidents: 2 fixed, 0 checked and left alone, 1 for you. Report: dataranger-report/dashboard.html Three problems planted, three found. Here is what happened to each. | Day | What we planted | Decision | Why | |---|---|---|---| | Nov 12 | Same payment twice, two amounts | Fixed | Keeping the second copy matches the source's total. Keeping the first does not. | | Nov 20 | Five identical duplicates | Fixed | Removing the extra copies matches the source's count and total. | | Nov 25 | Three payments missing | For you | The source says 40 payments and the table has 37. No fix can invent the missing rows, so a person is called. | Nov 12 is the interesting one. Open the audit log and print the fixes DataRanger considered for that day: python import json for line in open "dataranger-report/audit.jsonl" : d = json.loads line if d "partition" == "2026-11-12": for c in d "candidates" : print c "fix" , "| alert cleared:", c "monitors quiet" , "| gap to source:", round c "residual" , 4 none | alert cleared: False | gap to source: inf dedupe key=txn id | alert cleared: True | gap to source: 0.0276 dedupe keep=last, key=txn id | alert cleared: True | gap to source: 0.0 Read the middle line slowly. Keeping the first copy clears the duplicate alert. A monitor would call it fixed. It also leaves the day 2.76% away from what the source says, because it kept 112.31. Keeping the last copy clears the same alert and lands exactly on the source's total. Both fixes look identical to a monitor. Only one of them is right, and the control totals are what tell them apart. That is the answer to "which amount did it keep?" The log says txn id because DataRanger uses its own column names internally. It is your payment id . A check you have to remember to run is a check you will skip. Two places make it automatic. DataRanger ships as a GitHub Action. This runs the same patrol after your pipeline step and fails the job when an incident needs a person: - uses: akshaysharma1088/dataranger@v0.9.0 with: facts-file: payments.csv ref-file: customers.csv manifest-file: control totals.csv key: payment id reference: customer id date: booking date segment: channel category: category amount: amount The report folder is uploaded as a workflow artifact, so the dashboard and the audit log are attached to the run that produced them. The same action reads a DuckDB file, a Snowflake table or a dbt model if your data does not live in files. This is the case I care about most. Agents are now being handed write access to data, and an agent is very good at making an alert go away. DataRanger runs as an MCP server, so the agent can ask for a patrol instead of writing its own cleanup: claude mcp add dataranger -- uvx dataranger mcp The agent gets back the incidents, the decision for each one, and the reason. The rule stays the same whoever is asking. A fix is applied only when the source agrees, and everything else comes back marked for a person. I would rather you hear this from me than find it out in production. dataranger totals builds them for you, as we did above. Go back to the two rows at the start. The alert cleared and the dashboard went green, and nothing in the tooling could tell a cleared alert from a correct table. DataRanger is my attempt at that difference: fix only what the source can confirm, and page a person for the rest. It is open source under the MIT license. One question for the comments, and I mean it: where would checking against control totals still let a wrong fix through? If you can think of a case, post it. The best ones become test cases.