Skip to content

Action authoring and approval requirements

For new integrations that pin an exact patch and own equivalence tests plus migration review, the namespaced gradual-reveal API keeps immutable semantics separate from operation-scoped host dependencies and compiles to the same ActionDefinition and ActionRuntime used by the expert path. Other integrations should start with the supported Action facade or construct an ActionDefinition directly. See the versioning boundary.

experimental

Experimental gradual-reveal authoring API.

This namespace may change independently while it is evaluated. The expert root API remains the stable runtime contract.

ActionApplication

ActionApplication()

Bases: Generic[DepsT]

Minimal registration catalog for experimental action declarations.

is_frozen property

is_frozen: bool

registration_count property

registration_count: int

register

register(specification: ActionSpec[CommandT, PrivateSnapshotT, PreviewT, ResultT], recipe: ActionRecipe[DepsT, CommandT, PrivateSnapshotT, PreviewT, ResultT]) -> RegisteredAction[CommandT, PrivateSnapshotT, PreviewT, ResultT]

freeze

freeze() -> None

inspect

inspect(action: RegisteredAction[CommandT, PrivateSnapshotT, PreviewT, ResultT]) -> ActionInspection

bind

bind(action: RegisteredAction[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, dependencies: DepsT) -> Iterator[BoundAction[CommandT, PrivateSnapshotT, PreviewT, ResultT]]

ActionApplicationError

ActionApplicationError(code: ActionIssueCode)

Bases: RuntimeError

A content-safe experimental application failure.

code instance-attribute

code = code

ActionComponents dataclass

ActionComponents(preparation: PreparationPort[CommandT, PrivateSnapshotT, PreviewT], authorization: AuthorizationPort[CommandT, PrivateSnapshotT], authority_evaluator: AuthorityEvaluatorPort, state_resolver: StateResolverPort[PrivateSnapshotT, PreviewT], executor: GovernedExecutorPort[PrivateSnapshotT, ResultT], verifier: VerifierPort[ResultT], commitment_provider: CommitmentProviderPort, protection_codec: ProtectionCodecPort, retention: RetentionPort, store: ActionStore, retention_store: RetentionStore | None = None, clock: Clock | None = None, identifiers: IdentifierProvider | None = None, event_sink: EventSink | None = None, runtime_revision: str | None = None, recovery_authorization: RecoveryAuthorizationPort | None = None)

Bases: Generic[CommandT, PrivateSnapshotT, PreviewT, ResultT]

Operation-scoped ports and runtime services produced by a host recipe.

preparation instance-attribute

preparation: PreparationPort[CommandT, PrivateSnapshotT, PreviewT]

authorization instance-attribute

authorization: AuthorizationPort[CommandT, PrivateSnapshotT]

authority_evaluator instance-attribute

authority_evaluator: AuthorityEvaluatorPort

state_resolver instance-attribute

state_resolver: StateResolverPort[PrivateSnapshotT, PreviewT]

executor instance-attribute

executor: GovernedExecutorPort[PrivateSnapshotT, ResultT]

verifier instance-attribute

verifier: VerifierPort[ResultT]

commitment_provider instance-attribute

commitment_provider: CommitmentProviderPort

protection_codec instance-attribute

protection_codec: ProtectionCodecPort

retention instance-attribute

retention: RetentionPort

store instance-attribute

store: ActionStore

retention_store class-attribute instance-attribute

retention_store: RetentionStore | None = None

clock class-attribute instance-attribute

clock: Clock | None = None

identifiers class-attribute instance-attribute

identifiers: IdentifierProvider | None = None

event_sink class-attribute instance-attribute

event_sink: EventSink | None = None

runtime_revision class-attribute instance-attribute

runtime_revision: str | None = None

recovery_authorization class-attribute instance-attribute

recovery_authorization: RecoveryAuthorizationPort | None = None

ActionIssueCode

Bases: StrEnum

Content-safe issue vocabulary for the experimental authoring layer.

DEFINITION_NONCONFORMING is reserved for compatibility with the initial experimental contract. ActionApplication.bind() does not emit it because trusted definition-construction failures retain their original diagnostics.

INVALID_SPECIFICATION class-attribute instance-attribute

INVALID_SPECIFICATION = 'invalid_specification'

DUPLICATE_ACTION_TYPE class-attribute instance-attribute

DUPLICATE_ACTION_TYPE = 'duplicate_action_type'

REGISTRATION_FROZEN class-attribute instance-attribute

REGISTRATION_FROZEN = 'registration_frozen'

INCOMPLETE_BINDING class-attribute instance-attribute

INCOMPLETE_BINDING = 'incomplete_binding'

BINDING_INACTIVE class-attribute instance-attribute

BINDING_INACTIVE = 'binding_inactive'

DEFINITION_NONCONFORMING class-attribute instance-attribute

DEFINITION_NONCONFORMING = 'definition_nonconforming'

POLICY_UNAVAILABLE class-attribute instance-attribute

POLICY_UNAVAILABLE = 'policy_unavailable'

ActionRecipe dataclass

ActionRecipe(bind: Callable[[DepsT], ActionComponents[CommandT, PrivateSnapshotT, PreviewT, ResultT]])

Bases: Generic[DepsT, CommandT, PrivateSnapshotT, PreviewT, ResultT]

Trusted host code that maps fresh dependencies to operation components.

bind instance-attribute

bind: Callable[[DepsT], ActionComponents[CommandT, PrivateSnapshotT, PreviewT, ResultT]]

ActionSpec

Bases: BaseModel, Generic[CommandT, PrivateSnapshotT, PreviewT, ResultT]

Immutable action semantics that are safe to retain application-wide.

model_config class-attribute instance-attribute

model_config = ConfigDict(extra='forbid', strict=True, frozen=True, hide_input_in_errors=True)

action_type instance-attribute

action_type: ActionType

command_model instance-attribute

command_model: type[CommandT]

private_snapshot_model instance-attribute

private_snapshot_model: type[PrivateSnapshotT]

display_preview_model instance-attribute

display_preview_model: type[PreviewT]

result_model instance-attribute

result_model: type[ResultT]

proposal_ttl instance-attribute

proposal_ttl: PositiveTimedelta

executor_identity instance-attribute

executor_identity: GovernedExecutor

target_identity instance-attribute

target_identity: AuthoritativeTarget

authority_audience instance-attribute

authority_audience: SafeReference

authority_channel_assurance instance-attribute

authority_channel_assurance: SafeReference

verification_delay class-attribute instance-attribute

verification_delay: NonNegativeTimedelta = timedelta(0)

max_verification_attempts class-attribute instance-attribute

max_verification_attempts: Annotated[int, Field(gt=0)] = 3

effect_kind class-attribute instance-attribute

effect_kind: EffectKind = 'single'

allow_resend_after_final_absence class-attribute instance-attribute

allow_resend_after_final_absence: bool = False

verification_lease_duration class-attribute instance-attribute

verification_lease_duration: PositiveTimedelta = timedelta(minutes=1)

semantic_idempotency_strategy class-attribute instance-attribute

semantic_idempotency_strategy: Literal['host_defined'] = 'host_defined'

translate_validation_failure classmethod

translate_validation_failure(value: object, handler: ModelWrapValidatorHandler[Self]) -> Self

BoundAction dataclass

BoundAction(_state: _BindingState[CommandT, PrivateSnapshotT, PreviewT, ResultT])

Bases: Generic[CommandT, PrivateSnapshotT, PreviewT, ResultT]

Operation facade whose borrowed internals exist only inside bind.

prepare async

prepare(*, tenant_reference: str, command: CommandT, requesting_principal: RequestingPrincipal, proposing_agent: ProposingAgent | None = None, proposal_reference: str | None = None) -> ActionOperationResult

record_authority async

record_authority(*, evidence: AuthorityEvidence, authenticated_authority: ConfirmingAuthority, proposal_reference: str | None = None) -> ActionOperationResult

expire_due async

expire_due(*, tenant_reference: str, proposal_reference: str) -> ActionOperationResult

execute async

execute(*, tenant_reference: str, proposal_reference: str) -> ActionOperationResult

reconcile async

reconcile(*, tenant_reference: str, proposal_reference: str) -> ActionOperationResult

resume_verification async

resume_verification(*, tenant_reference: str, proposal_reference: str, expected_revision: int, operator: RecoveryOperator, intervention_reference: str) -> ActionOperationResult

Resume verification after a trusted host operator intervention.

read async

read(*, proposal_reference: str, context: ReadContext) -> ProposalView

read_recovery async

read_recovery(*, proposal_reference: str, context: ReadContext) -> ActionRecoveryView

Describe safe recovery options through the bound action.

export_evidence async

export_evidence(*, proposal_reference: str, context: ReadContext) -> ActionEvidenceBundle

Export one authorized, minimized proposal revision.

observation_context async

observation_context(*, proposal_reference: str, context: ReadContext) -> ExecutionContext

Authorize a read-only target observation for a custom adapter.

erase async

erase(*, proposal_reference: str, context: ReadContext) -> ActionOperationResult

RegisteredAction dataclass

RegisteredAction(action_type: ActionType, _registration_id: int, _application_token: object)

Bases: Generic[CommandT, PrivateSnapshotT, PreviewT, ResultT]

Typed static handle returned by explicit registration.

action_type instance-attribute

action_type: ActionType

Action remains the supported authoring facade for a host object that already implements every port. The runtime continues to accept definitions only.

action

Thin authoring facade that compiles to the public action definition.

Action

Action(*, authority_evaluator: AuthorityEvaluatorPort, commitment_provider: CommitmentProviderPort, protection_codec: ProtectionCodecPort)

Bases: ABC, Generic[CommandT, PrivateSnapshotT, PreviewT, ResultT]

Author an action as one typed object without creating a second runtime path.

Deployment services remain constructor-injected. Immutable action metadata stays visible on the subclass. to_definition is the only bridge to the runtime.

action_type class-attribute

action_type: ActionType

proposal_ttl class-attribute

proposal_ttl: timedelta

executor_identity class-attribute

executor_identity: GovernedExecutor

target_identity class-attribute

target_identity: AuthoritativeTarget

authority_audience class-attribute

authority_audience: str

authority_channel_assurance class-attribute

authority_channel_assurance: str

verification_delay class-attribute

verification_delay: timedelta = timedelta(0)

max_verification_attempts class-attribute

max_verification_attempts: int = 3

effect_kind class-attribute

effect_kind: EffectKind = 'single'

allow_resend_after_final_absence class-attribute

allow_resend_after_final_absence: bool = False

verification_lease_duration class-attribute

verification_lease_duration: timedelta = timedelta(minutes=1)

semantic_idempotency_strategy class-attribute

semantic_idempotency_strategy: Literal['host_defined'] = 'host_defined'

__init_subclass__

__init_subclass__(**kwargs: object) -> None

to_definition

to_definition() -> ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT]

