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
impl FileSessionStore
Sourcepub async fn search_session_ids(&self, query: &str) -> Vec<SessionId>
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.
Sourcepub async fn update_session_search_labels(
&self,
session_id: &SessionId,
topic: Option<&str>,
)
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
impl FileSessionStore
pub fn default_sessions_dir() -> Result<PathBuf, SessionStoreError>
pub fn default_store() -> Result<Self, SessionStoreError>
Sourcepub fn new(root: impl AsRef<Path>) -> Self
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.
pub fn sessions_dir(&self) -> &Path
Sourcepub fn subagents_store(&self, parent_session_id: &SessionId) -> Self
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.
Sourcepub async fn reserve_session(
&self,
session_id: &SessionId,
) -> Result<SessionReservation, SessionStoreError>
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.
Sourcepub async fn release_empty_reservation(
&self,
session_id: &SessionId,
reservation: SessionReservation,
)
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).
Sourcepub async fn contains_session(
&self,
session_id: &SessionId,
) -> Result<bool, SessionStoreError>
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.
Sourcepub fn session_dir(&self, session_id: &SessionId) -> PathBuf
pub fn session_dir(&self, session_id: &SessionId) -> PathBuf
Returns the directory containing durable state and archive files for session_id.