Skip to main content

SessionInfrastructure

Struct SessionInfrastructure 

Source
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: u64

Number of status updates received

§hook_event_count: u64

Number of hook events received

§last_error: Option<String>

Last error encountered (for debugging)

Implementations§

Source§

impl SessionInfrastructure

Source

pub fn new() -> Self

Creates new SessionInfrastructure.

Source

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.

Source

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)
Source

pub fn record_tool_use( &mut self, tool_name: &str, tool_use_id: Option<ToolUseId>, )

Records a tool usage.

Source

pub fn record_update(&mut self)

Increments the update count.

Source

pub fn record_error(&mut self, error: &str)

Records an error.

Source

pub fn last_tool(&self) -> Option<&ToolUsageRecord>

Returns the most recent tool used.

Source

pub fn recent_tools_iter(&self) -> impl Iterator<Item = &ToolUsageRecord>

Returns recent tools (most recent first).

Trait Implementations§

Source§

impl Clone for SessionInfrastructure

Source§

fn clone(&self) -> SessionInfrastructure

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionInfrastructure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SessionInfrastructure

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more