Skip to main content

PlanStore

Struct PlanStore 

Source
pub struct PlanStore { /* private fields */ }
Expand description

Persistent storage for task plans.

Implementations§

Source§

impl PlanStore

Source

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.

Source

pub fn pool(&self) -> SqlitePool

Get the underlying database pool.

Source

pub async fn create(&self, plan: &TaskPlan) -> Result<()>

Create a new plan.

Source

pub async fn update(&self, plan: &TaskPlan) -> Result<()>

Update an existing plan (full replacement).

Source

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.

Source

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.

Source

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.

Source

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.

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub async fn set_status(&self, plan_id: &str, status: PlanStatus) -> Result<()>

Update just the status of a plan.

Source

pub async fn set_checkpoint( &self, plan_id: &str, key: &str, value: Value, ) -> Result<()>

Set a checkpoint value (merges into existing checkpoint).

Source

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.

Source

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.

Source

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.

Source

pub async fn get(&self, plan_id: &str) -> Result<Option<TaskPlan>>

Get a plan by ID.

Source

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.

Source

pub async fn get_recent_for_session( &self, session_id: &str, limit: usize, ) -> Result<Vec<TaskPlan>>

Get recent plans for a session.

Source

pub async fn get_all_in_progress(&self) -> Result<Vec<TaskPlan>>

Get all plans that are in progress.

Source

pub async fn get_completed_since( &self, session_id: &str, since: DateTime<Utc>, ) -> Result<Vec<TaskPlan>>

Get completed plans since a given time (for consolidation).

Auto Trait Implementations§

§

impl !RefUnwindSafe for PlanStore

§

impl !UnwindSafe for PlanStore

§

impl Forget for PlanStore

§

impl Freeze for PlanStore
where *const ArcInner<PoolInner<Sqlite>> is !null: Freeze, PhantomData<ArcInner<PoolInner<Sqlite>>>: Freeze,

§

impl Move for PlanStore

§

impl Send for PlanStore
where Arc<PoolInner<Sqlite>>: Send,

§

impl Sync for PlanStore
where Arc<PoolInner<Sqlite>>: Sync,

§

impl Unpin for PlanStore
where Arc<PoolInner<Sqlite>>: Unpin,

§

impl UnsafeUnpin for PlanStore
where *const ArcInner<PoolInner<Sqlite>> is !null: UnsafeUnpin, PhantomData<ArcInner<PoolInner<Sqlite>>>: UnsafeUnpin,

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> 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, 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