pub struct SharedContext { /* private fields */ }Expand description
Durable cross-agent memory backed by an appendable JSONL file.
Implementations§
Sourcepub fn legacy() -> Option<Self>
pub fn legacy() -> Option<Self>
The installation-wide store of releases before 3.11.5. Served to no
project; read for the explicit lean-ctx migrate legacy-context
adoption only.
Sourcepub fn orphaned_entries() -> Vec<(PathBuf, SharedContextEntry)>
pub fn orphaned_entries() -> Vec<(PathBuf, SharedContextEntry)>
Facts left in a partition that is no longer the current one of the root they recorded: that project’s identity (remote, package name) changed since. Served to no project until adopted.
Sourcepub fn for_project(project_root: &str) -> Result<Self, String>
pub fn for_project(project_root: &str) -> Result<Self, String>
The shared facts of project_root, in its own partition of the data
directory.
pub fn path(&self) -> &Path
pub fn put( &self, content: impl Into<String>, agent: impl Into<String>, category: impl Into<String>, ) -> Result<String, String>
pub fn get_relevant( &self, query: &str, limit: usize, ) -> Result<Vec<SharedContextEntry>, String>
pub fn get_recent( &self, limit: usize, ) -> Result<Vec<SharedContextEntry>, String>
pub fn get_by_category( &self, category: &str, ) -> Result<Vec<SharedContextEntry>, String>
pub fn prune( &self, max_age_seconds: u64, max_entries: usize, ) -> Result<usize, String>
Sourcepub fn verify_fact(&self, hash: &str) -> Result<(), String>
pub fn verify_fact(&self, hash: &str) -> Result<(), String>
Record an explicit confirmation of a fact.
Sourcepub fn mark_stale(&self, hash: &str) -> Result<(), String>
pub fn mark_stale(&self, hash: &str) -> Result<(), String>
Lower the confidence of a fact identified as stale without removing it.
Sourcepub fn supersede(&self, old_hash: &str, new_fact: &str) -> Result<(), String>
pub fn supersede(&self, old_hash: &str, new_fact: &str) -> Result<(), String>
Mark old_hash as replaced by the existing fact identified by new_fact.
Sourcepub fn prune_stale(&self, max_age_days: u16) -> Result<usize, String>
pub fn prune_stale(&self, max_age_days: u16) -> Result<usize, String>
Remove facts whose latest verification (or creation) predates their expiry window.
Sourcepub fn prune_negative(&self) -> Result<usize, String>
pub fn prune_negative(&self) -> Result<usize, String>
Remove facts consistently associated with unsuccessful outcomes.
Sourcepub fn get_best(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SharedContextEntry>, String>
pub fn get_best( &self, query: &str, limit: usize, ) -> Result<Vec<SharedContextEntry>, String>
Return query-matching facts ordered by their provenance quality score.
Sourcepub fn record_fact_outcome(
&self,
hash: &str,
success: bool,
) -> Result<(), String>
pub fn record_fact_outcome( &self, hash: &str, success: bool, ) -> Result<(), String>
Fold an outcome into a fact’s correlation score with an exponential moving average.
Sourcepub fn cross_session_stats(&self) -> Result<MemoryStats, String>
pub fn cross_session_stats(&self) -> Result<MemoryStats, String>
Summarize provenance quality and the agents or users that contributed facts.
pub fn stats(&self) -> Result<SharedContextStats, String>
pub fn load(&self) -> Result<Vec<SharedContextEntry>, String>
Trait Implementations§
Auto Trait Implementations§
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more