pub struct Checkpoint {
pub thread_id: String,
pub checkpoint_id: String,
pub state: HashMap<String, Value>,
pub step: usize,
pub pending_nodes: Vec<String>,
pub metadata: HashMap<String, Value>,
pub created_at: DateTime<Utc>,
pub cleared_interrupt: Option<String>,
pub attempts: HashMap<String, u32>,
pub child_ledger: HashMap<String, Value>,
pub version: u64,
pub pending_writes: BTreeMap<String, PendingWrite>,
}graph only.Expand description
Checkpoint data structure for persistence
Fields§
§thread_id: StringThread identifier
checkpoint_id: StringUnique checkpoint ID
state: HashMap<String, Value>State at this checkpoint
step: usizeStep number
pending_nodes: Vec<String>Nodes pending execution
metadata: HashMap<String, Value>Additional metadata
created_at: DateTime<Utc>Creation timestamp
cleared_interrupt: Option<String>The node whose static interrupt produced this checkpoint.
A static interrupt is raised before the node runs, so the checkpoint holds a frontier that still contains it. Without this marker the resumed run reaches the same conclusion and raises the same interrupt, and the node never executes. The executor clears the marker once that node has run, so a cycle returning to the same gate asks again.
attempts: HashMap<String, u32>How many times each node has been attempted, for retry policies.
Held here so a retry budget survives a resume. adk-python does not persist its attempt count, so a resumed node there starts its budget again.
child_ledger: HashMap<String, Value>Outputs of children invoked imperatively from a node body, keyed by child path.
A resumed parent re-runs from the top, so without this every child would run again. Only successful outputs are recorded: a failed or interrupted child must re-run.
version: u64The checkpoint’s revision within its thread.
A Checkpointer stores a checkpoint only
when its version is greater than every version already stored for the thread,
so two writers on one thread cannot interleave: the one that falls behind is
refused with GraphError::CheckpointConflict.
The newest checkpoint is the one with the highest version. Versions start at 1.
pending_writes: BTreeMap<String, PendingWrite>Outputs of the nodes that finished in a super-step that did not complete, keyed by node name.
When one node of a parallel super-step fails, the nodes that succeeded keep their writes here, and a resumed run applies them instead of running those nodes again. Cleared once the super-step completes.
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn run_record(&self) -> Result<Option<RunRecord>, GraphError>
pub fn run_record(&self) -> Result<Option<RunRecord>, GraphError>
The run this checkpoint belongs to, or None for a checkpoint without one.
§Errors
Returns GraphError::SerializationError when the record is malformed.
§Example
use adk_graph::state::{Checkpoint, State};
let checkpoint = Checkpoint::new("t1", State::new(), 0, vec![]);
assert!(checkpoint.run_record()?.is_none());Sourcepub fn step_records(&self) -> Result<Vec<StepRecord>, GraphError>
pub fn step_records(&self) -> Result<Vec<StepRecord>, GraphError>
The steps finished since the previous saved checkpoint of the thread, oldest first; empty for a checkpoint without them.
§Errors
Returns GraphError::SerializationError when the records are malformed.
§Example
use adk_graph::state::{Checkpoint, State};
let checkpoint = Checkpoint::new("t1", State::new(), 0, vec![]);
assert!(checkpoint.step_records()?.is_empty());Sourcepub fn lineage(&self) -> Result<Option<Lineage>, GraphError>
pub fn lineage(&self) -> Result<Option<Lineage>, GraphError>
Where this checkpoint’s thread was forked from, or None for a thread that was not
forked.
§Errors
Returns GraphError::SerializationError when the record is malformed.
§Example
use adk_graph::state::{Checkpoint, State};
let checkpoint = Checkpoint::new("t1", State::new(), 0, vec![]);
assert!(checkpoint.lineage()?.is_none());Sourcepub fn open_pauses(&self) -> Result<Vec<String>, GraphError>
pub fn open_pauses(&self) -> Result<Vec<String>, GraphError>
The IDs of the thread’s checkpoints where a run paused and no run has resumed, as they stood when this checkpoint was written.
Read from the newest checkpoint, this lists every pause of the thread a caller can still resume by ID. A checkpoint written before the list existed reads as empty.
§Errors
Returns GraphError::SerializationError when the list is malformed.
§Example
use adk_graph::record::OPEN_PAUSES_METADATA_KEY;
use adk_graph::state::{Checkpoint, State};
use serde_json::json;
let newest = Checkpoint::new("t1", State::new(), 3, vec!["pay".into()])
.with_metadata(OPEN_PAUSES_METADATA_KEY, json!(["cp-2"]));
assert_eq!(newest.open_pauses()?, vec!["cp-2".to_string()]);Sourcepub fn is_paused(&self) -> bool
pub fn is_paused(&self) -> bool
Whether a node of this checkpoint’s frontier waits mid-step: the run stopped before a gated node, or a node paused itself.
§Example
use adk_graph::state::{Checkpoint, State};
let completed = Checkpoint::new("t1", State::new(), 1, vec!["pay".into()]);
assert!(!completed.is_paused());
assert!(completed.with_cleared_interrupt("pay").is_paused());Source§impl Checkpoint
impl Checkpoint
Sourcepub fn new(
thread_id: &str,
state: HashMap<String, Value>,
step: usize,
pending_nodes: Vec<String>,
) -> Checkpoint
pub fn new( thread_id: &str, state: HashMap<String, Value>, step: usize, pending_nodes: Vec<String>, ) -> Checkpoint
Create a new checkpoint
Sourcepub fn with_version(self, version: u64) -> Checkpoint
pub fn with_version(self, version: u64) -> Checkpoint
Sets the checkpoint’s revision within its thread.
A writer that continues a thread whose newest checkpoint has version n
saves version n + 1.
§Example
use adk_graph::state::{Checkpoint, State};
let first = Checkpoint::new("thread", State::new(), 0, vec!["a".into()]);
let next = Checkpoint::new("thread", State::new(), 1, vec![]).with_version(first.version + 1);
assert_eq!(next.version, 2);Sourcepub fn with_cleared_interrupt(self, node: impl Into<String>) -> Checkpoint
pub fn with_cleared_interrupt(self, node: impl Into<String>) -> Checkpoint
Record the node whose static interrupt produced this checkpoint.
Sourcepub fn with_metadata(self, key: &str, value: Value) -> Checkpoint
pub fn with_metadata(self, key: &str, value: Value) -> Checkpoint
Add metadata to the checkpoint
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§fn clone(&self) -> Checkpoint
fn clone(&self) -> Checkpoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Checkpoint
impl Debug for Checkpoint
Source§impl<'de> Deserialize<'de> for Checkpoint
impl<'de> Deserialize<'de> for Checkpoint
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Checkpoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Checkpoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Checkpoint
impl PartialEq for Checkpoint
Source§impl Serialize for Checkpoint
impl Serialize for Checkpoint
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Checkpoint
Auto Trait Implementations§
impl Forget for Checkpoint
impl Freeze for Checkpointwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<(String, Value)>: Freeze,
PhantomData<String>: Freeze,
NonZero<i32>: Freeze,
Utc: Freeze,
PhantomData<(String, u32)>: Freeze,
*const LeafNode<String, PendingWrite> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, PendingWrite)>>: Freeze,
impl Move for Checkpoint
impl RefUnwindSafe for Checkpoint
impl Send for Checkpoint
impl Sync for Checkpoint
impl Unpin for Checkpoint
impl UnsafeUnpin for Checkpointwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, Value)>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
PhantomData<(String, u32)>: UnsafeUnpin,
*const LeafNode<String, PendingWrite> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, PendingWrite)>>: UnsafeUnpin,
impl UnwindSafe for Checkpointwhere
RawVecInner: UnwindSafe,
HashMap<String, Value>: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
HashMap<String, u32>: UnwindSafe,
BTreeMap<String, PendingWrite>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.