fraudtwin.contracts.registry#
Versioned Avro contract validation and mapping.
Status: Stable
Classes#
|
Parsed source-controlled registry and its Avro schemas. |
|
Map domain records to and from one loaded observable contract registry. |
|
Summary returned after validating a complete registry. |
Exceptions#
|
Raised when registry metadata or an Avro contract is invalid. |
Functions#
|
Load and validate a registry in one call. |
|
Return the bundled registry path in a checkout or installed wheel. |
|
Load registry metadata and parse every declared Avro schema. |
|
Validate one mapped datum with Apache Avro's implementation. |
Detailed API#
Avro contract loading, compatibility checking, and observable mapping.
The M8 fraudtwin.schema helpers intentionally remain separate: those
helpers model data-quality schema faults, while this module validates the
clean observable contracts that a future M25 producer will publish.
- class fraudtwin.contracts.registry.AvroContractRegistry(root, compatibility, subjects)[source][source]
Bases:
objectParsed source-controlled registry and its Avro schemas.
- Parameters:
root (Path)
compatibility (str)
subjects (tuple[ContractSubject, ...])
- mapper()[source][source]
Return the explicit datum mapper for this registry.
- Return type:
AvroDatumMapper
- validate()[source][source]
Validate metadata, canonical fingerprints, and full compatibility.
- Return type:
RegistryReport
- datum(subject, record)[source][source]
Convert a domain record to a clean observable Avro datum.
Latent truth fields are never copied, even when present on the source model. Values are converted to Avro logical Python values (
datetimeandDecimal) without mutating the source model.- Return type:
dict[str,Any]- Parameters:
subject (str)
record (BaseModel | Mapping[str, Any])
- class fraudtwin.contracts.registry.AvroDatumMapper(registry)[source][source]
Bases:
objectMap domain records to and from one loaded observable contract registry.
- Parameters:
registry (AvroContractRegistry)
- to_datum(subject, record)[source][source]
Return a validated observable Avro datum for
subject.- Return type:
dict[str,Any]- Parameters:
subject (str)
record (BaseModel | Mapping[str, Any])
- exception fraudtwin.contracts.registry.ContractValidationError[source][source]
Bases:
ValueErrorRaised when registry metadata or an Avro contract is invalid.
- class fraudtwin.contracts.registry.RegistryReport(path, subjects, versions, fingerprints)[source][source]
Bases:
objectSummary returned after validating a complete registry.
- Parameters:
path (Path)
subjects (int)
versions (int)
fingerprints (dict[str, str])
- fraudtwin.contracts.registry.contract_registry(path=None)[source][source]
Load and validate a registry in one call.
- Return type:
AvroContractRegistry- Parameters:
path (str | Path | None)
- fraudtwin.contracts.registry.default_registry_path()[source][source]
Return the bundled registry path in a checkout or installed wheel.
- Return type:
Path