Skip to content

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 -- SqliteStorage with WAL mode, connection pooling, and migrations
  • WASM Support -- Optional IndexedDB adapters via the wasm-adapters feature
  • Async Wrapper -- AsyncStorage for non-blocking storage operations on native
  • Trajectory Storage -- Persist compression trajectories for learning analysis
  • Auto-Detection -- auto_detect_storage selects 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

TypeDescription
SqliteStorageNative SQLite storage backend
ConnectionPoolConnection pool for SQLite
AsyncStorageAsync wrapper around synchronous storage
StorageConfigDatabase path, pool size, WAL, cache settings
StorageStatsPattern count, category count, backend type
StorageBackendEnum of available storage backends
auto_detect_storageFactory function that selects the right backend
StorageErrorError enum for storage operations

Released under the MIT License.