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: StringSession identifier.
created_at: DateTime<Utc>When the session was created.
last_activity: DateTime<Utc>Last activity timestamp (for TTL).
message_count: u32Message counter (increments per pseudonymize call).
sensitivity: SensitivityLevelCurrent 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
impl SessionContext
Sourcepub fn new(session_id: String, config: SessionConfig) -> Self
pub fn new(session_id: String, config: SessionConfig) -> Self
Create a new session context.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this session has expired based on TTL.
Sourcepub fn record_entities(
&mut self,
entities: &[DetectedEntity],
tokens: &[PseudoToken],
)
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.
Sourcepub fn check_sensitivity(&mut self, text: &str) -> bool
pub fn check_sensitivity(&mut self, text: &str) -> bool
Check text for sensitivity escalation keywords. Returns true if sensitivity was escalated.
Sourcepub fn resolve_coreferences(
&self,
text: &str,
) -> Vec<(DetectedEntity, PseudoToken)>
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.
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> SessionStats
Get a summary of this session’s state (safe — no raw PII).
Sourcepub fn coreference_map(&self) -> &HashMap<String, Coreference>
pub fn coreference_map(&self) -> &HashMap<String, Coreference>
Get all coreference mappings (for inspection/debugging).
Sourcepub fn resolver_threshold(&self) -> f64
pub fn resolver_threshold(&self) -> f64
Get the session-aware resolver threshold (lower than global).