pub struct StepCtx<'a> {
pub node_id: &'a str,
pub run_id: &'a str,
pub input: &'a Value,
pub turn: usize,
pub results: &'a [EffectResult],
pub history: &'a [Vec<EffectResult>],
}Expand description
What the runtime tells a step about where it is.
Deliberately small. A step’s own reasoning state belongs in the value it carries, not here — that is what makes replay work: re-polling with the same journal reproduces the same decisions.
Fields§
§node_id: &'a strThis node’s id in the graph.
run_id: &'a strThe run this belongs to.
input: &'a ValueInput resolved from predecessors.
turn: usizeWhich turn this is, counting from 0. Part of the journal key, so a step that asks the same question twice gets two recorded answers.
results: &'a [EffectResult]Results of the effects requested last turn, in request order. Empty on turn 0.
history: &'a [Vec<EffectResult>]Every turn’s results so far, oldest first.
A step that accumulates — a conversation, a running total — rebuilds
it from here rather than holding it in self. That is what keeps
replay honest: the history is replayed identically, so the same
decisions follow, whereas hidden state would not survive a restart.
Implementations§
Source§impl<'a> StepCtx<'a>
impl<'a> StepCtx<'a>
Sourcepub fn new(
node_id: &'a str,
run_id: &'a str,
input: &'a Value,
turn: usize,
) -> Self
pub fn new( node_id: &'a str, run_id: &'a str, input: &'a Value, turn: usize, ) -> Self
A context with no results yet — what a first poll sees. Later turns
attach theirs with Self::with_history or Self::with_results.
Sourcepub fn with_history(self, history: &'a [Vec<EffectResult>]) -> Self
pub fn with_history(self, history: &'a [Vec<EffectResult>]) -> Self
Set the full history; results becomes its last entry.
Sourcepub fn with_results(self, results: &'a [EffectResult]) -> Self
pub fn with_results(self, results: &'a [EffectResult]) -> Self
Set only the current turn’s results — for tests and single-turn steps.
Sourcepub fn result(&self) -> Option<&EffectResult>
pub fn result(&self) -> Option<&EffectResult>
The single result of a one-effect turn.
Sourcepub fn all_results(&self) -> impl Iterator<Item = &EffectResult>
pub fn all_results(&self) -> impl Iterator<Item = &EffectResult>
Every result from every turn, oldest first, flattened.