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 checkpoint(&self) -> Result<()>
pub fn checkpoint(&self) -> Result<()>
Flush the WAL journal into the main database file.
Runs PRAGMA wal_checkpoint(TRUNCATE) which moves all WAL content
into the main DB file and then truncates the WAL to zero bytes.
This ensures the .db file is self-contained for backup purposes.
Sourcepub fn backup_to(&self, dest_path: &Path) -> Result<()>
pub fn backup_to(&self, dest_path: &Path) -> Result<()>
Create a consistent backup of the database at dest_path.
First checkpoints the WAL, then uses SQLite’s Online Backup API to produce a point-in-time snapshot. Safe to call while the database is open and even during concurrent reads.
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_item_id_by_key(
&self,
session_id: &str,
key: &str,
) -> Result<Option<String>>
pub fn get_item_id_by_key( &self, session_id: &str, key: &str, ) -> Result<Option<String>>
Look up the actual item ID by session + key.
Needed after upserts where ON CONFLICT keeps the original ID.
Sourcepub fn get_items_with_fast_embeddings(
&self,
session_id: &str,
) -> Result<Vec<(ContextItem, Option<Vec<f32>>)>>
pub fn get_items_with_fast_embeddings( &self, session_id: &str, ) -> Result<Vec<(ContextItem, Option<Vec<f32>>)>>
Get all context items for a session with their fast-tier embeddings (if any).
Single LEFT JOIN query — items without embeddings get None.
Only fetches chunk_index=0 (the primary embedding per item).
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 count_issues_grouped(
&self,
project_path: &str,
group_by: &str,
) -> Result<Vec<(String, i64)>>
pub fn count_issues_grouped( &self, project_path: &str, group_by: &str, ) -> Result<Vec<(String, i64)>>
Count issues grouped by a field (status, type, priority, assignee).
Sourcepub fn get_stale_issues(
&self,
project_path: &str,
stale_days: u64,
limit: u32,
) -> Result<Vec<Issue>>
pub fn get_stale_issues( &self, project_path: &str, stale_days: u64, limit: u32, ) -> Result<Vec<Issue>>
Get stale issues (not updated in N days).
Sourcepub fn get_blocked_issues(
&self,
project_path: &str,
limit: u32,
) -> Result<Vec<(Issue, Vec<Issue>)>>
pub fn get_blocked_issues( &self, project_path: &str, limit: u32, ) -> Result<Vec<(Issue, Vec<Issue>)>>
Get blocked issues with their blockers.
Sourcepub fn get_epic_progress(&self, epic_id: &str) -> Result<EpicProgress>
pub fn get_epic_progress(&self, epic_id: &str) -> Result<EpicProgress>
Get epic progress (child issue counts by status).
Sourcepub fn get_dependency_tree(&self, root_id: &str) -> Result<Vec<(Issue, i32)>>
pub fn get_dependency_tree(&self, root_id: &str) -> Result<Vec<(Issue, i32)>>
Get dependency tree starting from a root issue. Returns (issue, depth) pairs in tree order.
Sourcepub fn set_close_reason(
&mut self,
id: &str,
reason: &str,
actor: &str,
) -> Result<()>
pub fn set_close_reason( &mut self, id: &str, reason: &str, actor: &str, ) -> Result<()>
Update close_reason on an issue.
Sourcepub fn get_close_reason(&self, id: &str) -> Result<Option<String>>
pub fn get_close_reason(&self, id: &str) -> Result<Option<String>>
Get close_reason for an 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 count_items_since_last_checkpoint(&self, session_id: &str) -> Result<i64>
pub fn count_items_since_last_checkpoint(&self, session_id: &str) -> Result<i64>
Count context items created since the most recent checkpoint for a session.
Returns 0 if no items exist. If no checkpoint exists, counts all items.
§Errors
Returns an error if the query fails.
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 get_plans_by_project(&self, project_path: &str) -> Result<Vec<Plan>>
pub fn get_plans_by_project(&self, project_path: &str) -> Result<Vec<Plan>>
Get all plans for a specific project (for JSONL sync export).
§Errors
Returns an error if the query fails.
Sourcepub fn find_plan_by_source_hash(
&self,
source_hash: &str,
) -> Result<Option<Plan>>
pub fn find_plan_by_source_hash( &self, source_hash: &str, ) -> Result<Option<Plan>>
Find a plan by source hash (for capture deduplication).
§Errors
Returns an error if the query fails.
Sourcepub fn upsert_plan(&mut self, plan: &Plan) -> Result<()>
pub fn upsert_plan(&mut self, plan: &Plan) -> Result<()>
Sourcepub fn clear_dirty_plans(&mut self, ids: &[String]) -> Result<()>
pub fn clear_dirty_plans(&mut self, ids: &[String]) -> Result<()>
Sourcepub fn create_time_entry(
&mut self,
id: &str,
short_id: Option<&str>,
project_path: &str,
hours: f64,
description: &str,
work_date: &str,
issue_id: Option<&str>,
period: Option<&str>,
actor: &str,
) -> Result<()>
pub fn create_time_entry( &mut self, id: &str, short_id: Option<&str>, project_path: &str, hours: f64, description: &str, work_date: &str, issue_id: Option<&str>, period: Option<&str>, actor: &str, ) -> Result<()>
Create a new time entry.
Sourcepub fn get_time_entry(
&self,
id: &str,
project_path: Option<&str>,
) -> Result<Option<TimeEntry>>
pub fn get_time_entry( &self, id: &str, project_path: Option<&str>, ) -> Result<Option<TimeEntry>>
Get a time entry by ID (full or short).
Sourcepub fn list_time_entries(
&self,
project_path: &str,
period: Option<&str>,
status: Option<&str>,
issue_id: Option<&str>,
date_from: Option<&str>,
date_to: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<TimeEntry>>
pub fn list_time_entries( &self, project_path: &str, period: Option<&str>, status: Option<&str>, issue_id: Option<&str>, date_from: Option<&str>, date_to: Option<&str>, limit: Option<u32>, ) -> Result<Vec<TimeEntry>>
List time entries with optional filters.
Sourcepub fn update_time_entry(
&mut self,
id: &str,
project_path: &str,
hours: Option<f64>,
description: Option<&str>,
period: Option<&str>,
issue_id: Option<&str>,
work_date: Option<&str>,
actor: &str,
) -> Result<()>
pub fn update_time_entry( &mut self, id: &str, project_path: &str, hours: Option<f64>, description: Option<&str>, period: Option<&str>, issue_id: Option<&str>, work_date: Option<&str>, actor: &str, ) -> Result<()>
Update a time entry (partial fields).
Sourcepub fn update_time_entry_status(
&mut self,
id: &str,
project_path: &str,
status: &str,
actor: &str,
) -> Result<()>
pub fn update_time_entry_status( &mut self, id: &str, project_path: &str, status: &str, actor: &str, ) -> Result<()>
Update time entry status.
Sourcepub fn invoice_time_entries(
&mut self,
project_path: &str,
period: &str,
from_status: &str,
to_status: &str,
actor: &str,
) -> Result<(usize, f64)>
pub fn invoice_time_entries( &mut self, project_path: &str, period: &str, from_status: &str, to_status: &str, actor: &str, ) -> Result<(usize, f64)>
Batch update time entries from one status to another for a period. Returns (count, total_hours).
Sourcepub fn delete_time_entry(
&mut self,
id: &str,
project_path: &str,
actor: &str,
) -> Result<()>
pub fn delete_time_entry( &mut self, id: &str, project_path: &str, actor: &str, ) -> Result<()>
Delete a time entry.
Sourcepub fn get_time_total(
&self,
project_path: &str,
period: Option<&str>,
status: Option<&str>,
) -> Result<f64>
pub fn get_time_total( &self, project_path: &str, period: Option<&str>, status: Option<&str>, ) -> Result<f64>
Get total hours for a project, optionally filtered by period and/or status.
Sourcepub fn get_issue_time_total(&self, issue_id: &str) -> Result<f64>
pub fn get_issue_time_total(&self, issue_id: &str) -> Result<f64>
Get total hours logged against a specific issue.
Sourcepub fn get_time_entries_by_project(
&self,
project_path: &str,
) -> Result<Vec<TimeEntry>>
pub fn get_time_entries_by_project( &self, project_path: &str, ) -> Result<Vec<TimeEntry>>
Get all time entries for a project (for sync export).
Sourcepub fn get_dirty_time_entries_by_project(
&self,
project_path: &str,
) -> Result<Vec<String>>
pub fn get_dirty_time_entries_by_project( &self, project_path: &str, ) -> Result<Vec<String>>
Get dirty time entry IDs for a project.
Sourcepub fn clear_dirty_time_entries(&mut self, ids: &[String]) -> Result<()>
pub fn clear_dirty_time_entries(&mut self, ids: &[String]) -> Result<()>
Clear dirty flags for time entries after export.
Sourcepub fn upsert_time_entry(&mut self, entry: &TimeEntry) -> Result<()>
pub fn upsert_time_entry(&mut self, entry: &TimeEntry) -> Result<()>
Upsert a time entry (for sync import).
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 resync_embedding_status(&self) -> Result<usize>
pub fn resync_embedding_status(&self) -> Result<usize>
Resync embedding status for items claiming ‘complete’ but lacking actual data.
Migration 011 dropped the old vec_context_chunks table and reset statuses to ‘pending’, but subsequent logic set them back to ‘complete’ without actual embedding data. This method detects and fixes that mismatch.
Returns the number of items reset.
§Errors
Returns an error if the query fails.
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 UnsafeUnpin 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