pub struct SessionStore { /* private fields */ }Expand description
CRUD access to the acp_sessions metadata index.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new(pool: DbPool) -> Self
pub fn new(pool: DbPool) -> Self
Wrap an existing DbPool. zeph-session does not own a dedicated database file —
it shares the pool that already owns acp_sessions (migration 013).
Sourcepub async fn create(&self, session_id: &str) -> Result<(), SessionError>
pub async fn create(&self, session_id: &str) -> Result<(), SessionError>
Insert a new session row with status = 'active', ignoring the call if the row already
exists (idempotent, mirrors the existing create_acp_session pattern).
§Errors
Returns SessionError::Db if the write fails.
Sourcepub async fn update_seq(
&self,
session_id: &str,
last_seq: u64,
event_count: u64,
) -> Result<(), SessionError>
pub async fn update_seq( &self, session_id: &str, last_seq: u64, event_count: u64, ) -> Result<(), SessionError>
Update last_seq, event_count, and updated_at after a turn’s events are flushed to
the log (INV-SP-1: called only after the log append is durable).
Explicitly bumps updated_at here because the pre-cutover AFTER INSERT ON acp_session_events trigger (migration 017) that used to drive it never fires for
post-cutover sessions (spec-068 §12.3 / D-2: acp_session_events is a write target only
for legacy pre-cutover sessions) — without this, list_acp_sessions’ “ordered by last
activity descending” would silently degrade to “ordered by creation time” for every
session created after the cutover.
§Errors
Returns SessionError::Db if the write fails.
Sourcepub async fn set_status(
&self,
session_id: &str,
status: SessionStatus,
) -> Result<(), SessionError>
pub async fn set_status( &self, session_id: &str, status: SessionStatus, ) -> Result<(), SessionError>
Sourcepub async fn set_condensed_seq(
&self,
session_id: &str,
last_condensed_seq: u64,
) -> Result<(), SessionError>
pub async fn set_condensed_seq( &self, session_id: &str, last_condensed_seq: u64, ) -> Result<(), SessionError>
Update the high-water condensation mark (INV-SP-4 non-overlap tracking).
§Errors
Returns SessionError::Db if the write fails.
Sourcepub async fn get(
&self,
session_id: &str,
) -> Result<Option<SessionMetadata>, SessionError>
pub async fn get( &self, session_id: &str, ) -> Result<Option<SessionMetadata>, SessionError>
Sourcepub async fn list(
&self,
filter: &SessionFilter,
) -> Result<Vec<SessionMetadata>, SessionError>
pub async fn list( &self, filter: &SessionFilter, ) -> Result<Vec<SessionMetadata>, SessionError>
Sourcepub async fn link_conversation(
&self,
session_id: &str,
conversation_id: i64,
) -> Result<(), SessionError>
pub async fn link_conversation( &self, session_id: &str, conversation_id: i64, ) -> Result<(), SessionError>
Link this session to a ConversationId (raw i64 — zeph-session does not depend on
zeph-memory’s newtype), enforcing the SessionId<->ConversationId bijection (spec
§5.2) via the unique partial index added in migration 106.
§Errors
Returns SessionError::Db if the write fails (including a unique-constraint violation
when conversation_id is already linked to a different session).
Sourcepub async fn get_by_conversation_id(
&self,
conversation_id: i64,
) -> Result<Option<SessionMetadata>, SessionError>
pub async fn get_by_conversation_id( &self, conversation_id: i64, ) -> Result<Option<SessionMetadata>, SessionError>
Look up the session already linked to a ConversationId, if any.
Used at non-ACP channel startup (CLI/TUI/Telegram) to resume the same conversation’s
existing session (and its event log) across process restarts, rather than minting a new
SessionId every launch (spec §12.2).
§Errors
Returns SessionError::Db if the query fails.
Sourcepub async fn record_fork(
&self,
new_session_id: &str,
src_session_id: &str,
forked_at_seq: u64,
owner: Option<&str>,
) -> Result<(), SessionError>
pub async fn record_fork( &self, new_session_id: &str, src_session_id: &str, forked_at_seq: u64, owner: Option<&str>, ) -> Result<(), SessionError>
Record a fork: sets forked_from/forked_at_seq on the child row.
Does not touch the parent’s log (the ForkPoint provenance event is appended by
crate::replay’s ForkEngine, which owns the parent’s crate::log::SessionEventLog).
owner stamps owner_key (#5868): ACP’s fork_conversation passes its connection’s
owner identity so the freshly forked child is immediately listable by its creator;
the CLI’s sessions fork passes None (operator-scoped, unowned — consistent with
every other CLI-side session row).
§Errors
Returns SessionError::Db if either write fails.
Sourcepub async fn delete(&self, session_id: &str) -> Result<bool, SessionError>
pub async fn delete(&self, session_id: &str) -> Result<bool, SessionError>
Delete a session’s metadata row. Returns true if a row was deleted.
Does not remove the on-disk event log directory or blobs — callers with access to
[session] data_dir are responsible for that (mirrors the separation of concerns between
SessionStore and crate::log::SessionEventLog).
§Errors
Returns SessionError::Db if the write fails.
Auto Trait Implementations§
impl !RefUnwindSafe for SessionStore
impl !UnwindSafe for SessionStore
impl Freeze for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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