Skip to main content

harn_session_store/
lib.rs

1//! Durable Harn session-store primitive.
2//!
3//! One source of truth for persisted agent/session events (`Message`,
4//! `ToolCall`, `ToolResult`, `Plan`, `Compaction`, `SystemReminder`,
5//! `Hypothesis`, `Receipt`, `Reminder`, `PermissionDecision`, plus
6//! arbitrary `Custom` shapes), snapshots, replay, fork/truncate, signed
7//! receipts (Ed25519 over canonical JSON), and retention. Server and host
8//! adapters can layer transport, auth, and product policy on top without
9//! reimplementing transcript storage semantics.
10//!
11//! ## Layout
12//!
13//! - [`event`] - event taxonomy and canonical JSON encoder
14//! - [`identity`] - typed producer identity over canonical signed headers
15//! - [`redaction`] - dependency-inverted event redaction contract
16//! - [`signing`] - Ed25519 chain hashes and receipt signatures
17//! - [`store`] - public `SessionStore` trait and shared types
18//! - [`memory`] - in-memory backend for tests and headless dev
19//! - [`sqlite`] - persistent SQLite backend for local/self-hosted use
20//! - [`wal_watch`] - read-only data_version + title snapshots for cross-process watchers
21//! - [`retention`] - declarative per-tenant retention policy
22
23pub mod change;
24pub mod event;
25pub mod identity;
26pub mod memory;
27pub(crate) mod memory_helpers;
28pub mod redaction;
29pub mod retention;
30pub mod search;
31pub mod signing;
32pub mod sqlite;
33pub mod store;
34pub mod wal_watch;
35
36pub use change::{SessionChangeObserver, SharedSessionChangeObserver};
37pub use event::{
38    canonical_event_bytes, canonical_json_bytes, AppendEvent, EventId, EventSignature,
39    SessionEventKind, StoredEvent,
40};
41pub use identity::{EventIdentity, EventIdentityError, EventIdentityField};
42pub use memory::MemorySessionStore;
43pub use redaction::{EventRedactor, SharedEventRedactor};
44pub use retention::{ArchiveSink, RetentionPolicy, SharedArchiveSink, Tombstone};
45pub use search::{
46    cosine, default_embedder, event_search_text, Embedder, LexicalEmbedder, SearchFilter,
47    SearchHit, SearchMode, SearchQuery, SearchResponse, DEFAULT_SEARCH_LIMIT, MAX_SEARCH_LIMIT,
48};
49pub use signing::{
50    chain_root_fold, chain_root_hash, chain_root_init, compute_record_hash, re_anchor_events,
51    verify_event, verify_event_chain, verify_receipt_root, verify_session_chain, SessionSigner,
52    VerifyError, ALGORITHM as SIGNATURE_ALGORITHM,
53};
54pub use sqlite::SqliteSessionStore;
55pub use store::{
56    CreateSession, EventPage, ForkResult, ImportResult, ImportSession, ListFilter, ListOrder,
57    ListSortKey, ReadRange, SessionId, SessionImporter, SessionMeta, SessionStatus, SessionStore,
58    SessionType, SharedSessionStore, Snapshot, SnapshotId, StoreContention, StoreError, StoreHooks,
59    StoreResult, SweepReport, TruncateResult, UpdateSession, VerifyFailure, VerifyReport,
60    MAX_READ_BATCH,
61};