pub struct SessionInfrastructure {
pub pid: Option<u32>,
pub process_start_time: Option<u64>,
pub socket_path: Option<PathBuf>,
pub transcript_path: Option<TranscriptPath>,
pub recent_tools: VecDeque<ToolUsageRecord>,
pub update_count: u64,
pub hook_event_count: u64,
pub last_error: Option<String>,
}Expand description
Infrastructure-level data for a session.
Contains OS/system concerns that don’t belong in the domain model. Owned by RegistryActor alongside SessionDomain.
Fields§
§pid: Option<u32>Process ID of the Claude Code process (if known)
process_start_time: Option<u64>Process start time in clock ticks (from /proc/{pid}/stat field 22). Used to detect PID reuse - if the start time changes, it’s a different process.
socket_path: Option<PathBuf>Path to the Unix socket for this session (if applicable)
transcript_path: Option<TranscriptPath>Path to the transcript JSONL file
recent_tools: VecDeque<ToolUsageRecord>Recent tool usage history (bounded FIFO queue)
update_count: u64Number of status updates received
hook_event_count: u64Number of hook events received
last_error: Option<String>Last error encountered (for debugging)
Implementations§
Source§impl SessionInfrastructure
impl SessionInfrastructure
Sourcepub fn set_pid(&mut self, pid: u32)
pub fn set_pid(&mut self, pid: u32)
Sets the process ID and captures the process start time for PID reuse detection.
The start time is read from /proc/{pid}/stat field 22 (starttime in clock ticks).
If the PID is already set with the same value, this is a no-op.
§Validation
The PID is only stored if:
- It’s non-zero (PID 0 is invalid)
- We can successfully read its start time from
/proc/{pid}/stat
This prevents storing invalid PIDs that would cause incorrect liveness checks.
Sourcepub fn is_process_alive(&self) -> bool
pub fn is_process_alive(&self) -> bool
Checks if the tracked process is still alive.
Returns true if:
- No PID is tracked (can’t determine liveness)
- The process exists and has the same start time
Returns false if:
- The process no longer exists
- The PID has been reused by a different process (start time mismatch)
Sourcepub fn record_tool_use(
&mut self,
tool_name: &str,
tool_use_id: Option<ToolUseId>,
)
pub fn record_tool_use( &mut self, tool_name: &str, tool_use_id: Option<ToolUseId>, )
Records a tool usage.
Sourcepub fn record_update(&mut self)
pub fn record_update(&mut self)
Increments the update count.
Sourcepub fn record_error(&mut self, error: &str)
pub fn record_error(&mut self, error: &str)
Records an error.
Sourcepub fn last_tool(&self) -> Option<&ToolUsageRecord>
pub fn last_tool(&self) -> Option<&ToolUsageRecord>
Returns the most recent tool used.
Sourcepub fn recent_tools_iter(&self) -> impl Iterator<Item = &ToolUsageRecord>
pub fn recent_tools_iter(&self) -> impl Iterator<Item = &ToolUsageRecord>
Returns recent tools (most recent first).
Trait Implementations§
Source§impl Clone for SessionInfrastructure
impl Clone for SessionInfrastructure
Source§fn clone(&self) -> SessionInfrastructure
fn clone(&self) -> SessionInfrastructure
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more