attuned-store

Crates.ioattuned-store
lib.rsattuned-store
version1.0.1
created_at2025-12-18 17:39:15.001036+00
updated_at2025-12-18 19:41:54.659863+00
descriptionStorage traits and in-memory backend for Attuned
homepage
repositoryhttps://github.com/JtPerez-Acle/Attuned
max_upload_size
id1992979
size34,602
jt.. (JtPerez-Acle)

documentation

README

attuned-store

Storage traits and in-memory backend for Attuned.

Overview

This crate provides the StateStore trait for persisting user state snapshots, along with a production-ready in-memory implementation.

Quick Start

use attuned_store::{StateStore, MemoryStore};
use attuned_core::{StateSnapshot, Source};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create in-memory store
    let store = MemoryStore::new();

    // Create and store a state snapshot
    let state = StateSnapshot::builder()
        .user_id("user_123")
        .source(Source::SelfReport)
        .axis("cognitive_load", 0.8)
        .build()?;

    store.upsert_latest(state).await?;

    // Retrieve latest state
    if let Some(state) = store.get_latest("user_123").await? {
        println!("Cognitive load: {}", state.get_axis("cognitive_load"));
    }

    Ok(())
}

StateStore Trait

#[async_trait]
pub trait StateStore: Send + Sync {
    async fn upsert_latest(&self, state: StateSnapshot) -> Result<(), StoreError>;
    async fn get_latest(&self, user_id: &str) -> Result<Option<StateSnapshot>, StoreError>;
    async fn delete(&self, user_id: &str) -> Result<bool, StoreError>;
}

Implementations

Backend Crate Description
In-Memory attuned-store Thread-safe HashMap, good for development
Qdrant attuned-qdrant Vector database for production semantic search

License

Apache-2.0

Commit count: 0

cargo fmt