Skip to main content

FileSessionStore

Struct FileSessionStore 

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

File-backed session storage. Durable session facts append directly to journal.jsonl.

Store clones share an in-process append lock so runtime savepoints, compaction, and plan updates cannot interleave bytes or write duplicate headers. Callers that create or resume a live run should also hold a SessionReservation for cross-process exclusion.

Implementations§

Source§

impl FileSessionStore

Source

pub async fn search_session_ids(&self, query: &str) -> Vec<SessionId>

Returns session ids whose topic or user text matches query.

An empty or unusable query returns no rows. Index failures are logged and also return no rows; they do not affect resume.

Source

pub async fn update_session_search_labels( &self, session_id: &SessionId, topic: Option<&str>, )

Updates list labels without replacing indexed user text.

Source§

impl FileSessionStore

Source

pub fn default_sessions_dir() -> Result<PathBuf, SessionStoreError>

Source

pub fn default_store() -> Result<Self, SessionStoreError>

Source

pub fn new(root: impl AsRef<Path>) -> Self

Creates a store rooted at a directory.

Each session is stored below <root>/<session_id>/journal.jsonl.

Source

pub fn sessions_dir(&self) -> &Path

Source

pub fn subagents_store(&self, parent_session_id: &SessionId) -> Self

Returns a child-scoped session store rooted at <sessions_dir>/<parent_id>/subagents.

Storing child journals under a nested subagents/ directory keeps them durably paired with the parent session without polluting top-level session discovery listings.

Source

pub async fn reserve_session( &self, session_id: &SessionId, ) -> Result<SessionReservation, SessionStoreError>

Reserves exclusive write ownership of a session id until the returned guard is dropped.

The lock is acquired before callers inspect or write journal.jsonl, so independent runs cannot both pass a check-then-save collision window. The lock file is intentionally retained as an empty per-session inode; it is not session state and is ignored by session discovery.

Source

pub async fn release_empty_reservation( &self, session_id: &SessionId, reservation: SessionReservation, )

Releases a session reservation and removes its directory when it contains no persisted files other than .session.lock (for example, when a newly opened interactive session exits without recording any activity).

Source

pub async fn contains_session( &self, session_id: &SessionId, ) -> Result<bool, SessionStoreError>

Reports whether this store already holds committed state for a session id.

Saving appends journal.jsonl, so a new run that reuses an id would mix its transcript into an existing session. Callers that start a session check this first and refuse the id. A legacy state.json still occupies the id; those sessions are not resumed.

Source

pub fn session_dir(&self, session_id: &SessionId) -> PathBuf

Returns the directory containing durable state and archive files for session_id.

Trait Implementations§

Source§

impl Clone for FileSessionStore

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 FileSessionStore

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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