Skip to main content

squeez/context/
mod.rs

1pub mod cache;
2pub mod hash;
3pub mod intensity;
4pub mod redundancy;
5pub mod summarize;
6
7pub use cache::SessionContext;
8pub use intensity::Intensity;
9
10use crate::config::Config;
11use std::path::Path;
12
13/// Pre-pass: load context, derive intensity from current usage, return a
14/// scaled clone of the user's config to use for this single call.
15pub fn pre_pass(
16    cfg: &Config,
17    sessions_dir: &Path,
18    used_tokens: u64,
19) -> (SessionContext, Intensity, Config) {
20    let mut ctx = if cfg.context_cache_enabled {
21        SessionContext::load(sessions_dir)
22    } else {
23        SessionContext::default()
24    };
25    // Phase 5: apply configurable tunables so all methods use user's values.
26    ctx.init_tunables_from_config(cfg);
27    let level = intensity::derive(used_tokens, cfg);
28    let scaled = intensity::scale(cfg, level);
29    (ctx, level, scaled)
30}