Skip to main content

TursoStorage

Struct TursoStorage 

Source
pub struct TursoStorage { /* private fields */ }
Expand description

Turso storage backend for durable persistence

Implementations§

Source§

impl TursoStorage

Source

pub async fn add_relationship( &self, from_episode_id: Uuid, to_episode_id: Uuid, relationship_type: RelationshipType, metadata: RelationshipMetadata, ) -> Result<Uuid>

Add a relationship between two episodes

Source

pub async fn store_relationship( &self, relationship: &EpisodeRelationship, ) -> Result<()>

Store a relationship between two episodes

This is the StorageBackend trait implementation that takes a pre-built EpisodeRelationship.

Source

pub async fn remove_relationship(&self, relationship_id: Uuid) -> Result<()>

Remove a relationship by ID

Source

pub async fn get_relationships( &self, episode_id: Uuid, direction: Direction, ) -> Result<Vec<EpisodeRelationship>>

Get relationships for an episode

Source

pub async fn get_relationships_by_type( &self, episode_id: Uuid, relationship_type: RelationshipType, direction: Direction, ) -> Result<Vec<EpisodeRelationship>>

Get relationships by type

Source

pub async fn relationship_exists( &self, from_episode_id: Uuid, to_episode_id: Uuid, relationship_type: RelationshipType, ) -> Result<bool>

Check if a relationship exists

Source

pub async fn get_dependent_episodes( &self, episode_id: Uuid, ) -> Result<Vec<Uuid>>

Get all episodes that depend on the given episode (blocking it)

Source

pub async fn get_dependencies(&self, episode_id: Uuid) -> Result<Vec<Uuid>>

Get all episodes that the given episode depends on

Source§

impl TursoStorage

Source

pub async fn store_episodes_with_patterns_batch( &self, episodes: Vec<Episode>, patterns: Vec<Pattern>, ) -> Result<()>

Store episodes with their associated patterns in a single transaction

This is more efficient than storing episodes and patterns separately when they are related, as it ensures atomicity and reduces round-trips.

§Arguments
  • episodes - Episodes to store
  • patterns - Patterns to store (may be associated with episodes)
§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let episodes = vec![/* ... */];
let patterns = vec![/* ... */];

storage.store_episodes_with_patterns_batch(episodes, patterns).await?;
Source§

impl TursoStorage

Source

pub async fn store_episodes_batch(&self, episodes: Vec<Episode>) -> Result<()>

Store multiple episodes in a single transaction

Uses prepared statements and transactions for 4-6x throughput improvement.

§Arguments
  • episodes - Vector of episodes to store
§Returns

Result indicating success or failure

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let episodes = vec![
    Episode::new("Task 1".to_string(), TaskContext::default(), TaskType::CodeGeneration),
    Episode::new("Task 2".to_string(), TaskContext::default(), TaskType::Debugging),
];

storage.store_episodes_batch(episodes).await?;
Source§

impl TursoStorage

Source

pub async fn get_episodes_batch( &self, ids: &[Uuid], ) -> Result<Vec<Option<Episode>>>

Retrieve multiple episodes by IDs efficiently

Uses a single query with IN clause for efficient batch retrieval.

§Arguments
  • ids - Slice of episode UUIDs to retrieve
§Returns

Vector of optional episodes (None if episode not found)

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let ids = vec![Uuid::new_v4(), Uuid::new_v4()];
let episodes = storage.get_episodes_batch(&ids).await?;

for episode in episodes {
    if let Some(ep) = episode {
        println!("Found episode: {}", ep.episode_id);
    }
}
Source

pub async fn get_patterns_batch( &self, ids: &[PatternId], ) -> Result<Vec<Option<Pattern>>>

Retrieve multiple patterns by IDs efficiently

Uses a single query with IN clause for efficient batch retrieval.

§Arguments
  • ids - Slice of pattern IDs to retrieve
§Returns

Vector of optional patterns (None if pattern not found)

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let ids = vec![PatternId::new_v4(), PatternId::new_v4()];
let patterns = storage.get_patterns_batch(&ids).await?;

for pattern in patterns {
    if let Some(p) = pattern {
        println!("Found pattern: {:?}", p.id());
    }
}
Source

