cadrumo.domain.modelos.protocols module¶
Domain-level repository Protocols for the modelos aggregate.
Application-layer code that persists or loads modelo work-unit catalogues, filing records, calculation results, or verification reports depends on these Protocols, not on the concrete adapter-backed repository classes. This keeps the domain layer free of adapter imports while still providing typed port surfaces.
The calculation-revision, filing-record, and verification-report protocols
return CalculationRevisionCatalogue, ModeloRecordCatalogue,
and VerificationReportCatalogue instances while keeping application
code independent of concrete storage adapters. The work-unit port is defined
directly in work_unit_repository.
- class CalculationRevisionCatalogueRepositoryProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow domain-facing repository contract for calculation revisions.
Any object that provides
exists,load, andsaveover a per-bucketCalculationRevisionCataloguesatisfies this protocol. The concrete secure-object-backed implementation isCalculationRevisionCatalogueRepository.- exists()[source]¶
Return whether a calculation-revision catalogue object has been persisted.
- Return type:
- load()[source]¶
Return the persisted catalogue or an empty catalogue if absent.
- Return type:
- Returns:
The
CalculationRevisionCatalogueloaded from storage.
- load_revisioned()[source]¶
Return the catalogue together with its current persistence revision.
Co-commit callers must carry this revision into their guarded write so rebuilding the singleton catalogue cannot overwrite a concurrent calculation revision.
- Return type:
- save(catalogue)[source]¶
Persist
catalogueas the encrypted singleton object.- Return type:
- Parameters:
catalogue (CalculationRevisionCatalogue)
- to_secure_object_write(catalogue, *, expected_revision_id=None)[source]¶
Return the
SecureObjectWriteforcataloguewithout committing it.expected_revision_idis the compare-and-swap half. These catalogues are SINGLETON rows, so a co-commit composed from an unguarded read writes the whole row back and discards any entry another caller added in between. It is declared HERE, not only on the concrete repository, because a caller typed against this protocol could otherwise not pass it at all – the guard existed and was unreachable.- Return type:
- Parameters:
catalogue (CalculationRevisionCatalogue)
expected_revision_id (str | None)
- save_with_secure_object_writes(catalogue, extra_writes, *, expected_revision_id=None)[source]¶
Persist
catalogueplus co-emitted secure-object writes atomically.- Return type:
- Parameters:
catalogue (CalculationRevisionCatalogue)
extra_writes (tuple[SecureObjectWrite, ...])
expected_revision_id (str | None)
- class ModeloRecordCatalogueRepositoryProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow domain-facing repository contract for modelo filing records.
Any object that provides
exists,load, andsaveover a per-bucketModeloRecordCataloguesatisfies this protocol. The concrete secure-object-backed implementation isModeloRecordCatalogueRepository. The loaded catalogue supports member-scopedcurrent_forandhistory_forlookups for grupo fan-in filings.- load()[source]¶
Return the persisted
ModeloRecordCatalogueor an empty catalogue if absent.- Return type:
- load_revisioned()[source]¶
Return the catalogue and secure-object revision for guarded co-commit.
- Return type:
- save(catalogue)[source]¶
Persist
catalogueas the encrypted singleton object.- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
- mutate(mutation)[source]¶
Apply
mutationto the stored catalogue as one revision-guarded unit of work.On the port because the application needs it: the catalogue is a singleton row, so stamping one record rewrites every other, and doing that through
savediscards whatever a concurrent caller wrote.- Return type:
- Parameters:
mutation (Callable[[ModeloRecordCatalogue], ModeloRecordCatalogue])
- to_secure_object_write(catalogue, *, expected_revision_id=None)[source]¶
Return the
SecureObjectWriteforcataloguewithout committing it.expected_revision_idis the compare-and-swap half. These catalogues are SINGLETON rows, so a co-commit composed from an unguarded read writes the whole row back and discards any entry another caller added in between. It is declared HERE, not only on the concrete repository, because a caller typed against this protocol could otherwise not pass it at all – the guard existed and was unreachable.- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
expected_revision_id (str | None)
- save_with_secure_object_writes(catalogue, extra_writes, *, expected_revision_id=None)[source]¶
Persist
catalogueplus co-emitted secure-object writes atomically.- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
extra_writes (tuple[SecureObjectWrite, ...])
expected_revision_id (str | None)
- class VerificationReportCatalogueRepositoryProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow domain-facing repository contract for verification reports.
Any object that provides
exists,load, andsaveover a per-bucketVerificationReportCataloguesatisfies this protocol. The concrete secure-object-backed implementation isVerificationReportCatalogueRepository.- exists()[source]¶
Return whether a verification-report catalogue object has been persisted.
- Return type:
- load()[source]¶
Return the persisted catalogue or an empty catalogue if absent.
- Return type:
- Returns:
The
VerificationReportCatalogueloaded from storage.
- save(catalogue)[source]¶
Persist
catalogueas the encrypted singleton object.- Return type:
- Parameters:
catalogue (VerificationReportCatalogue)
- class TransactionParticipationIndexRepositoryProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow domain-facing repository contract for the participation index.
The participation index is a per-transaction, derived-and-rebuildable read-side cache mapping a ledger transaction to the calculation revisions it participates in. Unlike the singleton catalogue repositories, its objects are keyed by
transaction_id. Any object that providesexists,load, andsaveover aTransactionRevisionParticipationIndexsatisfies this protocol; the concrete secure-object-backed implementation isTransactionParticipationIndexRepository. Lifecycle correctness never depends on this cache’s freshness — it is rebuilt from the revision catalogue — so the port is a navigation/read seam, not a source of truth.- exists(transaction_id)[source]¶
Return whether a participation-index object exists for
transaction_id.
- load(transaction_id)[source]¶
Return the persisted index for
transaction_idor an empty index if absent.- Return type:
- Parameters:
transaction_id (str)
- save(index)[source]¶
Persist
indexas the encrypted per-transaction object.- Return type:
- Parameters: