pub struct SqliteStore { /* private fields */ }Implementations§
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn load_input_history(
&self,
limit: i64,
) -> Result<Vec<String>, MemoryError>
pub async fn load_input_history( &self, limit: i64, ) -> Result<Vec<String>, MemoryError>
Load the most recent input history entries, ordered chronologically.
§Errors
Returns an error if the query fails.
Sourcepub async fn save_input_entry(&self, text: &str) -> Result<(), MemoryError>
pub async fn save_input_entry(&self, text: &str) -> Result<(), MemoryError>
Sourcepub async fn clear_input_history(&self) -> Result<(), MemoryError>
pub async fn clear_input_history(&self) -> Result<(), MemoryError>
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn create_conversation(&self) -> Result<ConversationId, MemoryError>
pub async fn create_conversation(&self) -> Result<ConversationId, MemoryError>
Sourcepub async fn save_message(
&self,
conversation_id: ConversationId,
role: &str,
content: &str,
) -> Result<MessageId, MemoryError>
pub async fn save_message( &self, conversation_id: ConversationId, role: &str, content: &str, ) -> Result<MessageId, MemoryError>
Save a message to the given conversation and return the message ID.
§Errors
Returns an error if the insert fails.
Sourcepub async fn save_message_with_parts(
&self,
conversation_id: ConversationId,
role: &str,
content: &str,
parts_json: &str,
) -> Result<MessageId, MemoryError>
pub async fn save_message_with_parts( &self, conversation_id: ConversationId, role: &str, content: &str, parts_json: &str, ) -> Result<MessageId, MemoryError>
Sourcepub async fn load_history(
&self,
conversation_id: ConversationId,
limit: u32,
) -> Result<Vec<Message>, MemoryError>
pub async fn load_history( &self, conversation_id: ConversationId, limit: u32, ) -> Result<Vec<Message>, MemoryError>
Load the most recent messages for a conversation, up to limit.
§Errors
Returns an error if the query fails.
Sourcepub async fn latest_conversation_id(
&self,
) -> Result<Option<ConversationId>, MemoryError>
pub async fn latest_conversation_id( &self, ) -> Result<Option<ConversationId>, MemoryError>
Sourcepub async fn message_by_id(
&self,
message_id: MessageId,
) -> Result<Option<Message>, MemoryError>
pub async fn message_by_id( &self, message_id: MessageId, ) -> Result<Option<Message>, MemoryError>
Sourcepub async fn messages_by_ids(
&self,
ids: &[MessageId],
) -> Result<Vec<(MessageId, Message)>, MemoryError>
pub async fn messages_by_ids( &self, ids: &[MessageId], ) -> Result<Vec<(MessageId, Message)>, MemoryError>
Sourcepub async fn unembedded_message_ids(
&self,
limit: Option<usize>,
) -> Result<Vec<(MessageId, ConversationId, String, String)>, MemoryError>
pub async fn unembedded_message_ids( &self, limit: Option<usize>, ) -> Result<Vec<(MessageId, ConversationId, String, String)>, MemoryError>
Return message IDs and content for messages without embeddings.
§Errors
Returns an error if the query fails.
Sourcepub async fn count_messages(
&self,
conversation_id: ConversationId,
) -> Result<i64, MemoryError>
pub async fn count_messages( &self, conversation_id: ConversationId, ) -> Result<i64, MemoryError>
Sourcepub async fn count_messages_after(
&self,
conversation_id: ConversationId,
after_id: MessageId,
) -> Result<i64, MemoryError>
pub async fn count_messages_after( &self, conversation_id: ConversationId, after_id: MessageId, ) -> Result<i64, MemoryError>
Count messages in a conversation with id greater than after_id.
§Errors
Returns an error if the query fails.
Sourcepub async fn keyword_search(
&self,
query: &str,
limit: usize,
conversation_id: Option<ConversationId>,
) -> Result<Vec<(MessageId, f64)>, MemoryError>
pub async fn keyword_search( &self, query: &str, limit: usize, conversation_id: Option<ConversationId>, ) -> Result<Vec<(MessageId, f64)>, MemoryError>
Full-text keyword search over messages using FTS5.
Returns message IDs with BM25 relevance scores (lower = more relevant, negated to positive for consistency with vector scores).
§Errors
Returns an error if the query fails.
Sourcepub async fn load_messages_range(
&self,
conversation_id: ConversationId,
after_message_id: MessageId,
limit: usize,
) -> Result<Vec<(MessageId, String, String)>, MemoryError>
pub async fn load_messages_range( &self, conversation_id: ConversationId, after_message_id: MessageId, limit: usize, ) -> Result<Vec<(MessageId, String, String)>, MemoryError>
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn record_skill_usage(
&self,
skill_names: &[&str],
) -> Result<(), MemoryError>
pub async fn record_skill_usage( &self, skill_names: &[&str], ) -> Result<(), MemoryError>
Record usage of skills (UPSERT: increment count and update timestamp).
§Errors
Returns an error if the database operation fails.
Sourcepub async fn load_skill_usage(&self) -> Result<Vec<SkillUsageRow>, MemoryError>
pub async fn load_skill_usage(&self) -> Result<Vec<SkillUsageRow>, MemoryError>
Sourcepub async fn record_skill_outcome(
&self,
skill_name: &str,
version_id: Option<i64>,
conversation_id: Option<ConversationId>,
outcome: &str,
error_context: Option<&str>,
) -> Result<(), MemoryError>
pub async fn record_skill_outcome( &self, skill_name: &str, version_id: Option<i64>, conversation_id: Option<ConversationId>, outcome: &str, error_context: Option<&str>, ) -> Result<(), MemoryError>
Sourcepub async fn record_skill_outcomes_batch(
&self,
skill_names: &[String],
conversation_id: Option<ConversationId>,
outcome: &str,
error_context: Option<&str>,
) -> Result<(), MemoryError>
pub async fn record_skill_outcomes_batch( &self, skill_names: &[String], conversation_id: Option<ConversationId>, outcome: &str, error_context: Option<&str>, ) -> Result<(), MemoryError>
Record outcomes for multiple skills in a single transaction.
§Errors
Returns an error if any insert fails (whole batch is rolled back).
Sourcepub async fn skill_metrics(
&self,
skill_name: &str,
) -> Result<Option<SkillMetricsRow>, MemoryError>
pub async fn skill_metrics( &self, skill_name: &str, ) -> Result<Option<SkillMetricsRow>, MemoryError>
Sourcepub async fn load_skill_outcome_stats(
&self,
) -> Result<Vec<SkillMetricsRow>, MemoryError>
pub async fn load_skill_outcome_stats( &self, ) -> Result<Vec<SkillMetricsRow>, MemoryError>
Sourcepub async fn save_skill_version(
&self,
skill_name: &str,
version: i64,
body: &str,
description: &str,
source: &str,
error_context: Option<&str>,
predecessor_id: Option<i64>,
) -> Result<i64, MemoryError>
pub async fn save_skill_version( &self, skill_name: &str, version: i64, body: &str, description: &str, source: &str, error_context: Option<&str>, predecessor_id: Option<i64>, ) -> Result<i64, MemoryError>
Sourcepub async fn active_skill_version(
&self,
skill_name: &str,
) -> Result<Option<SkillVersionRow>, MemoryError>
pub async fn active_skill_version( &self, skill_name: &str, ) -> Result<Option<SkillVersionRow>, MemoryError>
Sourcepub async fn activate_skill_version(
&self,
skill_name: &str,
version_id: i64,
) -> Result<(), MemoryError>
pub async fn activate_skill_version( &self, skill_name: &str, version_id: i64, ) -> Result<(), MemoryError>
Activate a specific version (deactivates others for the same skill).
§Errors
Returns an error if the update fails.
Sourcepub async fn next_skill_version(
&self,
skill_name: &str,
) -> Result<i64, MemoryError>
pub async fn next_skill_version( &self, skill_name: &str, ) -> Result<i64, MemoryError>
Sourcepub async fn last_improvement_time(
&self,
skill_name: &str,
) -> Result<Option<String>, MemoryError>
pub async fn last_improvement_time( &self, skill_name: &str, ) -> Result<Option<String>, MemoryError>
Get the latest auto-generated version’s created_at for cooldown check.
§Errors
Returns an error if the query fails.
Sourcepub async fn ensure_skill_version_exists(
&self,
skill_name: &str,
body: &str,
description: &str,
) -> Result<(), MemoryError>
pub async fn ensure_skill_version_exists( &self, skill_name: &str, body: &str, description: &str, ) -> Result<(), MemoryError>
Ensure a base (v1 manual) version exists for a skill. Idempotent.
§Errors
Returns an error if the DB operation fails.
Sourcepub async fn load_skill_versions(
&self,
skill_name: &str,
) -> Result<Vec<SkillVersionRow>, MemoryError>
pub async fn load_skill_versions( &self, skill_name: &str, ) -> Result<Vec<SkillVersionRow>, MemoryError>
Load all versions for a skill, ordered by version number.
§Errors
Returns an error if the query fails.
Sourcepub async fn count_auto_versions(
&self,
skill_name: &str,
) -> Result<i64, MemoryError>
pub async fn count_auto_versions( &self, skill_name: &str, ) -> Result<i64, MemoryError>
Sourcepub async fn prune_skill_versions(
&self,
skill_name: &str,
max_versions: u32,
) -> Result<u32, MemoryError>
pub async fn prune_skill_versions( &self, skill_name: &str, max_versions: u32, ) -> Result<u32, MemoryError>
Delete oldest non-active auto versions exceeding max limit. Returns the number of pruned versions.
§Errors
Returns an error if the delete fails.
Sourcepub async fn predecessor_version(
&self,
version_id: i64,
) -> Result<Option<SkillVersionRow>, MemoryError>
pub async fn predecessor_version( &self, version_id: i64, ) -> Result<Option<SkillVersionRow>, MemoryError>
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn save_summary(
&self,
conversation_id: ConversationId,
content: &str,
first_message_id: MessageId,
last_message_id: MessageId,
token_estimate: i64,
) -> Result<i64, MemoryError>
pub async fn save_summary( &self, conversation_id: ConversationId, content: &str, first_message_id: MessageId, last_message_id: MessageId, token_estimate: i64, ) -> Result<i64, MemoryError>
Sourcepub async fn load_summaries(
&self,
conversation_id: ConversationId,
) -> Result<Vec<(i64, ConversationId, String, MessageId, MessageId, i64)>, MemoryError>
pub async fn load_summaries( &self, conversation_id: ConversationId, ) -> Result<Vec<(i64, ConversationId, String, MessageId, MessageId, i64)>, MemoryError>
Sourcepub async fn latest_summary_last_message_id(
&self,
conversation_id: ConversationId,
) -> Result<Option<MessageId>, MemoryError>
pub async fn latest_summary_last_message_id( &self, conversation_id: ConversationId, ) -> Result<Option<MessageId>, MemoryError>
Get the last message ID covered by the most recent summary.
§Errors
Returns an error if the query fails.
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn upsert_skill_trust(
&self,
skill_name: &str,
trust_level: &str,
source_kind: &str,
source_url: Option<&str>,
source_path: Option<&str>,
blake3_hash: &str,
) -> Result<(), MemoryError>
pub async fn upsert_skill_trust( &self, skill_name: &str, trust_level: &str, source_kind: &str, source_url: Option<&str>, source_path: Option<&str>, blake3_hash: &str, ) -> Result<(), MemoryError>
Sourcepub async fn load_skill_trust(
&self,
skill_name: &str,
) -> Result<Option<SkillTrustRow>, MemoryError>
pub async fn load_skill_trust( &self, skill_name: &str, ) -> Result<Option<SkillTrustRow>, MemoryError>
Sourcepub async fn load_all_skill_trust(
&self,
) -> Result<Vec<SkillTrustRow>, MemoryError>
pub async fn load_all_skill_trust( &self, ) -> Result<Vec<SkillTrustRow>, MemoryError>
Sourcepub async fn set_skill_trust_level(
&self,
skill_name: &str,
trust_level: &str,
) -> Result<bool, MemoryError>
pub async fn set_skill_trust_level( &self, skill_name: &str, trust_level: &str, ) -> Result<bool, MemoryError>
Update only the trust level for a skill.
§Errors
Returns an error if the skill does not exist or the update fails.
Sourcepub async fn delete_skill_trust(
&self,
skill_name: &str,
) -> Result<bool, MemoryError>
pub async fn delete_skill_trust( &self, skill_name: &str, ) -> Result<bool, MemoryError>
Sourcepub async fn update_skill_hash(
&self,
skill_name: &str,
blake3_hash: &str,
) -> Result<bool, MemoryError>
pub async fn update_skill_hash( &self, skill_name: &str, blake3_hash: &str, ) -> Result<bool, MemoryError>
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn new(path: &str) -> Result<Self, MemoryError>
pub async fn new(path: &str) -> Result<Self, MemoryError>
Open (or create) the SQLite database and run migrations.
Enables foreign key constraints at connection level so that
ON DELETE CASCADE and other FK rules are enforced.
§Errors
Returns an error if the database cannot be opened or migrations fail.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Expose the underlying pool for shared access by other stores.
Sourcepub async fn run_migrations(pool: &SqlitePool) -> Result<(), MemoryError>
pub async fn run_migrations(pool: &SqlitePool) -> Result<(), MemoryError>
Trait Implementations§
Source§impl Clone for SqliteStore
impl Clone for SqliteStore
Source§fn clone(&self) -> SqliteStore
fn clone(&self) -> SqliteStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SqliteStore
impl !RefUnwindSafe for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
impl !UnwindSafe for SqliteStore
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,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request