pub async fn get_heuristics_batch( &self, ids: &[Uuid], ) -> Result<Vec<Option<Heuristic>>>

Retrieve multiple heuristics by IDs efficiently

Uses a single query with IN clause for efficient batch retrieval.

§Arguments
  • ids - Slice of heuristic UUIDs to retrieve
§Returns

Vector of optional heuristics (None if heuristic not found)

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let ids = vec![Uuid::new_v4(), Uuid::new_v4()];
let heuristics = storage.get_heuristics_batch(&ids).await?;

for heuristic in heuristics {
    if let Some(h) = heuristic {
        println!("Found heuristic: {}", h.heuristic_id);
    }
}
Source§

impl TursoStorage

Source

pub async fn store_patterns_batch(&self, patterns: Vec<Pattern>) -> Result<()>

Store multiple patterns in a single transaction

Uses prepared statements and transactions for 4-6x throughput improvement. All patterns are stored atomically - if any fails, all are rolled back.

Source

pub async fn update_patterns_batch(&self, patterns: Vec<Pattern>) -> Result<()>

Update multiple patterns in a single transaction

Source

pub async fn store_patterns_batch_with_progress( &self, patterns: Vec<Pattern>, batch_size: usize, ) -> Result<BatchResult>

Store patterns in batches with progress tracking

Source

pub async fn get_patterns_batch_by_ids( &self, pattern_ids: Vec<PatternId>, ) -> Result<Vec<Pattern>>

Retrieve multiple patterns by IDs in a single query

Uses a single IN query for efficient bulk retrieval (4-6x improvement over individual queries).

§Arguments
  • pattern_ids - Vector of pattern IDs to retrieve
§Returns

Vector of patterns (only patterns that exist are returned)

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let ids = vec![
    PatternId::new_v4(),
    PatternId::new_v4(),
];

let patterns = storage.get_patterns_batch(&ids).await?;
Source

pub async fn delete_patterns_batch( &self, pattern_ids: Vec<PatternId>, ) -> Result<usize>

Delete multiple patterns in a single transaction

All deletions are atomic - if any fails, all are rolled back.

§Arguments
  • pattern_ids - Vector of pattern IDs to delete
§Returns

Number of patterns actually deleted

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let ids = vec![
    PatternId::new_v4(),
    PatternId::new_v4(),
];

let deleted = storage.delete_patterns_batch(ids).await?;
println!("Deleted {} patterns", deleted);
Source§

impl TursoStorage

Source

pub async fn store_heuristics_batch( &self, heuristics: Vec<Heuristic>, ) -> Result<()>

Store multiple heuristics in a single transaction

Uses prepared statements and transactions for 4-6x throughput improvement. All heuristics are stored atomically - if any fails, all are rolled back.

Source

pub async fn update_heuristics_batch( &self, heuristics: Vec<Heuristic>, ) -> Result<()>

Update multiple heuristics in a single transaction

Source

pub async fn store_heuristics_batch_with_progress( &self, heuristics: Vec<Heuristic>, batch_size: usize, ) -> Result<HeuristicBatchResult>

Store heuristics in batches with progress tracking

Source

pub async fn update_heuristics_batch_with_progress( &self, heuristics: Vec<Heuristic>, batch_size: usize, ) -> Result<HeuristicBatchResult>

Update heuristics in batches with progress tracking

Source

pub async fn delete_heuristics_batch(&self, ids: Vec<Uuid>) -> Result<()>

Delete multiple heuristics in a single transaction

Uses transactions for atomic deletion - if any fails, all are rolled back.

§Arguments
  • ids - Vector of heuristic IDs to delete
§Returns

Result indicating success or failure

§Example
let storage = TursoStorage::new("file:test.db", "").await?;

let ids = vec![Uuid::new_v4(), Uuid::new_v4()];
storage.delete_heuristics_batch(ids).await?;
Source

pub async fn delete_heuristics_batch_with_progress( &self, ids: Vec<Uuid>, batch_size: usize, ) -> Result<HeuristicBatchResult>

Delete heuristics in batches with progress tracking

Source§

impl TursoStorage

Source

pub async fn store_episode_with_capacity( &self, episode: &Episode, max_episodes: usize, ) -> Result<()>

