pub struct SessionJournal {
pub entries: Vec<SessionEntry>,
pub leaf_id: Option<EntryId>,
pub schema_version: u32,
pub spawn_depth: u32,
}Fields§
§entries: Vec<SessionEntry>§leaf_id: Option<EntryId>§schema_version: u32§spawn_depth: u32Implementations§
Source§impl SessionJournal
impl SessionJournal
pub fn new() -> Self
pub fn with_spawn_depth(depth: u32) -> Self
pub fn append(&mut self, kind: SessionEntryKind) -> EntryId
Sourcepub fn append_stamped(
&mut self,
kind: SessionEntryKind,
created_at: DateTime<Utc>,
) -> EntryId
pub fn append_stamped( &mut self, kind: SessionEntryKind, created_at: DateTime<Utc>, ) -> EntryId
Append an entry carrying the time the underlying event happened, not
the time the save ran. created_at is the journal’s timeline; stamping
it at append is what keeps a rebuilt journal honest — a save must never
rewrite an entry’s time to the moment it was written.
pub fn append_message(&mut self, message: Message) -> EntryId
pub fn append_compaction( &mut self, summary: String, tokens_before: Option<u64>, tokens_after: Option<u64>, model: Option<String>, ) -> EntryId
pub fn append_branch_summary( &mut self, branch_id: String, summary: String, parent_branch_id: Option<String>, ) -> EntryId
pub fn branch_to(&mut self, entry_id: &str) -> Result<(), String>
pub fn fork_from(&self, from_entry_id: Option<&str>) -> Result<Self, String>
pub fn index(&self) -> HashMap<&str, &SessionEntry>
pub fn contains(&self, entry_id: &str) -> bool
pub fn leaf(&self) -> Option<&SessionEntry>
pub fn root_to_leaf(&self) -> Vec<&SessionEntry>
pub fn active_messages(&self, include_system: bool) -> Vec<Message>
pub fn leaves(&self) -> Vec<&SessionEntry>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn validate(&self) -> Result<(), String>
pub fn from_messages(messages: Vec<Message>, spawn_depth: u32) -> Self
Sourcepub fn from_messages_stamped(
messages: Vec<Message>,
stamps: &[DateTime<Utc>],
spawn_depth: u32,
) -> Self
pub fn from_messages_stamped( messages: Vec<Message>, stamps: &[DateTime<Utc>], spawn_depth: u32, ) -> Self
Build the journal honoring a per-message append stamp. stamps[i] is
the time messages[i] entered the conversation; a missing stamp falls
back to now, so a drifted caller degrades to save-time ordering rather
than dropping the message.
pub fn to_messages(&self) -> Vec<Message>
Sourcepub fn rebranch_active_messages(&mut self, messages: &[Message]) -> Rebranch
pub fn rebranch_active_messages(&mut self, messages: &[Message]) -> Rebranch
Keep the shared prefix and its original stamps. A provisional user entry can gain its Engine stamp until another branch shares it.
Sourcepub fn rebranch_active_messages_stamped(
&mut self,
messages: &[Message],
stamps: &[DateTime<Utc>],
) -> Rebranch
pub fn rebranch_active_messages_stamped( &mut self, messages: &[Message], stamps: &[DateTime<Utc>], ) -> Rebranch
Preserve existing entry identity and timestamps; only append the changed suffix, keeping the previous branch reachable.
Sourcepub fn prune_plan(
&self,
dead_threshold: usize,
dead_budget: usize,
) -> Vec<EntryId>
pub fn prune_plan( &self, dead_threshold: usize, dead_budget: usize, ) -> Vec<EntryId>
Ids a bounded save may move out of this journal, in journal order.
Empty until more than dead_threshold entries sit off the active
branch — superseded versions left behind by compaction, undo and
edits (#6842). Past it, the plan keeps the root→leaf path, then whole
off-branch chains (an entry with every ancestor) newest first, with
Compaction/BranchSummary chains ahead of plain leaves, while the
kept off-branch total stays within dead_budget. A kept entry never
loses its parent, so the remainder always passes Self::validate.
Pure: callers archive the planned entries durably before removing
them with Self::remove_entries. Known limit: the active branch
itself is never pruned, so a session that never compacts stays as
long as its conversation.
Trait Implementations§
Source§impl Clone for SessionJournal
impl Clone for SessionJournal
Source§impl Debug for SessionJournal
impl Debug for SessionJournal
Source§impl Default for SessionJournal
impl Default for SessionJournal
Source§impl<'de> Deserialize<'de> for SessionJournal
impl<'de> Deserialize<'de> for SessionJournal
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SessionJournal
impl PartialEq for SessionJournal
Source§impl Serialize for SessionJournal
impl Serialize for SessionJournal
impl StructuralPartialEq for SessionJournal
Auto Trait Implementations§
impl Forget for SessionJournal
impl Freeze for SessionJournal
impl Move for SessionJournal
impl RefUnwindSafe for SessionJournal
impl Send for SessionJournal
impl Sync for SessionJournal
impl Unpin for SessionJournal
impl UnsafeUnpin for SessionJournal
impl UnwindSafe for SessionJournal
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.