Skip to main content

ActiveSession

Struct ActiveSession 

Source
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

Source

pub fn new( id: Uuid, name: Option<String>, description: Option<String>, ) -> ActiveSession

Create a new empty session with default preferences.

Source

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)

Source

pub fn id(&self) -> Uuid

Returns the session’s unique identifier.

Source

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.

Source

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).

Source

pub fn name(&self) -> Option<String>

Returns the session’s display name, if set.

Source

pub fn description(&self) -> Option<String>

Returns the session’s description, if set.

Source

pub fn created_at(&self) -> DateTime<Utc>

Returns the session creation timestamp.

Source

pub fn user_preferences(&self) -> &UserPreferences

Returns a reference to the session’s user preferences.

Source

pub async fn add_incremental_update( &mut self, update: ContextUpdate, ) -> Result<(), Error>

Add an incremental update, processing entity graph, code refs, and state.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_name(&mut self, name: Option<String>)

Update the session name (preserves created_at).

Source

pub fn set_description(&mut self, description: Option<String>)

Update the session description (preserves created_at).

Source

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).

Source

pub fn get_metadata(&self) -> (Option<String>, Option<String>)

Get the current name and description

Source

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).

Source

pub fn context_summary(&self) -> String

Recent updates from hot context as a human-readable bullet list.

Trait Implementations§

Source§

impl Clone for ActiveSession

Source§

fn clone(&self) -> ActiveSession

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActiveSession

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ActiveSession

Source§

fn default() -> ActiveSession

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ActiveSession

Source§

fn deserialize<D>( deserializer: D, ) -> Result<ActiveSession, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ActiveSession

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. 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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,