pub struct StateRuntime { /* private fields */ }Expand description
Preferred entrypoint: owns configuration and metrics.
Implementations§
Source§impl StateRuntime
impl StateRuntime
pub async fn get_backfill_state(&self) -> Result<BackfillState>
Sourcepub async fn try_claim_backfill(&self, lease_seconds: i64) -> Result<bool>
pub async fn try_claim_backfill(&self, lease_seconds: i64) -> Result<bool>
Attempt to claim ownership of rollout metadata backfill.
Returns true when this runtime claimed the backfill worker slot.
Returns false if backfill is already complete or currently owned by a
non-expired worker.
Sourcepub async fn mark_backfill_running(&self) -> Result<()>
pub async fn mark_backfill_running(&self) -> Result<()>
Mark rollout metadata backfill as running.
Sourcepub async fn checkpoint_backfill(&self, watermark: &str) -> Result<()>
pub async fn checkpoint_backfill(&self, watermark: &str) -> Result<()>
Persist rollout metadata backfill progress.
Source§impl StateRuntime
impl StateRuntime
pub async fn record_external_agent_config_import_completed( &self, import_id: &str, successes: &[ExternalAgentConfigImportSuccessRecord], failures: &[ExternalAgentConfigImportFailureRecord], ) -> Result<()>
pub async fn external_agent_config_import_details_record( &self, import_id: &str, ) -> Result<Option<ExternalAgentConfigImportDetailsRecord>>
pub async fn external_agent_config_import_history_records( &self, ) -> Result<Vec<ExternalAgentConfigImportHistoryRecord>>
Source§impl StateRuntime
impl StateRuntime
pub async fn insert_log(&self, entry: &LogEntry) -> Result<()>
Sourcepub async fn insert_logs(&self, entries: &[LogEntry]) -> Result<()>
pub async fn insert_logs(&self, entries: &[LogEntry]) -> Result<()>
Insert a batch of log entries into the logs table.
Sourcepub async fn query_logs(&self, query: &LogQuery) -> Result<Vec<LogRow>>
pub async fn query_logs(&self, query: &LogQuery) -> Result<Vec<LogRow>>
Query logs with optional filters.
Sourcepub async fn query_feedback_logs_for_threads(
&self,
thread_ids: &[&str],
) -> Result<Vec<u8>>
pub async fn query_feedback_logs_for_threads( &self, thread_ids: &[&str], ) -> Result<Vec<u8>>
Query feedback logs for a set of threads, capped to the SQLite retention budget.
Sourcepub async fn query_feedback_logs(&self, thread_id: &str) -> Result<Vec<u8>>
pub async fn query_feedback_logs(&self, thread_id: &str) -> Result<Vec<u8>>
Query per-thread feedback logs, capped to the per-thread SQLite retention budget.
Sourcepub async fn max_log_id(&self, query: &LogQuery) -> Result<i64>
pub async fn max_log_id(&self, query: &LogQuery) -> Result<i64>
Return the max log id matching optional filters.
Source§impl StateRuntime
impl StateRuntime
pub async fn get_remote_control_enrollment( &self, websocket_url: &str, account_id: &str, app_server_client_name: Option<&str>, ) -> Result<Option<RemoteControlEnrollmentRecord>>
pub async fn upsert_remote_control_enrollment( &self, enrollment: &RemoteControlEnrollmentRecord, ) -> Result<()>
pub async fn set_remote_control_enabled( &self, websocket_url: &str, account_id: &str, app_server_client_name: Option<&str>, remote_control_enabled: bool, ) -> Result<u64>
pub async fn delete_remote_control_enrollment( &self, websocket_url: &str, account_id: &str, app_server_client_name: Option<&str>, ) -> Result<u64>
Source§impl StateRuntime
impl StateRuntime
pub async fn get_thread(&self, id: ThreadId) -> Result<Option<ThreadMetadata>>
pub async fn get_thread_memory_mode( &self, id: ThreadId, ) -> Result<Option<String>>
pub async fn set_thread_preview_if_empty( &self, thread_id: ThreadId, preview: &str, ) -> Result<bool>
Sourcepub async fn upsert_thread_spawn_edge(
&self,
parent_thread_id: ThreadId,
child_thread_id: ThreadId,
status: DirectionalThreadSpawnEdgeStatus,
) -> Result<()>
pub async fn upsert_thread_spawn_edge( &self, parent_thread_id: ThreadId, child_thread_id: ThreadId, status: DirectionalThreadSpawnEdgeStatus, ) -> Result<()>
Persist or replace the directional parent-child edge for a spawned thread.
Sourcepub async fn set_thread_spawn_edge_status(
&self,
child_thread_id: ThreadId,
status: DirectionalThreadSpawnEdgeStatus,
) -> Result<()>
pub async fn set_thread_spawn_edge_status( &self, child_thread_id: ThreadId, status: DirectionalThreadSpawnEdgeStatus, ) -> Result<()>
Update the persisted lifecycle status of a spawned thread’s incoming edge.
Sourcepub async fn list_thread_spawn_children_with_status(
&self,
parent_thread_id: ThreadId,
status: DirectionalThreadSpawnEdgeStatus,
) -> Result<Vec<ThreadId>>
pub async fn list_thread_spawn_children_with_status( &self, parent_thread_id: ThreadId, status: DirectionalThreadSpawnEdgeStatus, ) -> Result<Vec<ThreadId>>
List direct spawned children of parent_thread_id whose edge matches status.
Sourcepub async fn list_thread_spawn_children(
&self,
parent_thread_id: ThreadId,
) -> Result<Vec<ThreadId>>
pub async fn list_thread_spawn_children( &self, parent_thread_id: ThreadId, ) -> Result<Vec<ThreadId>>
List all direct spawned children of parent_thread_id.
Sourcepub async fn list_thread_spawn_descendants_with_status(
&self,
root_thread_id: ThreadId,
status: DirectionalThreadSpawnEdgeStatus,
) -> Result<Vec<ThreadId>>
pub async fn list_thread_spawn_descendants_with_status( &self, root_thread_id: ThreadId, status: DirectionalThreadSpawnEdgeStatus, ) -> Result<Vec<ThreadId>>
List spawned descendants of root_thread_id whose edges match status.
Descendants are returned breadth-first by depth, then by thread id for stable ordering.
Sourcepub async fn list_thread_spawn_descendants(
&self,
root_thread_id: ThreadId,
) -> Result<Vec<ThreadId>>
pub async fn list_thread_spawn_descendants( &self, root_thread_id: ThreadId, ) -> Result<Vec<ThreadId>>
List all spawned descendants of root_thread_id.
Descendants are returned breadth-first by depth, then by thread id for stable ordering.
Sourcepub async fn find_thread_spawn_child_by_path(
&self,
parent_thread_id: ThreadId,
agent_path: &str,
) -> Result<Option<ThreadId>>
pub async fn find_thread_spawn_child_by_path( &self, parent_thread_id: ThreadId, agent_path: &str, ) -> Result<Option<ThreadId>>
Find a direct spawned child of parent_thread_id by canonical agent path.
Sourcepub async fn find_thread_spawn_descendant_by_path(
&self,
root_thread_id: ThreadId,
agent_path: &str,
) -> Result<Option<ThreadId>>
pub async fn find_thread_spawn_descendant_by_path( &self, root_thread_id: ThreadId, agent_path: &str, ) -> Result<Option<ThreadId>>
Find a spawned descendant of root_thread_id by canonical agent path.
Sourcepub async fn find_rollout_path_by_id(
&self,
id: ThreadId,
archived_only: Option<bool>,
) -> Result<Option<PathBuf>>
pub async fn find_rollout_path_by_id( &self, id: ThreadId, archived_only: Option<bool>, ) -> Result<Option<PathBuf>>
Find a rollout path by thread id using the underlying database.
Sourcepub async fn find_thread_by_exact_title(
&self,
title: &str,
allowed_sources: &[String],
model_providers: Option<&[String]>,
archived_only: bool,
cwd: Option<&Path>,
) -> Result<Option<ThreadMetadata>>
pub async fn find_thread_by_exact_title( &self, title: &str, allowed_sources: &[String], model_providers: Option<&[String]>, archived_only: bool, cwd: Option<&Path>, ) -> Result<Option<ThreadMetadata>>
Find the newest thread whose user-facing title exactly matches title.
Sourcepub async fn list_threads(
&self,
page_size: usize,
filters: ThreadFilterOptions<'_>,
) -> Result<ThreadsPage>
pub async fn list_threads( &self, page_size: usize, filters: ThreadFilterOptions<'_>, ) -> Result<ThreadsPage>
List threads using the underlying database.
Sourcepub async fn list_threads_by_parent(
&self,
page_size: usize,
parent_thread_id: ThreadId,
filters: ThreadFilterOptions<'_>,
) -> Result<ThreadsPage>
pub async fn list_threads_by_parent( &self, page_size: usize, parent_thread_id: ThreadId, filters: ThreadFilterOptions<'_>, ) -> Result<ThreadsPage>
List direct children of parent_thread_id using persisted spawn edges.
Sourcepub async fn list_threads_by_relation(
&self,
page_size: usize,
relation_filter: ThreadRelationFilter,
filters: ThreadFilterOptions<'_>,
) -> Result<ThreadsPage>
pub async fn list_threads_by_relation( &self, page_size: usize, relation_filter: ThreadRelationFilter, filters: ThreadFilterOptions<'_>, ) -> Result<ThreadsPage>
List threads matching a persisted spawn-graph relationship.
Sourcepub async fn list_thread_ids(
&self,
limit: usize,
anchor: Option<&Anchor>,
sort_key: SortKey,
allowed_sources: &[String],
model_providers: Option<&[String]>,
archived_only: bool,
) -> Result<Vec<ThreadId>>
pub async fn list_thread_ids( &self, limit: usize, anchor: Option<&Anchor>, sort_key: SortKey, allowed_sources: &[String], model_providers: Option<&[String]>, archived_only: bool, ) -> Result<Vec<ThreadId>>
List thread ids using the underlying database (no rollout scanning).
Sourcepub async fn upsert_thread(&self, metadata: &ThreadMetadata) -> Result<()>
pub async fn upsert_thread(&self, metadata: &ThreadMetadata) -> Result<()>
Insert or replace thread metadata directly.
pub async fn insert_thread_if_absent( &self, metadata: &ThreadMetadata, ) -> Result<bool>
pub async fn set_thread_memory_mode( &self, thread_id: ThreadId, memory_mode: &str, ) -> Result<bool>
pub async fn update_thread_title( &self, thread_id: ThreadId, title: &str, ) -> Result<bool>
pub async fn update_thread_name( &self, thread_id: ThreadId, name: Option<&str>, ) -> Result<bool>
pub async fn touch_thread_updated_at( &self, thread_id: ThreadId, updated_at: DateTime<Utc>, ) -> Result<bool>
pub async fn touch_thread_recency_at( &self, thread_id: ThreadId, recency_at: DateTime<Utc>, ) -> Result<bool>
Source§impl StateRuntime
impl StateRuntime
pub async fn update_thread_git_info( &self, thread_id: ThreadId, git_sha: Option<Option<&str>>, git_branch: Option<Option<&str>>, git_origin_url: Option<Option<&str>>, ) -> Result<bool>
Sourcepub async fn apply_rollout_items(
&self,
builder: &ThreadMetadataBuilder,
items: &[RolloutItem],
new_thread_memory_mode: Option<&str>,
updated_at_override: Option<DateTime<Utc>>,
) -> Result<()>
pub async fn apply_rollout_items( &self, builder: &ThreadMetadataBuilder, items: &[RolloutItem], new_thread_memory_mode: Option<&str>, updated_at_override: Option<DateTime<Utc>>, ) -> Result<()>
Apply rollout items incrementally using the underlying database.
Sourcepub async fn mark_archived(
&self,
thread_id: ThreadId,
rollout_path: &Path,
archived_at: DateTime<Utc>,
) -> Result<()>
pub async fn mark_archived( &self, thread_id: ThreadId, rollout_path: &Path, archived_at: DateTime<Utc>, ) -> Result<()>
Mark a thread as archived using the underlying database.
Sourcepub async fn mark_unarchived(
&self,
thread_id: ThreadId,
rollout_path: &Path,
) -> Result<()>
pub async fn mark_unarchived( &self, thread_id: ThreadId, rollout_path: &Path, ) -> Result<()>
Mark a thread as unarchived using the underlying database.
Sourcepub async fn delete_thread(&self, thread_id: ThreadId) -> Result<u64>
pub async fn delete_thread(&self, thread_id: ThreadId) -> Result<u64>
Delete a thread and all associated state by id.
Sourcepub async fn delete_threads_strict(
&self,
thread_ids: &[ThreadId],
) -> Result<u64>
pub async fn delete_threads_strict( &self, thread_ids: &[ThreadId], ) -> Result<u64>
Delete a set of threads and all associated state.
Spawn edges and thread rows are deleted last so a failed delete can be retried with enough state left to rediscover the same spawned subtree.
Source§impl StateRuntime
impl StateRuntime
Sourcepub async fn init(
codex_home: PathBuf,
default_provider: String,
) -> Result<Arc<Self>>
pub async fn init( codex_home: PathBuf, default_provider: String, ) -> Result<Arc<Self>>
Initialize the state runtime using the provided Codex home and default provider.
This opens (and migrates) the SQLite databases under codex_home.
Logs and paginated thread history live in dedicated files to reduce
lock contention with the rest of the state store.
Sourcepub fn codex_home(&self) -> &Path
pub fn codex_home(&self) -> &Path
Return the configured Codex home directory for this runtime.
pub fn thread_goals(&self) -> &GoalStore
pub fn memories(&self) -> &MemoryStore
Sourcepub async fn close(&self)
pub async fn close(&self)
Close all SQLite pools and wait for outstanding pool workers to exit.
pub async fn clear_memory_data_in_sqlite_home( sqlite_home: &Path, ) -> Result<bool>
Trait Implementations§
Source§impl Clone for StateRuntime
impl Clone for StateRuntime
Source§fn clone(&self) -> StateRuntime
fn clone(&self) -> StateRuntime
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 StateRuntime
impl !UnwindSafe for StateRuntime
impl Freeze for StateRuntime
impl Send for StateRuntime
impl Sync for StateRuntime
impl Unpin for StateRuntime
impl UnsafeUnpin for StateRuntime
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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