Skip to main content

tea_session/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3
4//! Append-only session semantics, deterministic replay, and replaceable storage
5//! contracts for `tea-rs`.
6//!
7//! Canonical [`tea_protocol::RecordEnvelope`] values are the source
8//! of truth. [`SessionReducer`] derives rebuildable materialized state without
9//! reading clocks, executing tools, contacting providers, or depending on an
10//! async runtime.
11//!
12//! # Replay
13//!
14//! ```
15//! use tea_protocol::RecordEnvelope;
16//! use tea_session::SessionReducer;
17//!
18//! # fn rebuild(records: Vec<RecordEnvelope>) -> Result<(), Box<dyn std::error::Error>> {
19//! let state = SessionReducer::replay(records)?;
20//! assert_eq!(state.tail_sequence().get() + 1, state.tail_sequence().get() + 1);
21//! # Ok(())
22//! # }
23//! ```
24
25mod archive;
26mod artifact;
27mod catalog;
28mod error;
29mod memory;
30mod reducer;
31mod state;
32mod store;
33mod store_engine;
34
35pub use archive::{
36    CURRENT_ARCHIVE_FORMAT_VERSION, MAX_ARCHIVE_BYTES, MAX_ARCHIVE_ENTRIES, SessionArchive,
37    SessionArchiveError,
38};
39pub use artifact::{
40    ApprovalArtifactEntry, ArtifactState, ArtifactValidationError, GrantJournalEntry,
41};
42pub use catalog::{
43    MAX_SESSION_NAME_BYTES, SessionCatalog, SessionCatalogEntry, SessionName, SessionNameError,
44};
45pub use error::{SessionReplayError, SessionStoreError, SessionStoreErrorCode};
46pub use memory::InMemorySessionStore;
47pub use reducer::SessionReducer;
48pub use state::{
49    BranchSummary, MaterializedSessionState, PendingApproval, RunRecoveryState, SessionCompaction,
50    SessionConfiguration, ToolCallState, ToolExecutionState, TurnCheckpoint,
51};
52pub use store::{
53    AppendOutcome, AppendTransaction, SessionSnapshot, SessionStore, SessionStoreFuture,
54};
55pub use store_engine::{
56    StoredSession, active_grants_for_actor, apply_transaction, apply_transaction_in_place,
57};