A volume anomaly Check halts a stage or prod Sync whose row count is far outside its load history
A Source that suddenly sends ten times its usual rows (a duplicated export, a broken filter) or a Full Refresh table that suddenly shrinks to a tenth (a truncated Source) passes every other built-in Check: keys stay unique and the row count matches the Source. So every Sync table gets one more built-in Check, volume_anomaly, which compares the rows this load wrote with the table's own past loads. Like the other built-in Checks (ADR-0013) it is on by default, a pure rule over measured facts, and skippable per table with a written reason.
The rule. The Load Baseline is the rows_loaded of the last 10 Load Records for the same Environment, Pipeline, Step and table whose outcome is loaded and that are not marked as a backfill, newest first. Then:
- With fewer than 5 such loads the Check passes. A new table cannot halt on its first loads.
- Spike: the Check fails when this load wrote at least 1,000 rows and more than 10x the baseline median. Under 1,000 rows a load never halts, so a table that usually loads 0 or 3 rows does not halt on 40.
- Drop: only a Full Refresh table can halt on a drop, and only when the baseline median is at least 1,000. It fails when this load wrote fewer than the median divided by 10. An Incremental table never halts on a drop, because loading few or no new rows is normal for it.
- The multiplier (10), window (10), minimum history (5) and floor (1,000 rows) are fixed constants in
src/adops/domain/checks.py. There is no per-table tuning;skip_checksis the only per-table override.
For example, with an invented invoices table whose last five loads wrote 4,200, 3,900, 4,100, 4,000 and 4,300 rows (median 4,100), a load of 52,000 rows halts the run with:
Step sync_billing: Checks failed: invoices: volume_anomaly failed โ spike: 52000 rows loaded, more than 41000 (10x the median 4100 of the last 5 loads)
Where it runs. Only in stage and prod runs, where Load Records exist. dev and Branch runs report no volume_anomaly result at all. It runs after the load, beside row_count_matches and no_row_loss.
What a halt does and does not do. The Step fails with outcome check_failed, every later Step is not run, and, like every failed Check, the Step and the Steps after it forget their saved fingerprints, so the next deploy reruns from that Step. A halt is never retried. A halt does not roll back the loaded rows: they are already in the Warehouse. The halt stops the Transform and the Reverse Sync from passing them on. The halted load is recorded as check_failed, not loaded, so it never enters the baseline.
Backfill. adops backfill runs the whole Pipeline, but only the table it rewinds skips volume_anomaly (the result reads volume_anomaly skipped โ a backfill run reloads this table), and that table's Load Record is marked is_backfill, so the large reload never enters its baseline. Every other table in a backfill run is checked and recorded as usual.
A history that cannot be read passes. If reading the Load Baseline fails, the Check passes with a message that names only the error type (load history unreadable (WarehouseUnreachable)); it never fails or retries the Step. A broken history table must not stop prod, and the error text could hold a Warehouse secret.
After a real change in volume. When a table's volume changes for a good reason (a new customer region, a retired product), add a skip to that table in the Pipeline file:
- name: invoices
mode: full_refresh
primary_key: invoice_id
skip_checks:
checks: [volume_anomaly]
reason: new region doubles invoices from March; remove after 6 loads at the new volume
Keep the skip until at least 6 of the last 10 loaded Load Records for that table reflect the new volume. Halted loads were recorded check_failed and never entered the baseline, so the baseline still holds only the old volume when the skip is added. Only loads that pass while skipped add the new volume. Once 6 of the 10 do, the median is a new-volume load, whatever the sizes. With 5 or fewer, the median can still be an old-volume load, and removing the skip halts the next run again. For the invented invoices table that went from about 4,000 to about 60,000 rows per load: after four skipped loads the median of the last 10 is still about 4,000 and a 60,000-row load would halt; after six it is about 60,000 and the skip can go.
Contract for Sync engines. The Check reads rows_loaded from the Load Record. Any Sync engine must report rows_loaded per table as the number of rows extracted in this load: for an Incremental table the new or changed rows merged this time, for a Full Refresh table every row it reloaded. It is never the table's total row count for an Incremental table, and never None for a table whose outcome is loaded. The dlt engine reports dlt's per-table normalize row count, 0 when dlt reports none. A record with no rows_loaded is left out of the baseline, and a load with none is not judged.
Considered Options: a fixed per-table max_rows (users would have to know and maintain a number for every table); a z-score or standard-deviation rule (a few quiet loads make it hair-triggered, and it is harder to explain in a halt message than "10x the median"); per-table tuning keys for multiplier and window (no user has asked for them yet; skipping with a reason covers the cases seen so far); rolling back the halted load (the rows are already merged into the Warehouse table when the Check runs, and undoing a merge needs the old values; the halt already keeps them from reaching the Transform and the Reverse Sync).