Data Contracts: Enforcing Data Quality at the Producer Boundary
Jul 2026 · Data GovernanceMost data-quality programs I've seen start the same way. A dashboard shows garbage, someone traces it back through a chain of transformations, and the team adds more tests in the warehouse. Those tests catch the next bad value, but only after it has landed three layers down. A data contract puts the check where the producer works, so bad data gets blocked before anyone reads it.
It's easiest to show with one change, followed from the commit to the dashboard. The example below is made up, but every step in it is ordinary.
One schema change, followed downstream
On Monday afternoon an engineer on the orders service adds a new order status, refunded. Until now a refunded order was marked cancelled. The change is small, the service's own tests pass, and it ships. Nobody outside that team hears about it, because from their side nothing broke.
That night the ingestion job copies the new rows into the warehouse. status is still a string, so the schema check passes.
On Tuesday the transformation models run. The revenue mart subtracts cancelled orders from gross sales, and it has no rule for refunded, so those orders now count as sales. The warehouse tests pass too. There are no nulls, the IDs are unique and no timestamp is in the future.
By Thursday the weekly revenue dashboard is up a little, and someone in finance asks why. An analyst spends most of a day tracing the number back through the mart, the staging model and the raw table before finding the new value. The fix needs the producer to explain what refunded means and the data team to update the mart and backfill the week. If a churn model trained on that week, it picked up the bad numbers as well.
On Monday the same problem was a five-minute conversation.
That's the pattern with data defects. The further a bad value travels and the more tables use it, the more it costs to fix. Most teams know this, but the default setup still puts every quality gate at the far end of the pipeline.
Where a contract would have stopped it
A contract on the orders data lists the allowed values for status. Adding refunded changes the contract, and the contract's change policy says a new value needs a version bump and a notice to the teams that read the data. How early the change gets caught depends on where the check runs.
If it runs in the orders service's CI, the commit fails on Monday afternoon and the engineer sees it before merging. That's the strongest spot. It's also the hardest to get, because the producing team has to own the contract as part of their job, and that's mostly an org problem.
If it runs at ingestion, the new rows get quarantined Monday night. The bad rows still exist, but they stop at the warehouse door, ahead of the mart and the dashboard. Most teams can start here.
If it runs as dbt (or similar) assertions in the transformation layer, the build fails on Tuesday. This is closest to the old downstream tests and the easiest to set up. With an owner and a change policy behind it, it's still a big step up from a loose pile of tests. But the rows have landed by then, so I wouldn't stop there.
In all three cases the check has to block. If a failed check only posts a warning to a dashboard nobody owns, Thursday's meeting happens anyway.
What goes in a contract
A schema tells you the shape of the data. A contract adds what the fields mean, which values are allowed and what happens when the producer wants to change any of it.
| Part | What it says | In the example |
|---|---|---|
| Schema | Field names, types and nullability | status is a string and never null. This passed every time. |
| Meaning | What each field stands for and which values are allowed | status is one of a fixed list, and closed and cancelled are different things |
| Quality thresholds | Limits the producer commits to, checked on every load | A value in at least 99.9% of rows, unique IDs, no timestamps in the future |
| Change policy | Which changes are backward-compatible and which need notice first | A new status value needs a version bump |
The schema is usually the only part a team writes down. The change policy is the part teams forget most, and it's the part that would have caught refunded. Without it, a contract is a description that goes out of date the first time the producer ships something.
I've written about the same failure from the intake side. In my post on customer MDM intake, the trouble was free-text fields and a portal that let bad records in before any platform could reject them. A contract applies that idea to every producer, with one check between the systems that write data and the ones that read it.
How I'd roll it out
I wouldn't write contracts for every dataset at once as a top-down mandate. When a central team writes contracts for data it doesn't produce, those contracts go stale the first time a producer changes something.
I'd pick the two or three sources behind the worst repeat incidents and write each contract with the producer in the room, so the thresholds are ones the source can meet. Make the check blocking wherever you can today, even if that's only at ingestion. Then keep track of the incidents that stop. That's what gets other teams asking for contracts, much more than a memo from a steering committee. I saw the same thing in a data-stewardship rollout, where the work that stuck was the work someone downstream had asked for.
Classification and AI
A contract is also a good place to check classification. It can say that a column tagged as PII stays tagged and keeps its sensitivity class, so a producer can't change what the field holds without anyone noticing. Access control depends on that. The attribute-based policies in my post on moving from Unity Catalog grants to ABAC are only as good as the tags under them.
AI makes the gap wider. A retrieval or feature pipeline takes in every bad value from its sources without raising an error, and a language model will reason over a malformed value as readily as a clean one. In the example, a model asked about last week's revenue would have given the inflated number. I argued in the data dictionary post that unmanaged definitions spoil retrieval. Contracts keep the values inside what those definitions promise. Once agents act on retrieved data, fewer people sit downstream to catch a bad input, so the producer is the last good place to stop it.
When a contract isn't worth it
- A source that feeds one or two tables, owned by the same team that produces it, is cheap to fix downstream. A contract there is mostly overhead.
- Producers who won't take on the check leave you with ingestion-level contracts. Those still help, but you lose the Monday-afternoon catch.
- Some fields change their allowed values on purpose all the time, like campaign codes that marketing creates every week. A fixed list would block good data over and over, and a format check fits better.
Data & AI governance, from the field
Notes on data governance that works in practice, plus my free RFP & TCO scorecard when you sign up.
No spam, unsubscribe anytime · Privacy
You're in. Check your inbox for a welcome note.