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//! - [`retention`] - declarative per-tenant retention policy
21
22pub mod event;
23pub mod identity;
24pub mod memory;
25pub(crate) mod memory_helpers;
26pub mod redaction;
27pub mod retention;
28pub mod search;
29pub mod signing;
30pub mod sqlite;
31pub mod store;
32
33pub use event::{
34    canonical_event_bytes, canonical_json_bytes, AppendEvent, EventId, EventSignature,
35    SessionEventKind, StoredEvent,
36};
37pub use identity::{EventIdentity, EventIdentityError, EventIdentityField};
38pub use memory::MemorySessionStore;
39pub use redaction::{EventRedactor, SharedEventRedactor};
40pub use retention::{ArchiveSink, RetentionPolicy, SharedArchiveSink, Tombstone};
41pub use search::{
42    cosine, default_embedder, event_search_text, Embedder, LexicalEmbedder, SearchFilter,
43    SearchHit, SearchMode, SearchQuery, SearchResponse, DEFAULT_SEARCH_LIMIT, MAX_SEARCH_LIMIT,
44};
45pub use signing::{
46    chain_root_fold, chain_root_hash, chain_root_init, compute_record_hash, re_anchor_events,
47    verify_event, verify_event_chain, verify_receipt_root, verify_session_chain, SessionSigner,
48    VerifyError, ALGORITHM as SIGNATURE_ALGORITHM,
49};
50pub use sqlite::SqliteSessionStore;
51pub use store::{
52    CreateSession, EventPage, ForkResult, ImportResult, ImportSession, ListFilter, ListOrder,
53    ListSortKey, ReadRange, SessionId, SessionImporter, SessionMeta, SessionStatus, SessionStore,
54    SessionType, SharedSessionStore, Snapshot, SnapshotId, StoreContention, StoreError, StoreHooks,
55    StoreResult, SweepReport, TruncateResult, UpdateSession, VerifyFailure, VerifyReport,
56    MAX_READ_BATCH,
57};