Source code for cadrumo.application.operator_surface.errors
"""Errors for the backend-owned operator-surface contract.:class:`OperatorSurfaceContractError` is the registered:class:`~core.errors.hierarchy.CadrumoError` raised by:func:`~application.operator_surface.contract.require_accepted_root` and:func:`~application.operator_surface.contract.resolve_source_kind_alias` when acaller asks for a root, source-kind token, or command-surface shape outside theaccepted :class:`~application.operator_surface.models.OperatorSurfaceContract`.The application error registry binds it to ``REFUSED_OPERATOR_SURFACE_CONTRACT``so boundary adapters can render the refusal through the shared error contract."""from__future__importannotationsfromcollections.abcimportMappingfrom...core.errors.hierarchyimportCadrumoError,TerminalPreconditionErrorMixinfrom...core.i18n.renderimporttrfrom...core.operator_action_enumsimportActionEvidenceProvenance,NoRecoveryOutcomefrom..operator_actions.modelsimportPreconditionVerdictfrom..operator_actions.preconditionsimportno_action_precondition_verdict
[docs]defoperator_surface_contract_verdict(condition_id:str,*,facts:Mapping[str,str|bool|int],)->PreconditionVerdict:"""Build the terminal verdict for an invalid operator-surface contract request."""returnno_action_precondition_verdict(condition_id=condition_id,facts=facts,provenance=ActionEvidenceProvenance.APPLICATION_STATE,outcome=NoRecoveryOutcome.TERMINAL,)
[docs]classOperatorSurfaceContractError(TerminalPreconditionErrorMixin[PreconditionVerdict],CadrumoError):"""Registered application error for rejected operator-surface requests. The message is localized with a stable, non-secret ``surface`` / ``reason`` context payload. Raw operator input is stored only in structured context for the central error renderer to handle consistently. """def__init__(self,surface:str,*,reason:str,precondition_verdict:PreconditionVerdict|None=None,)->None:"""Initialize this public contract."""super().__init__(tr("cli.operator_surface.errors.contract_not_accepted",surface=repr(surface),reason=reason,),context={"surface":surface,"reason":reason},precondition_verdict=precondition_verdict,)self.surface=surfaceself.reason=reason