Skip to main content

SessionContext

Struct SessionContext 

Source
pub struct SessionContext {
    pub session_id: String,
    pub created_at: DateTime<Utc>,
    pub last_activity: DateTime<Utc>,
    pub message_count: u32,
    pub sensitivity: SensitivityLevel,
    pub escalation_keywords: Vec<String>,
    pub entities: HashMap<String, SessionEntity>,
    pub coreferences: HashMap<String, Coreference>,
    /* private fields */
}
Expand description

Per-session context buffer.

Fields§

§session_id: String

Session identifier.

§created_at: DateTime<Utc>

When the session was created.

§last_activity: DateTime<Utc>

Last activity timestamp (for TTL).

§message_count: u32

Message counter (increments per pseudonymize call).

§sensitivity: SensitivityLevel

Current sensitivity level.

§escalation_keywords: Vec<String>

Keywords that triggered escalation.

§entities: HashMap<String, SessionEntity>

Entities seen in this session (original text → SessionEntity).

§coreferences: HashMap<String, Coreference>

Coreference mappings (surface form → Coreference).

Implementations§

Source§

impl SessionContext

Source

pub fn new(session_id: String, config: SessionConfig) -> Self

Create a new session context.

Source

pub fn is_expired(&self) -> bool

Check if this session has expired based on TTL.

Source

pub fn record_entities( &mut self, entities: &[DetectedEntity], tokens: &[PseudoToken], )

Record entities detected in the current message. Call this after pseudonymization to update session state.

Source

pub fn check_sensitivity(&mut self, text: &str) -> bool

Check text for sensitivity escalation keywords. Returns true if sensitivity was escalated.

Source

pub fn resolve_coreferences( &self, text: &str, ) -> Vec<(DetectedEntity, PseudoToken)>

Resolve coreferences in the text — returns additional entities to pseudonymize.

Finds pronouns, abbreviations, and definite articles that refer to previously seen entities, and returns them as DetectedEntity instances so the caller can pseudonymize them.

Source

pub fn stats(&self) -> SessionStats

Get a summary of this session’s state (safe — no raw PII).

Source

pub fn coreference_map(&self) -> &HashMap<String, Coreference>

Get all coreference mappings (for inspection/debugging).

Source

pub fn resolver_threshold(&self) -> f64

Get the session-aware resolver threshold (lower than global).

Trait Implementations§

Source§

impl Debug for SessionContext

Source§

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

Formats the value using the given formatter. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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