Skip to main content

TaskPlan

Struct TaskPlan 

Source
pub struct TaskPlan {
    pub id: String,
    pub session_id: String,
    pub description: String,
    pub trigger_message: String,
    pub steps: Vec<PlanStep>,
    pub current_step: usize,
    pub status: PlanStatus,
    pub checkpoint: Value,
    pub creation_reason: String,
    pub task_id: Option<String>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}
Expand description

A persistent multi-step task plan.

Fields§

§id: String

Unique identifier (UUID)

§session_id: String

Session this plan belongs to

§description: String

Human-readable description (from user request)

§trigger_message: String

The original user message that triggered this plan

§steps: Vec<PlanStep>

Ordered list of steps

§current_step: usize

Index of current step (0-based)

§status: PlanStatus

Overall plan status

§checkpoint: Value

Arbitrary checkpoint data (tool outputs, intermediate results)

§creation_reason: String

Why the plan was created (complexity heuristic result)

§task_id: Option<String>

Task ID from event store (links plan to events)

§created_at: DateTime<Utc>§updated_at: DateTime<Utc>

Implementations§

Source§

impl TaskPlan

Source

pub fn new( session_id: impl Into<String>, trigger_message: impl Into<String>, description: impl Into<String>, steps: Vec<String>, creation_reason: impl Into<String>, ) -> Self

Create a new task plan with the given steps.

Source

pub fn current_step_ref(&self) -> Option<&PlanStep>

Get the current step, if any.

Source

pub fn current_step_mut(&mut self) -> Option<&mut PlanStep>

Get the current step mutably, if any.

Source

pub fn sync_active_step(&mut self)

Keep the user-facing execution pointer aligned with checklist state. While work remains, exactly one pending step is promoted to in-progress.

Source

pub fn duration_secs(&self) -> u64

Calculate total duration in seconds.

Source

pub fn completed_steps(&self) -> usize

Count completed steps.

Source

pub fn unverified_steps(&self) -> usize

Completed action steps no receipt verified: the only steps the card flags (PlanStep::unverified).

Source

pub fn confirm_steps(&mut self, indices: &BTreeSet<usize>) -> bool

The steps at indices were confirmed by typed evidence (the run’s receipts proved their checklist items): no longer said done only. Returns whether any step changed.

Source

pub fn helper_did_not_start(&mut self, indices: &[usize], reason: &str) -> bool

The helper meant for the steps at indices never started (its spawn_agent call failed): nothing works on them, so they are not done, and the card says they didn’t run. A step already done or set aside is left alone. Returns whether any step changed.

Source

pub fn is_finished(&self) -> bool

Check if all steps are done (completed, failed, or skipped).

Source

pub fn resolved_status(&self) -> PlanStatus

Derive the terminal plan state from typed step outcomes. A deferred item is resolved for scheduling purposes but is not successful work.

Source

pub fn validate_graph(&self) -> Result<(), String>

Validate the persisted step dependency graph.

Source

pub fn ready_step_indices(&self) -> Result<Vec<usize>, String>

Pending steps whose prerequisites have reached accepted terminal state. The current executor selects one deterministically; task-level workers can use the same graph shape for actual parallel branches.

Source

pub fn advance_to_next_step(&mut self) -> bool

Advance to the next step. Returns true if there was a next step.

Source

pub fn complete_current_step(&mut self, summary: Option<String>)

Mark the current step as completed with a summary.

Source

pub fn fail_current_step(&mut self, error: String)

Mark the current step as failed with an error message.

Source

pub fn retry_current_step(&mut self)

Increment retry count for current step and reset to in-progress.

Source

pub fn unchecked_steps(&self) -> Vec<&PlanStep>

Steps still requiring action (not completed/deferred/failed/skipped).

Source

pub fn has_background_steps(&self) -> bool

Whether a background job is still working on any step.

Hand the steps at indices to the background job job_id. A step owns its runs in order and its outcome is its latest run’s: a step an earlier run failed or stopped short on is taken over by this one (a retry), and only this job’s end settles it. A step already done or skipped is left alone. Returns whether any step changed.

Source

pub fn launch_steps(&self, named: &[usize], owner_units: &[usize]) -> Vec<usize>

The steps a launch takes on: the steps it names that the plan lists, and each step whose owner units all fall within the units the launch says it carries out (owner_units). Typed links only: a launch whose named item is not a step of this plan, but which names the owner’s unit, takes on the plan’s own step for that unit, never a new row.

A unit one of its named steps already carries is taken on through that step: the launch’s own row for the unit, not every row of it. Several steps can share one unit (“install both sites”); a batch’s children each name their own, and expanding the shared unit gave every child every row, so each row read both children’s folders (live 2026-11-14: “Install Drupal … (made claude-company-wordpress-2, claude-company-drupal-2)”).

Source

pub fn steps_covered_by_running_jobs( &self, indices: &[usize], running: impl Fn(&str) -> bool, ) -> Vec<CoveredStep>