Store an episode with capacity management

When the episode limit is reached, the least relevant episodes are evicted based on the configured eviction policy.

Source

pub async fn get_capacity_statistics(&self) -> Result<CapacityStatistics>

Get storage statistics including capacity info

Source§

impl TursoStorage

Source

pub fn get_embedding_table_for_dimension( &self, dimension: usize, ) -> &'static str

Source

pub fn get_vector_index_for_dimension( &self, dimension: usize, ) -> Option<&'static str>

Source§

impl TursoStorage

Source

pub async fn store_episode(&self, episode: &Episode) -> Result<()>

Store an episode

Uses INSERT OR REPLACE for upsert semantics. When compression is enabled, large payloads are compressed to reduce bandwidth.

Source

pub async fn get_episode(&self, episode_id: Uuid) -> Result<Option<Episode>>

Retrieve an episode by ID

When adaptive-ttl feature is enabled and caching is configured, this method will first check the cache before querying the database. Cache hits record access for TTL adaptation.

Source

pub async fn delete_episode(&self, episode_id: Uuid) -> Result<()>

Delete an episode by ID

Source

pub async fn store_episode_summary( &self, summary: &EpisodeSummary, ) -> Result<()>

Store an episode summary

Source

pub async fn get_episode_summary( &self, episode_id: Uuid, ) -> Result<Option<EpisodeSummary>>

Retrieve an episode summary by episode ID

Source

pub async fn get_episode_by_task_desc( &self, task_desc: &str, ) -> Result<Option<Episode>>

Retrieve an episode by task description

Source§

impl TursoStorage

Source

pub async fn query_episodes(&self, query: &EpisodeQuery) -> Result<Vec<Episode>>

Query episodes with filters

Source

pub async fn query_episodes_since( &self, since: DateTime<Utc>, limit: Option<usize>, ) -> Result<Vec<Episode>>

Query episodes modified since a given timestamp

§Arguments
  • since - Timestamp to query from
  • limit - Maximum number of episodes to return (default: 100, max: 1000)
Source

pub async fn query_episodes_by_metadata( &self, key: &str, value: &str, limit: Option<usize>, ) -> Result<Vec<Episode>>

Query episodes by metadata key-value pair

Uses json_extract for efficient querying of JSON metadata fields. Falls back to LIKE pattern matching if json_extract is not available.

§Arguments
  • key - Metadata key to search for
  • value - Metadata value to match
  • limit - Maximum number of episodes to return (default: 100, max: 1000)
Source§

impl TursoStorage

Source

pub async fn query_episodes_raw(&self, sql: &str) -> Result<Vec<Episode>>

Execute a raw SQL query for episodes

Convenience method for cache integration. See RawEpisodeQuery for details.

Source

pub async fn query_episodes_raw_with_params<P: IntoParams>( &self, sql: &str, params: P, ) -> Result<Vec<Episode>>

Execute a parameterized SQL query for episodes

Convenience method for cache integration with safe parameters.

Source§

impl TursoStorage

Source

pub async fn store_heuristic(&self, heuristic: &Heuristic) -> Result<()>

Store a heuristic

Source

pub async fn get_heuristic(&self, id: Uuid) -> Result<Option<Heuristic>>

Retrieve a heuristic by ID

Source

pub async fn get_heuristics(&self) -> Result<Vec<Heuristic>>

Get all heuristics

Source

pub async fn delete_heuristic(&self, id: Uuid) -> Result<()>

Delete a heuristic by ID

Source§

impl TursoStorage

Source

pub async fn store_execution_record( &self, record: &ExecutionRecord, ) -> Result<()>

Store an execution record

Source

pub async fn store_agent_metrics(&self, metrics: &AgentMetrics) -> Result<()>

Store agent metrics

Source

pub async fn store_task_metrics(&self, metrics: &TaskMetrics) -> Result<()>

Store task metrics

Source

pub async fn load_agent_metrics( &self, agent_name: &str, ) -> Result<Option<AgentMetrics>>

Load agent metrics

Source

pub async fn load_execution_records( &self, agent_name: Option<&str>, limit: usize, ) -> Result<Vec<ExecutionRecord>>

Load execution records

Source

