promptdojo_

Dataset schema validation — reject, quarantine, and the receipt rule — step 7 of 8

Claims need receipts: the extraction contract

Everything in this lesson so far validated the shape of records: right fields, right types, values in range. There's one more thing a schema should demand when the records come from AI reading your documents — and it's the difference between a dataset you can defend and a pile of assertions.

Every extracted claim carries its receipt. Four provenance fields, attached to the claim itself:

  • source — which document the claim came from
  • excerpt — the actual quoted text that supports it
  • timestamp — when the extraction ran (documents change; a claim extracted in March may be stale by September)
  • confidence — the model's own uncertainty, kept visible instead of discarded

The editor shows the contract as a plain validation pass: list the required fields, reject any record that's missing one. Same [f for f in REQUIRED if f not in record] move you've used all chapter — pointed at provenance instead of types.

Why this belongs in the schema, not in your memory

If provenance is optional, it disappears. The model returns a claim without an excerpt, your pipeline shrugs, and three weeks later someone asks "where did this number come from?" and the honest answer is the model said so. That answer ends careers in some rooms.

Making the fields required in the schema moves the enforcement from human discipline to code. A claim without a receipt doesn't get a warning — it gets rejected at the boundary, the same way a malformed record does. The schema eats the policy.

Two honest caveats:

  1. confidence is the model's guess about itself, not a measurement. Treat it as a sorting key for which claims a human checks first, never as permission to skip checking.
  2. An excerpt proves the claim matches the document, not that the document is right. Provenance gives you a trail to audit — it doesn't audit for you.

Run the editor, then delete the "excerpt" line and run it again. Watch the record bounce. That rejection is the contract working.