Struct AcpSessionStore
pub struct AcpSessionStore { /* private fields */ }Implementations§
Source§impl AcpSessionStore
impl AcpSessionStore
pub fn new(workspace_dir: &Path) -> Result<Self>
Sourcepub fn create_session(
&self,
session_uuid: &str,
agent_alias: &str,
workspace_dir: &str,
) -> Result<i64>
pub fn create_session( &self, session_uuid: &str, agent_alias: &str, workspace_dir: &str, ) -> Result<i64>
Record a new session. Returns the integer id assigned by SQLite.
Sourcepub fn load_session(&self, session_uuid: &str) -> Result<Option<AcpSessionData>>
pub fn load_session(&self, session_uuid: &str) -> Result<Option<AcpSessionData>>
Load session metadata and full message history for restore.
Returns None if the session_uuid is not found.
Sourcepub fn load_session_for_restore(
&self,
session_uuid: &str,
) -> Result<AcpSessionRestore>
pub fn load_session_for_restore( &self, session_uuid: &str, ) -> Result<AcpSessionRestore>
Load only durable ACP rows that are allowed to become live sessions. Killed rows keep their transcript for history/export but are terminal for runtime restore paths.
Sourcepub fn list_sessions(&self) -> Result<Vec<AcpSessionSummary>>
pub fn list_sessions(&self) -> Result<Vec<AcpSessionSummary>>
List restorable sessions as lightweight summaries, ordered by most recent
activity first. This is the picker-facing read: it avoids the full
message-history hydration that load_session performs. Killed rows keep
history/export data but are terminal and must not be offered for restore.
Sourcepub fn append_turn(
&self,
session_uuid: &str,
messages: &[ConversationMessage],
) -> Result<()>
pub fn append_turn( &self, session_uuid: &str, messages: &[ConversationMessage], ) -> Result<()>
Append all ConversationMessages from one completed turn, decomposing AssistantToolCalls / ToolResults variants into the appropriate tables. Single transaction.
pub fn set_token_count( &self, session_uuid: &str, token_count: u64, ) -> Result<()>
Sourcepub fn set_plan(&self, session_uuid: &str, entries: &[PlanEntry]) -> Result<()>
pub fn set_plan(&self, session_uuid: &str, entries: &[PlanEntry]) -> Result<()>
Persist the session’s latest TodoWrite plan as a JSON array of
PlanEntry (whole-list replace). An empty slice stores an empty
array (a cleared plan), distinct from SQL NULL (never had one).
Sourcepub fn get_plan(&self, session_uuid: &str) -> Result<Vec<PlanEntry>>
pub fn get_plan(&self, session_uuid: &str) -> Result<Vec<PlanEntry>>
Load the session’s stored plan. Returns an empty vec when the session has no plan (NULL or absent). Malformed JSON is treated as an empty plan rather than a hard error, so a corrupt plan column never blocks session restore.
Sourcepub fn append_event(
&self,
session_uuid: &str,
action: Action,
outcome: EventOutcome,
payload: Option<&str>,
) -> Result<()>
pub fn append_event( &self, session_uuid: &str, action: Action, outcome: EventOutcome, payload: Option<&str>, ) -> Result<()>
Record a session-lifecycle event. Caller passes typed enums; the SQLite
layer is the only place strings appear. Same Action / EventOutcome
values are used at the matching zeroclaw_log::record! call site.
Sourcepub fn delete_session(&self, session_uuid: &str) -> Result<bool>
pub fn delete_session(&self, session_uuid: &str) -> Result<bool>
Delete a session and all its child rows (messages, tool calls, events
cascade via FK). Returns true if the session existed.
Sourcepub fn count_live_sessions_by_agent(&self, agent_alias: &str) -> Result<usize>
pub fn count_live_sessions_by_agent(&self, agent_alias: &str) -> Result<usize>
Count live ACP sessions for agent_alias — rows not yet killed
(killed_at IS NULL). A non-zero count is a HARD blocker for deleting the
agent: the operator must end the sessions first.
Sourcepub fn list_sessions_by_agent(
&self,
agent_alias: &str,
) -> Result<Vec<AcpSessionSummary>>
pub fn list_sessions_by_agent( &self, agent_alias: &str, ) -> Result<Vec<AcpSessionSummary>>
Summaries of every ACP session (live or killed) attributed to
agent_alias, for the export-then-delete archive.
Sourcepub fn delete_sessions_by_agent(&self, agent_alias: &str) -> Result<usize>
pub fn delete_sessions_by_agent(&self, agent_alias: &str) -> Result<usize>
Delete every ACP session (live or killed) for agent_alias, returning the
row count. Child tables (acp_messages/acp_tool_calls/acp_session_events)
cascade via their ON DELETE CASCADE FKs (foreign_keys = ON).
Sourcepub fn rename_sessions_by_agent(&self, from: &str, to: &str) -> Result<usize>
pub fn rename_sessions_by_agent(&self, from: &str, to: &str) -> Result<usize>
Re-point every ACP session (live or killed) from from to to,
returning the row count. The agent-rename cascadekeeps the
session and its transcript; only the owning alias moves. Unlike delete,
a live session (killed_at IS NULL) is no obstacle to rename.
Sourcepub fn mark_session_killed(&self, session_uuid: &str) -> Result<bool>
pub fn mark_session_killed(&self, session_uuid: &str) -> Result<bool>
Persist that an admin intentionally killed this ACP session. The transcript stays durable, but runtime rehydration must not revive it.
Sourcepub fn is_session_killed(&self, session_uuid: &str) -> Result<bool>
pub fn is_session_killed(&self, session_uuid: &str) -> Result<bool>
Return whether this durable ACP session has been intentionally killed. Missing rows are not killed; callers can then use normal load handling to distinguish SESSION_NOT_FOUND from a terminal killed session.
Sourcepub fn touch_session(&self, session_uuid: &str) -> Result<()>
pub fn touch_session(&self, session_uuid: &str) -> Result<()>
Update last_activity without appending messages.