aeat.domain.attachments package

Public facade for content-addressed attachment evidence.

This package owns the immutable Attachment manifest and in-memory AttachmentCatalogue records used by ledger and filing evidence flows. Each manifest is keyed by the stored bytes’ SHA-256 (attachment_id == sha256) and records AttachmentKind, AttachmentSource, the source reference, MIME type, byte size, capture timestamp, owning bucket, linked transaction/invoice ids, metadata, and notes. Link-only URI-list manifests are rejected: an attachment evidence record must represent document bytes, not an external pointer.

Persistence is a protocol boundary. Domain helpers accept an AttachmentStoreProtocol; the concrete adapters.persistence.storage.AttachmentStore lives in the adapter layer and stores encrypted blob rows plus manifest adapters.persistence.storage.Envelope rows through adapters.persistence.storage.SecureObjectRepository at FINANCIAL adapters.persistence.storage.SensitivityClass. This package does not own a plaintext or on-disk repository implementation.

Service helpers add_attachment() and add_attachment_bytes() hash file or in-memory bytes, write them through the supplied store, build the manifest, and persist it; load_attachment() and list_attachments() read manifests back through the same protocol. link_attachment_invoice() re-persists an already-stored manifest with an invoice id appended to Attachment.linked_invoice_ids, for the case where the invoice is minted only after the evidence is already captured (e.g. confirming an extracted invoice draft). DocumentLinkSource narrows operator doclink channels, but a document link must be resolved to bytes before add_attachment_bytes(); there is no link-only attachment path.

Callers must import public models, errors, enums, protocols, and service helpers from aeat.domain.attachments and must not reach into private underscore modules inside this package.

See also

application.ledger

Ledger lifecycle that verifies attachment existence, byte custody, and bucket ownership before a transaction claims attachment evidence.

domain.invoices

Purchase-invoice evidence records that remain distinct from generic encrypted attachment bytes while sharing ledger evidence workflows.

application.aggregation

Calculation-source and evidence-advisory surfaces that consume transaction evidence links without reading plaintext files from disk.

adapters.persistence.storage

Secure-object and encrypted blob storage that implements AttachmentStoreProtocol.

Submodules