Skip to main content

vs_store/
lib.rs

1//! SQLite-backed durable state for vibesurfer.
2//!
3//! The store owns one SQLite database file at `~/.vibesurfer/state.db`
4//! (or in-memory for tests). It is the **source of truth** for every
5//! piece of cross-restart state: sessions, pages, refs, marks,
6//! annotations, the audit log, encrypted auth blobs, and the skill
7//! cache. The daemon's in-memory caches are derivative — on restart
8//! they are rebuilt from this crate.
9//!
10//! # Layout
11//!
12//! - [`Store`] — the main handle. CRUD methods for every table.
13//! - [`types`] — owned domain types mirroring the SQL schema.
14//! - [`auth`] — AES-256-GCM helpers and master-key resolution
15//!   (OS keyring → `~/.vibesurfer/key`).
16//! - [`error::StoreError`] — every fallible function returns this.
17//! - [`migrate`] — the migration runner; called automatically by
18//!   [`Store::open`].
19
20#![forbid(unsafe_code)]
21
22pub mod auth;
23pub mod error;
24pub mod migrate;
25mod store;
26pub mod types;
27
28pub use auth::{decrypt, encrypt, EncryptedBlob, MasterKey};
29pub use error::{Result, StoreError};
30pub use store::{epoch_secs, Store, IDEMPOTENCY_TTL_SECS};
31pub use types::{
32    Action, ActionFilter, ActionInsert, Annotation, AnnotationTarget, AuthBlobMeta, Mark, Page,
33    Session, SessionStatus, SkillEntry, StoredRef,
34};
35
36/// Returns the crate version (matches the workspace version).
37#[must_use]
38pub fn version() -> &'static str {
39    env!("CARGO_PKG_VERSION")
40}
41
42#[cfg(test)]
43mod tests {
44    use super::version;
45
46    #[test]
47    fn version_matches_cargo_pkg_version() {
48        assert_eq!(version(), env!("CARGO_PKG_VERSION"));
49    }
50}