pub struct PlanStore { /* private fields */ }Expand description
Persistent storage for task plans.
Implementations§
Source§impl PlanStore
impl PlanStore
Sourcepub async fn new(pool: SqlitePool) -> Result<Self>
pub async fn new(pool: SqlitePool) -> Result<Self>
Create a new PlanStore with the given database pool. Runs migrations to create the task_plans table.
Sourcepub fn pool(&self) -> SqlitePool
pub fn pool(&self) -> SqlitePool
Get the underlying database pool.
Sourcepub async fn update(&self, plan: &TaskPlan) -> Result<()>
pub async fn update(&self, plan: &TaskPlan) -> Result<()>
Update an existing plan (full replacement).
Sourcepub async fn latest(
&self,
session_id: &str,
task_id: Option<&str>,
) -> Result<Option<TaskPlan>>
pub async fn latest( &self, session_id: &str, task_id: Option<&str>, ) -> Result<Option<TaskPlan>>
The session’s latest plan, when it belongs to task_id (any task
when None): the checklist a launch’s checklist_items index into.
Sourcepub async fn modify(
&self,
plan_id: &str,
change: impl FnOnce(&mut TaskPlan) -> bool,
) -> Result<Option<TaskPlan>>
pub async fn modify( &self, plan_id: &str, change: impl FnOnce(&mut TaskPlan) -> bool, ) -> Result<Option<TaskPlan>>
Plan plan_id changed by change under the plan write lock, stored
when change says it changed. Returns the plan as it now stands.
Sourcepub async fn upsert_checklist(
&self,
session_id: &str,
task_id: Option<&str>,
trigger: &str,
items: &[(String, StepStatus)],
) -> Result<TaskPlan>
pub async fn upsert_checklist( &self, session_id: &str, task_id: Option<&str>, trigger: &str, items: &[(String, StepStatus)], ) -> Result<TaskPlan>
Create or replace the active checklist for a session. Full-set replace: the provided items become the plan’s steps. Reuses an existing incomplete plan (same id) when present so updates are idempotent.
Sourcepub async fn upsert_checklist_graph(
&self,
session_id: &str,
task_id: Option<&str>,
trigger: &str,
items: &[ChecklistItem],
) -> Result<TaskPlan>
pub async fn upsert_checklist_graph( &self, session_id: &str, task_id: Option<&str>, trigger: &str, items: &[ChecklistItem], ) -> Result<TaskPlan>
Create or replace a checklist with explicit prerequisite edges.
Sourcepub async fn link_background_job(
&self,
session_id: &str,
task_id: Option<&str>,
indices: &[usize],
job_id: &str,
) -> Result<Option<TaskPlan>>
pub async fn link_background_job( &self, session_id: &str, task_id: Option<&str>, indices: &[usize], job_id: &str, ) -> Result<Option<TaskPlan>>
Hand steps of the session’s checklist for task_id to the background
job job_id (TaskPlan::link_background_job). Returns the updated
plan, or None when there is no such checklist or nothing changed.
Sourcepub async fn helper_did_not_start(
&self,
session_id: &str,
task_id: Option<&str>,
indices: &[usize],
reason: &str,
) -> Result<Option<TaskPlan>>
pub async fn helper_did_not_start( &self, session_id: &str, task_id: Option<&str>, indices: &[usize], reason: &str, ) -> Result<Option<TaskPlan>>
The helper for the steps at indices of the session’s checklist for
task_id never started (TaskPlan::helper_did_not_start).
Returns the updated plan, or None when nothing changed.
Sourcepub async fn for_task(
&self,
session_id: &str,
task_id: &str,
) -> Result<Option<TaskPlan>>
pub async fn for_task( &self, session_id: &str, task_id: &str, ) -> Result<Option<TaskPlan>>
The session’s checklist for task_id: its latest plan, when that
plan belongs to the task.
Sourcepub async fn confirm_steps(
&self,
session_id: &str,
task_id: &str,
indices: &BTreeSet<usize>,
) -> Result<Option<TaskPlan>>
pub async fn confirm_steps( &self, session_id: &str, task_id: &str, indices: &BTreeSet<usize>, ) -> Result<Option<TaskPlan>>
The run’s receipts proved the checklist items at indices of the
session’s checklist for task_id (TaskPlan::confirm_steps).
Returns the updated plan, or None when nothing changed.
Sourcepub async fn mark_not_attempted(
&self,
session_id: &str,
task_id: &str,
indices: &BTreeSet<usize>,
) -> Result<Option<TaskPlan>>
pub async fn mark_not_attempted( &self, session_id: &str, task_id: &str, indices: &BTreeSet<usize>, ) -> Result<Option<TaskPlan>>
Settle the steps at indices of the session’s checklist for
task_id as not attempted (TaskPlan::mark_not_attempted).
Sourcepub async fn wait_on_background_jobs(
&self,
session_id: &str,
task_id: Option<&str>,
job_ids: &[String],
) -> Result<Option<TaskPlan>>
pub async fn wait_on_background_jobs( &self, session_id: &str, task_id: Option<&str>, job_ids: &[String], ) -> Result<Option<TaskPlan>>
The session’s checklist for task_id waits on background jobs
job_ids (TaskPlan::wait_on_background_jobs). Returns the updated
plan, or None when there is no such checklist or nothing changed.
Sourcepub async fn note_job_folders(
&self,
session_id: &str,
job_id: &str,
folders: &[String],
) -> Result<()>
pub async fn note_job_folders( &self, session_id: &str, job_id: &str, folders: &[String], ) -> Result<()>
The folders background job job_id made, on the session’s checklist
steps it took on (TaskPlan::note_job_folders).
Sourcepub async fn settle_background_job(
&self,
session_id: &str,
job_id: &str,
end: JobEnd,
) -> Result<Option<TaskPlan>>
pub async fn settle_background_job( &self, session_id: &str, job_id: &str, end: JobEnd, ) -> Result<Option<TaskPlan>>
Record the end of background job job_id on the session’s checklist
that handed it work (TaskPlan::settle_background_job). Returns the
updated plan, or None when no checklist step waited on that job.
Sourcepub async fn settle_open_steps(&self, plan_id: &str) -> Result<Option<TaskPlan>>
pub async fn settle_open_steps(&self, plan_id: &str) -> Result<Option<TaskPlan>>
Settle plan plan_id’s open steps as not done
(TaskPlan::settle_open_steps). Returns the plan as it now stands.
Sourcepub async fn set_status(&self, plan_id: &str, status: PlanStatus) -> Result<()>
pub async fn set_status(&self, plan_id: &str, status: PlanStatus) -> Result<()>
Update just the status of a plan.
Sourcepub async fn set_checkpoint(
&self,
plan_id: &str,
key: &str,
value: Value,
) -> Result<()>
pub async fn set_checkpoint( &self, plan_id: &str, key: &str, value: Value, ) -> Result<()>
Set a checkpoint value (merges into existing checkpoint).
Sourcepub async fn reconcile_checklist_after_tool_success(
&self,
session_id: &str,
semantics: &ToolCallSemantics,
receipt_id: &str,
result: &str,
) -> Result<Option<TaskPlan>>
pub async fn reconcile_checklist_after_tool_success( &self, session_id: &str, semantics: &ToolCallSemantics, receipt_id: &str, result: &str, ) -> Result<Option<TaskPlan>>
Reconcile a successful tool-call receipt into explicit checklist evidence contracts. Step descriptions are display-only and never decide completion.
Sourcepub async fn carry_into_turn(
&self,
session_id: &str,
task_id: &str,
) -> Result<Option<TaskPlan>>
pub async fn carry_into_turn( &self, session_id: &str, task_id: &str, ) -> Result<Option<TaskPlan>>
A turn that continues the same request (a runtime continuation, a resume, or a turn that adopted the request’s open obligations) carries the request’s open checklist: the session’s open plan moves to this turn’s task, so its card, its helpers’ links and its outcome all read it. A new request calls nothing here and starts its own plan. Returns the carried plan.
Sourcepub async fn set_task_id(&self, plan_id: &str, task_id: &str) -> Result<()>
pub async fn set_task_id(&self, plan_id: &str, task_id: &str) -> Result<()>
Link a plan to a task ID from the event store.
Sourcepub async fn get_incomplete_for_session(
&self,
session_id: &str,
) -> Result<Option<TaskPlan>>
pub async fn get_incomplete_for_session( &self, session_id: &str, ) -> Result<Option<TaskPlan>>
Get the incomplete plan for a session (if any). Returns the most recently updated incomplete plan.
Sourcepub async fn get_recent_for_session(
&self,
session_id: &str,
limit: usize,
) -> Result<Vec<TaskPlan>>
pub async fn get_recent_for_session( &self, session_id: &str, limit: usize, ) -> Result<Vec<TaskPlan>>
Get recent plans for a session.
Sourcepub async fn get_all_in_progress(&self) -> Result<Vec<TaskPlan>>
pub async fn get_all_in_progress(&self) -> Result<Vec<TaskPlan>>
Get all plans that are in progress.
Auto Trait Implementations§
impl !RefUnwindSafe for PlanStore
impl !UnwindSafe for PlanStore
impl Forget for PlanStore
impl Freeze for PlanStore
impl Move for PlanStore
impl Send for PlanStore
impl Sync for PlanStore
impl Unpin for PlanStore
impl UnsafeUnpin for PlanStorewhere
*const ArcInner<PoolInner<Sqlite>> is !null: UnsafeUnpin,
PhantomData<ArcInner<PoolInner<Sqlite>>>: UnsafeUnpin,
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> 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