Available on crate feature
contract only.Expand description
Data contracts (issue #204): a declarative, versioned schema + semantic
contract for a pipeline’s output — required fields, types, nullability,
enum sets, regex patterns, numeric/length bounds — enforced per page after
transforms and quality checks and before the sink write. Breaches fail,
quarantine (via the DLQ), or warn per the contract-level policy.
Pure evaluation; the pipeline wires DLQ routing and metrics in
run_stream / instrumented_apply_contract.
Modules§
- compile
- Compile a
ContractSpecinto aCompiledContract: validate the version, field-name uniqueness, per-type constraint compatibility, and bounds, and compile regexes/enum sets once so the per-record pass is cheap. Failures surface asFaucetError::Configat config-load time, never mid-run. - config
- Config-shaped types for the data-contract layer (issue #204). Pure
declarations — validation and compilation live in
compile.rs, evaluation in the module root. - export
- Machine-readable contract exports: JSON Schema and an OpenLineage
SchemaDatasetFacet. Pure functions over aContractSpec— no I/O. Used byfaucet contract --export …; available to library callers too.
Structs§
- Compiled
Contract - A fully compiled contract. Built once via
CompiledContract::compile. - Compiled
Field - One compiled field rule.
- Contract
Outcome - Result of applying the contract pass to one page.
- Contract
Spec - The
contract:config block: a declarative, versioned schema + semantic contract for a pipeline’s output, enforced per page after transforms and quality checks and before the sink write. - Contract
Violation - One observed contract breach.
- Field
Contract - One promised top-level field: its type plus optional semantic constraints.
- Violating
Record - A record removed from the page by a
quarantinebreach, destined for the DLQ.
Enums§
- Contract
Field Type - Declared type of a contract field.
- OnBreach
- What to do when a record breaches the contract. Contract-level (not per-field): a contract is a single versioned promise, so one policy governs every rule in it.
Constants§
- OPENLINEAGE_
SCHEMA_ FACET_ URL - Pinned OpenLineage
SchemaDatasetFacetschema URL used byto_openlineage_facet.
Functions§
- apply_
contract - Apply the contract to one page. Pure: no metrics, no DLQ I/O.
- to_
json_ schema - Render the contract as a standalone JSON Schema (draft 2020-12) document.
- to_
openlineage_ facet - Render the contract as an OpenLineage
SchemaDatasetFacet— the same facet shapefaucet-lineageattaches to dataset events, so downstream OpenLineage consumers can ingest the contract as a schema promise.