pub struct SqliteStorage { /* private fields */ }Expand description
SQLite-based storage backend.
Implementations§
Source§impl SqliteStorage
impl SqliteStorage
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open a database at the given path.
Creates the database and applies schema if it doesn’t exist.
§Errors
Returns an error if the connection cannot be established or schema fails.
Sourcepub fn open_with_timeout(path: &Path, timeout_ms: Option<u64>) -> Result<Self>
pub fn open_with_timeout(path: &Path, timeout_ms: Option<u64>) -> Result<Self>
Open a database with an optional busy timeout.
§Errors
Returns an error if the connection cannot be established or schema fails.
Sourcepub fn open_memory() -> Result<Self>
pub fn open_memory() -> Result<Self>
Open an in-memory database (for testing).
§Errors
Returns an error if the connection cannot be established.
Sourcepub fn conn(&self) -> &Connection
pub fn conn(&self) -> &Connection
Get a reference to the underlying connection (for read operations).
Sourcepub fn mutate<F, R>(&mut self, op: &str, actor: &str, f: F) -> Result<R>
pub fn mutate<F, R>(&mut self, op: &str, actor: &str, f: F) -> Result<R>
Execute a mutation with the transaction protocol.
This method:
- Begins an IMMEDIATE transaction (for write locking)
- Executes the mutation closure
- Writes audit events
- Updates dirty tracking tables
- Commits (or rolls back on error)
§Errors
Returns an error if any step fails. The transaction is rolled back on error.
Sourcepub fn create_session(
&mut self,
id: &str,
name: &str,
description: Option<&str>,
project_path: Option<&str>,
branch: Option<&str>,
actor: &str,
) -> Result<()>
pub fn create_session( &mut self, id: &str, name: &str, description: Option<&str>, project_path: Option<&str>, branch: Option<&str>, actor: &str, ) -> Result<()>
Sourcepub fn list_sessions(
&self,
project_path: Option<&str>,
status: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<Session>>
pub fn list_sessions( &self, project_path: Option<&str>, status: Option<&str>, limit: Option<u32>, ) -> Result<Vec<Session>>
Sourcepub fn list_sessions_with_search(
&self,
project_path: Option<&str>,
status: Option<&str>,
limit: Option<u32>,
search: Option<&str>,
) -> Result<Vec<Session>>
pub fn list_sessions_with_search( &self, project_path: Option<&str>, status: Option<&str>, limit: Option<u32>, search: Option<&str>, ) -> Result<Vec<Session>>
List sessions with optional filters and search.
Uses the session_projects junction table for project path filtering,
matching the MCP server’s listSessionsByPaths behavior.
§Errors
Returns an error if the query fails.
Sourcepub fn delete_session(&mut self, id: &str, actor: &str) -> Result<()>
pub fn delete_session(&mut self, id: &str, actor: &str) -> Result<()>
Delete a session and all related data.
This cascades to delete:
- Context items in the session
- Checkpoints for the session
- Session project paths
§Errors
Returns an error if the session doesn’t exist or can’t be deleted.
Sourcepub fn add_session_path(
&mut self,
session_id: &str,
project_path: &str,
actor: &str,
) -> Result<()>
pub fn add_session_path( &mut self, session_id: &str, project_path: &str, actor: &str, ) -> Result<()>
Add a project path to a session (for multi-project sessions).
§Errors
Returns an error if the session doesn’t exist or the path is already added.
Sourcepub fn remove_session_path(
&mut self,
session_id: &str,
project_path: &str,
actor: &str,
) -> Result<()>
pub fn remove_session_path( &mut self, session_id: &str, project_path: &str, actor: &str, ) -> Result<()>
Remove a project path from a session.
Cannot remove the last path (sessions must have at least the primary path).
§Errors
Returns an error if the session doesn’t exist or this is the last path.
Sourcepub fn get_session_paths(&self, session_id: &str) -> Result<Vec<String>>
pub fn get_session_paths(&self, session_id: &str) -> Result<Vec<String>>
Get all project paths for a session.
Returns the primary path from the session plus any additional paths from session_projects.
Sourcepub fn save_context_item(
&mut self,
id: &str,
session_id: &str,
key: &str,
value: &str,
category: Option<&str>,
priority: Option<&str>,
actor: &str,
) -> Result<()>
pub fn save_context_item( &mut self, id: &str, session_id: &str, key: &str, value: &str, category: Option<&str>, priority: Option<&str>, actor: &str, ) -> Result<()>
Sourcepub fn get_context_items(
&self,
session_id: &str,
category: Option<&str>,
priority: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<ContextItem>>
pub fn get_context_items( &self, session_id: &str, category: Option<&str>, priority: Option<&str>, limit: Option<u32>, ) -> Result<Vec<ContextItem>>
Sourcepub fn delete_context_item(
&mut self,
session_id: &str,
key: &str,
actor: &str,
) -> Result<()>
pub fn delete_context_item( &mut self, session_id: &str, key: &str, actor: &str, ) -> Result<()>
Sourcepub fn update_context_item(
&mut self,
session_id: &str,
key: &str,
value: Option<&str>,
category: Option<&str>,
priority: Option<&str>,
channel: Option<&str>,
actor: &str,
) -> Result<()>
pub fn update_context_item( &mut self, session_id: &str, key: &str, value: Option<&str>, category: Option<&str>, priority: Option<&str>, channel: Option<&str>, actor: &str, ) -> Result<()>
Update a context item’s value, category, priority, or channel.
§Errors
Returns an error if the update fails.
Sourcepub fn create_issue(
&mut self,
id: &str,
short_id: Option<&str>,
project_path: &str,
title: &str,
description: Option<&str>,
details: Option<&str>,
issue_type: Option<&str>,
priority: Option<i32>,
plan_id: Option<&str>,
actor: &str,
) -> Result<()>
pub fn create_issue( &mut self, id: &str, short_id: Option<&str>, project_path: &str, title: &str, description: Option<&str>, details: Option<&str>, issue_type: Option<&str>, priority: Option<i32>, plan_id: Option<&str>, actor: &str, ) -> Result<()>
Sourcepub fn list_issues(
&self,
project_path: &str,
status: Option<&str>,
issue_type: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<Issue>>
pub fn list_issues( &self, project_path: &str, status: Option<&str>, issue_type: Option<&str>, limit: Option<u32>, ) -> Result<Vec<Issue>>
Sourcepub fn list_all_issues(
&self,
status: Option<&str>,
issue_type: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<Issue>>
pub fn list_all_issues( &self, status: Option<&str>, issue_type: Option<&str>, limit: Option<u32>, ) -> Result<Vec<Issue>>
Sourcepub fn update_issue_status(
&mut self,
id: &str,
status: &str,
actor: &str,
) -> Result<()>
pub fn update_issue_status( &mut self, id: &str, status: &str, actor: &str, ) -> Result<()>
Update issue status.
Accepts either full ID or short_id.
§Errors
Returns an error if the update fails.
Sourcepub fn update_issue(
&mut self,
id: &str,
title: Option<&str>,
description: Option<&str>,
details: Option<&str>,
priority: Option<i32>,
issue_type: Option<&str>,
plan_id: Option<&str>,
parent_id: Option<&str>,
actor: &str,
) -> Result<()>
pub fn update_issue( &mut self, id: &str, title: Option<&str>, description: Option<&str>, details: Option<&str>, priority: Option<i32>, issue_type: Option<&str>, plan_id: Option<&str>, parent_id: Option<&str>, actor: &str, ) -> Result<()>
Update issue fields (title, description, details, priority, issue_type).
Only updates fields that are Some. Status is handled separately.
§Errors
Returns an error if the update fails.
Sourcepub fn claim_issue(&mut self, id: &str, actor: &str) -> Result<()>
pub fn claim_issue(&mut self, id: &str, actor: &str) -> Result<()>
Claim an issue (assign to agent).
Accepts either full ID or short_id.
§Errors
Returns an error if the claim fails.
Sourcepub fn release_issue(&mut self, id: &str, actor: &str) -> Result<()>
pub fn release_issue(&mut self, id: &str, actor: &str) -> Result<()>
Release an issue (unassign).
Accepts either full ID or short_id.
§Errors
Returns an error if the release fails.
Sourcepub fn remove_issue_labels(
&mut self,
id: &str,
labels: &[String],
actor: &str,
) -> Result<()>
pub fn remove_issue_labels( &mut self, id: &str, labels: &[String], actor: &str, ) -> Result<()>
Sourcepub fn issue_has_dependencies(&self, id: &str) -> Result<bool>
pub fn issue_has_dependencies(&self, id: &str) -> Result<bool>
Check if an issue has any dependencies (depends on other issues).
Sourcepub fn issue_has_subtasks(&self, id: &str) -> Result<bool>
pub fn issue_has_subtasks(&self, id: &str) -> Result<bool>
Check if an issue has any subtasks (child issues via parent-child dependency).
Sourcepub fn get_child_issue_ids(&self, parent_id: &str) -> Result<HashSet<String>>
pub fn get_child_issue_ids(&self, parent_id: &str) -> Result<HashSet<String>>
Get the set of issue IDs that are children of a specific parent.
Returns IDs of issues that have a parent-child dependency on the given parent ID.
Sourcepub fn add_issue_dependency(
&mut self,
issue_id: &str,
depends_on_id: &str,
dependency_type: &str,
actor: &str,
) -> Result<()>
pub fn add_issue_dependency( &mut self, issue_id: &str, depends_on_id: &str, dependency_type: &str, actor: &str, ) -> Result<()>
Sourcepub fn remove_issue_dependency(
&mut self,
issue_id: &str,
depends_on_id: &str,
actor: &str,
) -> Result<()>
pub fn remove_issue_dependency( &mut self, issue_id: &str, depends_on_id: &str, actor: &str, ) -> Result<()>
Sourcepub fn clone_issue(
&mut self,
id: &str,
new_title: Option<&str>,
actor: &str,
) -> Result<Issue>
pub fn clone_issue( &mut self, id: &str, new_title: Option<&str>, actor: &str, ) -> Result<Issue>
Sourcepub fn mark_issue_duplicate(
&mut self,
id: &str,
duplicate_of_id: &str,
actor: &str,
) -> Result<()>
pub fn mark_issue_duplicate( &mut self, id: &str, duplicate_of_id: &str, actor: &str, ) -> Result<()>
Sourcepub fn get_ready_issues(
&self,
project_path: &str,
limit: u32,
) -> Result<Vec<Issue>>
pub fn get_ready_issues( &self, project_path: &str, limit: u32, ) -> Result<Vec<Issue>>
Get issues that are ready to work on (open, no blocking dependencies, not assigned).
§Errors
Returns an error if the query fails.
Sourcepub fn get_next_issue_block(
&mut self,
project_path: &str,
count: u32,
actor: &str,
) -> Result<Vec<Issue>>
pub fn get_next_issue_block( &mut self, project_path: &str, count: u32, actor: &str, ) -> Result<Vec<Issue>>
Sourcepub fn create_checkpoint(
&mut self,
id: &str,
session_id: &str,
name: &str,
description: Option<&str>,
git_status: Option<&str>,
git_branch: Option<&str>,
actor: &str,
) -> Result<()>
pub fn create_checkpoint( &mut self, id: &str, session_id: &str, name: &str, description: Option<&str>, git_status: Option<&str>, git_branch: Option<&str>, actor: &str, ) -> Result<()>
Sourcepub fn add_checkpoint_item(
&mut self,
checkpoint_id: &str,
context_item_id: &str,
actor: &str,
) -> Result<()>
pub fn add_checkpoint_item( &mut self, checkpoint_id: &str, context_item_id: &str, actor: &str, ) -> Result<()>
Sourcepub fn list_checkpoints(
&self,
session_id: &str,
limit: Option<u32>,
) -> Result<Vec<Checkpoint>>
pub fn list_checkpoints( &self, session_id: &str, limit: Option<u32>, ) -> Result<Vec<Checkpoint>>
Sourcepub fn get_checkpoint(&self, id: &str) -> Result<Option<Checkpoint>>
pub fn get_checkpoint(&self, id: &str) -> Result<Option<Checkpoint>>
Sourcepub fn get_checkpoint_items(
&self,
checkpoint_id: &str,
) -> Result<Vec<ContextItem>>
pub fn get_checkpoint_items( &self, checkpoint_id: &str, ) -> Result<Vec<ContextItem>>
Sourcepub fn restore_checkpoint(
&mut self,
checkpoint_id: &str,
target_session_id: &str,
restore_categories: Option<&[String]>,
restore_tags: Option<&[String]>,
actor: &str,
) -> Result<usize>
pub fn restore_checkpoint( &mut self, checkpoint_id: &str, target_session_id: &str, restore_categories: Option<&[String]>, restore_tags: Option<&[String]>, actor: &str, ) -> Result<usize>
Restore a checkpoint to a target session.
This clears existing context items in the target session and recreates them from the checkpoint. Optional filters can limit which items are restored.
§Errors
Returns an error if the restore fails.
Sourcepub fn remove_checkpoint_item(
&mut self,
checkpoint_id: &str,
context_item_id: &str,
actor: &str,
) -> Result<()>
pub fn remove_checkpoint_item( &mut self, checkpoint_id: &str, context_item_id: &str, actor: &str, ) -> Result<()>
Sourcepub fn add_checkpoint_items_by_keys(
&mut self,
checkpoint_id: &str,
session_id: &str,
keys: &[String],
actor: &str,
) -> Result<usize>
pub fn add_checkpoint_items_by_keys( &mut self, checkpoint_id: &str, session_id: &str, keys: &[String], actor: &str, ) -> Result<usize>
Add items to checkpoint by their keys (from current session).
§Errors
Returns an error if the operation fails.
Sourcepub fn remove_checkpoint_items_by_keys(
&mut self,
checkpoint_id: &str,
keys: &[String],
actor: &str,
) -> Result<usize>
pub fn remove_checkpoint_items_by_keys( &mut self, checkpoint_id: &str, keys: &[String], actor: &str, ) -> Result<usize>
Sourcepub fn save_memory(
&mut self,
id: &str,
project_path: &str,
key: &str,
value: &str,
category: &str,
actor: &str,
) -> Result<()>
pub fn save_memory( &mut self, id: &str, project_path: &str, key: &str, value: &str, category: &str, actor: &str, ) -> Result<()>
Save a memory item (project-level persistent storage).
§Errors
Returns an error if the operation fails.
Sourcepub fn list_memory(
&self,
project_path: &str,
category: Option<&str>,
) -> Result<Vec<Memory>>
pub fn list_memory( &self, project_path: &str, category: Option<&str>, ) -> Result<Vec<Memory>>
Sourcepub fn get_dirty_sessions(&self) -> Result<Vec<String>>
pub fn get_dirty_sessions(&self) -> Result<Vec<String>>
Sourcepub fn get_dirty_issues(&self) -> Result<Vec<String>>
pub fn get_dirty_issues(&self) -> Result<Vec<String>>
Sourcepub fn get_dirty_context_items(&self) -> Result<Vec<String>>
pub fn get_dirty_context_items(&self) -> Result<Vec<String>>
Sourcepub fn clear_dirty_sessions(&mut self, ids: &[String]) -> Result<()>
pub fn clear_dirty_sessions(&mut self, ids: &[String]) -> Result<()>
Clear dirty flags for sessions after successful export.
§Errors
Returns an error if the delete fails.
Sourcepub fn clear_dirty_issues(&mut self, ids: &[String]) -> Result<()>
pub fn clear_dirty_issues(&mut self, ids: &[String]) -> Result<()>
Sourcepub fn clear_dirty_context_items(&mut self, ids: &[String]) -> Result<()>
pub fn clear_dirty_context_items(&mut self, ids: &[String]) -> Result<()>
Clear dirty flags for context items after successful export.
§Errors
Returns an error if the delete fails.
Sourcepub fn get_export_hash(
&self,
entity_type: &str,
entity_id: &str,
) -> Result<Option<String>>
pub fn get_export_hash( &self, entity_type: &str, entity_id: &str, ) -> Result<Option<String>>
Get the stored content hash for an entity (for incremental export).
§Errors
Returns an error if the query fails.
Sourcepub fn set_export_hash(
&mut self,
entity_type: &str,
entity_id: &str,
hash: &str,
) -> Result<()>
pub fn set_export_hash( &mut self, entity_type: &str, entity_id: &str, hash: &str, ) -> Result<()>
Sourcepub fn record_deletion(
&mut self,
entity_type: &str,
entity_id: &str,
project_path: &str,
actor: &str,
) -> Result<()>
pub fn record_deletion( &mut self, entity_type: &str, entity_id: &str, project_path: &str, actor: &str, ) -> Result<()>
Record a deletion for sync export.
This should be called when an entity is deleted so that the deletion can be exported and applied on other machines.
§Errors
Returns an error if the insert fails.
Sourcepub fn get_pending_deletions(
&self,
project_path: &str,
) -> Result<Vec<SyncDeletion>>
pub fn get_pending_deletions( &self, project_path: &str, ) -> Result<Vec<SyncDeletion>>
Get pending deletions for a project that haven’t been exported yet.
§Errors
Returns an error if the query fails.
Sourcepub fn get_all_deletions(&self, project_path: &str) -> Result<Vec<SyncDeletion>>
pub fn get_all_deletions(&self, project_path: &str) -> Result<Vec<SyncDeletion>>
Sourcepub fn mark_deletions_exported(&mut self, ids: &[i64]) -> Result<()>
pub fn mark_deletions_exported(&mut self, ids: &[i64]) -> Result<()>
Sourcepub fn count_pending_deletions(&self, project_path: &str) -> Result<usize>
pub fn count_pending_deletions(&self, project_path: &str) -> Result<usize>
Sourcepub fn apply_deletion(
&mut self,
entity_type: &str,
entity_id: &str,
) -> Result<bool>
pub fn apply_deletion( &mut self, entity_type: &str, entity_id: &str, ) -> Result<bool>
Delete entity by ID for import (applies deletion from another machine).
§Errors
Returns an error if the delete fails.
Sourcepub fn get_all_sessions(&self) -> Result<Vec<Session>>
pub fn get_all_sessions(&self) -> Result<Vec<Session>>
Sourcepub fn get_all_issues(&self) -> Result<Vec<Issue>>
pub fn get_all_issues(&self) -> Result<Vec<Issue>>
Sourcepub fn get_all_context_items(
&self,
category: Option<&str>,
priority: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<ContextItem>>
pub fn get_all_context_items( &self, category: Option<&str>, priority: Option<&str>, limit: Option<u32>, ) -> Result<Vec<ContextItem>>
Sourcepub fn get_all_memory(&self) -> Result<Vec<Memory>>
pub fn get_all_memory(&self) -> Result<Vec<Memory>>
Sourcepub fn get_all_issue_short_ids(&self) -> Result<Vec<String>>
pub fn get_all_issue_short_ids(&self) -> Result<Vec<String>>
Get all issue short IDs (for Levenshtein suggestions).
Returns short_ids (e.g. “SC-a1b2”) for all issues, used by
find_similar_ids() when an issue lookup fails.
Sourcepub fn get_all_session_ids(&self) -> Result<Vec<String>>
pub fn get_all_session_ids(&self) -> Result<Vec<String>>
Get all session IDs (for Levenshtein suggestions).
Sourcepub fn get_all_checkpoint_ids(&self) -> Result<Vec<String>>
pub fn get_all_checkpoint_ids(&self) -> Result<Vec<String>>
Get all checkpoint IDs (for Levenshtein suggestions).
Sourcepub fn get_all_checkpoints(&self) -> Result<Vec<Checkpoint>>
pub fn get_all_checkpoints(&self) -> Result<Vec<Checkpoint>>
Sourcepub fn get_context_item(&self, id: &str) -> Result<Option<ContextItem>>
pub fn get_context_item(&self, id: &str) -> Result<Option<ContextItem>>
Sourcepub fn get_context_items_by_project(
&self,
project_path: &str,
) -> Result<Vec<ContextItem>>
pub fn get_context_items_by_project( &self, project_path: &str, ) -> Result<Vec<ContextItem>>
Get all context items for sessions in a specific project.
Context items are linked to sessions, so we join on session_id and filter by the session’s project_path.
§Errors
Returns an error if the query fails.
Sourcepub fn get_checkpoints_by_project(
&self,
project_path: &str,
) -> Result<Vec<Checkpoint>>
pub fn get_checkpoints_by_project( &self, project_path: &str, ) -> Result<Vec<Checkpoint>>
Get all checkpoints for sessions in a specific project.
Checkpoints are linked to sessions, so we join on session_id and filter by the session’s project_path.
§Errors
Returns an error if the query fails.
Sourcepub fn get_dirty_context_items_by_project(
&self,
project_path: &str,
) -> Result<Vec<String>>
pub fn get_dirty_context_items_by_project( &self, project_path: &str, ) -> Result<Vec<String>>
Sourcepub fn backfill_dirty_for_project(
&mut self,
project_path: &str,
) -> Result<BackfillStats>
pub fn backfill_dirty_for_project( &mut self, project_path: &str, ) -> Result<BackfillStats>
Backfill dirty tables with all records for a project.
This is used on first sync export when no prior exports exist. It marks all existing records for the project as dirty so they get included in the initial export.
§Errors
Returns an error if the queries fail.
Sourcepub fn get_project_counts(&self, project_path: &str) -> Result<ProjectCounts>
pub fn get_project_counts(&self, project_path: &str) -> Result<ProjectCounts>
Get total record counts for a project (for status display).
§Errors
Returns an error if the query fails.
Sourcepub fn upsert_session(&mut self, session: &Session) -> Result<()>
pub fn upsert_session(&mut self, session: &Session) -> Result<()>
Upsert a session (for sync import).
This performs an INSERT OR REPLACE, preserving all fields from the imported record.
§Errors
Returns an error if the upsert fails.
Sourcepub fn upsert_issue(&mut self, issue: &Issue) -> Result<()>
pub fn upsert_issue(&mut self, issue: &Issue) -> Result<()>
Sourcepub fn upsert_context_item(&mut self, item: &ContextItem) -> Result<()>
pub fn upsert_context_item(&mut self, item: &ContextItem) -> Result<()>
Sourcepub fn upsert_memory(&mut self, memory: &Memory) -> Result<()>
pub fn upsert_memory(&mut self, memory: &Memory) -> Result<()>
Sourcepub fn upsert_checkpoint(&mut self, checkpoint: &Checkpoint) -> Result<()>
pub fn upsert_checkpoint(&mut self, checkpoint: &Checkpoint) -> Result<()>
Upsert a checkpoint (for sync import).
Note: This does not import checkpoint items - those would need separate handling.
§Errors
Returns an error if the upsert fails.
Sourcepub fn update_project(
&mut self,
id: &str,
name: Option<&str>,
description: Option<&str>,
issue_prefix: Option<&str>,
actor: &str,
) -> Result<()>
pub fn update_project( &mut self, id: &str, name: Option<&str>, description: Option<&str>, issue_prefix: Option<&str>, actor: &str, ) -> Result<()>
Sourcepub fn delete_project(&mut self, id: &str, actor: &str) -> Result<()>
pub fn delete_project(&mut self, id: &str, actor: &str) -> Result<()>
Delete a project and all associated data.
This cascades to delete:
- All sessions (and their context items, checkpoints)
- All issues
- All plans
- All project memory
§Errors
Returns an error if the project doesn’t exist or deletion fails.
Sourcepub fn get_or_create_project(
&mut self,
project_path: &str,
actor: &str,
) -> Result<Project>
pub fn get_or_create_project( &mut self, project_path: &str, actor: &str, ) -> Result<Project>
Get or create a project for the given path.
If a project already exists at the path, returns it. Otherwise, creates a new project with a name derived from the path.
§Errors
Returns an error if the database operation fails.
Sourcepub fn get_next_issue_number(&mut self, project_path: &str) -> Result<i32>
pub fn get_next_issue_number(&mut self, project_path: &str) -> Result<i32>
Increment and return the next issue number for a project.
§Errors
Returns an error if the project doesn’t exist or the update fails.
Sourcepub fn list_plans(
&self,
project_path: &str,
status: Option<&str>,
limit: usize,
) -> Result<Vec<Plan>>
pub fn list_plans( &self, project_path: &str, status: Option<&str>, limit: usize, ) -> Result<Vec<Plan>>
Sourcepub fn update_plan(
&mut self,
id: &str,
title: Option<&str>,
content: Option<&str>,
status: Option<&str>,
success_criteria: Option<&str>,
actor: &str,
) -> Result<()>
pub fn update_plan( &mut self, id: &str, title: Option<&str>, content: Option<&str>, status: Option<&str>, success_criteria: Option<&str>, actor: &str, ) -> Result<()>
Sourcepub fn store_embedding_chunk(
&mut self,
id: &str,
item_id: &str,
chunk_index: i32,
chunk_text: &str,
embedding: &[f32],
provider: &str,
model: &str,
) -> Result<()>
pub fn store_embedding_chunk( &mut self, id: &str, item_id: &str, chunk_index: i32, chunk_text: &str, embedding: &[f32], provider: &str, model: &str, ) -> Result<()>
Store an embedding chunk for a context item.
Embeddings are stored as BLOBs (binary f32 arrays). Large items may have multiple chunks for full semantic coverage.
§Errors
Returns an error if the insert fails.
Sourcepub fn get_embedding_chunks(&self, item_id: &str) -> Result<Vec<EmbeddingChunk>>
pub fn get_embedding_chunks(&self, item_id: &str) -> Result<Vec<EmbeddingChunk>>
Sourcepub fn get_items_without_embeddings(
&self,
session_id: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<ContextItem>>
pub fn get_items_without_embeddings( &self, session_id: Option<&str>, limit: Option<u32>, ) -> Result<Vec<ContextItem>>
Sourcepub fn count_embedding_status(
&self,
session_id: Option<&str>,
) -> Result<EmbeddingStats>
pub fn count_embedding_status( &self, session_id: Option<&str>, ) -> Result<EmbeddingStats>
Sourcepub fn semantic_search(
&self,
query_embedding: &[f32],
session_id: Option<&str>,
limit: usize,
threshold: f32,
) -> Result<Vec<SemanticSearchResult>>
pub fn semantic_search( &self, query_embedding: &[f32], session_id: Option<&str>, limit: usize, threshold: f32, ) -> Result<Vec<SemanticSearchResult>>
Perform semantic search using cosine similarity.
This is a brute-force search that computes cosine similarity between the query embedding and all stored embeddings. Efficient for <50K items; use Hora for larger datasets.
§Errors
Returns an error if the query fails.
Sourcepub fn delete_embeddings(&mut self, item_id: &str) -> Result<()>
pub fn delete_embeddings(&mut self, item_id: &str) -> Result<()>
Sourcepub fn store_fast_embedding_chunk(
&mut self,
id: &str,
item_id: &str,
chunk_index: i32,
chunk_text: &str,
embedding: &[f32],
model: &str,
) -> Result<()>
pub fn store_fast_embedding_chunk( &mut self, id: &str, item_id: &str, chunk_index: i32, chunk_text: &str, embedding: &[f32], model: &str, ) -> Result<()>
Store a fast-tier embedding chunk (Model2Vec).
Fast tier embeddings are stored separately for dimension isolation. These are generated inline on save for instant semantic search.
§Errors
Returns an error if the insert fails.
Sourcepub fn search_fast_tier(
&self,
query_embedding: &[f32],
session_id: Option<&str>,
limit: usize,
threshold: f32,
) -> Result<Vec<SemanticSearchResult>>
pub fn search_fast_tier( &self, query_embedding: &[f32], session_id: Option<&str>, limit: usize, threshold: f32, ) -> Result<Vec<SemanticSearchResult>>
Search fast-tier embeddings only.
Returns candidates for tiered search or direct fast results. Fast tier is optimized for speed over accuracy.
§Errors
Returns an error if the query fails.
Sourcepub fn get_items_needing_quality_upgrade(
&self,
session_id: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<ContextItem>>
pub fn get_items_needing_quality_upgrade( &self, session_id: Option<&str>, limit: Option<u32>, ) -> Result<Vec<ContextItem>>
Get context items with fast embeddings but no quality embeddings.
Used by background quality upgrade process.
§Errors
Returns an error if the query fails.
Sourcepub fn delete_fast_embeddings(&mut self, item_id: &str) -> Result<()>
pub fn delete_fast_embeddings(&mut self, item_id: &str) -> Result<()>
Sourcepub fn count_fast_embedding_status(
&self,
session_id: Option<&str>,
) -> Result<EmbeddingStats>
pub fn count_fast_embedding_status( &self, session_id: Option<&str>, ) -> Result<EmbeddingStats>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SqliteStorage
impl !RefUnwindSafe for SqliteStorage
impl Send for SqliteStorage
impl !Sync for SqliteStorage
impl Unpin for SqliteStorage
impl !UnwindSafe for SqliteStorage
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> 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