cadrumo.domain.attachments.models module¶
Strict immutable attachment-manifest model.
- normalize_media_type(value)[source]¶
Return the canonical MIME token without display-only parameters.
Manifests preserve their original, trimmed MIME value as provenance. Content classification instead compares this normalized token, so case and valid parameters cannot change an evidence boundary’s meaning.
- is_link_only_mime_type(value)[source]¶
Return whether
valuenames the link-only URI-list media type.MIME syntax permits a parameter section (
type/subtype; param=value), so the comparison is against the parsed media type — the token before any;— not the full string.text/uri-list; charset=utf-8is as link-only as the bare form and must be refused by every boundary that guards evidence-byte manifests.
- class Attachment(**data)[source]¶
Bases:
BaseModelImmutable attachment manifest tying bytes to transactions and invoices.
Each attachment is content-addressed:
attachment_idis the SHA-256 of the stored bytes, and the model enforces thatattachment_id == sha256so the manifest cannot drift from the byte payload it references.The manifest also records the originating channel (
domain.attachments.enums.AttachmentSource), the document kind (domain.attachments.enums.AttachmentKind), and optional cross-references back to transaction and invoice identifiers so the evidence layer is traversable in either direction.- Variables:
attachment_id – 64-character lowercase hex SHA-256 digest. Equals
sha256.kind – Document kind. See
domain.attachments.enums.AttachmentKind.source – Channel the bytes were captured from. See
domain.attachments.enums.AttachmentSource.source_reference – Channel-specific reference (e.g. a Gmail message id, a Drive file id, a local path).
sha256 – 64-character lowercase hex SHA-256 of the stored bytes.
mime_type – Trimmed non-empty MIME type string.
bytes_size – Size in bytes of the stored payload.
captured_at – Timezone-aware capture timestamp.
linked_transaction_ids – Transaction identifiers this attachment supports.
linked_invoice_ids – Invoice identifiers this attachment supports.
bucket_id – Owning profile bucket for secure evidence attachment.
captured_by – Actor that captured or imported the evidence when known.
source_command – Backend/CLI command source that captured it when known.
metadata – Frozen string-to-string mapping for channel-specific metadata.
notes – Free-form trimmed notes; the empty string is allowed.
- Parameters:
data (Any)
- attachment_id: Hex64Str¶
- kind: AttachmentKind¶
- source: AttachmentSource¶
- source_reference: str¶
- sha256: ContentDigest¶
- mime_type: str¶
- bytes_size: NonNegativeInt¶
- captured_at: UtcInstant¶
- linked_transaction_ids: tuple[str, ...]¶
- linked_invoice_ids: tuple[str, ...]¶
- bucket_id: BucketId | None¶
- captured_by: str | None¶
- source_command: str | None¶
- metadata: Mapping[str, str]¶
- notes: str¶