pub struct BrowsingMemory { /* private fields */ }Expand description
The user-facing browsing memory: open (unflushed) segments per owner plus the loaded trace corpus, with the design-pass reads over both.
Implementations§
Source§impl BrowsingMemory
impl BrowsingMemory
Sourcepub fn new(segment_size: usize) -> Self
pub fn new(segment_size: usize) -> Self
An empty memory with the given segment size (events per flushed trace).
Sourcepub async fn load(store: &mut dyn Store, segment_size: usize) -> Result<Self>
pub async fn load(store: &mut dyn Store, segment_size: usize) -> Result<Self>
Load every stored trace from the Store into a memory.
Sourcepub fn record_traversal(&mut self, owner: &str, event: TraceEvent) -> bool
pub fn record_traversal(&mut self, owner: &str, event: TraceEvent) -> bool
Append a traversal to owner’s open segment. Returns true when the
segment has reached the configured size and wants a
flush.
Sourcepub async fn flush(
&mut self,
store: &mut dyn Store,
now_ms: u64,
) -> Result<Vec<ManifestId>>
pub async fn flush( &mut self, store: &mut dyn Store, now_ms: u64, ) -> Result<Vec<ManifestId>>
Flush every non-empty open segment as a stored trace. Returns the new manifest ids.
Sourcepub fn adopt(&mut self, trace: BrowsingTrace)
pub fn adopt(&mut self, trace: BrowsingTrace)
Adopt an already-built trace into the in-memory corpus without persisting it (projection and import outputs that the caller saves — or not — on its own schedule).
Sourcepub fn recent_corridor(&self, n: usize) -> Vec<TraceEvent>
pub fn recent_corridor(&self, n: usize) -> Vec<TraceEvent>
The recent corridor: the last n traversals, returned in
chronological order — the path that led here.
Sourcepub fn nodes_visited_in_window(
&self,
start_ms: u64,
end_ms: u64,
) -> Vec<PageRef>
pub fn nodes_visited_in_window( &self, start_ms: u64, end_ms: u64, ) -> Vec<PageRef>
Pages visited in [start_ms, end_ms], chronological, deduplicated by
URL (first-seen title wins).
Sourcepub fn co_occurrence(&self, a: &str, b: &str) -> u32
pub fn co_occurrence(&self, a: &str, b: &str) -> u32
How often a and b were traversed together: the count of direct
traversals between them, in either direction. (Definition kept
deliberately narrow and edge-shaped so it cannot drift from
node-lineage’s aggregated edge view; broader togetherness measures
are a consumer’s fold.)
Sourcepub fn traces(&self) -> impl Iterator<Item = &BrowsingTrace>
pub fn traces(&self) -> impl Iterator<Item = &BrowsingTrace>
The loaded + adopted traces, oldest first.
Sourcepub async fn apply_quota(
&mut self,
store: &mut dyn Store,
keep_n: usize,
) -> Result<usize>
pub async fn apply_quota( &mut self, store: &mut dyn Store, keep_n: usize, ) -> Result<usize>
Keep the keep_n most recent stored traces and delete the
manifests of older ones (blob bytes await the explicit GC pass).
Adopted unsaved traces are untouched — there is nothing stored to
age out. Returns how many manifests were deleted.
Sourcepub async fn forget_url(
&mut self,
store: &mut dyn Store,
url: &str,
) -> Result<usize>
pub async fn forget_url( &mut self, store: &mut dyn Store, url: &str, ) -> Result<usize>
Forget every trace mentioning url (as either end of any event): delete its
stored manifest and drop it from the loaded corpus and any open segment.
Returns how many traces were forgotten. The eidetic-search index is rebuilt
from this corpus per query, so a forgotten trace also leaves the index — a
forget that left the index behind would not be a forget. (Capture plan C4.)