Skip to main content

SessionStoreV2

Struct SessionStoreV2 

Source
pub struct SessionStoreV2 { /* private fields */ }

Implementations§

Source§

impl SessionStoreV2

Source

pub async fn new(bamboo_home_dir: PathBuf) -> Result<Self>

Source

pub fn search_index(&self) -> &SessionSearchIndex

Source

pub fn bamboo_home_dir(&self) -> &Path

Source

pub fn index_path(&self) -> &Path

Source

pub async fn rebuild_search_index(&self) -> Result<()>

Source

pub fn sessions_root_dir(&self) -> &Path

Source

pub async fn list_index_entries(&self) -> Vec<SessionIndexEntry>

Source

pub async fn get_index_entry( &self, session_id: &str, ) -> Option<SessionIndexEntry>

Source

pub async fn resolve_rel_path(&self, session_id: &str) -> Option<String>

Source

pub async fn migrate_runtime_sidecars(&self) -> Result<usize>

One-shot migration: create the runtime sidecar (runtime.json) for every existing session that predates the message/control-plane split.

Loading already tolerates a missing sidecar (it falls back to the embedded control-plane in session.json), so this is an optimization migration, not a correctness one — but running it once means the fast runtime-save path is in effect immediately for legacy sessions, and the denormalized children id vectors (now #[serde(skip)]) drop out of the sidecar.

Idempotent and cheap on later boots: guarded by a marker file, and any session that already has a sidecar is skipped. Returns the number of sidecars created.

Source

pub async fn write_image_attachment( &self, session: &Session, raw_base64_or_data_url: &str, mime_hint: Option<&str>, ) -> Result<(String, String)>

Source

pub async fn read_attachment( &self, session_id: &str, attachment_id: &str, ) -> Result<Option<(Vec<u8>, String)>>

Read an attachment by id, returning bytes + inferred MIME.

Source

pub async fn clear_session(&self, session_id: &str) -> Result<bool>

Source

pub async fn cleanup( &self, mode: CleanupMode, keep_pinned: bool, ) -> Result<CleanupResult>

Source

pub async fn dev_reset(&self) -> Result<()>

Development-only: hard reset all sessions and the index.

This is the supported “greenfield” mechanism. It deletes:

  • bamboo_home_dir/sessions/
  • bamboo_home_dir/sessions.json (rewritten to empty index)
Source

pub async fn delete_session_recursive( &self, session_id: &str, force: bool, ) -> Result<bool>

Delete a session. If the session is a root, deletes its entire directory (and all child sessions). If the session is a child, deletes only that child directory.

force=true ignores pinned protection; callers must enforce confirmations at the API/UI layer.

Trait Implementations§

Source§

impl AttachmentReader for SessionStoreV2

Source§

fn read_attachment<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 str, attachment_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, String)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl Debug for SessionStoreV2

Source§

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

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

impl Storage for SessionStoreV2

Source§

fn save_session<'life0, 'life1, 'async_trait>( &'life0 self, session: &'life1 Session, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Saves a session’s metadata.
Source§

fn load_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a session by ID, returns None if not found.
Source§

fn delete_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes a session, returns true if anything was deleted.
Source§

fn save_runtime_state<'life0, 'life1, 'async_trait>( &'life0 self, session: &'life1 Session, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist ONLY the runtime control-plane (everything except the potentially large messages history) for an already-existing session. Read more
Source§

fn load_runtime_control_plane<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load only the runtime control-plane snapshot — a Session whose messages are left empty — when the backend keeps one. Read more
Source§

fn list_child_run_statuses<'life0, 'life1, 'async_trait>( &'life0 self, parent_session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Option<String>)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List (child_session_id, last_run_status) for every direct child of the given parent session, sourced from the index/metadata the backend keeps. Read more
Source§

fn append_token_usage_record<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 str, json_line: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Append one analysis record — a single JSON line — to the session’s dedicated, append-only token-usage log, stored alongside the session’s other files in its per-session directory. 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> 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, 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<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