pub struct ContextLedger {
pub window_size: usize,
pub entries: Vec<LedgerEntry>,
pub total_tokens_sent: usize,
pub total_tokens_saved: usize,
}Fields§
§window_size: usize§entries: Vec<LedgerEntry>§total_tokens_sent: usize§total_tokens_saved: usizeImplementations§
Source§impl ContextLedger
impl ContextLedger
pub fn new() -> Self
pub fn with_window_size(size: usize) -> Self
pub fn record( &mut self, path: &str, mode: &str, original_tokens: usize, sent_tokens: usize, )
pub fn record_with_task( &mut self, path: &str, mode: &str, original_tokens: usize, sent_tokens: usize, task: Option<&str>, )
Sourcepub fn upsert(
&mut self,
path: &str,
mode: &str,
original_tokens: usize,
sent_tokens: usize,
source_hash: Option<&str>,
kind: ContextKind,
provenance: Option<Provenance>,
)
pub fn upsert( &mut self, path: &str, mode: &str, original_tokens: usize, sent_tokens: usize, source_hash: Option<&str>, kind: ContextKind, provenance: Option<Provenance>, )
Record with full CFT metadata including source hash and provenance.
Sourcepub fn update_phi(&mut self, path: &str, phi: f64)
pub fn update_phi(&mut self, path: &str, phi: f64)
Update the Phi score for an entry.
Sourcepub fn set_state(&mut self, path: &str, state: ContextState)
pub fn set_state(&mut self, path: &str, state: ContextState)
Set the state for an entry.
Sourcepub fn find_by_id(&self, id: &ContextItemId) -> Option<&LedgerEntry>
pub fn find_by_id(&self, id: &ContextItemId) -> Option<&LedgerEntry>
Find an entry by its ContextItemId.
Sourcepub fn items_by_state(&self, state: ContextState) -> Vec<&LedgerEntry>
pub fn items_by_state(&self, state: ContextState) -> Vec<&LedgerEntry>
Get all entries with a specific state.
Sourcepub fn eviction_candidates_by_phi(&self, keep_count: usize) -> Vec<String>
pub fn eviction_candidates_by_phi(&self, keep_count: usize) -> Vec<String>
Eviction candidates ordered by Phi (lowest first), falling back to timestamp for entries without Phi scores.
Sourcepub fn mark_stale_by_hash(&mut self, path: &str, new_hash: &str)
pub fn mark_stale_by_hash(&mut self, path: &str, new_hash: &str)
Mark entries as stale if their source hash has changed.
pub fn pressure(&self) -> ContextPressure
pub fn compression_ratio(&self) -> f64
pub fn files_by_token_cost(&self) -> Vec<(String, usize)>
pub fn mode_distribution(&self) -> HashMap<String, usize>
pub fn eviction_candidates(&self, keep_count: usize) -> Vec<String>
pub fn remove(&mut self, path: &str)
pub fn save(&self)
pub fn prune(&mut self) -> usize
pub fn load() -> Self
pub fn format_summary(&self) -> String
pub fn adjusted_total_saved(&self) -> isize
Source§impl ContextLedger
impl ContextLedger
pub fn reinjection_plan( &self, intent: &StructuredIntent, target_utilization: f64, ) -> ReinjectionPlan
Trait Implementations§
Source§impl Clone for ContextLedger
impl Clone for ContextLedger
Source§fn clone(&self) -> ContextLedger
fn clone(&self) -> ContextLedger
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextLedger
impl Debug for ContextLedger
Source§impl Default for ContextLedger
impl Default for ContextLedger
Source§impl<'de> Deserialize<'de> for ContextLedger
impl<'de> Deserialize<'de> for ContextLedger
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContextLedger
impl RefUnwindSafe for ContextLedger
impl Send for ContextLedger
impl Sync for ContextLedger
impl Unpin for ContextLedger
impl UnsafeUnpin for ContextLedger
impl UnwindSafe for ContextLedger
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
Mutably borrows from an owned value. Read more
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>
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 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>
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