Stores¶
Store contracts¶
base ¶
Tenant-scoped persistence contract for the action lifecycle.
SafeReference
module-attribute
¶
SafeReference = Annotated[str, StringConstraints(min_length=1, max_length=255), AfterValidator(_validate_safe_reference)]
Receipt
module-attribute
¶
Receipt = Annotated[ProposalReceipt | AuthorityReceipt | ExecutionReceipt | VerificationReceipt, Field(discriminator='receipt_type')]
ALLOWED_LIFECYCLE_TRANSITIONS
module-attribute
¶
ALLOWED_LIFECYCLE_TRANSITIONS: dict[LifecycleStatus, frozenset[LifecycleStatus]] = {LifecycleStatus.AWAITING_AUTHORITY: frozenset({LifecycleStatus.AUTHORIZED, LifecycleStatus.DENIED, LifecycleStatus.EXPIRED}), LifecycleStatus.AUTHORIZED: frozenset({LifecycleStatus.BLOCKED, LifecycleStatus.EXPIRED, LifecycleStatus.EXECUTING, LifecycleStatus.STALE}), LifecycleStatus.EXECUTING: frozenset({LifecycleStatus.STALE, LifecycleStatus.FAILED_KNOWN, LifecycleStatus.FAILED_UNKNOWN, LifecycleStatus.VERIFICATION_PENDING}), LifecycleStatus.FAILED_UNKNOWN: frozenset({LifecycleStatus.VERIFICATION_PENDING}), LifecycleStatus.VERIFICATION_PENDING: frozenset({LifecycleStatus.AUTHORIZED, LifecycleStatus.EXECUTING, LifecycleStatus.FAILED_KNOWN, LifecycleStatus.FAILED_UNKNOWN, LifecycleStatus.PARTIALLY_SUCCEEDED, LifecycleStatus.VERIFICATION_UNRESOLVED, LifecycleStatus.VERIFIED}), LifecycleStatus.STALE: frozenset({LifecycleStatus.SUPERSEDED}), LifecycleStatus.VERIFIED: frozenset(), LifecycleStatus.BLOCKED: frozenset(), LifecycleStatus.DENIED: frozenset(), LifecycleStatus.EXPIRED: frozenset(), LifecycleStatus.FAILED_KNOWN: frozenset(), LifecycleStatus.PARTIALLY_SUCCEEDED: frozenset(), LifecycleStatus.SUPERSEDED: frozenset(), LifecycleStatus.VERIFICATION_UNRESOLVED: frozenset()}
ERASABLE_LIFECYCLE_STATUSES
module-attribute
¶
ERASABLE_LIFECYCLE_STATUSES = frozenset(status for status in LifecycleStatus if status not in {LifecycleStatus.EXECUTING, LifecycleStatus.FAILED_UNKNOWN, LifecycleStatus.VERIFICATION_PENDING})
AuthorityEvidence ¶
Bases: ExperimentalModel
A bound authority decision; it is not authorization by itself.
domain
class-attribute
instance-attribute
¶
schema_version
class-attribute
instance-attribute
¶
audience
class-attribute
instance-attribute
¶
audience: tuple[SafeReference, ...] = Field(min_length=1)
KeyedCommitment ¶
ProtectedPayload ¶
ActionType ¶
ExperimentalModel ¶
Bases: BaseModel
Strict, immutable base for the experimental public contract.
model_config
class-attribute
instance-attribute
¶
LifecycleStatus ¶
ProposingAgent ¶
Bases: ExperimentalModel
RequestingPrincipal ¶
Bases: ExperimentalModel
kind
class-attribute
instance-attribute
¶
ProposalAlreadyExistsError ¶
Bases: RuntimeError
StoreInvariantError ¶
Bases: RuntimeError
StoredProposal ¶
Bases: ExperimentalModel
Persistence-neutral lifecycle record; private state is always protected.
display_preview
class-attribute
instance-attribute
¶
display_preview: JsonObject = Field(default_factory=dict)
requesting_principal
class-attribute
instance-attribute
¶
requesting_principal: RequestingPrincipal | None = None
authority_evidence
class-attribute
instance-attribute
¶
authority_evidence: tuple[AuthorityEvidence, ...] = ()
verification_attempts
class-attribute
instance-attribute
¶
max_verification_attempts
class-attribute
instance-attribute
¶
next_verification_at
class-attribute
instance-attribute
¶
execution_precondition
class-attribute
instance-attribute
¶
execution_precondition: SafeReference | None = None
erasure_pending_at
class-attribute
instance-attribute
¶
ActionStore ¶
Bases: Protocol
compare_and_set
async
¶
compare_and_set(*, tenant_reference: str, proposal_reference: str, expected_revision: int, expected_statuses: tuple[LifecycleStatus, ...], updated: StoredProposal) -> bool
admit_execution
async
¶
admit_execution(*, tenant_reference: str, proposal_reference: str, expected_revision: int, admitted_at: datetime, updated: StoredProposal) -> EffectClaimResult
get_effect_claim_owner
async
¶
get_effect_claim_owner(*, tenant_reference: str, action_type: ActionType, semantic_effect_reference: str) -> str | None
RetentionStore ¶
Bases: Protocol
Privileged persistence operations kept outside the runtime DB role.
mark_erasure_pending
async
¶
mark_erasure_pending(*, tenant_reference: str, proposal_reference: str, expected_revision: int, pending_at: datetime) -> bool
complete_erasure
async
¶
complete_erasure(*, tenant_reference: str, proposal_reference: str, expected_revision: int, erased_at: datetime) -> bool
proposal_with_erasure_pending ¶
proposal_with_erasure_pending(proposal: StoredProposal, *, pending_at: datetime) -> StoredProposal
erased_proposal ¶
erased_proposal(proposal: StoredProposal, *, erased_at: datetime) -> StoredProposal
validate_proposal_update ¶
validate_proposal_update(*, current: StoredProposal, updated: StoredProposal) -> None
In-memory store¶
memory ¶
Concurrency-correct in-memory implementation of :mod:stores.base.
MemoryActionStore ¶
Bases: ActionStore, RetentionStore
An in-process conformance store with tenant-scoped guarded writes.
compare_and_set
async
¶
compare_and_set(*, tenant_reference: str, proposal_reference: str, expected_revision: int, expected_statuses: tuple[LifecycleStatus, ...], updated: StoredProposal) -> bool
admit_execution
async
¶
admit_execution(*, tenant_reference: str, proposal_reference: str, expected_revision: int, admitted_at: datetime, updated: StoredProposal) -> EffectClaimResult
get_effect_claim_owner
async
¶
get_effect_claim_owner(*, tenant_reference: str, action_type: ActionType, semantic_effect_reference: str) -> str | None
mark_erasure_pending
async
¶
mark_erasure_pending(*, tenant_reference: str, proposal_reference: str, expected_revision: int, pending_at: datetime) -> bool
complete_erasure
async
¶
complete_erasure(*, tenant_reference: str, proposal_reference: str, expected_revision: int, erased_at: datetime) -> bool
The durable adapters are documented in PostgreSQL and migrations and SQLite and migrations. Use Build a custom action store for another database.