The steps a new helper would do that a helper still running already does, each with the running jobs on it. indices are the steps the new launch names (checklist_items). A launch that names none is judged against every open step: it is covered only when each of them is already being done (live 2026-11-14: the turn launched a WordPress and a Drupal helper, then a third helper for the WordPress install while the first still ran). A step whose helpers all ended is not covered, whatever its status still says, so a step an earlier helper ended without finishing can be launched again. running says whether a job is still running (the run records know that, not the plan).

Source

pub fn wait_on_background_jobs(&mut self, job_ids: &[String]) -> bool

The turn handed its work to background jobs job_ids without naming the steps they do (checklist_items): every step still open (marked handed off with no job yet, or already waiting on an earlier job) waits on them, so the card reads “continuing in the background”, never “stopped short”, while they run. Their typed ends settle such a step (PlanStep::waited_jobs). Returns whether anything changed.

Source

pub fn unmark_runless_background_steps(&mut self) -> bool

A step the checklist marked “background” that no run took on or waits on is not running: it is open again, judged like any open step (a launch takes it, the turn’s end settles it). The mark alone never leaves a row “running in the background” with nothing running. Returns whether anything changed.

Source

pub fn note_job_folders(&mut self, job_id: &str, folders: &[String]) -> bool

The folders background job job_id made (its claim evidence), on the steps it took on, before its end settles them. Returns whether any step changed.

Source

pub fn settle_background_job(&mut self, job_id: &str, end: JobEnd) -> bool

Record the end of background job job_id, as its run record says. A step handed to several jobs (or waiting on them) settles once the last of them ended, from all their typed ends: completed when every one succeeded, failed when one failed (a step handed to it; a step that only waited on it is not done, with that reason), and not done when one stopped before finishing or ended short because the owner declined one of its steps. While others still run it stays in the background, so a later run’s success is never lost (live 2026-11-13: the WordPress helper’s end marked steps both helpers shared as not done, the Drupal helper then finished them, and the card read “1 of 5 done” above its helpers’ finished lines). The plan resolves once nothing is left to run. Returns whether any step changed.

Source

pub fn settle_open_steps(&mut self) -> bool

Its turn is over and nothing it handed work to is still running: a step still open (pending, in progress, or waiting on a job no longer running) can no longer be done by anything, so it settles as not done (NotDoneReason::LeftOpen) and the plan resolves. A card never stays “working” on a step nothing is working on (live 2026-11-13: a “Report each helper’s measured time” step held a card on “Working · step 4 of 4” for 14 minutes after both helpers ended). Returns whether anything changed.

While a job a launch handed a step to has not ended (it is still listed on the step), the plan’s work is still going and nothing settles: that job’s own end settles its step (Self::settle_background_job) and then the rest, however the card’s runs were counted when this settle ran. Live 2026-11-13: the first helper’s end settled the card while the second, launched for the WordPress step, was not yet counted on it; the card read “Stopped short · 1 of 3 (not done: nothing was left working on it)”, then “Continuing”, then “Stopped”.

Source

pub fn mark_not_attempted(&mut self, indices: &BTreeSet<usize>) -> bool

The run’s ledger says nothing ever took on the steps at indices (NotDoneReason::NotAttempted): each settles as not done with that reason, unless it is done or skipped. A step that only waited on the turn’s jobs without being handed to one waits no longer: no job is doing it. Returns whether anything changed.

Source

pub fn hold_back_unfinished_steps(&mut self, reason: NotDoneReason) -> bool

Record that the steps not done in this plan were held back because the turn could not make changes: a failed or deferred step becomes a deferred step with NotDoneReason::ChangesOff, which the card shows as correctly not done. Returns whether anything changed.

Source

pub fn card(&self) -> PlanCard

The plan as the card shows it: Self::render_compact_checklist and its step count, which decides whether the card is kept.

Source

pub fn render_compact_checklist(&self) -> String

Compact, channel-friendly checklist for the live status card.

One header line carries the state and the count; the steps follow, a blank line apart so wrapped descriptions stay readable on a phone. A one-step plan is just that step (a header and a “1 of 1” would only repeat it). A fully completed card starts with ✅ (is_completed_checklist), so the card drops the turn’s own step line. A step that turned out not to be needed, or that was held back for a known reason, is never shown as a failure.

Source

pub fn render_recap(&self) -> String

End-of-turn recap of what got done vs what remains/deferred.

Source

pub fn format_for_prompt(&self) -> String

Format the plan for system prompt injection.

Trait Implementations§

Source§

impl Clone for TaskPlan

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TaskPlan

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TaskPlan

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Forget for TaskPlan

§

impl Freeze for TaskPlan

§

impl Move for TaskPlan

§

impl RefUnwindSafe for TaskPlan

§

impl Send for TaskPlan
where RawVecInner: Send, NonZero<i32>: Send, Utc: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl Sync for TaskPlan
where RawVecInner: Sync, NonZero<i32>: Sync, Utc: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl Unpin for TaskPlan
where *const u8 is !null: Unpin, NonZero<i32>: Unpin, Utc: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for TaskPlan

§

impl UnwindSafe for TaskPlan

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more