pub async fn load_task_metrics( &self, task_type: &str, ) -> Result<Option<TaskMetrics>>

Load task metrics

Source§

impl TursoStorage

Source

pub async fn store_pattern(&self, pattern: &CorePattern) -> Result<()>

Store a pattern

Source

pub async fn get_pattern( &self, pattern_id: PatternId, ) -> Result<Option<CorePattern>>

Retrieve a pattern by ID

Source

pub async fn query_patterns( &self, query: &PatternQuery, ) -> Result<Vec<CorePattern>>

Query patterns with filters

Source§

impl TursoStorage

Source

pub async fn query_patterns_raw(&self, sql: &str) -> Result<Vec<Pattern>>

Execute a raw SQL query for patterns

Convenience method for cache integration. See RawPatternQuery for details.

Source

pub async fn query_patterns_raw_with_params<P: IntoParams>( &self, sql: &str, params: P, ) -> Result<Vec<Pattern>>

Execute a parameterized SQL query for patterns

Convenience method for cache integration with safe parameters.

Source§

impl TursoStorage

Source§

impl TursoStorage

Source

pub async fn _store_embedding_internal( &self, item_id: &str, item_type: &str, embedding: &[f32], ) -> Result<()>

Store an embedding (internal implementation)

When compression is enabled, embeddings are compressed using the configured algorithm (LZ4, Zstd, or Gzip) to reduce network bandwidth.

When turso_multi_dimension feature is enabled, routes to dimension-specific tables.

Source

pub async fn _get_embedding_internal( &self, item_id: &str, item_type: &str, ) -> Result<Option<Vec<f32>>>

Get an embedding (internal implementation)

Automatically decompresses embeddings if they were stored compressed.

Source

pub async fn _delete_embedding_internal(&self, item_id: &str) -> Result<bool>

Delete an embedding (internal implementation)

Source

pub async fn _store_embeddings_batch_internal( &self, embeddings: Vec<(String, Vec<f32>)>, ) -> Result<()>

Store embeddings in batch (internal implementation)

Source

pub async fn _get_embeddings_batch_internal( &self, item_ids: &[String], ) -> Result<Vec<Option<Vec<f32>>>>

Get embeddings in batch (internal implementation)

Source

pub async fn migrate_embeddings_to_vector_format(&self) -> Result<usize>

Migrate existing embeddings to populate embedding_vector column

This migration populates the embedding_vector F32_BLOB column for embeddings that were stored before native vector support was added. The vector column enables DiskANN-accelerated vector_top_k search.

Returns the number of embeddings migrated.

Source

pub async fn has_vector_embeddings(&self) -> Result<bool>

Check if embedding vector column is populated for vector_top_k search

Returns true if at least one embedding has the vector column populated.

Source

pub async fn store_embedding_backend( &self, id: &str, embedding: Vec<f32>, ) -> Result<()>

Store an embedding (backend API)

Source

pub async fn get_embedding_backend(&self, id: &str) -> Result<Option<Vec<f32>>>

Get an embedding (backend API)

Source

pub async fn delete_embedding_backend(&self, id: &str) -> Result<bool>

Delete an embedding (backend API)

Source

pub async fn store_embeddings_batch_backend( &self, embeddings: Vec<(String, Vec<f32>)>, ) -> Result<()>

Store embeddings in batch (backend API)

Source

pub async fn get_embeddings_batch_backend( &self, ids: &[String], ) -> Result<Vec<Option<Vec<f32>>>>

Get embeddings in batch (backend API)

Source§

impl TursoStorage

Source

pub async fn initialize_schema(&self) -> Result<()>

Initialize the database schema

Creates tables and indexes if they don’t exist. Safe to call multiple times.

Source§

impl TursoStorage

Source

pub async fn new_with_adaptive_pool( url: &str, token: &str, config: TursoConfig, adaptive_config: AdaptivePoolConfig, ) -> Result<Self>

Create a new Turso storage instance with adaptive connection pool

The adaptive pool automatically adjusts its size based on load:

  • Scales up when utilization exceeds threshold (default: 70%)
  • Scales down during low utilization (default: <30%)
  • Provides 20% better performance under variable load
