fraudtwin.contracts#
Versioned data contracts and schema access.
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. |
Detailed API#
Bundled Avro contracts for observable operational events.
- class fraudtwin.contracts.AvroContractRegistry(root, compatibility, subjects)[source][source]
Bases:
objectParsed source-controlled registry and its Avro schemas.
- Parameters:
root (Path)
compatibility (str)
subjects (tuple[ContractSubject, ...])
- 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])
- decode(subject, payload)[source][source]
Decode one payload using the latest subject schema.
- Return type:
dict[str,Any]- Parameters:
subject (str)
payload (bytes)
- encode(subject, record)[source][source]
Encode one observable datum using the latest subject schema.
- Return type:
bytes- Parameters:
subject (str)
record (BaseModel | Mapping[str, Any])
- class fraudtwin.contracts.AvroDatumMapper(registry)[source][source]
Bases:
objectMap domain records to and from one loaded observable contract registry.
- Parameters:
registry (AvroContractRegistry)
- decode(subject, payload)[source][source]
Decode one payload using the latest subject schema.
- Return type:
dict[str,Any]- Parameters:
subject (str)
payload (bytes)
- exception fraudtwin.contracts.ContractValidationError[source][source]
Bases:
ValueErrorRaised when registry metadata or an Avro contract is invalid.
- class fraudtwin.contracts.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.contract_registry(path=None)[source][source]
Load and validate a registry in one call.
- Return type:
AvroContractRegistry- Parameters:
path (str | Path | None)