pub mod auto_dict;
pub mod counter;
pub mod dictionaries;
pub mod engine;
pub mod mcp_compress;
pub mod pipeline;
pub mod quality;
pub mod residual;
pub mod scoring;
const READ_FAMILY: &[&str] = &[
"ctx_read",
"ctx_multi_read",
"ctx_smart_read",
"ctx_compress",
"ctx_overview",
];
#[must_use]
pub fn is_verbatim_read(name: &str, mode: Option<&str>) -> bool {
if READ_FAMILY.contains(&name) {
return true;
}
mode.is_some_and(|m| m == "full" || m == "raw" || m.starts_with("lines:"))
}
#[derive(Debug, Clone)]
pub struct TerseResult {
pub output: String,
pub tokens_before: u32,
pub tokens_after: u32,
pub savings_pct: f32,
pub layers_applied: Vec<&'static str>,
pub pattern_savings: u32,
pub terse_savings: u32,
pub quality_passed: bool,
}
impl TerseResult {
pub fn passthrough(text: String, tokens: u32) -> Self {
Self {
output: text,
tokens_before: tokens,
tokens_after: tokens,
savings_pct: 0.0,
layers_applied: Vec::new(),
pattern_savings: 0,
terse_savings: 0,
quality_passed: true,
}
}
}
#[cfg(test)]
mod verbatim_read_tests {
use super::is_verbatim_read;
#[test]
fn read_family_is_always_verbatim() {
for name in [
"ctx_read",
"ctx_multi_read",
"ctx_smart_read",
"ctx_compress",
"ctx_overview",
] {
assert!(is_verbatim_read(name, Some("signatures")), "{name}");
assert!(is_verbatim_read(name, None), "{name}");
}
}
#[test]
fn verbatim_modes_protect_any_tool() {
for mode in ["full", "raw", "lines:1-40", "lines:10-10"] {
assert!(is_verbatim_read("ctx_future_reader", Some(mode)), "{mode}");
}
}
#[test]
fn non_read_lossy_modes_stay_eligible() {
for mode in ["map", "aggressive", "entropy", "signatures"] {
assert!(
!is_verbatim_read("ctx_search", Some(mode)),
"non-read {mode} must remain terse-eligible"
);
}
assert!(!is_verbatim_read("ctx_shell", None));
}
}