aeat.application.evidence._models module¶
Pydantic models for operator-facing evidence bundles.
An evidence bundle is a content-addressed manifest that groups related
persisted records (calculation revisions, filing records, and their
attached objects) under a single verifiable identity. The bundle’s
bundle_id is a SHA-256 hash of the canonical manifest inputs so it
is stable across re-imports of the same data and globally unique per
bucket + work-unit + manifest-version triple.
Key types:
EvidenceBundle— the persisted manifest record.EvidenceRecordRef— one record reference inside the manifest.BundleVerificationState— closed lifecycle states for offline bundle verification.derive_bundle_id()— content-addressed id derivation.
Bundle manifests reference work-unit, calculation-revision, and filing-record payloads without replacing those catalogues as the source of truth. Verification replays the manifest against supplied object bytes and reports reachability and digest results without contacting AEAT.
- exception EvidenceBundleNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
AeatErrorRaised when an evidence-bundle lookup misses by id.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception EvidenceBundleVerificationError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
AeatErrorRaised when bundle verification fails and the caller refuses
--force-incomplete.The verification service raises this when one or more
VerificationCheckitems fail and the operator has not passed an override flag that permits incomplete bundles.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class BundleVerificationState(*values)[source]¶
Bases:
StrEnumClosed lifecycle states for a
EvidenceBundle’s verification status.PENDINGis the initial state when a bundle is first written.VERIFIEDmeans allVerificationCheckitems passed.INCOMPLETEmeans reachability or digest checks found missing records but the operator accepted the partial bundle.FAILEDmeans at least one blocking integrity check failed.- PENDING¶
- VERIFIED¶
- INCOMPLETE¶
- FAILED¶
- class VerificationCheck(*values)[source]¶
Bases:
StrEnumNamed integrity checks a bundle’s offline verification pass runs.
Each member identifies one distinct check the verifier executes against the bundle manifest and the backing object store:
MANIFEST_DIGEST— recomputebundle_idand compare.RECORD_DIGESTS— re-hash each referenced object payload.BUCKET_BINDING— confirm the bundle’sbucket_idmatches the repository it was loaded from.WORK_UNIT_BINDING— confirm thework_unit_idexists.OBJECT_REACHABILITY— confirm every referenced object is present in the bucket’s object store.
- MANIFEST_DIGEST¶
- RECORD_DIGESTS¶
- BUCKET_BINDING¶
- WORK_UNIT_BINDING¶
- OBJECT_REACHABILITY¶
- class EvidenceBundleCheckResult(**data)[source]¶
Bases:
BaseModelOne
VerificationCheckoutcome from a bundle verification pass.passedisTruewhen the check succeeded.detailcarries a human-readable explanation when the check failed or when extra diagnostic context is available.- Parameters:
check (VerificationCheck)
passed (bool)
detail (str)
- check: VerificationCheck¶
- passed: bool¶
- detail: str¶
- class EvidenceRecordRef(**data)[source]¶
Bases:
BaseModelOne referenced record entry inside an
EvidenceBundlemanifest.object_typenames theBucketEventObjectTypeof the record;object_idis its stable store key;content_sha256is the SHA-256 hex digest of the record’s raw payload bytes;payload_size_bytesis the byte count used for completeness-ratio calculation.- Parameters:
object_type (BucketEventObjectType)
object_id (str)
content_sha256 (str)
payload_size_bytes (int)
- object_type: BucketEventObjectType¶
- object_id: str¶
- content_sha256: str¶
- payload_size_bytes: int¶
- class EvidenceBundle(**data)[source]¶
Bases:
BaseModelOne persisted evidence bundle.
The manifest is content-addressed by
bundle_id(SHA-256 of the canonical manifest payload). All record references carry their own content digest so bundle verification is offline-pure: given a bucket-scoped object store, a verifier can recompute digests and confirm reachability without contacting AEAT or any remote service.- Parameters:
bundle_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)])
manifest_version (int)
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
work_unit_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)])
calculation_revision_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)] | None)
filing_record_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)] | None)
records (tuple[EvidenceRecordRef, ...])
verification_state (BundleVerificationState)
completeness_ratio (float)
created_at (datetime)
notes (str)
- bundle_id: BundleId¶
- manifest_version: int¶
- bucket_id: BucketId¶
- work_unit_id: WorkUnitId¶
- calculation_revision_id: CalculationRevisionId | None¶
- filing_record_id: FilingRecordId | None¶
- records: tuple[EvidenceRecordRef, ...]¶
- verification_state: BundleVerificationState¶
- completeness_ratio: float¶
- created_at: datetime¶
- notes: str¶
- derive_bundle_id(*, bucket_id, work_unit_id, manifest_version, records, calculation_revision_id=None, filing_record_id=None)[source]¶
Compute the content-addressed
bundle_idfor canonical inputs.The digest covers manifest version, bucket id, work-unit id, optional calculation revision id, optional filing record id, and the ordered
EvidenceRecordRefobject type/id/content-digest triples.
- utcnow()[source]¶
Return the current UTC timestamp via
core.time.now().- Return type: