pub struct SessionContext {
pub session_id: String,
pub session_dir: PathBuf,
pub base_dir: PathBuf,
pub is_new_session: bool,
/* private fields */
}Expand description
Session context — holds the session ID, directory, base directory, and file lock.
Created via resolve_session. The lock is released when the struct is dropped.
Fields§
§session_id: StringSession identifier (user-provided or auto-generated).
session_dir: PathBufPath to the session directory on disk.
base_dir: PathBufBase directory for all session data.
is_new_session: boolWhether this session was just created (vs reused).
Implementations§
Source§impl SessionContext
impl SessionContext
Sourcepub fn session_id_path(&self) -> PathBuf
pub fn session_id_path(&self) -> PathBuf
Path to the session ID marker file.
Sourcepub fn metadata_path(&self) -> PathBuf
pub fn metadata_path(&self) -> PathBuf
Path to the session metadata JSON file.
Sourcepub fn turn_path(&self, turn: usize) -> PathBuf
pub fn turn_path(&self, turn: usize) -> PathBuf
Path to the per-turn JSONL event log. turn is 1-indexed.
Sourcepub fn messages_jsonl_path(&self) -> PathBuf
pub fn messages_jsonl_path(&self) -> PathBuf
Path to the messages.jsonl window snapshot (one ChatMessage per line).
Sourcepub fn last_turn_number(&self) -> u32
pub fn last_turn_number(&self) -> u32
Highest turn number already logged for this session (0 if none).
Scans session_dir for turn_NNN.jsonl files and returns the max N.
Consumers that persist per-turn logs should initialize their turn
counter from this value (then increment) so that reusing a session id
across process runs continues the turn sequence instead of resetting
to 1 and appending a later run’s turn_001.jsonl into an earlier one.