Conformance helpers¶
conformance ¶
Reusable conformance helpers for action stores, hosts, and safe projections.
SafeReference
module-attribute
¶
SafeReference = Annotated[str, StringConstraints(min_length=1, max_length=255), AfterValidator(_validate_safe_reference)]
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()}
__all__
module-attribute
¶
__all__ = ['BenchmarkResult', 'ConformanceError', 'LeakageFinding', 'PerformanceProfile', 'RuntimeConformanceDriver', 'StoreConformanceCase', 'assert_action_store_conforms', 'assert_no_sensitive_data', 'assert_performance_profile', 'assert_providers_conform', 'assert_runtime_conforms', 'benchmark_async', 'benchmark_async_concurrent', 'benchmark_sync', 'find_sensitive_data']
LifecycleStatus ¶
AuthorityReceipt ¶
Bases: _ReceiptBase
AuthorityReceiptStatus ¶
OperationOutcome ¶
StoreInvariantError ¶
Bases: RuntimeError
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)
CommitmentProvider ¶
Bases: Protocol
Host-owned proposal-scoped keyed commitment boundary.
Destruction must be idempotent so an interrupted erasure can resume safely.
verify
async
¶
verify(*, proposal_reference: str, canonical_payload: bytes, commitment: KeyedCommitment) -> bool
ProtectionCodec ¶
Bases: Protocol
Host-owned protection boundary for canonical private snapshots.
Destruction must be idempotent so an interrupted erasure can resume safely.
ActionOperationResult ¶
Bases: ExperimentalModel
display_preview
class-attribute
instance-attribute
¶
fresh_proposal_reference
class-attribute
instance-attribute
¶
fresh_proposal_reference: SafeReference | None = None
is_terminal
property
¶
Whether the proposal lifecycle has no valid transition left.
needs_reconciliation
property
¶
Whether authoritative reconciliation may advance this proposal.
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
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
¶
ConformanceError ¶
Bases: AssertionError
A stable, secret-free conformance failure.
LeakageFinding
dataclass
¶
StoreConformanceCase
dataclass
¶
StoreConformanceCase(store: ActionStore, retention_store: RetentionStore, original: StoredProposal, evidence: AuthorityEvidence, observed_at: datetime)
IndependentStoreConformanceCase
dataclass
¶
IndependentStoreConformanceCase(first_store: ActionStore, second_store: ActionStore, original: StoredProposal, evidence: AuthorityEvidence, observed_at: datetime, security_profile_identifier: str)
Two adapters backed by independently created connections to one store.
IndependentStoreConformanceReport
dataclass
¶
BenchmarkResult
dataclass
¶
PerformanceProfile
dataclass
¶
RuntimeConformanceDriver ¶
Bases: Protocol
Small host-owned driver used by the reusable runtime scenarios.
_derived_safe_reference ¶
find_sensitive_data ¶
find_sensitive_data(value: object, *, forbidden_literals: Mapping[str, str], forbidden_key_fragments: Collection[str] = ()) -> tuple[LeakageFinding, ...]
Recursively locate seeded secrets without echoing them in the report.
assert_no_sensitive_data ¶
assert_no_sensitive_data(value: object, *, forbidden_literals: Mapping[str, str], forbidden_key_fragments: Collection[str] = ()) -> None
Fail with labels and structural paths while keeping seeded values secret.
assert_action_store_conforms
async
¶
assert_action_store_conforms(case: StoreConformanceCase) -> None
Exercise tenant isolation, guarded updates, and atomic effect admission.
assert_independent_store_connections_conform
async
¶
assert_independent_store_connections_conform(case: IndependentStoreConformanceCase) -> IndependentStoreConformanceReport
Prove shared visibility, guarded revisions, and effect admission across stores.
_assert_store_update_invariants
async
¶
_assert_store_update_invariants(case: StoreConformanceCase) -> None
_assert_lifecycle_transition_guards
async
¶
_assert_lifecycle_transition_guards(case: StoreConformanceCase) -> None
_proposal_at_status
async
¶
_proposal_at_status(case: StoreConformanceCase, status: LifecycleStatus) -> StoredProposal
_lifecycle_seed_paths ¶
_lifecycle_seed_paths() -> dict[LifecycleStatus, tuple[LifecycleStatus, ...]]
_conformance_proposal ¶
_conformance_proposal(case: StoreConformanceCase, suffix: str) -> StoredProposal
_conformance_evidence ¶
_conformance_evidence(case: StoreConformanceCase, proposal: StoredProposal) -> AuthorityEvidence
_independent_proposal ¶
_independent_proposal(original: StoredProposal, suffix: str) -> StoredProposal
_independent_evidence ¶
_independent_evidence(original: AuthorityEvidence, proposal: StoredProposal) -> AuthorityEvidence
_require_update_rejected
async
¶
_require_update_rejected(case: StoreConformanceCase, *, current: StoredProposal, updated: StoredProposal, code: str) -> None
assert_providers_conform
async
¶
assert_providers_conform(*, commitment_provider: CommitmentProvider, protection_codec: ProtectionCodec, proposal_reference: str, canonical_payload: bytes, mutated_payload: bytes) -> None
Check commitment binding and protected-snapshot round trips.
assert_runtime_conforms
async
¶
assert_runtime_conforms(factory: Callable[[], RuntimeConformanceDriver]) -> None
Run framework-neutral happy, forged-resume, revocation, and drift scenarios.
benchmark_sync ¶
benchmark_sync(operation: Callable[[], T], *, profile: PerformanceProfile, iterations: int | None = None, warmup: int = 10) -> BenchmarkResult
Measure framework-owned synchronous work independently from external I/O.
benchmark_async
async
¶
benchmark_async(operation: Callable[[], Awaitable[T]], *, profile: PerformanceProfile, iterations: int | None = None, warmup: int = 10) -> BenchmarkResult
Measure asynchronous orchestration supplied by an in-process test host.
benchmark_async_concurrent
async
¶
benchmark_async_concurrent(operation: Callable[[int], Awaitable[T]], *, profile: PerformanceProfile, concurrency: int = 100, batches: int = 10, warmup_batches: int = 1) -> BenchmarkResult
Measure per-operation latency while running fixed concurrent batches.
assert_performance_profile ¶
assert_performance_profile(result: BenchmarkResult, profile: PerformanceProfile) -> None
_benchmark_result ¶
_benchmark_result(samples: Sequence[float], *, profile: PerformanceProfile) -> BenchmarkResult
_gather_timings
async
¶
_gather_timings(operation: Callable[[int], Awaitable[float]], *, offset: int, concurrency: int) -> list[float]
_validate_benchmark_counts ¶
_validate_benchmark_counts(*, count: int, warmup: int, profile: PerformanceProfile) -> None