Skip to main content

Workflow

Struct Workflow 

Source
pub struct Workflow {
Show 17 fields pub name: String, pub version: u32, pub priority: Priority, pub unload: Unload, pub durable: Option<bool>, pub state: BTreeMap<String, StateDecl>, pub description: Option<String>, pub armed: bool, pub inputs_schema: Option<Value>, pub concurrency: Concurrency, pub key: Option<String>, pub tool: Option<WorkflowTool>, pub limits: WorkflowLimits, pub outputs_schema: Option<Value>, pub steps: BTreeMap<String, Step>, pub hash: String, pub definition: Value,
}
Expand description

A parsed, validated workflow.

Fields§

§name: String§version: u32§priority: Priority

Scheduling weight under contention. low admissions shed one pressure level EARLIER (at warn, not just shed), and ready steps of higher-priority runs are scheduled first each tick. It is a tiebreak under scarcity, not a reservation.

§unload: Unload

Retirement policy for live runs (unload: {policy, timeout}).

§durable: Option<bool>

Durability class: Some(false) ⇒ runs of this workflow are memory-only (no checkpoints, gone after a restart — the fast path for recomputable work); Some(true) ⇒ durable even under store.durability.work: ephemeral. None in a freshly parsed document; the loader resolves it against the store’s default before the definition is armed.

§state: BTreeMap<String, StateDecl>

Declared run variables: {key: {type, reducer}}.

Optional, and the point is to make concurrent writes a DECLARED policy instead of a heuristic. Without it the parser can only guess from the modes two racing writers happen to use; with it, the workflow states what a key is and how writes to it combine, and disagreement is a config error rather than a value that depends on completion order.

§description: Option<String>§armed: bool§inputs_schema: Option<Value>§concurrency: Concurrency§key: Option<String>

The logical thing a run is ABOUT, rendered from the trigger payload ("{{payload.account_id}}").

Everything else in the runtime is keyed — breakers, rate buckets, start state, webhook dedup, step idempotency — but the run itself had no logical name, only an id. That is why per-entity serialization was not expressible: max_runs could count runs but not runs about the same account.

§tool: Option<WorkflowTool>

Register this workflow in the tool registry as a first-class contract.

The shapes already match: a workflow carries a description, an input schema, an output schema and a definition hash, which is exactly a tool contract. What it adds over an MCP tool is everything the engine already has — a “tool call” that takes thirty minutes, survives a restart, and has retry, breaker, idempotency and a human gate INSIDE it. And it is strictly better for the trifecta fold: a subagent handed billing.refund spends its legs on one reviewed procedure instead of a whole server’s tool surface.

§limits: WorkflowLimits§outputs_schema: Option<Value>§steps: BTreeMap<String, Step>§hash: String

SHA-256 of the canonical definition. A run pins the hash it started against, so a redefinition never changes the shape of work already in flight, and workflow.list can show whether two instances agree.

§definition: Value

The definition as given (canonical JSON), for workflow.list/hash.

Implementations§

Source§

impl Workflow

Source

pub fn start_steps(&self) -> Vec<&Step>

Source

pub fn step(&self, id: &str) -> Option<&Step>

Source

pub fn dependents(&self, id: &str) -> Vec<&Step>

The steps that depend on id.

Source

pub fn is_long_lived(&self) -> bool

Whether any start node makes this workflow long-lived: one that keeps firing — a timer, a schedule, a subscription, an inbound signal, event, A2A message or stream — rather than running once and finishing.

This decides daemon shape. An instance holding a long-lived workflow must not idle-exit, because the workflow’s whole purpose is to still be there when its trigger arrives.

Source

pub fn topo_order(&self) -> Vec<String>

The step ids in a deterministic topological order (deps first).

Trait Implementations§

Source§

impl Clone for Workflow

Source§

fn clone(&self) -> Workflow

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 Workflow

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Workflow

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Workflow

Source§

fn eq(&self, other: &Workflow) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Workflow

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Workflow

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

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