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: StringUnique identifier (UUID)
session_id: StringSession this plan belongs to
description: StringHuman-readable description (from user request)
trigger_message: StringThe original user message that triggered this plan
steps: Vec<PlanStep>Ordered list of steps
current_step: usizeIndex of current step (0-based)
status: PlanStatusOverall plan status
checkpoint: ValueArbitrary checkpoint data (tool outputs, intermediate results)
creation_reason: StringWhy 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
impl TaskPlan
Sourcepub 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
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.
Sourcepub fn current_step_ref(&self) -> Option<&PlanStep>
pub fn current_step_ref(&self) -> Option<&PlanStep>
Get the current step, if any.
Sourcepub fn current_step_mut(&mut self) -> Option<&mut PlanStep>
pub fn current_step_mut(&mut self) -> Option<&mut PlanStep>
Get the current step mutably, if any.
Sourcepub fn sync_active_step(&mut self)
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.
Sourcepub fn duration_secs(&self) -> u64
pub fn duration_secs(&self) -> u64
Calculate total duration in seconds.
Sourcepub fn completed_steps(&self) -> usize
pub fn completed_steps(&self) -> usize
Count completed steps.
Sourcepub fn unverified_steps(&self) -> usize
pub fn unverified_steps(&self) -> usize
Completed action steps no receipt verified: the only steps the card
flags (PlanStep::unverified).
Sourcepub fn confirm_steps(&mut self, indices: &BTreeSet<usize>) -> bool
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.
Sourcepub fn helper_did_not_start(&mut self, indices: &[usize], reason: &str) -> bool
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.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if all steps are done (completed, failed, or skipped).
Sourcepub fn resolved_status(&self) -> PlanStatus
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.
Sourcepub fn validate_graph(&self) -> Result<(), String>
pub fn validate_graph(&self) -> Result<(), String>
Validate the persisted step dependency graph.
Sourcepub fn ready_step_indices(&self) -> Result<Vec<usize>, String>
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.
Sourcepub fn advance_to_next_step(&mut self) -> bool
pub fn advance_to_next_step(&mut self) -> bool
Advance to the next step. Returns true if there was a next step.
Sourcepub fn complete_current_step(&mut self, summary: Option<String>)
pub fn complete_current_step(&mut self, summary: Option<String>)
Mark the current step as completed with a summary.
Sourcepub fn fail_current_step(&mut self, error: String)
pub fn fail_current_step(&mut self, error: String)
Mark the current step as failed with an error message.
Sourcepub fn retry_current_step(&mut self)
pub fn retry_current_step(&mut self)
Increment retry count for current step and reset to in-progress.
Sourcepub fn unchecked_steps(&self) -> Vec<&PlanStep>
pub fn unchecked_steps(&self) -> Vec<&PlanStep>
Steps still requiring action (not completed/deferred/failed/skipped).
Sourcepub fn has_background_steps(&self) -> bool
pub fn has_background_steps(&self) -> bool
Whether a background job is still working on any step.
Sourcepub fn link_background_job(&mut self, indices: &[usize], job_id: &str) -> bool
pub fn link_background_job(&mut self, indices: &[usize], job_id: &str) -> bool
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.
Sourcepub fn launch_steps(&self, named: &[usize], owner_units: &[usize]) -> Vec<usize>
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)”).
Sourcepub fn steps_covered_by_running_jobs(
&self,
indices: &[usize],
running: impl Fn(&str) -> bool,
) -> Vec<CoveredStep>
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).
Sourcepub fn wait_on_background_jobs(&mut self, job_ids: &[String]) -> bool
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.
Sourcepub fn unmark_runless_background_steps(&mut self) -> bool
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.
Sourcepub fn note_job_folders(&mut self, job_id: &str, folders: &[String]) -> bool
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.
Sourcepub fn settle_background_job(&mut self, job_id: &str, end: JobEnd) -> bool
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.
Sourcepub fn settle_open_steps(&mut self) -> bool
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”.
Sourcepub fn mark_not_attempted(&mut self, indices: &BTreeSet<usize>) -> bool
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.
Sourcepub fn hold_back_unfinished_steps(&mut self, reason: NotDoneReason) -> bool
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.
Sourcepub fn card(&self) -> PlanCard
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.
Sourcepub fn render_compact_checklist(&self) -> String
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.
Sourcepub fn render_recap(&self) -> String
pub fn render_recap(&self) -> String
End-of-turn recap of what got done vs what remains/deferred.
Sourcepub fn format_for_prompt(&self) -> String
pub fn format_for_prompt(&self) -> String
Format the plan for system prompt injection.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TaskPlan
impl<'de> Deserialize<'de> for TaskPlan
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Forget for TaskPlan
impl Freeze for TaskPlan
impl Move for TaskPlan
impl RefUnwindSafe for TaskPlan
impl Send for TaskPlan
impl Sync for TaskPlan
impl Unpin for TaskPlan
impl UnsafeUnpin for TaskPlanwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<PlanStep>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
impl UnwindSafe for TaskPlanwhere
RawVecInner: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
Blanket Implementations§
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
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> 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 more