Skip to main content

StepLedger

Trait StepLedger 

Source
pub trait StepLedger: Send + Sync {
    // Required methods
    fn set_plan(&self, steps: &[String]) -> usize;
    fn advance(&self) -> Option<String>;
    fn steps(&self) -> Vec<Step>;
    fn count(&self) -> u64;
    fn done_count(&self) -> u64;
    fn clear(&self);
    fn snapshot(&self) -> PlanSnapshot;
    fn restore(&self, snap: &PlanSnapshot);
}
Expand description

A session store for the ordered plan (Step 26.6b). &self methods (interior mutability) so one shared &dyn StepLedger serves both the per-turn <plan> injection and the update_plan tool. Task-specific → cleared on /new.

Required Methods§

Source

fn set_plan(&self, steps: &[String]) -> usize

Replace the plan with a fresh ordered list — the first step becomes Active, the rest Todo. Blank descriptions are dropped; capped at [MAX_STEPS]. Returns the number of steps actually set.

Source

fn advance(&self) -> Option<String>

Mark the Active step Done and activate the next Todo. Returns the new active step’s description, or None when the plan is complete/empty.

Source

fn steps(&self) -> Vec<Step>

A snapshot of the steps (for the <plan> block).

Source

fn count(&self) -> u64

Total steps (for /context stats).

Source

fn done_count(&self) -> u64

Completed steps (for /context stats).

Source

fn clear(&self)

Drop the plan (/new).

Source

fn snapshot(&self) -> PlanSnapshot

A full-state PlanSnapshot for persistence/resume (#715): the ordered steps with each one’s status, so a later Self::restore reinstates the ledger EXACTLY (unlike Self::set_plan, which resets every status).

Source

fn restore(&self, snap: &PlanSnapshot)

Restore the ledger from a PlanSnapshot (#715) — replaces the steps and their statuses verbatim (a full clear + replace, the inverse of Self::snapshot). An empty snapshot leaves the ledger empty.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§