cadrumo.core.operations module

Closed, frontend-neutral axes for supervised application operations.

class OperationLifecycle(*values)[source]

Bases: StrEnum

Global position of an operation before, during, and after execution.

CREATED
QUEUED
RUNNING
WAITING_FOR_INTERACTION
WAITING_FOR_EXTERNAL
CANCELLATION_REQUESTED
SETTLING
TERMINAL
LIFECYCLES_BEFORE_ANY_CANCELLATION_REQUEST: frozenset[OperationLifecycle]

Lifecycle stages an operation can only be in before any cancellation request has been made.

Requesting cancellation is an irreversible, immediate lifecycle transition: the moment a cancellation is requested, the operation moves to CANCELLATION_REQUESTED and can never return to one of these five stages. So a recorded cancellation-request fact is inconsistent with the lifecycle still sitting in this set – if a request exists, the lifecycle must already be CANCELLATION_REQUESTED, SETTLING, or TERMINAL.

The complement is NOT “the states cancellation causes” – SETTLING and TERMINAL are reached by every operation, cancelled or not. It is only the states a recorded cancellation-request fact remains CONSISTENT with, because the forward-only transition already ruled out coming back here.

LIFECYCLES_BEFORE_EXECUTOR_ENTRY: frozenset[OperationLifecycle]

Lifecycle stages an operation occupies before its executor can have entered.

An operation in one of these two stages has not been handed to an executor, so it cannot have recorded an executor_entered_at instant.

This set is NOT interchangeable with executor_entered_at is None, and the direction matters. The persisted-snapshot validator enforces one implication only – a recorded entry instant means the lifecycle has already left this set – so this set is strictly NARROWER than “no entry recorded”. The converse does not hold: an operation can sit outside these stages with no entry instant, which is exactly the pre-entry TERMINAL case the journal validates separately. Swapping one condition for the other therefore changes behaviour, and a caller must pick the one it means: this set asks “has it been handed to an executor yet”, the field asks “did an executor ever enter”.

class OperationTerminalCondition(*values)[source]

Bases: StrEnum

Reason an operation reached its settled terminal lifecycle.

SUCCEEDED
REFUSED
FAILED
CANCELLED
TIMED_OUT
INTERRUPTED
class OperationEffect(*values)[source]

Bases: StrEnum

Authoritative extent of committed effect, independent of terminal condition.

NONE
UPDATED
PARTIAL
UNKNOWN
EFFECTS_WITHOUT_PARTIAL_COMMIT: frozenset[OperationEffect]

Effects declarable by an operation that either does nothing, fully applies, or leaves an unknown extent, but never a partially-applied one.

OperationEffect.PARTIAL is excluded deliberately: an operation whose sub-steps can fail independently and leave only some of them committed declares PARTIAL explicitly in its own permitted_effects instead of using this set. See cadrumo.application.live.filed_history_operation, whose replay operation returns OperationEffect.PARTIAL when some sub-operations fail, for the contrasting case.

class OperationDurability(*values)[source]

Bases: StrEnum

Persistence and recovery guarantee declared by an operation definition.

EPHEMERAL
RECORDED
RESUMABLE
class OperationCancellation(*values)[source]

Bases: StrEnum

Cancellation mechanism an operation can truthfully support.

UNSUPPORTED
COOPERATIVE
CONTAINED
class OperationDeadline(*values)[source]

Bases: StrEnum

Aggregate deadline guarantee declared by an operation definition.

ABSENT
COOPERATIVE
ENFORCED
class OperationClosePolicy(*values)[source]

Bases: StrEnum

Frontend close behavior projected from operation policy.

DETACH_ALLOWED
REQUEST_CANCEL
BLOCK_UNTIL_SETTLED
class OperationEventKind(*values)[source]

Bases: StrEnum

Closed families of ordered, safe operation events.

PHASE
PROGRESS
LOG
EFFECT
NOTICE
RECONCILIATION
DIAGNOSTIC
INTERACTION
TERMINAL
class OperationInteractionKind(*values)[source]

Bases: StrEnum

Closed presentation families for typed operator interaction.

INPUT
CHOICE
REVIEW
APPLY
REJECT
profile_operation_subject(profile_id)[source]

Return the operation subject naming one profile.

The profile: prefix is the wire form other subjects are distinguished from, so it is spelled once. Three modules each formatted it inline, which meant three places had to agree on a string that nothing validated.

Return type:

str

Parameters:

profile_id (str)