pub struct RunState {Show 27 fields
pub break_before: Option<String>,
pub id: String,
pub workflow: String,
pub workflow_hash: String,
pub inputs: Value,
pub status: RunStatus,
pub start: Start,
pub steps: BTreeMap<String, StepState>,
pub vars: Map<String, Value>,
pub tokens: u64,
pub steps_run: u32,
pub output: Option<Value>,
pub error: Option<String>,
pub task: Option<String>,
pub principal: Option<String>,
pub conversation: Option<String>,
pub children: Vec<String>,
pub parent: Option<Value>,
pub msg_depth: u32,
pub key: Option<String>,
pub attempt: u32,
pub created: u64,
pub updated: u64,
pub finished: Option<u64>,
pub deadline_ms: Option<u64>,
pub durable: bool,
pub dirty: bool,
}Expand description
The durable run record: the whole state of one run, and the only thing that has to survive a restart for the scheduler to carry on where it stopped.
Fields§
§break_before: Option<String>Stop this run just before the named step starts (a breakpoint set with
workflow.pause {before_step}). Durable, so it survives a restart —
which is the point: the interesting bugs are the ones that need one.
id: String§workflow: String§workflow_hash: String§inputs: Value§status: RunStatus§start: Start§steps: BTreeMap<String, StepState>§vars: Map<String, Value>§tokens: u64§steps_run: u32§output: Option<Value>§error: Option<String>§task: Option<String>§principal: Option<String>§conversation: Option<String>§children: Vec<String>§parent: Option<Value>§msg_depth: u32How many message hops caused this run, counted from the last trigger
that was not itself a delivered message. A run started by a schedule,
webhook or stream is depth 0; one started by an agent that a message
woke inherits that message’s depth. message refuses past
limits.max_message_depth, which is what stops
message → turn → run → message from re-arming itself forever. Volume
alone cannot be the test: twenty unrelated workflows greeting the
operator are not a loop, and one workflow greeting itself is.
key: Option<String>The logical thing this run is about (the workflow’s key:, rendered
against the trigger payload). Durable, so a restart still knows which
runs are about the same entity.
attempt: u32§created: u64§updated: u64§finished: Option<u64>§deadline_ms: Option<u64>§durable: boolDurability class, resolved at creation from the workflow (default
true). false ⇒ this run is memory-only: the checkpoint skips it and
a restart forgets it — the fast path for recomputable work. Restored
records (all durable by construction) default true.
dirty: boolImplementations§
Source§impl RunState
impl RunState
pub fn new(id: &str, wf: &Workflow, start: Start, inputs: Value) -> RunState
pub fn touch(&mut self)
pub fn step(&self, id: &str) -> Option<&StepState>
Sourcepub fn data(&self, env: Value, memory: Value) -> Data
pub fn data(&self, env: Value, memory: Value) -> Data
The template data view of this run: the root names {{…}} and CEL
expressions may reference. memory and env are supplied by the
caller rather than read here, because env must be curated and
secret-free before a template can see it.
Sourcepub fn begin_step(&mut self, id: &str) -> u32
pub fn begin_step(&mut self, id: &str) -> u32
Mark a step running (attempt +1). Returns the attempt.
Sourcepub fn end_step(
&mut self,
id: &str,
status: StepStatus,
output: Option<Value>,
error: Option<String>,
)
pub fn end_step( &mut self, id: &str, status: StepStatus, output: Option<Value>, error: Option<String>, )
Record a step’s terminal outcome.
Sourcepub fn suspend_step(&mut self, id: &str, wait: Value)
pub fn suspend_step(&mut self, id: &str, wait: Value)
Record a suspension (timer/gate/budget).
Sourcepub fn finish(
&mut self,
status: RunStatus,
output: Option<Value>,
error: Option<String>,
)
pub fn finish( &mut self, status: RunStatus, output: Option<Value>, error: Option<String>, )
Terminal transition of the run.
Sourcepub fn write_var(&mut self, key: &str, value: Value, mode: &str)
pub fn write_var(&mut self, key: &str, value: Value, mode: &str)
Apply an assign/transform write with a reducer mode.