Skip to main content

AgentRunStore

Struct AgentRunStore 

Source
pub struct AgentRunStore {
    pool: SqlitePool,
    workspace_id: String,
}
Expand description

Workspace-scoped persistence facade, sharing the application connection pool.

Fields§

§pool: SqlitePool§workspace_id: String

Implementations§

Source§

impl AgentRunStore

Source

pub fn new(pool: SqlitePool, workspace_id: &str) -> Result<Self>

Source

pub async fn create_run( &self, agent_name: &str, agent_version: &str, model: &str, input: &str, ) -> Result<AgentRun>

Create the materialized run and its initial event atomically.

Source

pub async fn create_run_with_budgets( &self, agent_name: &str, agent_version: &str, model: &str, input: &str, budgets: RunBudgets, ) -> Result<AgentRun>

Source

pub(crate) async fn create_root_run_in( &self, tx: &mut Transaction<'_, Sqlite>, agent_name: &str, agent_version: &str, model: &str, input: &str, budgets: &RunBudgets, ) -> Result<String>

Create a root run inside a caller-owned transaction. Task linkage uses this to make the run identity and task event one atomic commit.

Source

pub async fn lineage(&self, id: &str) -> Result<RunLineage>

Source

pub async fn children(&self, id: &str) -> Result<Vec<RunLineage>>

Source

async fn has_lineage_table(&self) -> Result<bool>

Source

pub async fn create_child_run( &self, parent_id: &str, call_id: &str, agent_name: &str, agent_version: &str, model: &str, input: &str, ) -> Result<AgentRun>

Bind exactly one child to a started delegation invocation atomically.

Source

pub async fn create_child_run_with_budgets( &self, parent_id: &str, call_id: &str, agent_name: &str, agent_version: &str, model: &str, input: &str, budgets: RunBudgets, ) -> Result<AgentRun>

Source

pub async fn get_run(&self, id: &str) -> Result<Option<AgentRun>>

Source

pub(crate) async fn get_run_raw(&self, id: &str) -> Result<Option<AgentRun>>

Source

pub async fn history(&self, limit: u32) -> Result<Vec<AgentRun>>

Most recent runs first, with a bounded result count.

Source

pub async fn recovery_disposition( &self, id: &str, ) -> Result<RecoveryDisposition>

Classify only persisted state. This performs no provider/resource resolution and makes no network, process, or model calls.

Source

async fn classify_recovery(&self, run: &AgentRun) -> Result<RecoveryDisposition>

Source

async fn active_budget_chain( tx: &mut Transaction<'_, Sqlite>, id: &str, workspace_id: &str, ) -> Result<Vec<BudgetRow>>

Source

async fn acquire_run_write( tx: &mut Transaction<'_, Sqlite>, id: &str, workspace_id: &str, ) -> Result<()>

Source

async fn save_usage( tx: &mut Transaction<'_, Sqlite>, row: &BudgetRow, usage: &RunUsage, ) -> Result<()>

Source

pub async fn record_model_requested( &self, id: &str, payload: &Value, ) -> Result<BudgetDecision>

Atomically reserve one model attempt for this run and its active ancestors.

Source

pub async fn record_model_responded( &self, id: &str, payload: &Value, usage: Option<(u64, u64, u64)>, ) -> Result<BudgetDecision>

Record provider usage and debit the complete active ancestry atomically.

Source

pub async fn check_tool_call_budget( &self, id: &str, calls: usize, ) -> Result<BudgetDecision>

Check an entire response batch before any ordinary call is persisted.

Source

pub async fn check_model_turn_budget(&self, id: &str) -> Result<BudgetDecision>

Source

pub async fn append_event( &self, id: &str, event_type: &str, payload: &Value, ) -> Result<i64>

Append a runtime event. Run, tool lifecycle and checkpoint events use the dedicated operations so the event log and materialized state agree.

Source

pub async fn events( &self, id: &str, after_sequence: i64, limit: u32, ) -> Result<Vec<AgentEvent>>

Incremental ordered event reads. Unknown/cross-workspace IDs fail closed.

Source

pub async fn save_checkpoint( &self, id: &str, schema_version: i64, turn: i64, state: &Value, ) -> Result<i64>

Persist a checkpoint and checkpoint.created event in one transaction.

Source

pub async fn latest_checkpoint( &self, id: &str, ) -> Result<Option<AgentCheckpoint>>

Source

pub async fn latest_suspension(&self, id: &str) -> Result<Option<RunSuspension>>

Source

pub async fn reopen_run( &self, id: &str, expected_sequence: i64, ) -> Result<AgentRun>

Reopen only an unchanged, recoverable run. The caller must also hold the runtime’s exclusive execution lock and validate its checkpoint before calling this method; the sequence guard prevents stale validation.

Source

pub async fn continue_suspended_run( &self, id: &str, expected_sequence: i64, suspension_sequence: i64, input: &str, checkpoint_schema: i64, checkpoint_turn: i64, checkpoint_state: &Value, ) -> Result<AgentRun>

Resolve one exact suspension and durably checkpoint its continuation before the caller is allowed to invoke the model again.

Source

pub async fn record_artifact( &self, id: &str, relative_path: &str, sha256: &str, size: u64, ) -> Result<i64>

Record metadata after the caller durably publishes the artifact file. Paths are normalized relative to the workspace root. File contents and filesystem containment are validated by the runtime.

Source

pub async fn artifacts(&self, id: &str) -> Result<Vec<ArtifactMetadata>>

Source

pub async fn finish_run(&self, id: &str, outcome: RunOutcome) -> Result<()>

Terminal runs reject ordinary writes; recovery requires reopen_run.

Source

pub(crate) async fn finish_run_with_pending_suspension( &self, id: &str, outcome: RunOutcome, pending_assistant: Option<Value>, ) -> Result<()>

Source

async fn finish_in( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, stopped: &StoppedRun, ) -> Result<i64>

Source

pub async fn request_tool( &self, id: &str, call_id: &str, name: &str, arguments: &Value, ) -> Result<()>

Source

pub async fn request_approval( &self, id: &str, call_id: &str, capabilities: &[Capability], ) -> Result<()>

Request one decision covering all approval-required capabilities of a call. The event log is the authoritative approval state; no separate grant survives this invocation or can authorize a later call.

Source

pub async fn decide_approval( &self, id: &str, call_id: &str, granted: bool, ) -> Result<()>

Source

async fn lock_requested_tool( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, call_id: &str, ) -> Result<()>

Source

async fn approval_state( tx: &mut Transaction<'_, Sqlite>, id: &str, call_id: &str, ) -> Result<Option<String>>

Source

async fn deny_pending_approval( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, call_id: &str, reason: &str, ) -> Result<()>

Source

pub async fn start_tool(&self, id: &str, call_id: &str) -> Result<()>

Source

pub async fn finish_tool( &self, id: &str, call_id: &str, outcome: ToolOutcome, ) -> Result<()>

Source

pub(crate) async fn finish_tool_with_count( &self, id: &str, call_id: &str, outcome: ToolOutcome, ) -> Result<Option<u32>>

Source

pub async fn tool_invocations(&self, id: &str) -> Result<Vec<ToolInvocation>>

Source

async fn project_working_state( tx: &mut Transaction<'_, Sqlite>, id: &str, event_type: &str, payload: &Value, ) -> Result<()>

Source

async fn refresh_working_state( tx: &mut Transaction<'_, Sqlite>, id: &str, ) -> Result<()>

Source

pub async fn working_state(&self, id: &str) -> Result<WorkingStateInspection>

Source

pub async fn rebuild_working_state( &self, id: &str, ) -> Result<WorkingStateInspection>

Source

async fn append_in( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, event_type: &str, payload: &Value, ) -> Result<i64>

Trait Implementations§

Source§

impl Clone for AgentRunStore

Source§

fn clone(&self) -> AgentRunStore

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

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

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
§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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

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