pub struct SessionState {Show 16 fields
pub session_id: String,
pub created_at: Instant,
pub last_activity: Instant,
pub protocol_version: Option<String>,
pub request_count: u64,
pub tools_list_seen: bool,
pub oauth_subject: Option<String>,
pub pinned_manifest: Option<ToolManifest>,
pub memory_tracker: MemoryTracker,
pub elicitation_count: u32,
pub sampling_count: u32,
pub token_expires_at: Option<u64>,
pub current_call_chain: Vec<CallChainEntry>,
pub agent_identity: Option<AgentIdentity>,
pub risk_score: Option<RiskScore>,
pub discovered_tools: HashMap<String, DiscoveredToolSession>,
/* private fields */
}Expand description
Per-session state tracked by the HTTP proxy.
Fields§
§session_id: String§created_at: Instant§last_activity: Instant§protocol_version: Option<String>§request_count: u64§tools_list_seen: boolWhether the initial tools/list response has been seen for this session. Used for rug-pull detection: tool additions after the first list are suspicious.
oauth_subject: Option<String>OAuth subject identifier from the authenticated token (if OAuth is enabled). Stored for inclusion in audit trail entries.
pinned_manifest: Option<ToolManifest>Pinned tool manifest for this session. Built from the first tools/list response, used to verify subsequent tools/list responses.
memory_tracker: MemoryTrackerOWASP ASI06: Per-session memory poisoning tracker. Records fingerprints of notable strings from tool responses and flags when those strings appear verbatim in subsequent tool call parameters.
elicitation_count: u32Number of elicitation requests processed in this session.
Used for per-session rate limiting of elicitation/create requests.
sampling_count: u32Number of sampling requests processed in this session.
Used for per-session rate limiting of sampling/createMessage requests.
SECURITY (FIND-R125-001): Parity with elicitation rate limiting.
token_expires_at: Option<u64>SECURITY (R15-OAUTH-4): Token expiry timestamp (Unix seconds).
current_call_chain: Vec<CallChainEntry>OWASP ASI08: Call chain for multi-agent communication monitoring.
Tracks upstream agent hops for the latest policy-evaluated request.
Updated from X-Upstream-Agents headers on tool calls, resource reads,
and task requests.
agent_identity: Option<AgentIdentity>OWASP ASI07: Cryptographically attested agent identity from X-Agent-Identity JWT. Populated when the header is present and valid, provides stronger identity guarantees than the legacy oauth_subject field.
risk_score: Option<RiskScore>Phase 21: Per-session risk score for continuous authorization.
discovered_tools: HashMap<String, DiscoveredToolSession>Phase 34: Tools discovered via vv_discover with TTL tracking.
Maps tool_id → session entry with discovery timestamp and TTL.
Implementations§
Source§impl SessionState
impl SessionState
pub fn new(session_id: String) -> Self
Sourcepub fn known_tools(&self) -> &HashMap<String, ToolAnnotations>
pub fn known_tools(&self) -> &HashMap<String, ToolAnnotations>
Read-only access to known tools.
Sourcepub fn flagged_tools(&self) -> &HashSet<String>
pub fn flagged_tools(&self) -> &HashSet<String>
Read-only access to flagged tools.
Sourcepub fn backend_sessions(&self) -> &HashMap<String, String>
pub fn backend_sessions(&self) -> &HashMap<String, String>
Read-only access to backend sessions.
Sourcepub fn gateway_tools(&self) -> &HashMap<String, Vec<String>>
pub fn gateway_tools(&self) -> &HashMap<String, Vec<String>>
Read-only access to gateway tools.
Sourcepub fn abac_granted_policies(&self) -> &[String]
pub fn abac_granted_policies(&self) -> &[String]
Read-only access to ABAC granted policies.
Sourcepub fn insert_backend_session(
&mut self,
backend_id: String,
upstream_session_id: String,
) -> bool
pub fn insert_backend_session( &mut self, backend_id: String, upstream_session_id: String, ) -> bool
SECURITY (FIND-R51-001): Insert a backend session with capacity bound.
Returns true if the entry was inserted or already existed, false if at capacity.
Sourcepub fn insert_gateway_tools(
&mut self,
backend_id: String,
tools: Vec<String>,
) -> bool
pub fn insert_gateway_tools( &mut self, backend_id: String, tools: Vec<String>, ) -> bool
SECURITY (FIND-R51-001): Insert gateway tools for a backend with capacity bounds.
Returns true if inserted, false if at capacity.
Sourcepub fn insert_granted_policy(&mut self, policy_id: String)
pub fn insert_granted_policy(&mut self, policy_id: String)
SECURITY (FIND-R51-002): Insert an ABAC granted policy with capacity bound and dedup.
Sourcepub fn insert_known_tool(
&mut self,
name: String,
annotations: ToolAnnotationsCompact,
) -> bool
pub fn insert_known_tool( &mut self, name: String, annotations: ToolAnnotationsCompact, ) -> bool
SECURITY (FIND-R51-012): Insert a known tool with capacity bound.
Returns true if inserted or updated, false if at capacity.
Sourcepub fn insert_flagged_tool(&mut self, name: String)
pub fn insert_flagged_tool(&mut self, name: String)
SECURITY (FIND-R51-014): Insert a flagged tool with capacity bound.
Sourcepub fn record_discovered_tools(&mut self, tool_ids: &[String], ttl: Duration)
pub fn record_discovered_tools(&mut self, tool_ids: &[String], ttl: Duration)
Record a set of discovered tools with the given TTL.
Overwrites any existing entry for the same tool_id (re-discovery resets the TTL).
If the session is at capacity (MAX_DISCOVERED_TOOLS_PER_SESSION), expired
entries are evicted first. If still at capacity, new tools are silently dropped.
Sourcepub fn is_tool_discovery_expired(&self, tool_id: &str) -> Option<bool>
pub fn is_tool_discovery_expired(&self, tool_id: &str) -> Option<bool>
Check whether a discovered tool has expired.
Returns None if the tool was never discovered (not an error — the tool
may be a statically-known tool that doesn’t require discovery).
Returns Some(true) if discovered but expired, Some(false) if still valid.
Sourcepub fn mark_tool_used(&mut self, tool_id: &str) -> bool
pub fn mark_tool_used(&mut self, tool_id: &str) -> bool
Mark a discovered tool as “used” (the agent actually called it).
Returns true if the tool was found and marked, false if not found.
Sourcepub fn evict_expired_discoveries(&mut self) -> usize
pub fn evict_expired_discoveries(&mut self) -> usize
Remove expired discovered tools from the session.
Returns the number of entries evicted.