§Arguments
  • url - Database URL
  • token - Authentication token
  • config - Turso configuration
  • adaptive_config - Adaptive pool configuration
§Example
use do_memory_storage_turso::{TursoStorage, TursoConfig, AdaptivePoolConfig};
use std::time::Duration;

let config = TursoConfig::default();
let adaptive_config = AdaptivePoolConfig {
    min_connections: 5,
    max_connections: 50,
    scale_up_threshold: 0.7,
    scale_down_threshold: 0.3,
    scale_up_cooldown: Duration::from_secs(10),
    scale_down_cooldown: Duration::from_secs(30),
    scale_up_increment: 5,
    scale_down_decrement: 5,
    check_interval: Duration::from_secs(5),
};

let storage = TursoStorage::new_with_adaptive_pool(
    "libsql://localhost:8080",
    "token",
    config,
    adaptive_config
).await?;
Source§

impl TursoStorage

Source

pub async fn new(url: &str, token: &str) -> Result<Self>

Create a new Turso storage instance

§Arguments
  • url - Database URL (only libsql://, file:, or :memory: protocols allowed)
  • token - Authentication token (required for libsql://, empty for local files)
§Security

This method enforces secure connections:

  • Remote connections must use libsql:// protocol with a valid token
  • HTTP/HTTPS protocols are rejected to prevent insecure connections
  • Local file: and :memory: databases are allowed without tokens
§Example
// Remote connection with authentication
let storage = TursoStorage::new("libsql://localhost:8080", "my-token").await?;

// Local file database
let local = TursoStorage::new("file:local.db", "").await?;
Source

pub fn from_database(db: Database) -> Result<Self>

Create a Turso storage instance from an existing Database

This is useful for testing with local file-based databases.

§Arguments
  • db - libSQL Database instance
§Example
let db = Builder::new_local("test.db").build().await?;
let storage = TursoStorage::from_database(db)?;
Source

pub async fn with_config( url: &str, token: &str, config: TursoConfig, ) -> Result<Self>

Create a new Turso storage instance with custom configuration

§Security

This method enforces the following security requirements:

  • Only libsql://, file:, and :memory: protocols are allowed
  • Remote connections (libsql://) require a non-empty authentication token
  • Local file and memory databases do not require tokens

These checks prevent accidental use of insecure protocols and ensure proper authentication for remote Turso databases.

Source§

impl TursoStorage

Source

pub async fn get_connection(&self) -> Result<Connection>

Get a database connection

If connection pooling is enabled, this will use a pooled connection. If keep-alive pool is enabled, it will be used for reduced overhead. If adaptive pool is enabled, it will be used for variable load optimization. Otherwise, it creates a new connection each time.

Source

pub async fn get_connection_with_id(&self) -> Result<(Connection, ConnectionId)>

Get a database connection with its cache ID

This method returns both the connection and a unique connection ID for use with the prepared statement cache. The ID should be passed to prepare_cached and clear_prepared_cache for proper cache management.

§Returns

A tuple of (Connection, ConnectionId)

§Example
let (conn, conn_id) = storage.get_connection_with_id().await?;
// Use conn and conn_id with prepare_cached
Source

pub async fn get_count(&self, conn: &Connection, table: &str) -> Result<usize>

Get count of records in a table

§Safety

The table parameter should be a validated table name from a fixed whitelist. This function does not sanitize the table name, so callers must ensure it comes from a trusted source (e.g., the fixed list in capacity.rs). CodeQL may flag this as a potential SQL injection, but it is safe when used with the predefined table names from the whitelist.

Source

pub async fn execute_pragmas(&self, conn: &Connection) -> Result<()>

Execute PRAGMA statements for database configuration

PRAGMA statements may return rows, so we need to consume them before continuing.

Source

pub async fn execute_with_retry( &self, conn: &Connection, sql: &str, ) -> Result<()>

Execute a SQL statement with retry logic

Source

pub async fn health_check(&self) -> Result<bool>

Health check - verify database connectivity

Source

pub fn with_cache_default(self) -> CachedTursoStorage

Wrap this storage with a cache layer using default cache configuration

This provides transparent caching for episodes, patterns, and heuristics with adaptive TTL based on access patterns.

§Example
let storage = TursoStorage::new("file:test.db", "").await?;
let cached = storage.with_cache_default();
Source

pub fn with_cache(self, cache_config: CacheConfig) -> CachedTursoStorage

Wrap this storage with a cache layer using custom cache configuration

§Arguments
  • config - Cache configuration to use
§Returns

A new CachedTursoStorage wrapping this storage

§Example
let storage = TursoStorage::new("file:test.db", "").await?;
let config = CacheConfig {
    max_episodes: 1000,
    episode_ttl: Duration::from_secs(3600),
    ..Default::default()
};
let cached = storage.with_cache(config);
Source

pub fn cache_config(&self) -> Option<&CacheConfig>

Get the cache configuration if set

Source

pub fn prepared_cache_stats(&self) -> PreparedCacheStats

Get prepared statement cache statistics

Source

pub fn prepared_cache(&self) -> &PreparedStatementCache

Get a reference to the prepared statement cache

Source

pub async fn get_statistics(&self) -> Result<StorageStatistics>

Get database statistics

Source

pub async fn pool_statistics(&self) -> Option<PoolStatistics>

Get pool statistics if pooling is enabled

Source

pub async fn pool_utilization(&self) -> Option<f32>

Get pool utilization if pooling is enabled

Source

pub fn adaptive_pool_metrics(&self) -> Option<AdaptivePoolMetrics>

Get adaptive pool metrics if enabled

Source

pub fn adaptive_pool_size(&self) -> Option<(u32, u32)>

Get current adaptive pool size

Source

pub async fn check_adaptive_pool_scale(&self)

Manually trigger adaptive pool scaling check

Source

pub async fn prepare_cached( &self, conn_id: ConnectionId, conn: &Connection, sql: &str, ) -> Result<Statement>

Prepare a SQL statement with cache tracking

This method prepares a SQL statement and tracks cache statistics. If the statement is already cached for this connection, it’s a cache hit. Otherwise, it’s a cache miss and the statement is prepared and tracked.

§Arguments
  • conn_id - Connection identifier for cache tracking
  • conn - Database connection to prepare on
  • sql - SQL statement to prepare
§Returns

The prepared statement

§Errors

Returns error if statement preparation fails

Source

pub fn clear_prepared_cache(&self, conn_id: ConnectionId) -> usize

Clear the prepared statement cache for a connection

This should be called when a connection is returned to the pool to prevent memory leaks and ensure proper cache management.

§Arguments
  • conn_id - Connection identifier to clear
§Returns

Number of statements cleared from the cache

Trait Implementations§

Source§

impl EmbeddingStorageBackend for TursoStorage

Source§

fn store_episode_embedding<'life0, 'async_trait>( &'life0 self, episode_id: Uuid, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store an episode embedding
Source§

fn store_pattern_embedding<'life0, 'async_trait>( &'life0 self, pattern_id: PatternId, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a pattern embedding
Source§

fn get_episode_embedding<'life0, 'async_trait>( &'life0 self, episode_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get an episode embedding
Source§

fn get_pattern_embedding<'life0, 'async_trait>( &'life0 self, pattern_id: PatternId, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a pattern embedding
Source§

fn find_similar_episodes<'life0, 'async_trait>( &'life0 self, query_embedding: Vec<f32>, limit: usize, threshold: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<SimilaritySearchResult<Episode>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find similar episodes using vector similarity
Source§

fn find_similar_patterns<'life0, 'async_trait>( &'life0 self, query_embedding: Vec<f32>, limit: usize, threshold: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<SimilaritySearchResult<Pattern>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find similar patterns using vector similarity
Source§

impl MonitoringStorageBackend for TursoStorage

Implement the MonitoringStorageBackend trait for TursoStorage

Source§

fn store_execution_record<'life0, 'life1, 'async_trait>( &'life0 self, record: &'life1 ExecutionRecord, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn store_agent_metrics<'life0, 'life1, 'async_trait>( &'life0 self, metrics: &'life1 AgentMetrics, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn store_task_metrics<'life0, 'life1, 'async_trait>( &'life0 self, metrics: &'life1 TaskMetrics, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_agent_metrics<'life0, 'life1, 'async_trait>( &'life0 self, agent_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<AgentMetrics>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_execution_records<'life0, 'life1, 'async_trait>( &'life0 self, agent_name: Option<&'life1 str>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ExecutionRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_task_metrics<'life0, 'life1, 'async_trait>( &'life0 self, task_type: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskMetrics>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl StorageBackend for TursoStorage

Implement the unified StorageBackend trait for TursoStorage

Source§

fn store_episode<'life0, 'life1, 'async_trait>( &'life0 self, episode: &'life1 Episode, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store an episode Read more
Source§

fn get_episode<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Episode>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve an episode by ID Read more
Source§

fn delete_episode<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete an episode by ID Read more
Source§

fn store_pattern<'life0, 'life1, 'async_trait>( &'life0 self, pattern: &'life1 Pattern, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a pattern Read more
Source§

fn get_pattern<'life0, 'async_trait>( &'life0 self, id: PatternId, ) -> Pin<Box<dyn Future<Output = Result<Option<Pattern>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a pattern by ID Read more
Source§

fn store_heuristic<'life0, 'life1, 'async_trait>( &'life0 self, heuristic: &'life1 Heuristic, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a heuristic Read more
Source§

fn get_heuristic<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Heuristic>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a heuristic by ID Read more
Source§

fn query_episodes_since<'life0, 'async_trait>( &'life0 self, since: DateTime<Utc>, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Episode>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query episodes modified since a given timestamp Read more
Source§

fn query_episodes_by_metadata<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 str, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Episode>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Query episodes by metadata key-value pair Read more
Source§

fn store_embedding<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, embedding: Vec<f32>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store embedding for an episode or pattern Read more
Source§

fn get_embedding<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve embedding by ID Read more
Source§

fn delete_embedding<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete embedding by ID Read more
Source§

fn store_embeddings_batch<'life0, 'async_trait>( &'life0 self, embeddings: Vec<(String, Vec<f32>)>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store multiple embeddings in batch Read more
Source§

fn get_embeddings_batch<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<f32>>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get embeddings for multiple IDs Read more
Source§

fn store_relationship<'life0, 'life1, 'async_trait>( &'life0 self, relationship: &'life1 EpisodeRelationship, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a relationship between two episodes Read more
Source§

fn remove_relationship<'life0, 'async_trait>( &'life0 self, relationship_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a relationship by ID Read more
Source§

fn get_relationships<'life0, 'async_trait>( &'life0 self, episode_id: Uuid, direction: Direction, ) -> Pin<Box<dyn Future<Output = Result<Vec<EpisodeRelationship>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get relationships for an episode Read more
Source§

fn relationship_exists<'life0, 'async_trait>( &'life0 self, from_episode_id: Uuid, to_episode_id: Uuid, relationship_type: RelationshipType, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if a relationship exists Read more
Source§

fn store_recommendation_session<'life0, 'life1, 'async_trait>( &'life0 self, session: &'life1 RecommendationSession, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist a recommendation session for durability and analytics.
Source§

fn get_recommendation_session<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<RecommendationSession>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a recommendation session by ID.
Source§

fn get_recommendation_session_for_episode<'life0, 'async_trait>( &'life0 self, episode_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<RecommendationSession>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve the most recent recommendation session for an episode.
Source§

fn store_recommendation_feedback<'life0, 'life1, 'async_trait>( &'life0 self, feedback: &'life1 RecommendationFeedback, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist feedback associated with a recommendation session.
Source§

fn get_recommendation_feedback<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<RecommendationFeedback>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve feedback for a recommendation session.
Source§

fn get_recommendation_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RecommendationStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compute global recommendation statistics.
Source§

fn cleanup_episodes<'life0, 'life1, 'async_trait>( &'life0 self, policy: &'life1 EpisodeRetentionPolicy, ) -> Pin<Box<dyn Future<Output = Result<CleanupResult, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Clean up expired episodes based on retention policy Read more
Source§

fn count_cleanup_candidates<'life0, 'life1, 'async_trait>( &'life0 self, policy: &'life1 EpisodeRetentionPolicy, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get count of episodes that would be cleaned up (dry run) Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> SendAlias for T

Source§

impl<T> SendAlias for T

Source§

impl<T> SyncAlias for T

Source§

impl<T> SyncAlias for T