pub struct SessionJournal { /* private fields */ }Expand description
Thread-safe, append-only, hash-chained session journal.
Create one per session and share it (via Arc<SessionJournal>) with all
guards that need session-aware context.
Implementations§
Source§impl SessionJournal
impl SessionJournal
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Return the session identifier.
Sourcepub fn record(&self, params: RecordParams) -> Result<u64, SessionJournalError>
pub fn record(&self, params: RecordParams) -> Result<u64, SessionJournalError>
Append a new entry to the journal.
The entry is hash-chained to the previous entry. Returns the sequence number of the new entry.
Sourcepub fn data_flow(&self) -> Result<CumulativeDataFlow, SessionJournalError>
pub fn data_flow(&self) -> Result<CumulativeDataFlow, SessionJournalError>
Return a snapshot of the cumulative data flow statistics.
Sourcepub fn tool_sequence(&self) -> Result<Vec<String>, SessionJournalError>
pub fn tool_sequence(&self) -> Result<Vec<String>, SessionJournalError>
Return the ordered tool invocation sequence.
Sourcepub fn tool_counts(&self) -> Result<HashMap<String, u64>, SessionJournalError>
pub fn tool_counts(&self) -> Result<HashMap<String, u64>, SessionJournalError>
Return per-tool invocation counts.
Sourcepub fn len(&self) -> Result<usize, SessionJournalError>
pub fn len(&self) -> Result<usize, SessionJournalError>
Return the number of entries in the journal.
Sourcepub fn is_empty(&self) -> Result<bool, SessionJournalError>
pub fn is_empty(&self) -> Result<bool, SessionJournalError>
Return whether the journal is empty.
Sourcepub fn entries(&self) -> Result<Vec<JournalEntry>, SessionJournalError>
pub fn entries(&self) -> Result<Vec<JournalEntry>, SessionJournalError>
Return a clone of all journal entries.
Sourcepub fn recent_entries(
&self,
n: usize,
) -> Result<Vec<JournalEntry>, SessionJournalError>
pub fn recent_entries( &self, n: usize, ) -> Result<Vec<JournalEntry>, SessionJournalError>
Return the most recent N entries (or all if fewer than N exist).
Sourcepub fn verify_integrity(&self) -> Result<(), SessionJournalError>
pub fn verify_integrity(&self) -> Result<(), SessionJournalError>
Verify the integrity of the hash chain.
Returns Ok(()) if all entries are correctly chained, or an error
indicating where the chain breaks.
Sourcepub fn head_hash(&self) -> Result<String, SessionJournalError>
pub fn head_hash(&self) -> Result<String, SessionJournalError>
Return the hash of the most recent entry (or the zero hash if empty).