Skip to main content

SessionAnalyzer

Struct SessionAnalyzer 

Source
pub struct SessionAnalyzer { /* private fields */ }
Expand description

Session-aware multi-turn security analyzer.

Implementations§

Source§

impl SessionAnalyzer

Source

pub fn new(config: SessionAnalyzerConfig) -> Self

Create an analyzer with the given configuration.

Source

pub fn with_defaults() -> Self

Create an analyzer with default thresholds.

Source

pub fn record_event( &mut self, session_id: &str, request_text: &str, response_text: Option<&str>, risk_score: f64, finding_types: Vec<String>, ) -> SessionAnalysisResult

Record a new event and return the updated analysis for its session.

Source

pub fn analyze_session(&self, session_id: &str) -> SessionAnalysisResult

Analyse an existing session without recording a new event.

Source

pub fn detect_escalation( &self, session: &SessionState, ) -> Option<EscalationAlert>

Detect whether the session shows progressive risk escalation.

Source

pub fn detect_extraction_probing( &self, session: &SessionState, ) -> Vec<ExtractionIndicator>

Scan all turns for extraction-probe regex matches.

Source

pub fn detect_topic_shifting( &self, session: &SessionState, ) -> Option<TopicShiftAlert>

Detect a suspicious topic shift using Jaccard similarity on token sets.

A shift is flagged when similarity drops below topic_shift_sensitivity AND the risk score of the second turn is non-zero (indicating the shift accompanies suspicious content).

Source

pub fn compute_cumulative_risk(&self, session: &SessionState) -> f64

Return the cumulative risk for a session.

Source

pub fn cleanup_expired_sessions(&mut self)

Remove sessions that have been inactive longer than max_session_age.

Source

pub fn session_count(&self) -> usize

Number of active sessions being tracked.

Source

pub fn to_security_findings( result: &SessionAnalysisResult, ) -> Vec<SecurityFinding>

Convert a session analysis result into security findings for pipeline integration.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V