Compile this authoring facade to the runtime's public plumbing.

prepare abstractmethod async

prepare(command: CommandT, *, context: PreparationContext) -> PreparedAction[PrivateSnapshotT, PreviewT]

can_prepare abstractmethod async

can_prepare(command: CommandT, *, context: PreparationContext) -> AuthorizationResult

can_decide abstractmethod async

can_decide(evidence: AuthorityEvidence, *, context: DecisionContext) -> AuthorizationResult

can_execute abstractmethod async

can_execute(snapshot: PrivateSnapshotT, *, context: ExecutionContext) -> AuthorizationResult

can_read abstractmethod async

can_read(proposal_reference: str, *, context: ReadContext) -> bool

can_recover async

can_recover(proposal_reference: str, *, context: RecoveryContext) -> AuthorizationResult

Deny operator recovery until an action explicitly authorizes it.

resolve abstractmethod async

resolve(snapshot: PrivateSnapshotT, *, context: ExecutionContext) -> ResolvedState[PrivateSnapshotT, PreviewT]

execute abstractmethod async

execute(snapshot: PrivateSnapshotT, *, context: ExecutionContext, execution_precondition: str) -> ExecutionResult[ResultT]

verify abstractmethod async

verify(*, context: ExecutionContext) -> VerificationResult[ResultT]

