Chapter 1 · Frame and baseline

Data contracts, ownership, lineage, and quality

A data contract is a shared operational promise about meaning, time, quality, and response—not a list of column types.

65–90 min4 key conceptsReviewed 26 Aug 2026
01 · Production proposition

A late feature silently corrupts every downstream prediction.

This chapter moves from write semantic promises to attach lineage to releases. We will make the idea concrete in a small code example before placing it back inside a production system with a declared latency, cost, and operator-capacity budget.

Decision

Persist source and transform identities with training sets, feature materializations, models, and predictions.

Evidence

Verify the behavior illustrated in transactions.contract.yaml, then measure decision utility, slice reliability, and system latency.

Failure consequence

A backfill uses corrected future knowledge and silently inflates offline AUC. An unsafe release must degrade to a named baseline or the last known-good version.

02 · Guided chapter

Build the idea one layer at a time.

A table can keep the same columns while its meaning quietly changes. A production data contract protects semantics as well as types: who owns the data, when it becomes available, what each value means, how quality is measured, and which consumers are at risk.

Schema validation catches a missing column or incompatible type, but it cannot infer that cents became dollars or that a status is now written before human review. Contracts add units, keys, null rules, freshness, event and availability time, acceptable ranges, and compatibility policy. Ownership turns a failed check into an actionable incident rather than an orphaned alert.

Lineage connects a prediction back through features, source snapshots, transformations, and code. Quality rules should sit at meaningful boundaries: producer checks protect source truth, transformation checks protect derived invariants, and consumer checks protect the assumptions a model actually uses.

Keep in view
  • Kafka
  • Flink/Spark
  • Parquet/lakehouse
  • watermarks
WORKED PATH

Follow the reasoning before touching the code.

  1. 01

    Write semantic promises

    For each field, state meaning, unit, key, temporal semantics, null behavior, and allowed evolution—not only its storage type.

  2. 02

    Assign boundaries and owners

    Name who detects, triages, fixes, approves exceptions, and communicates blast radius for each contract.

  3. 03

    Attach lineage to releases

    Persist source and transform identities with training sets, feature materializations, models, and predictions.

yamltransactions.contract.yaml
dataset: transactions
owner: [email protected]
primary_key: [transaction_id]
fields:
  amount_cents:
    type: integer
    minimum: 0
    unit: USD_cents
  available_at:
    type: timestamp
freshness: 15m
on_incompatible_change: quarantine

A compact contract carries semantics and response ownership

READ THE EXAMPLE

What to notice

  • The unit makes a physically valid but semantically wrong dollars-to-cents change detectable in review and tests.
  • Quarantine is an explicit behavior; silent coercion would let corrupted rows spread to every downstream artifact.
YOUR TURN Pause and predict before revealing the answer.

A producer begins sending refunds as negative amount_cents. Which parts of the contract and system must change before accepting it?

Need a hint?

Consider range, semantic meaning, downstream aggregates, compatibility, and ownership.

Check your reasoning

Revise the amount semantics and minimum, version the contract, test every consumer that assumed nonnegative purchases, backfill deliberately, and obtain producer and consumer approval before promotion.

Bring forward

Data & features, GPU training

03 · Formal treatment

Connect the chapter to the course’s quantitative spine.

A data contract is a shared operational promise about meaning, time, quality, and response—not a list of column types. The point-in-time feature lookup below is the shared course-level lens that helps quantify the surrounding system. Name each symbol, check its units or shape, and use only values that were available at the production cutoff.

Formal treatment
fj(tp)=value⁡ ⁣(arg max⁡etevent(e))subject to tevent(e), tavailable(e)≤tpf_j(t_p) = \operatorname{value}\!\left(\operatorname*{arg\,max}_e t_{\mathrm{event}}(e)\right) \quad \text{subject to } t_{\mathrm{event}}(e),\,t_{\mathrm{available}}(e) \le t_p

Point-in-time feature lookup

Symbol, shape or unit contract
SymbolMeaning / shape / unit
jentity
t_phistorical prediction time
eeligible event
Open derivation and numerical substitution

Start from the production quantity being optimized, substitute the observed values with their declared units, then isolate the model-controlled term. Preserve shape annotations at each step so broadcasting or aggregation cannot silently change the result.

  1. Write the named inputs: j, t_p, e.
  2. Substitute one small, hand-checkable batch before vectorizing.
  3. Calculate an independent reference value and compare within a declared tolerance.
# equation → code contract
inputs = validate_shapes_and_units(batch)
value = compute_c17(inputs)
assert is_finite(value)
04 · Deterministic lab

Change one assumption and make the tradeoff visible.

Use the worked chapter as your prediction, then change one input in the lab and explain why the output moves. The lab runs predefined TypeScript and never executes learner code, so the focus stays on the concept rather than setup.

Exact computation

Point-in-time freshness lab

Delay feature arrival and see which historical rows remain eligible.

h
Primary4/5 eligible
Secondary6 h watermark
DiagnosisWithin SLA

Assumption: Five events have fixed prediction cutoffs separated by six hours.

Open nonvisual data table
ItemComputed stateInterpretation
row 1cutoff +0hnot yet knowable
row 2cutoff +6heligible
row 3cutoff +12heligible
row 4cutoff +18heligible
row 5cutoff +24heligible
05 · Production implications

Trace the complete operating path.

Carry the chapter’s central idea into the system: A data contract is a shared operational promise about meaning, time, quality, and response—not a list of column types. The path below shows where that reasoning needs an artifact, a test, an owner, or a fallback.

  1. 01

    Turn “Write semantic promises” into a written invariant and a failing test.

  2. 02

    Promote transactions.contract.yaml from illustration to a versioned implementation with representative fixtures.

  3. 03

    Use “Attach lineage to releases” as the release checkpoint: Persist source and transform identities with training sets, feature materializations, models, and predictions.

  4. 04

    Serve or materialize behind explicit a declared latency, cost, and operator-capacity budget.

  5. 05

    Join telemetry to mature outcomes and retain a rollback path.

Observability

Join service health, input quality, prediction distributions, slice behavior, and mature outcomes by exact version.

Cost

Measure storage, preprocessing, compute, queueing, and human review under a representative arrival pattern.

Failure modes

A backfill uses corrected future knowledge and silently inflates offline AUC. Add a detector, owner, mitigation, and stop condition for this class of failure.

Alternatives

Compare a rule, a simpler statistical baseline, and a different system boundary before adding model complexity.

06 · Check understanding

Explain the contract, not just the vocabulary.

Browser-graded checkpointPass ≥ 80%
01Why constrain event and availability time?
02What should offline and online features share?
03What should incompatible schema change do?
07 · Apply in production

Local mini ML platform

Specify idempotent events, a point-in-time join, shared feature definition, quality gates, lineage, and model registration.

  • Data contract
  • Late-event semantics
  • Feature parity design
  • Lineage/registry record
Open assignment and rubric
08 · Sources & next depth

Read primary material with a purpose.

09 · Production resolution

Return to the opening failure.

Make temporal correctness, ownership, lineage, reproducibility, and escape hatches the platform defaults.

For this lesson, the release evidence is the worked code example, a hand-checked formal result, deterministic simulation output, a ≥80% checkpoint, the production rubric, and a named fallback. The course resolves when the system can produce a traced batch/stream platform with orchestration, registry, lineage, and ownership.