aeat.application.ledger._evidence_input module¶
In-memory evidence-input representation for on-host LLM reading.
A transient, in-process container for the decrypted bytes of a transaction’s attached evidence (a purchase invoice or a linked attachment), read from secure storage so an on-host reader – the in-tree text-layer or a local vision model – can consume it.
CRITICAL (sensitive-financial-data-secure-storage-only): this object holds
decrypted FINANCIAL bytes in process memory ONLY. It MUST NEVER be persisted,
serialized to disk, written to a temp file, embedded in a persisted document, or
logged. It carries no JSON serializer; EvidenceInput.model_dump and
EvidenceInput.model_dump_json are overridden to raise so a stray
persistence call fails loudly rather than leaking bytes out of secure storage. The
raw data field is excluded from repr for the same reason.
- cloud_evidence_read_permitted(settings, *, acknowledged)[source]¶
Whether an off-host cloud evidence read is permitted for THIS invocation.
On-host reading is always allowed and is the default; this gate governs only the cloud exception. A cloud read is permitted only when the
cloud_evidence_uploadcapability resolves enabled for the active profile AND the operator acknowledged the upload for this specific invocation.The capability resolution (
resolve_active_capability) is the single place the posture is computed: the gestor-mode bar is applied first and absolutely (aeat_evidence_gestor_mode), then the active profile’s opt-in/out fact, then — when no profile fact is set — the globalaeat_evidence_cloud_upload_permittedflag as the fallback default (so existing deployments behave unchanged until a profile sets the capability). A capability can only NARROW this floor, never widen it. The acknowledgement is never sticky – it must be re-affirmed each time (sensitive-financial-data-secure-storage-only).
- class EvidenceInput(**data)[source]¶
Bases:
BaseModelTransient in-memory evidence bytes plus the provenance needed to cite them.
Built by the resolver from evidence already held in secure storage. The bytes live only for the duration of a single on-host read; this model is never persisted (see the module docstring and the overridden dump methods).
- Variables:
media_kind – Whether the bytes are a PDF or an image.
mime_type – Concrete MIME type of the bytes (e.g.
application/pdf).data – The decrypted evidence bytes, in memory only. Excluded from
repr.content_sha256 – 64-character lowercase hex SHA-256 of
data; the content address the bytes were read under. Enforced to matchdata.evidence_id – Originating purchase-invoice
evidence_idwhen the bytes came from aPurchaseInvoiceEvidencerecord, elseNone.attachment_id – Originating
attachment_idwhen the bytes came from anAttachment, elseNone.
- Parameters:
- media_kind: MediaKind¶
- mime_type: str¶
- data: bytes¶
- content_sha256: str¶
- evidence_id: str | None¶
- attachment_id: str | None¶
- resolve_attachment_evidence_input(attachment_id, *, store)[source]¶
Read a linked attachment’s bytes from secure storage into an
EvidenceInput.Loads the attachment manifest and its encrypted blob from the
AttachmentStoreProtocol(active bucket) into memory. No file is written.- Parameters:
attachment_id (
str) – Content-addressed id of the linked attachment.store (
AttachmentStoreProtocol) – Attachment store bound to the operation’s secure-storage bucket.
- Returns:
In-memory bytes plus provenance, for an on-host read.
- Return type:
- resolve_purchase_invoice_evidence_input(evidence, *, store)[source]¶
Read a purchase-invoice evidence record’s bytes from secure storage.
Reads via the record’s
attachment_id– the in-store byte home written ataddtime. A record without anattachment_idpredates that contract and has no in-store bytes to read; this raises rather than falling back to the cleartextsource_path(sensitive-financial-data-secure-storage-only).- Parameters:
evidence (
PurchaseInvoiceEvidence) – The purchase-invoice evidence record.store (
AttachmentStoreProtocol) – Attachment store bound to the operation’s secure-storage bucket.
- Returns:
In-memory bytes plus provenance, for an on-host read.
- Return type:
- Raises:
PurchaseInvoiceEvidenceInputError – When the record carries no
attachment_id.