Skip to main content

StepDescriptor

Struct StepDescriptor 

Source
pub struct StepDescriptor { /* private fields */ }
Expand description

The description of a step: its identity, effect contract, and ambiguity policy.

A descriptor is what a step is, independent of when it runs. The durable layer derives the step’s IdempotencyKey and replay-divergence fingerprint from the descriptor, so the same program point must build an equal descriptor on every run — a structurally different descriptor at a given StepId is a DurableError::ReplayDivergence.

Build a descriptor through the effect-specific constructors; the exactly_once_guarded constructor enforces the construction-time ambiguity rule (FR-DE-09).

§Examples

use zeph_durable::{EffectIntentSubClass, OnAmbiguous, StepDescriptor};

// A read-only step is idempotent and needs no ambiguity policy.
let read = StepDescriptor::idempotent("read_file", b"tool:read_file:/etc/hosts".to_vec());

// A destructive guarded step MUST declare its ambiguity policy or construction fails.
let delete = StepDescriptor::exactly_once_guarded(
    "delete_file",
    EffectIntentSubClass::Destructive,
    Some(OnAmbiguous::Fail),
    b"tool:delete_file:/tmp/x".to_vec(),
);
assert!(delete.is_ok());

let unsafe_delete = StepDescriptor::exactly_once_guarded(
    "delete_file",
    EffectIntentSubClass::Destructive,
    None,
    b"tool:delete_file:/tmp/x".to_vec(),
);
assert!(unsafe_delete.is_err(), "a destructive guarded step needs an explicit policy");

Implementations§

Source§

impl StepDescriptor

Source

pub fn idempotent(name: &'static str, op_fingerprint: impl Into<Bytes>) -> Self

Describe an EffectClass::Idempotent step (pure or naturally repeatable).

A replayed idempotent step returns its journaled result and never re-invokes the closure (INV-10). No ambiguity policy applies.

Source

pub fn at_least_once( name: &'static str, op_fingerprint: impl Into<Bytes>, ) -> Self

Describe an EffectClass::AtLeastOnce step (safe to repeat under an ambiguous replay).

Source

pub fn exactly_once_guarded( name: &'static str, sub_class: EffectIntentSubClass, on_ambiguous: Option<OnAmbiguous>, op_fingerprint: impl Into<Bytes>, ) -> Result<Self, DurableError>

Describe an EffectClass::ExactlyOnceGuarded step, enforcing the ambiguity-policy rule.

The sub_class refines what the effect does; the resulting OnAmbiguous policy decides what happens if a crash leaves the step in the ambiguous window. Only EffectIntentSubClass::CostBearingOrBoundaryIdempotent has a safe default (OnAmbiguous::Skip); every other sub-class requires an explicit policy.

§Errors

Returns DurableError::AmbiguityPolicyRequired when sub_class requires an explicit policy (EffectIntentSubClass::requires_explicit_policy) but on_ambiguous is None.

Source

pub fn name(&self) -> &'static str

The step’s stable name (used in spans, audit records, and error messages).

Source

pub fn effect(&self) -> EffectClass

The step’s effect class.

Source

pub fn on_ambiguous(&self) -> Option<OnAmbiguous>

The resolved ambiguity policy, Some only for a guarded step.

Source

pub fn op_fingerprint(&self) -> &Bytes

The opaque, non-secret operation fingerprint (INV-6).

Trait Implementations§

Source§

impl Clone for StepDescriptor

Source§

fn clone(&self) -> StepDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StepDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more