ML data engineering
Data Validation and Release Gates
Combine structural, semantic, relational, temporal, and population checks into governed release decisions.
By the end you can
- Place validation at source, transformation, and release boundaries
- Combine structural, semantic, relational, temporal, and population checks
- Choose approve, quarantine, degrade, reject, or time-limited release outcomes
- Govern waivers with scope, ownership, expiry, and compensating controls
Example
Monitoring systems can fail operationally too
A metric can be theoretically useful and still do nothing, because the alert carrying it has no context and no action attached. The cost of that is measured, not guessed. Hospital prescribing software warns clinicians about dangerous drug combinations. A 2006 review of 17 such studies by van der Sijs and colleagues, in the Journal of the American Medical Informatics Association, opened with the number: “Drug safety alerts are overridden by clinicians in 49% to 96% of cases.” The review named the conditions that produce the overriding: low specificity, unclear information content, unnecessary workflow disruptions. Those are the same three properties an under-designed data-quality alert has.
The decay itself was measured next. Ancker and colleagues examined 1,266,325 alerts, of which 326,203 were drug-drug or drug-allergy interaction alerts, across 430,803 encounters, and published the result in 2017. The likelihood of accepting a reminder fell by 30% for each additional reminder in the same encounter. It fell by 10% for each five-percentage-point rise in the share of reminders that were repeats. Attention is a budget with a decay curve. Every uninformative page spends part of it.
- Static threshold: weekend volume triggers a weekly false alarm because seasonality was ignored — and it is the repetition, not the individual page, that costs 30% of acceptance each time it recurs.
- Global alert: aggregate freshness passes while one critical country is twelve hours behind.
- No lineage: the alert names a changed column but cannot identify affected models or the producing job.
- No runbook: the page reaches an on-call engineer who cannot tell whether to block, roll back, or wait — the unclear information content behind a 49% to 96% override range.
- Auto-repair loop: a system repeatedly fills missing values and hides a worsening source outage.
Validate at the boundary where a bad release becomes expensive
Validation should run in three places: near the sources, after major transformations, and before a version becomes available to consumers. Each place catches a different failure, and each costs a different amount to recover from. A release gate combines evidence from several checks and records the exceptions it accepted. It should identify exactly which dataset version and which consumer population the decision covers.
What a missing row-accounting invariant costs at the load boundary is on the public record. Public Health England disclosed on 4 October 2020: “A technical issue was identified overnight on Friday 2 October in the data load process that transfers COVID-19 positive lab results into reporting dashboards. After rapid investigation, we have identified that 15,841 cases between 25 September and 2 October were not included in the reported daily COVID-19 cases.” The cause was mundane: “some files containing positive test results exceeded the maximum file size that takes these data files and loads then into central systems”. Nothing crashed. The dashboards published on schedule, and they were wrong by 15,841 positive results.
The downstream cost was later measured in infections rather than rows. Findlater and colleagues counted 15,861 case records that failed to import from SGSS into the CTAS contact-tracing tool, and published the analysis in BMJ Open in 2023. Among non-household contacts, the secondary attack rate was 7.9% (95% CI 6.5–9.2) in the delayed group, against 5.9% (95% CI 5.3–6.6) in the comparison group. Reconciling the count that leaves the source system against the count that enters the published table is a cheap check at that boundary. Nothing further downstream could recover the week.
Google turned this judgement into a scored checklist. Breck and colleagues published the ML Test Score in 2017, presenting “28 specific tests and monitoring needs, drawn from experience with a wide range of production ML systems”. The tests fall into four groups: data, model, ML infrastructure and monitoring. A release gate is where some of those tests stop being advisory and become binding.
A validation result becomes governance only when it controls publication of a named release.
Visual
Controls operate at several layers
Earlier controls reduce blast radius. Later controls reveal consumer-specific failures. Source and contract checks validate payloads, schemas and identifiers near generation. Pipeline invariants check row accounting, joins, timestamps and uniqueness. Dataset statistics watch distributions, missingness, coverage, freshness and important slices. Consumer parity compares training, serving and logged feature behaviour for the same contract. Outcome impact connects data incidents to model quality, decisions, users and operational queues. A file-size limit that silently truncates a load is invisible to the first layer and obvious to the second. That is precisely why the layers are not substitutes.
- 01
Source and contract checks
Validate event payloads, schemas, identifiers, and producer guarantees near generation.
- 02
Pipeline invariants
Check row accounting, joins, timestamps, uniqueness, and transformation expectations.
- 03
Dataset statistics
Monitor distributions, missingness, coverage, freshness, labels, and important slices.
- 04
Consumer parity
Compare training, serving, and logged feature behavior for the same contract.
- 05
Outcome impact
Connect data incidents to model quality, decisions, users, and operational queues.
No single layer can replace the others because each observes a different failure boundary.
Comparison
Fail, quarantine, warn, or record?
Response should reflect confidence, reversibility and consumer harm, rather than one universal threshold. This split is not a taxonomy invented for a lesson. Amazon built it into Deequ, its data-validation system, and published how Deequ works in 2018. On its use inside the company, the paper reports: “Additionally, data producers can leverage our system to halt their data publishing pipelines when they encounter cases of data anomalies.”
The worked example puts a number on the boundary between the two middle dispositions below. The count of newly added records raises a warning once it moves more than three standard deviations from the running mean. Beyond four, it throws an error. Same measurement, same slice, two different release consequences, separated by one standard deviation of confidence. The shipped AWS library, awslabs/deequ, exposes exactly that pair as CheckLevel.Warning and CheckLevel.Error, attached to constraints such as isComplete, isUnique and isContainedIn. The severity choice is written into the check definition, not argued about after the alert fires.
Block publication
Stop the release when a critical invariant is violated.
- Appropriate for impossible schemas or severe leakage risk
- Prevents broad contamination
- Can harm freshness if overused
- Example: duplicate primary example keys
Quarantine records
Publish valid data while isolating known problematic records.
- Contains localized defects
- Creates completeness and backlog obligations
- Needs explicit provisional status
- Example: malformed events from one client version
Warn and investigate
Allow publication while raising a time-bound review.
- Useful for statistical or seasonal changes
- Preserves service when evidence is uncertain
- Needs owner, deadline, and escalation
- Example: moderate distribution shift in one category
Record for trend
Store low-severity signals without paging.
- Supports gradual-degradation analysis
- Avoids alert fatigue
- Needs periodic review and aggregation
- Example: slow growth in median event delay
Good quality rules include action and context
A rule should state scope, reference, threshold, severity, owner, consumer impact, exception policy, and remediation. “Alert if distribution changes” is not operationally complete.
Use slices that map to real risk, but control combinatorial explosion. Prioritize protected groups, high-volume segments, high-consequence workflows, source versions, and known weak points.
Evaluate alert precision and recall using incident history and synthetic fault injection. Missing a failure and paging on harmless noise are both measurable outcomes.
Banking supervisors have written this list into a standard. BCBS 239, the Basel Committee's Principles for effective risk data aggregation and risk reporting, dates from January 2013 and sets out 14 principles. The third is “Accuracy and Integrity – A bank should be able to generate accurate and reliable risk data… Data should be aggregated on a largely automated basis so as to minimise the probability of errors”. Paragraph 40 states the operational half: “Supervisors expect banks to measure and monitor the accuracy of data and to develop appropriate escalation channels and action plans to be in place to rectify poor data quality.” Measurement, escalation channel, action plan — the same fields a well-formed rule carries.
Which half organisations actually fail is also on the record. In May 2018 the European Central Bank reviewed 25 significant institutions and concluded: “Thus far, none of those significant institutions – some of which are classified as global systemically important banks – have fully implemented the BCBS 239 principles.” The review named the main weakness as “a lack of clarity regarding responsibility and accountability for data quality”. The failing field is the owner, not the threshold.
Retire or revise rules that no longer represent the product. Monitoring definitions need versioning because normal behavior, sources, and consumer tolerance evolve.
A data-quality rule is an operational policy with a measurement, owner, decision, and lifecycle.
Steps
Make a dataset release decision
The review should separate correctness invariants from lower-confidence change signals. Freeze the candidate, run layered checks, review exceptions against the prior approved release, choose a disposition, and record accountability.
The last step is the one teams treat as paperwork. It is also the one two regulators on two continents have written down in nearly identical terms. FDA's 21 CFR 11.10(e) requires “Use of secure, computer-generated, time-stamped audit trails to independently record the date and time of operator entries and actions that create, modify, or delete electronic records. Record changes shall not obscure previously recorded information.” The MHRA imposes the same non-obscuring requirement in its data integrity guidance, revised in March 2018: “An audit trail provides for secure recording of life-cycle details such as creation, additions, deletions or alterations of information in a record, either paper or electronic, without obscuring or overwriting the original record.” It also requires the trail to capture the who, what, when and why of the action: reviewer, change, timestamp, rationale.
Storing reviewer, rationale, waivers, expiry and follow-up evidence is therefore not a documentation preference. In regulated industries it is the control. And the specific thing both texts forbid is the one a silent threshold edit does: overwriting the record of what the check used to say.
1. Freeze the candidate
Assign a release identity and preserve its source versions.
2. Run layered checks
Evaluate schema, semantics, relationships, time, labels, and population coverage.
3. Review exceptions
Inspect violating examples and compare them with the prior approved release.
4. Choose disposition
Approve, quarantine, degrade, reject, or time-limit the release.
5. Record accountability
Store reviewer, rationale, waivers, expiry, and follow-up evidence.
Key idea
A waiver is a temporary risk decision, not a deleted rule
If a release proceeds despite a failed check, preserve the violation, affected scope, owner, expiry, and compensating control. Silent threshold changes erase the evidence needed to understand later incidents. Repeated waivers indicate that the rule, source, or operating target needs redesign, and they should be reviewed as a pattern rather than closed one by one.
The clearest demonstration of that last sentence is not a data pipeline. A primary O-ring burned through on mission 51-B. Solid Rocket Booster Project Manager Lawrence Mulloy and the Marshall Problem Assessment Committee then placed a formal launch constraint on the Shuttle system, covering STS 51-F and every flight after it — including Challenger's STS 51-L. The Rogers Commission report of June 1986 disposes of what happened next in one sentence: “After the launch constraint was imposed, Project Manager Mulloy waived it for each Shuttle flight after July 10, 1985.” Questioned about it, Mulloy did not dispute the description: “So there was a launch constraint, and you waived it. — Yes, sir”. A decade later the U.S. General Accounting Office restated the count: “NASA solid rocket motor manager waived constraint to launch for six consecutive launches prior to Challenger.” NASA Levels I and II were unaware that either the constraint or the waivers existed.
Read one at a time, each waiver was a defensible local judgement about a single flight. Read as a series, six of them were a rule that had been deleted without anyone deciding to delete it. The people approving the releases could not see the pattern, because no artefact accumulated it. That is the failure mode a waiver register exists to prevent: not the first exception, but the sixth, granted by the same person against the same constraint, invisible to the level above.
Databases already model the time-limited waiver properly. PostgreSQL lets a constraint be added NOT VALID, and “this potentially-lengthy scan is skipped”. “The constraint will still be enforced against subsequent inserts or updates”, while the existing rows are left alone for now. The database “will not assume that the constraint holds for all rows in the table, until it is validated by using the VALIDATE CONSTRAINT option”. The exception stays visible in the catalogue with a name attached. A VALIDATE CONSTRAINT command is the only thing that closes it.
Exceptions should accumulate accountability, not normalize uncertainty.
Key takeaways
- Execution success, data correctness, and consumer fitness are distinct signals: Public Health England's load process reported no failure while 15,841 positive cases went unpublished between 25 September and 2 October 2020.
- Layered validation covers source contracts, pipeline invariants, dataset statistics, offline–online parity, and outcome impact, because a file-size truncation invisible to one layer is a row-count violation at the next.
- Blocking, quarantine, warning, and trend recording should reflect confidence, severity, reversibility, and freshness cost — Deequ draws the warn/error line at three versus four standard deviations from the running mean, and ships it as CheckLevel.Warning and CheckLevel.Error.
- Freshness measures the age of valid evidence for a consumer, not merely the time of the latest successful job.
- Data incidents require confirmation, containment, lineage-based diagnosis, validated correction, controlled backfill, and post-incident learning; the follow-up study measured the cost of a week's delay as a 7.9% secondary attack rate against 5.9%.
- Quality rules need scope, reference, threshold, severity, owner, consumer impact, exception policy, and lifecycle management — and the ECB's review of 25 significant institutions found the failing field is ownership, not measurement.