Source code for cadrumo.entrypoints.tui.ledger.workspace_injection
"""The dependency set one Ledger workspace is constructed from.The route factory and the workspace controller each declared theseparameters in full, so adding one more meant editing both signatures and theforwarding call between them. Declaring them once removes that, and makes theset itself nameable: a caller now hands over ONE thing whose contents arevalidated at construction rather than a dozen arguments validated in two places.The guard runs in ``__post_init__``, which is what closes the gap the twosignatures allowed. Previously the factory refused a miswired ``review_action``and the controller did not, so a caller constructing the controller directlyskipped that refusal. There is one construction path now, so a check cannotapply on one and not the other."""from__future__importannotationsfromcollections.abcimportCallablefromdataclassesimportdataclassfrom....application.ledger.attachment_reviewimportAttachmentReviewItemfrom....application.ledger.workspaceimportLedgerWorkspaceProjectionV1from....application.operator_actions.modelsimportActionReferencefrom.action_guardsimportrequire_canonical_ledger_actionsfrom.modelsimport(LedgerClassificationSubmitterV1,LedgerEvidenceDoorV1,LedgerExclusionSubmitterV1,LedgerImportDoorV1,LedgerInvoiceAddDoorV1,LedgerLinkSubmitterV1,)
[docs]@dataclass(frozen=True,slots=True)classLedgerWorkspaceRefreshV1:"""The per-visit state a workspace re-reads after it has written something."""projection:LedgerWorkspaceProjectionV1evidence_items:tuple[AttachmentReviewItem,...]|None
[docs]@dataclass(frozen=True,slots=True)classLedgerWorkspaceInjection:"""Every dependency the Ledger workspace is given from outside. An absent action means the area is not offered, which is distinct from an action that is offered but miswired: the first is a supported state, the second is refused at construction. """review_action:ActionReferenceclassify_action:ActionReference|None=Noneclassification_submitter:LedgerClassificationSubmitterV1|None=Noneimport_door:LedgerImportDoorV1|None=Noneevidence_action:ActionReference|None=Noneevidence_items:tuple[AttachmentReviewItem,...]|None=Nonelink_action:ActionReference|None=Nonelink_submitter:LedgerLinkSubmitterV1|None=Noneinvoice_add_door:LedgerInvoiceAddDoorV1|None=Noneexclusion_submitter:LedgerExclusionSubmitterV1|None=None"""Offered only beside ``classify_action``: excluding is a classification outcome."""evidence_door:LedgerEvidenceDoorV1|None=Nonerefresh:LedgerWorkspaceRefreshDoorV1|None=None"""Re-read the projection after a write; without it a flow shows its own result only."""def__post_init__(self)->None:"""Refuse a miswired action."""require_canonical_ledger_actions(review_action=self.review_action,classify_action=self.classify_action,evidence_action=self.evidence_action,link_action=self.link_action,)