1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! [`SessionStore`] — persistence for per-execution session records.
use ;
use async_trait;
/// A persisted record of a single agent execution session.
///
/// One record is created per execution run and ties together all governance
/// events within that run. Backends key the record by its
/// [`session_id`](SessionRecord::session_id).
/// Persists, loads, and deletes [`SessionRecord`]s.
///
/// The runtime saves a record when a session starts, loads it to resume
/// governance context, and deletes it when the session ends.
///
/// # Example
///
/// ```
/// use aa_core::storage::{Result, SessionId, SessionRecord, SessionStore, StorageError};
/// use async_trait::async_trait;
///
/// /// A store that holds no sessions.
/// struct EmptySessionStore;
///
/// #[async_trait]
/// impl SessionStore for EmptySessionStore {
/// async fn save(&self, _session: SessionRecord) -> Result<()> {
/// Ok(())
/// }
///
/// async fn load(&self, session_id: &SessionId) -> Result<SessionRecord> {
/// Err(StorageError::NotFound(format!("{:?}", session_id.as_bytes())))
/// }
///
/// async fn delete(&self, _session_id: &SessionId) -> Result<()> {
/// Ok(())
/// }
/// }
/// ```