authorize_erasure async

authorize_erasure(proposal_reference: str, *, context: ReadContext) -> bool

ActionConfigurationError

Bases: TypeError

Raised when an Action subclass cannot compile to ActionDefinition.

Approval requirements evaluate evidence after the host has authenticated and authorized each decision. They are not authorization policies.

approvals

Evidence-only approval requirements.

These helpers evaluate already authenticated and host-authorized authority evidence. They never decide whether an authority is currently permitted to act.

SingleApproval dataclass

SingleApproval(authority: ConfirmingAuthority)

Require one specific authority after the host authorizes the decision.

authority instance-attribute

evaluate async

evaluate(*, binding: AuthorityBinding, evidence: tuple[AuthorityEvidence, ...]) -> AuthorityEvaluation

AnyApproval dataclass

AnyApproval(authorities: tuple[ConfirmingAuthority, ...])

Require one distinct authority from a declared set.

authorities instance-attribute

authorities: tuple[ConfirmingAuthority, ...]

__post_init__

__post_init__() -> None

evaluate async

evaluate(*, binding: AuthorityBinding, evidence: tuple[AuthorityEvidence, ...]) -> AuthorityEvaluation

MOfNApprovals dataclass

MOfNApprovals(required: int, authorities: tuple[ConfirmingAuthority, ...])

Require approvals from a distinct M-of-N set of authorities.

required instance-attribute

required: int

authorities instance-attribute

authorities: tuple[ConfirmingAuthority, ...]

__post_init__

__post_init__() -> None

evaluate async

evaluate(*, binding: AuthorityBinding, evidence: tuple[AuthorityEvidence, ...]) -> AuthorityEvaluation

ApprovalReasonCode

Bases: StrEnum

Reason codes generated by the evidence-only approval requirements.

MORE_AUTHORITY_REQUIRED class-attribute instance-attribute

MORE_AUTHORITY_REQUIRED = 'more_authority_required'