cadrumo.application.review.source_adapters module¶
Read-only source projections for the unified review queue.
Each projection reads one application-owned source capability and emits a tuple
of typed ReviewItem records. Projections are pure and stateless; they
tolerate missing source records by returning an empty tuple. Severity is
derived per source via a first-match-wins predicate table.
Persistence is supplied by the required DraftReviewPorts bundle. This
module owns only source classification and typed review-item projection; the
encrypted repositories remain outer composition concerns.
- transactions_pending(*, ports, catalogue=None)[source]¶
Return one
TransactionReviewItemper pending-review transaction.catalogueis an optionalTransactionCatalogueoverride; the repository is loaded whenNone.Skips fully-classified rows (BUSINESS / PERSONAL / MIXED), rows explicitly skipped by rule (
SKIPPED_BY_RULE), and rows the operator reviewed and deliberately excluded (REVIEWED_EXCLUDED) — those have a final disposition and do not want the operator’s attention.- Return type:
- Parameters:
ports (DraftReviewPorts)
catalogue (TransactionCatalogue | None)
- transactions_low_confidence(*, ports, threshold, catalogue=None)[source]¶
Return transactions whose decision confidence sits below a threshold.
- Parameters:
ports (
DraftReviewPorts) – Composed application capabilities for the profile to inspect.threshold (
Decimal) – Minimum acceptable confidence; transactions strictly below this value are included.catalogue (
TransactionCatalogue|None) – OptionalTransactionCatalogueoverride; whenNonethe catalogue is loaded from the composed repository.
- Return type:
Surfaces every transaction whose
classification_confidenceis non-None and strictly less than the threshold, regardless of classification state. Transactions withNoneconfidence are excluded because they have no claim to filter against.Each element in the returned tuple is a
TransactionReviewItem.
- load_transactions(*, ports)[source]¶
Load the transaction catalogue through the composed application port.
- Return type:
- Parameters:
ports (DraftReviewPorts)
- invoices_pending(*, ports, catalogue=None)[source]¶
Return
InvoiceReviewItemrecords for unmatched / disputed / pending invoices.- Parameters:
ports (
DraftReviewPorts) – Composed application capabilities for the profile to inspect.catalogue (
InvoiceCatalogue|None) – OptionalInvoiceCatalogueoverride; the repository is loaded whenNone.
- Return type:
- load_invoices(*, ports)[source]¶
Load the invoice catalogue through the composed application port.
- Return type:
- Parameters:
ports (DraftReviewPorts)
- drafts_pending(settings, *, bucket_id, ports, operation, drafts=None)[source]¶
Return
FindingReviewItemrecords for findings + unready drafts.- Parameters:
settings (
Settings) – Active application settings.bucket_id (
str) – Stable bucket identifier for the draft repository to inspect.ports (
DraftReviewPorts) – Required encrypted persistence capabilities.operation (
PinnedAuthorityOperation) – Caller-owned generation-pinned indexed authority operation.drafts (
tuple[tuple[Path,ModeloDraft],...] |None) – Optional pre-loaded sequence of(path, draft)pairs where each draft is aModeloDraft; whenNonedrafts are loaded from that bucket’s secure storage.
- Return type:
A draft whose
profile_tax_iddoes not match the active profile’s tax id is not the active profile’s data and is skipped. Callers see only drafts owned by the active profile.
- reviewed_against_current_state(draft, *, bucket_id, ports, operation)[source]¶
Return
draftwith an aged-out approval reported as aged out.An approval is a claim about the inputs it was granted over, and the review queue is the surface whose job is to notice when that claim has stopped holding. Reading only the stored status cannot notice: an approved draft stays approved on disk however far the ledger, invoices, taxpayer profile or registry schema have moved underneath it, so the
APROBACION_CADUCADArow this adapter already knows how to emit was unreachable and the queue reported nothing to do.Only
APROBADOdrafts are recomputed. Every other status either has no approval basis to compare or is already downstream of approval, and the recomputation loads catalogues and a registry snapshot, which is not work to do for a draft that cannot be stale.The refreshed draft is NOT written back. This module’s adapters are pure readers, and the verdict is derived state: freezing it into the store on a read would make the stored status depend on when someone happened to open the review queue.
Core types:
ModeloDraft.- Return type:
- Parameters:
draft (ModeloDraft)
bucket_id (str)
ports (DraftReviewPorts)
operation (PinnedAuthorityOperation)
- load_drafts(*, ports, operation)[source]¶
Iterate every persisted draft via the composed application capability.
Drafts are ciphertext-at-rest only. The helper returns the secure backend’s logical path marker alongside the typed payload so callers can identify the draft without consulting a plaintext draft directory.
- Return type:
tuple[tuple[Path,ModeloDraft],...]- Parameters:
ports (DraftReviewPorts)
operation (PinnedAuthorityOperation)