cadrumo.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, translated_message=None)[source]¶
Bases:
CadrumoErrorRaised when an evidence-bundle lookup misses by id.
- Parameters:
- Return type:
None
- code¶
- exception EvidenceBundleVerificationError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorRaised 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¶
- 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:
data (Any)
- check: VerificationCheck¶
- passed: bool¶
- detail: _CheckDetail¶
- 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 canonicalContentDigestof the record’s raw payload bytes, so a non-hex digest is refused on construction rather than at the later verification pass that recomputes it;payload_size_bytesis the byte count used for completeness-ratio calculation.- Parameters:
data (Any)
- object_type: BucketEventObjectType¶
- object_id: str¶
- content_sha256: ContentDigest¶
- payload_size_bytes: NonNegativeInt¶
- 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:
data (Any)
- bundle_id: Hex64Str¶
- 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: UnitFraction¶
- created_at: datetime¶
- notes: EvidenceBundleNotes¶
- 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.