pub struct AgentRunStore {
pool: SqlitePool,
workspace_id: String,
}Expand description
Workspace-scoped persistence facade, sharing the application connection pool.
Fields§
§pool: SqlitePool§workspace_id: StringImplementations§
Source§impl AgentRunStore
impl AgentRunStore
pub fn new(pool: SqlitePool, workspace_id: &str) -> Result<Self>
Sourcepub async fn create_run(
&self,
agent_name: &str,
agent_version: &str,
model: &str,
input: &str,
) -> Result<AgentRun>
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.
pub async fn create_run_with_budgets( &self, agent_name: &str, agent_version: &str, model: &str, input: &str, budgets: RunBudgets, ) -> Result<AgentRun>
Sourcepub(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>
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.
pub async fn lineage(&self, id: &str) -> Result<RunLineage>
pub async fn children(&self, id: &str) -> Result<Vec<RunLineage>>
async fn has_lineage_table(&self) -> Result<bool>
Sourcepub async fn create_child_run(
&self,
parent_id: &str,
call_id: &str,
agent_name: &str,
agent_version: &str,
model: &str,
input: &str,
) -> Result<AgentRun>
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.
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>
pub async fn get_run(&self, id: &str) -> Result<Option<AgentRun>>
pub(crate) async fn get_run_raw(&self, id: &str) -> Result<Option<AgentRun>>
Sourcepub async fn history(&self, limit: u32) -> Result<Vec<AgentRun>>
pub async fn history(&self, limit: u32) -> Result<Vec<AgentRun>>
Most recent runs first, with a bounded result count.
Sourcepub async fn recovery_disposition(
&self,
id: &str,
) -> Result<RecoveryDisposition>
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.
async fn classify_recovery(&self, run: &AgentRun) -> Result<RecoveryDisposition>
async fn active_budget_chain( tx: &mut Transaction<'_, Sqlite>, id: &str, workspace_id: &str, ) -> Result<Vec<BudgetRow>>
async fn acquire_run_write( tx: &mut Transaction<'_, Sqlite>, id: &str, workspace_id: &str, ) -> Result<()>
async fn save_usage( tx: &mut Transaction<'_, Sqlite>, row: &BudgetRow, usage: &RunUsage, ) -> Result<()>
Sourcepub async fn record_model_requested(
&self,
id: &str,
payload: &Value,
) -> Result<BudgetDecision>
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.
Sourcepub async fn record_model_responded(
&self,
id: &str,
payload: &Value,
usage: Option<(u64, u64, u64)>,
) -> Result<BudgetDecision>
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.
Sourcepub async fn check_tool_call_budget(
&self,
id: &str,
calls: usize,
) -> Result<BudgetDecision>
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.
pub async fn check_model_turn_budget(&self, id: &str) -> Result<BudgetDecision>
Sourcepub async fn append_event(
&self,
id: &str,
event_type: &str,
payload: &Value,
) -> Result<i64>
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.
Sourcepub async fn events(
&self,
id: &str,
after_sequence: i64,
limit: u32,
) -> Result<Vec<AgentEvent>>
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.
Sourcepub async fn save_checkpoint(
&self,
id: &str,
schema_version: i64,
turn: i64,
state: &Value,
) -> Result<i64>
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.
pub async fn latest_checkpoint( &self, id: &str, ) -> Result<Option<AgentCheckpoint>>
pub async fn latest_suspension(&self, id: &str) -> Result<Option<RunSuspension>>
Sourcepub async fn reopen_run(
&self,
id: &str,
expected_sequence: i64,
) -> Result<AgentRun>
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.
Sourcepub 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>
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.
Sourcepub async fn record_artifact(
&self,
id: &str,
relative_path: &str,
sha256: &str,
size: u64,
) -> Result<i64>
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.
pub async fn artifacts(&self, id: &str) -> Result<Vec<ArtifactMetadata>>
Sourcepub async fn finish_run(&self, id: &str, outcome: RunOutcome) -> Result<()>
pub async fn finish_run(&self, id: &str, outcome: RunOutcome) -> Result<()>
Terminal runs reject ordinary writes; recovery requires reopen_run.
pub(crate) async fn finish_run_with_pending_suspension( &self, id: &str, outcome: RunOutcome, pending_assistant: Option<Value>, ) -> Result<()>
async fn finish_in( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, stopped: &StoppedRun, ) -> Result<i64>
pub async fn request_tool( &self, id: &str, call_id: &str, name: &str, arguments: &Value, ) -> Result<()>
Sourcepub async fn request_approval(
&self,
id: &str,
call_id: &str,
capabilities: &[Capability],
) -> Result<()>
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.
pub async fn decide_approval( &self, id: &str, call_id: &str, granted: bool, ) -> Result<()>
async fn lock_requested_tool( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, call_id: &str, ) -> Result<()>
async fn approval_state( tx: &mut Transaction<'_, Sqlite>, id: &str, call_id: &str, ) -> Result<Option<String>>
async fn deny_pending_approval( &self, tx: &mut Transaction<'_, Sqlite>, id: &str, call_id: &str, reason: &str, ) -> Result<()>
pub async fn start_tool(&self, id: &str, call_id: &str) -> Result<()>
pub async fn finish_tool( &self, id: &str, call_id: &str, outcome: ToolOutcome, ) -> Result<()>
pub(crate) async fn finish_tool_with_count( &self, id: &str, call_id: &str, outcome: ToolOutcome, ) -> Result<Option<u32>>
pub async fn tool_invocations(&self, id: &str) -> Result<Vec<ToolInvocation>>
async fn project_working_state( tx: &mut Transaction<'_, Sqlite>, id: &str, event_type: &str, payload: &Value, ) -> Result<()>
async fn refresh_working_state( tx: &mut Transaction<'_, Sqlite>, id: &str, ) -> Result<()>
pub async fn working_state(&self, id: &str) -> Result<WorkingStateInspection>
pub async fn rebuild_working_state( &self, id: &str, ) -> Result<WorkingStateInspection>
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
impl Clone for AgentRunStore
Source§fn clone(&self) -> AgentRunStore
fn clone(&self) -> AgentRunStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AgentRunStore
impl !UnwindSafe for AgentRunStore
impl Freeze for AgentRunStore
impl Send for AgentRunStore
impl Sync for AgentRunStore
impl Unpin for AgentRunStore
impl UnsafeUnpin for AgentRunStore
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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