Skip to main content

SessionStore

Struct SessionStore 

Source
pub struct SessionStore { /* private fields */ }
Expand description

Persists SessionSnapshot JSON files to disk under <data_dir>/sessions/.

By default, secret redaction is enabled so API keys and tokens are scrubbed from saved event text.

Implementations§

Source§

impl SessionStore

Source

pub fn new(data_dir: PathBuf) -> Self

Creates a new store with secret redaction enabled.

Source

pub fn with_redaction(data_dir: PathBuf, redact_secrets: bool) -> Self

Creates a new store with the given redaction setting.

Source

pub fn root(&self) -> &PathBuf

Returns the directory where session JSON files are stored.

Source

pub fn create_id() -> SessionId

Generates a session id that is unique across concurrent NAVI instances.

The timestamp keeps ids naturally ordered, while the process id, in-process sequence, and random nonce prevent two agents started in the same millisecond from sharing a provider cache-affinity identity.

Source

pub fn save(&self, snapshot: &SessionSnapshot) -> Result<PathBuf>

Serializes and saves a snapshot to disk, creating the sessions directory if needed. Applies secret redaction unless disabled.

This is the blocking implementation used internally and in tests. Use Self::save_async from async contexts to avoid blocking the Tokio runtime.

Source

pub async fn save_async(&self, snapshot: SessionSnapshot) -> Result<PathBuf>

Async wrapper around Self::save that runs the blocking filesystem operations on the Tokio blocking thread pool.

Source

pub fn list(&self) -> Vec<SessionSnapshot>

Loads all saved sessions from disk, sorted by most recently updated first.

Source

pub fn list_info(&self) -> Vec<SessionSnapshotInfo>

Loads only session metadata from disk, sorted by most recently updated first.

Source

pub async fn list_async(&self) -> Vec<SessionSnapshot>

Async wrapper around Self::list that runs the blocking filesystem operations on the Tokio blocking thread pool.

Source

pub async fn list_info_async(&self) -> Vec<SessionSnapshotInfo>

Async wrapper around Self::list_info that avoids blocking the async runtime.

Source

pub fn load(&self, session_id: &str) -> Result<SessionSnapshot>

Loads a single session by id. Returns an error if the file is missing or the snapshot version is newer than supported.

Source

pub async fn load_async(&self, session_id: String) -> Result<SessionSnapshot>

Async wrapper around Self::load that runs the blocking filesystem operations on the Tokio blocking thread pool.

Source

pub fn delete(&self, session_id: &str) -> Result<bool>

Deletes the session file. Returns true if the file existed and was removed.

Source

pub fn rename(&self, session_id: &str, title: &str) -> Result<bool>

Renames a saved session by updating its title field in the snapshot. Returns true if the session existed and was updated.

Source

pub async fn rename_async( &self, session_id: String, title: String, ) -> Result<bool>

Async wrapper around Self::rename.

Source

pub async fn delete_async(&self, session_id: String) -> Result<bool>

Async wrapper around Self::delete that runs the blocking filesystem operations on the Tokio blocking thread pool.

Source

pub fn save_memory( &self, project_dir: &Path, memory: &ProjectMemory, ) -> Result<PathBuf>

Persists project memory to <data_dir>/memory/<hash>.json.

Source

pub async fn save_memory_async( &self, project_dir: PathBuf, memory: ProjectMemory, ) -> Result<PathBuf>

Async wrapper around Self::save_memory that runs the blocking filesystem operations on the Tokio blocking thread pool.

Source

pub fn load_memory(&self, project_dir: &Path) -> Option<ProjectMemory>

Loads project memory from disk, returning None if no memory file exists.

Source

pub async fn load_memory_async( &self, project_dir: PathBuf, ) -> Option<ProjectMemory>

Async wrapper around Self::load_memory that runs the blocking filesystem operations on the Tokio blocking thread pool.

Source

pub fn add_memory_entry( &self, project_dir: &Path, session_id: &SessionId, summary: String, ) -> Result<PathBuf>

Appends a new memory entry for the project and persists it to disk.

Source

pub async fn add_memory_entry_async( &self, project_dir: PathBuf, session_id: String, summary: String, ) -> Result<PathBuf>

Async wrapper around Self::add_memory_entry that runs the blocking filesystem operations on the Tokio blocking thread pool.

Trait Implementations§

Source§

impl Clone for SessionStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more