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 signing;
29pub mod sqlite;
30pub mod store;
31
32pub use event::{
33    canonical_event_bytes, canonical_json_bytes, AppendEvent, EventId, EventSignature,
34    SessionEventKind, StoredEvent,
35};
36pub use identity::{EventIdentity, EventIdentityError, EventIdentityField};
37pub use memory::MemorySessionStore;
38pub use redaction::{EventRedactor, SharedEventRedactor};
39pub use retention::{ArchiveSink, RetentionPolicy, SharedArchiveSink, Tombstone};
40pub use signing::{
41    chain_root_fold, chain_root_hash, chain_root_init, compute_record_hash, re_anchor_events,
42    verify_event, verify_event_chain, verify_receipt_root, verify_session_chain, SessionSigner,
43    VerifyError, ALGORITHM as SIGNATURE_ALGORITHM,
44};
45pub use sqlite::SqliteSessionStore;
46pub use store::{
47    CreateSession, EventPage, ForkResult, ImportResult, ImportSession, ListFilter, ReadRange,
48    SessionId, SessionImporter, SessionMeta, SessionStatus, SessionStore, SharedSessionStore,
49    Snapshot, SnapshotId, StoreError, StoreHooks, StoreResult, SweepReport, TruncateResult,
50    VerifyFailure, VerifyReport, MAX_READ_BATCH,
51};