cadrumo.adapters.persistence.profile.filing_drafts module¶
Governed-persistence repository for filing drafts.
ModeloDraft records carry exact casilla
arithmetic and tax due values. They are stored as encrypted byte objects via
SecureObjectRepository at
FINANCIAL SensitivityClass and
serialised through an Envelope by
SecureBoundRepository; no plaintext
draft JSON or envelope file lands on disk.
This concrete repository lives in the persistence adapter (not in
domain.filing) because its
SecureBoundRepository base is
SQL/crypto-coupled; the domain package owns the typed
ModeloDraft payload.
See also
ModeloDraftStrict filing payload persisted by this repository.
SecureBoundRepositoryGeneric encrypted-envelope repository base used for the draft store.
adapters.persistence.storage.secure_object_namespaces.FILING_DRAFTS_NAMESPACENamespace, sensitivity, schema-version, object-key, and custody contract for draft secure objects.
application.filingApplication review flow that reads and updates persisted drafts.
- class ModeloDraftRepository(*, bucket_id=None, objects=None)[source]¶
Bases:
SecureBoundRepository[ModeloDraft]Encrypted FINANCIAL repository for
ModeloDraftpayloads.The
SecureBoundRepositorybase wraps each draft in anEnvelopeand writes it underadapters.persistence.storage.secure_object_namespaces.FILING_DRAFTS_NAMESPACE. The draft id is the natural key, so list and iteration APIs expose draft aggregates rather than submission or amendment records. The namespace definition supplies theFINANCIALSensitivityClass, schema version, object-key grammar, and custody contract.- Parameters:
bucket_id (str | None)
objects (SecureObjectRepository | None)
- namespace: ClassVar[str]¶
- sensitivity: ClassVar[SensitivityClass]¶
- schema_version: ClassVar[int]¶
- classmethod payload_model()[source]¶
Return the
ModeloDraftencrypted payload model for filing drafts.- Return type:
- extract_identifier(payload)[source]¶
Return the natural id for
payload(used as the SQL object key).Subclasses MUST override. The base implementation raises
NotImplementedError.- Return type:
- Parameters:
payload (ModeloDraft)
- save(payload)[source]¶
Persist
payloadafter confirmingdraft_idis its content address.draft_idis documented as a hash over the draft’s modelo, period, taxpayer, registry snapshot, casilla values, and binding values, andcompute_modelo_draft_id()is its sole canonical derivation — but nothing recomputed it, so an arbitrary, blank, whitespace, or stale id was persisted and reloaded unchanged and a stored draft could claim an identity that was not its own content. Two different drafts could then occupy one row, or one draft two rows.The check lives here rather than on the model because the id is a durable claim: an in-memory draft may legitimately carry a caller-chosen handle while its content is still being assembled, but once written it is the natural key this repository files it under and every later reader resolves it by.
- Parameters:
payload (
ModeloDraft) – TheModeloDraftaggregate to persist under its own content-addresseddraft_id.- Raises:
FilingValidationError –
draft_idis not the content address the canonical helper derives for this draft.- Return type:
- to_secure_object_write(payload, *, expected_revision_id=None)[source]¶
Prepare the same identity-preserving encrypted payload as
save().Core types:
ModeloDraft.- Return type:
- Parameters:
payload (ModeloDraft)
expected_revision_id (str | None)
- iter_drafts()[source]¶
Yield every persisted
ModeloDraft, in lexicographic id order.- Return type: