Skip to main content

Module contract

Module contract 

Source
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 ContractSpec into a CompiledContract: 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 as FaucetError::Config at 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 a ContractSpec — no I/O. Used by faucet contract --export …; available to library callers too.

Structs§

CompiledContract
A fully compiled contract. Built once via CompiledContract::compile.
CompiledField
One compiled field rule.
ContractOutcome
Result of applying the contract pass to one page.
ContractSpec
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.
ContractViolation
One observed contract breach.
FieldContract
One promised top-level field: its type plus optional semantic constraints.
ViolatingRecord
A record removed from the page by a quarantine breach, destined for the DLQ.

Enums§

ContractFieldType
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 SchemaDatasetFacet schema URL used by to_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 shape faucet-lineage attaches to dataset events, so downstream OpenLineage consumers can ingest the contract as a schema promise.