pe-graph 0.1.0

Graph execution engine for Potential Expectations — state graphs, Pregel model, ReAct topology, and builder DSL
Documentation
//! State snapshots for checkpoint inspection and time travel.
//!
//! A `StateSnapshot` captures the full state of a graph execution at a
//! specific superstep, along with metadata for resumption and debugging.

use pe_core::State;
use std::time::SystemTime;

/// Complete snapshot of graph execution state at a point in time.
///
/// Used for:
/// - Human-in-the-loop: show state to human before they decide to resume
/// - Time travel: inspect or resume from any past checkpoint
/// - Debugging: see what the state looked like at each superstep
///
/// # Example
///
/// ```ignore
/// let snapshot = graph.get_state("thread-1").await?;
/// if let Some(snap) = snapshot {
///     println!("Step {}: next nodes = {:?}", snap.step, snap.next_nodes);
/// }
/// ```
/// NOTE: `#[non_exhaustive]` — will grow with metadata, branch info, etc.
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct StateSnapshot<S: State> {
    /// The full state at this checkpoint.
    pub state: S,

    /// Unique identifier for this checkpoint.
    pub checkpoint_id: String,

    /// Which superstep this was taken at.
    pub step: u32,

    /// Thread this checkpoint belongs to.
    pub thread_id: String,

    /// The checkpoint this one was derived from (if any).
    pub parent_checkpoint_id: Option<String>,

    /// When this checkpoint was created.
    pub created_at: SystemTime,

    /// Which nodes are scheduled to run next.
    /// Empty if the graph completed or hit recursion limit.
    pub next_nodes: Vec<String>,
}