pub struct SessionContext {Show 24 fields
pub session_file: String,
pub call_counter: u64,
pub seen_files: Vec<FileFingerprint>,
pub seen_errors: Vec<u64>,
pub error_snippets: Vec<(u64, String)>,
pub seen_git_refs: Vec<String>,
pub call_log: Vec<CallEntry>,
pub call_log_shingles: Vec<Vec<u64>>,
pub tokens_bash: u64,
pub tokens_read: u64,
pub tokens_grep: u64,
pub tokens_other: u64,
pub reread_count: u32,
pub exact_dedup_hits: u32,
pub fuzzy_dedup_hits: u32,
pub summarize_triggers: u32,
pub intensity_ultra_calls: u32,
pub agent_spawns: u32,
pub agent_estimated_tokens: u64,
pub agent_spawn_log: Vec<AgentSpawnEntry>,
pub burn_window: Vec<BurnEntry>,
pub max_call_log: usize,
pub recent_window: usize,
pub similarity_threshold: f32,
}Fields§
§session_file: String§call_counter: u64§seen_files: Vec<FileFingerprint>§seen_errors: Vec<u64>§error_snippets: Vec<(u64, String)>First-128-char snippets parallel to seen_errors (phase 2).
Each entry is (fingerprint, snippet_text) in insertion order.
seen_git_refs: Vec<String>§call_log: Vec<CallEntry>§call_log_shingles: Vec<Vec<u64>>Bottom-k MinHash sketch parallel to call_log. Each entry is the
sorted-deduplicated trigram-shingle hash set for that call’s output.
Used by lookup_similar for fuzzy redundancy matching that survives
whitespace/timestamp/single-line-edit perturbations.
May be shorter than call_log after loading older context.json files
that pre-date this field; callers must check length parity defensively.
tokens_bash: u64Cumulative token counts by tool category (Bash, Read, Grep, Other)
tokens_read: u64§tokens_grep: u64§tokens_other: u64§reread_count: u32How many times a file was accessed that was already in seen_files (re-read metric).
exact_dedup_hits: u32§fuzzy_dedup_hits: u32§summarize_triggers: u32§intensity_ultra_calls: u32§agent_spawns: u32§agent_estimated_tokens: u64§agent_spawn_log: Vec<AgentSpawnEntry>§burn_window: Vec<BurnEntry>§max_call_log: usize§recent_window: usize§similarity_threshold: f32Implementations§
Source§impl SessionContext
impl SessionContext
pub fn load(sessions_dir: &Path) -> Self
Sourcepub fn init_tunables_from_config(&mut self, cfg: &Config)
pub fn init_tunables_from_config(&mut self, cfg: &Config)
Copy tunable values from Config into this context so all methods use
the user’s configured values rather than the compiled-in defaults.
Called in context::pre_pass after loading or constructing the context.
pub fn save(&self, sessions_dir: &Path)
pub fn next_call_n(&mut self) -> u64
pub fn record_call( &mut self, cmd: &str, output_hash: u64, output_len: usize, call_n: u64, )
Sourcepub fn record_call_with_shingles(
&mut self,
cmd: &str,
output_hash: u64,
output_len: usize,
call_n: u64,
shingles: Vec<u64>,
)
pub fn record_call_with_shingles( &mut self, cmd: &str, output_hash: u64, output_len: usize, call_n: u64, shingles: Vec<u64>, )
Like record_call, but additionally stores a MinHash shingle sketch
of the output so that lookup_similar can find near-matches later.
Sourcepub fn lookup_recent(&self, hash: u64, len: usize) -> Option<&CallEntry>
pub fn lookup_recent(&self, hash: u64, len: usize) -> Option<&CallEntry>
Lookup a recent call with matching hash AND output_len. Only considers
the last self.recent_window entries.
Sourcepub fn lookup_similar(
&self,
query_shingles: &[u64],
query_len: usize,
) -> Option<SimilarMatch>
pub fn lookup_similar( &self, query_shingles: &[u64], query_len: usize, ) -> Option<SimilarMatch>
Lookup the highest-similarity recent call whose Jaccard distance to
query_shingles is at least self.similarity_threshold AND whose length
ratio with query_len is within LENGTH_RATIO_GUARD. Considers only
the last self.recent_window entries.
Returns None when:
- the query has no shingles (text too short for trigrams)
- no candidate clears the threshold
- shingles have not been recorded yet for the matching call (legacy load)
Sourcepub fn note_file(&mut self, path: &str, access: FileAccess)
pub fn note_file(&mut self, path: &str, access: FileAccess)
Record a file access with an explicit access type (phase 4).
Sourcepub fn note_files(&mut self, files: &[String])
pub fn note_files(&mut self, files: &[String])
Record multiple files as Read access (backward-compatible wrapper).
pub fn note_errors(&mut self, errors: &[String])
Sourcepub fn note_redundancy_hit_exact(&mut self)
pub fn note_redundancy_hit_exact(&mut self)
Record an exact-hash redundancy hit (called from wrap.rs after check()).
Sourcepub fn note_redundancy_hit_fuzzy(&mut self)
pub fn note_redundancy_hit_fuzzy(&mut self)
Record a fuzzy-similarity redundancy hit (called from wrap.rs after check()).
Sourcepub fn note_summarize_trigger(&mut self)
pub fn note_summarize_trigger(&mut self)
Record that the summarizer was triggered for this call.
Sourcepub fn note_intensity_ultra(&mut self)
pub fn note_intensity_ultra(&mut self)
Record that Ultra intensity was active for this call.
pub fn note_git(&mut self, refs: &[String])
Sourcepub fn note_agent_spawn(&mut self, tool_name: &str, estimated_tokens: u64)
pub fn note_agent_spawn(&mut self, tool_name: &str, estimated_tokens: u64)
Record a sub-agent spawn (Agent or Task tool call).
Sourcepub fn note_tool_tokens(&mut self, tool: &str, tokens: u64)
pub fn note_tool_tokens(&mut self, tool: &str, tokens: u64)
Record token usage by tool category.
pub fn file_was_seen(&self, path: &str) -> Option<u64>
Trait Implementations§
Source§impl Clone for SessionContext
impl Clone for SessionContext
Source§fn clone(&self) -> SessionContext
fn clone(&self) -> SessionContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more