pub struct ActiveSession {
pub metadata: Arc<SessionMetadata>,
pub last_updated: DateTime<Utc>,
pub hot_context: Arc<HotContext>,
pub warm_context: Arc<Vec<CompressedUpdate>>,
pub cold_context: Arc<Vec<StructuredSummary>>,
pub current_state: Arc<StructuredContext>,
pub incremental_updates: Arc<Vec<ContextUpdate>>,
pub code_references: Arc<HashMap<String, Vec<CodeReference>>>,
pub change_history: Arc<Vec<ChangeRecord>>,
pub entity_graph: Arc<SimpleEntityGraph>,
pub vectorized_update_ids: Arc<DashSet<Uuid>>,
}Expand description
ActiveSession with lock-free granular components Uses Arc-wrapped lock-free structures for concurrent access and cheap cloning
Copy-on-Write (CoW) Semantics:
Heavy fields are wrapped in Arc for efficient cloning. When the session needs
to be modified, use Arc::make_mut() which will:
- Return a mutable reference if this is the only owner
- Clone the data only if there are other owners
This dramatically reduces cloning overhead when sessions are frequently updated.
Fields§
§metadata: Arc<SessionMetadata>Immutable session metadata (id, name, preferences)
last_updated: DateTime<Utc>Timestamp of the last modification
hot_context: Arc<HotContext>Lock-free hot updates (DashMap-based)
warm_context: Arc<Vec<CompressedUpdate>>CoW compressed updates (storage tier)
cold_context: Arc<Vec<StructuredSummary>>CoW periodic summaries (storage tier)
current_state: Arc<StructuredContext>Current queryable structured state
incremental_updates: Arc<Vec<ContextUpdate>>All incremental updates (biggest CoW vector)
code_references: Arc<HashMap<String, Vec<CodeReference>>>Code references indexed by file path
change_history: Arc<Vec<ChangeRecord>>Recorded change history
entity_graph: Arc<SimpleEntityGraph>Named-entity graph with relationships
vectorized_update_ids: Arc<DashSet<Uuid>>IDs of updates that have been vectorized
Implementations§
Source§impl ActiveSession
impl ActiveSession
Sourcepub fn new(
id: Uuid,
name: Option<String>,
description: Option<String>,
) -> ActiveSession
pub fn new( id: Uuid, name: Option<String>, description: Option<String>, ) -> ActiveSession
Create a new empty session with default preferences.
Sourcepub fn from_components(
id: Uuid,
name: Option<String>,
description: Option<String>,
created_at: DateTime<Utc>,
last_updated: DateTime<Utc>,
user_preferences: UserPreferences,
hot_context_vec: Vec<ContextUpdate>,
warm_context: Vec<CompressedUpdate>,
cold_context: Vec<StructuredSummary>,
current_state: StructuredContext,
incremental_updates: Vec<ContextUpdate>,
code_references: HashMap<String, Vec<CodeReference>>,
change_history: Vec<ChangeRecord>,
entity_graph: SimpleEntityGraph,
vectorized_update_ids: Vec<Uuid>,
) -> ActiveSession
pub fn from_components( id: Uuid, name: Option<String>, description: Option<String>, created_at: DateTime<Utc>, last_updated: DateTime<Utc>, user_preferences: UserPreferences, hot_context_vec: Vec<ContextUpdate>, warm_context: Vec<CompressedUpdate>, cold_context: Vec<StructuredSummary>, current_state: StructuredContext, incremental_updates: Vec<ContextUpdate>, code_references: HashMap<String, Vec<CodeReference>>, change_history: Vec<ChangeRecord>, entity_graph: SimpleEntityGraph, vectorized_update_ids: Vec<Uuid>, ) -> ActiveSession
Reconstruct an ActiveSession from individual components (used for SurrealDB native storage)
Sourcepub fn is_vectorization_pending(&self, entry_id: Uuid) -> bool
pub fn is_vectorization_pending(&self, entry_id: Uuid) -> bool
Returns true if entry_id is queued for vectorisation but the
embedding has not yet landed in the vector index.
Sourcepub fn pending_vectorization_count(&self) -> usize
pub fn pending_vectorization_count(&self) -> usize
Returns the number of context entries currently waiting for the
embedding pipeline. Useful as a per-session counterpart to
Pipeline::backlog() (which is process-wide).
Sourcepub fn description(&self) -> Option<String>
pub fn description(&self) -> Option<String>
Returns the session’s description, if set.
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Returns the session creation timestamp.
Sourcepub fn user_preferences(&self) -> &UserPreferences
pub fn user_preferences(&self) -> &UserPreferences
Returns a reference to the session’s user preferences.
Sourcepub async fn add_incremental_update(
&mut self,
update: ContextUpdate,
) -> Result<(), Error>
pub async fn add_incremental_update( &mut self, update: ContextUpdate, ) -> Result<(), Error>
Add an incremental update, processing entity graph, code refs, and state.
Sourcepub async fn add_incremental_update_fast(
&mut self,
update: ContextUpdate,
) -> Result<(), Error>
pub async fn add_incremental_update_fast( &mut self, update: ContextUpdate, ) -> Result<(), Error>
Fast path: same as add_incremental_update but skips update_entity_graph. Entity graph update should be applied separately via apply_entity_graph_update.
Sourcepub async fn apply_entity_graph_update(
&mut self,
update: &ContextUpdate,
) -> Result<(), Error>
pub async fn apply_entity_graph_update( &mut self, update: &ContextUpdate, ) -> Result<(), Error>
Apply entity graph update only. Used as background task after CAS success.
Sourcepub fn remove_update_by_id(&mut self, entry_id: &Uuid) -> bool
pub fn remove_update_by_id(&mut self, entry_id: &Uuid) -> bool
Remove a single incremental update by its ContextUpdate.id (entry_id).
Cleans up the hot context cache, the warm-compressed cache, and the
canonical incremental_updates vector. Returns true if the entry existed.
Caller is responsible for persisting the session and (optionally) rebuilding
the entity graph if relations from this update should be revoked.
Sourcepub fn remove_updates_for_file(&mut self, file_path: &str) -> usize
pub fn remove_updates_for_file(&mut self, file_path: &str) -> usize
Remove incremental updates whose related_code.file_path matches file_path.
Also removes the corresponding code_references entry.
Returns the number of updates removed.
Sourcepub async fn rebuild_entity_graph_from_updates(
&mut self,
) -> Result<(usize, usize), Error>
pub async fn rebuild_entity_graph_from_updates( &mut self, ) -> Result<(usize, usize), Error>
Rebuild the entity graph by clearing it and replaying all updates through NER extraction. Returns (entities_before, entities_after) counts.
Sourcepub fn set_name(&mut self, name: Option<String>)
pub fn set_name(&mut self, name: Option<String>)
Update the session name (preserves created_at).
Sourcepub fn set_description(&mut self, description: Option<String>)
pub fn set_description(&mut self, description: Option<String>)
Update the session description (preserves created_at).
Sourcepub fn update_metadata(
&mut self,
name: Option<String>,
description: Option<String>,
)
pub fn update_metadata( &mut self, name: Option<String>, description: Option<String>, )
Update both name and description (preserves existing values if None
provided, and always preserves the original created_at).
Sourcepub fn get_metadata(&self) -> (Option<String>, Option<String>)
pub fn get_metadata(&self) -> (Option<String>, Option<String>)
Get the current name and description
Sourcepub async fn add_context_update(
&mut self,
description: String,
metadata: Option<Value>,
) -> Result<(String, ContextUpdate), String>
pub async fn add_context_update( &mut self, description: String, metadata: Option<Value>, ) -> Result<(String, ContextUpdate), String>
Build a ContextUpdate from a description (or deserialize one from caller metadata)
and append it via add_incremental_update_fast. Returns (update_id, update).
Sourcepub fn context_summary(&self) -> String
pub fn context_summary(&self) -> String
Recent updates from hot context as a human-readable bullet list.
Trait Implementations§
Source§impl Clone for ActiveSession
impl Clone for ActiveSession
Source§fn clone(&self) -> ActiveSession
fn clone(&self) -> ActiveSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ActiveSession
impl Debug for ActiveSession
Source§impl Default for ActiveSession
impl Default for ActiveSession
Source§fn default() -> ActiveSession
fn default() -> ActiveSession
Source§impl<'de> Deserialize<'de> for ActiveSession
impl<'de> Deserialize<'de> for ActiveSession
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ActiveSession, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ActiveSession, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Serialize for ActiveSession
impl Serialize for ActiveSession
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl Freeze for ActiveSession
impl !RefUnwindSafe for ActiveSession
impl Send for ActiveSession
impl Sync for ActiveSession
impl Unpin for ActiveSession
impl UnsafeUnpin for ActiveSession
impl !UnwindSafe for ActiveSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request