spt-reasoning-storage
Multi-backend storage for reasoning patterns
Overview
Provides persistent storage with indexing, connection pooling, and efficient query capabilities across native and WASM platforms. On native targets, uses SQLite with WAL mode and connection pooling. On WASM, supports IndexedDB via optional adapters. Also stores compression trajectories for learning from historical API call outcomes.
Key Features
- SQLite Backend --
SqliteStoragewith WAL mode, connection pooling, and migrations - WASM Support -- Optional IndexedDB adapters via the
wasm-adaptersfeature - Async Wrapper --
AsyncStoragefor non-blocking storage operations on native - Trajectory Storage -- Persist compression trajectories for learning analysis
- Auto-Detection --
auto_detect_storageselects the appropriate backend at runtime
Dependencies
Key internal dependencies:
spt-reasoning-core-- Pattern types, compression trajectory types
External (native): rusqlite (bundled), parking_lot, tokio. External (WASM): wasm-bindgen, js-sys, web-sys.
Usage
rust
use spt_reasoning_storage::{
SqliteStorage, StorageConfig, AsyncStorage,
StorageBackend, auto_detect_storage,
};
let config = StorageConfig {
database_path: "reasoning.db".into(),
enable_wal: true,
..Default::default()
};
let storage = SqliteStorage::open(&config)?;API Reference
Core Types
| Type | Description |
|---|---|
SqliteStorage | Native SQLite storage backend |
ConnectionPool | Connection pool for SQLite |
AsyncStorage | Async wrapper around synchronous storage |
StorageConfig | Database path, pool size, WAL, cache settings |
StorageStats | Pattern count, category count, backend type |
StorageBackend | Enum of available storage backends |
auto_detect_storage | Factory function that selects the right backend |
StorageError | Error enum for storage operations |