cadrumo.application.operations.persistence.journal module¶
Application ports for durable operation state, events, leases, and operands.
- class OperationPersistedSnapshot(**data)[source]¶
Bases:
BaseModelCredential-free state and event batch written for one journal transition.
The runtime
OperationSnapshotretains its concrete registered request payload. This record instead retains only the content digest that addresses that confidential operand in secure storage.- Parameters:
data (Any)
- schema_version: Literal[6]¶
- identity: OperationIdentity¶
- definition_contract_digest: ContentDigest¶
- request_storage: OperationRequestStoragePolicy¶
- request_reference: ContentDigest¶
- credential_free_request_json: str | None¶
- secret_requirement: OperationSecretRequirement | None¶
- executor_entered_at: datetime | None¶
- revision: OperationRevision¶
- lifecycle: OperationLifecycle¶
- terminal_condition: OperationTerminalCondition | None¶
- effect: OperationEffect¶
- phase_code: OperationEventCode | None¶
- started_at: datetime¶
- updated_at: datetime¶
- execution_deadline: datetime | None¶
- cleanup_deadline: datetime | None¶
- cancellation_requested_at: datetime | None¶
- cancellation_acknowledged_at: datetime | None¶
- cancellation_deferred: bool¶
- event_cursor: OperationEventCursor¶
- terminal_receipt: OperationTerminalReceipt | None¶
- events: tuple[OperationEvent, ...]¶
- idempotency_claim: OperationIdempotencyClaim | None¶
- pending_interaction: OperationPendingInteraction | None¶
- consumed_interactions: tuple[OperationConsumedInteraction, ...]¶
- property operation_id: OperationId¶
Return the filename identity consumed by the journal substrate.
- class OperationProgressFoldCheckpoint(**data)[source]¶
Bases:
BaseModelCompaction-safe progress state through one authoritative event cursor.
- Parameters:
data (Any)
- identity: OperationIdentity¶
- through_cursor: OperationEventCursor¶
- phase_code: OperationEventCode | None¶
- progress_event: OperationProgressEvent | None¶
- class OperationProgressFoldInput(**data)[source]¶
Bases:
BaseModelExact checkpoint suffix needed to fold current progress through an anchor.
- Parameters:
data (Any)
- checkpoint: OperationProgressFoldCheckpoint | None¶
- events: tuple[OperationEvent, ...]¶
- class OperationObservationMaterialization(**data)[source]¶
Bases:
BaseModelSnapshot, replay page, and progress input from one atomic journal read.
- Parameters:
data (Any)
- snapshot: OperationPersistedSnapshot¶
- anchor_cursor: OperationEventCursor¶
- replay: OperationReplayPage¶
- progress_fold: OperationProgressFoldInput¶
- exception OperationObservationUnknownOperationError(operation_id)[source]¶
Bases:
CadrumoErrorThe locked observation read found no journal for the requested operation.
- Parameters:
operation_id (OperationId)
- Return type:
None
- code¶
- exception OperationObservationCursorAheadError(*, requested_cursor, anchor_cursor)[source]¶
Bases:
CadrumoErrorThe caller cursor is beyond the authoritative anchor read under the journal lock.
- Parameters:
requested_cursor (OperationEventCursor)
anchor_cursor (OperationEventCursor)
- Return type:
None
- code¶
- class OperationJournal(*args, **kwargs)[source]¶
Bases:
ProtocolAtomic snapshot-plus-event persistence with optimistic revision checks.
- async load(operation_id)[source]¶
Load the latest persisted snapshot for one operation.
- Return type:
- Parameters:
operation_id (OperationId)
- async resolve_idempotency(claim)[source]¶
Resolve a claim only when its matching operation journal exists.
- Return type:
TypeAliasType|None- Parameters:
claim (OperationIdempotencyClaim)
- async create(snapshot, *, lease)[source]¶
Atomically create one initial snapshot and its optional retry claim.
- Return type:
TypeAliasType- Parameters:
snapshot (OperationPersistedSnapshot)
lease (OperationOwnerLease)
- async commit(snapshot, *, expected_revision, lease)[source]¶
Atomically compare revision and append the snapshot and ordered events.
- Return type:
- Parameters:
snapshot (OperationPersistedSnapshot)
expected_revision (OperationRevision)
lease (OperationOwnerLease)
- class OperationEventStream(*args, **kwargs)[source]¶
Bases:
ProtocolReplay ordered operation events from an exclusive cursor.
- class OperationObservationReader(*args, **kwargs)[source]¶
Bases:
ProtocolRead one internally consistent operation observation from persistence.
A missing operation raises
OperationObservationUnknownOperationError. A cursor beyond the read anchor raisesOperationObservationCursorAheadError.
- class OperationLeaseRepository(*args, **kwargs)[source]¶
Bases:
ProtocolObserve and transition one durable owner lease against explicit evidence time.
- async inspect(scope_ref, operation_id, *, observed_at)[source]¶
Observe the current lease state for one conflict scope.
- Return type:
- Parameters:
scope_ref (OperationConflictScopeReference)
operation_id (OperationId)
observed_at (datetime)
- async acquire(candidate, *, observed_at)[source]¶
Acquire a candidate owner lease against explicit evidence time.
- Return type:
- Parameters:
candidate (OperationOwnerLease)
observed_at (datetime)
- async compare_and_swap(predecessor, successor, *, observed_at)[source]¶
Replace one exact live lease with its verified successor.
- Return type:
- Parameters:
predecessor (OperationOwnerLease)
successor (OperationOwnerLease)
observed_at (datetime)
- async release(predecessor, *, observed_at)[source]¶
Release one exact current lease against explicit evidence time.
- Return type:
- Parameters:
predecessor (OperationOwnerLease)
observed_at (datetime)
- class OperationSecureReferenceStore(*args, **kwargs)[source]¶
Bases:
ProtocolStore and resolve confidential operands outside credential-free journals.
- async put(operand, *, written_at)[source]¶
Store one typed confidential operand and return its reference.
- Return type:
TypeAliasType- Parameters:
operand (BaseModel)
written_at (datetime)
- async resolve(reference, operand_type)[source]¶
Resolve one typed confidential operand by its content reference.
- Return type:
TypeVar(OperandT, bound=BaseModel)- Parameters:
reference (ContentDigest)
operand_type (type[OperandT])