Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

fix(rust): clippy 1.95 unnecessary_sort_by + pin toolchain

chopratejas62301a2d687c
diff --git a/crates/headroom-core/src/transforms/smart_crusher/analyzer.rs b/crates/headroom-core/src/transforms/smart_crusher/analyzer.rs
index acbdf642e..897b03aed 100644
--- a/crates/headroom-core/src/transforms/smart_crusher/analyzer.rs
+++ b/crates/headroom-core/src/transforms/smart_crusher/analyzer.rs
@@ -776,7 +776,7 @@ fn top_n_by_count(strs: &[&str], n: usize) -> Vec<(String, usize)> {
// Stable sort by count desc preserves first-occurrence tie order.
let mut pairs: Vec<(&&str, usize)> = order.iter().map(|k| (k, counts[k])).collect();
- pairs.sort_by(|a, b| b.1.cmp(&a.1));
+ pairs.sort_by_key(|b| std::cmp::Reverse(b.1));
pairs
.into_iter()
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 85f36062a..1890e60a1 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,4 +1,16 @@
[toolchain]
-channel = "stable"
+# Pin to a specific stable version so CI and local use the EXACT same
+# compiler. With `channel = "stable"`, CI runners (dtolnay/rust-
+# toolchain@stable) always grab the latest stable while local dev
+# machines run whatever version was last installed — a clippy lint
+# added in a newer stable then breaks CI without firing locally
+# (this happened on 2026-04-27: `unnecessary_sort_by` landed in
+# clippy 1.95 while a dev box had 1.92). Pinning makes "passes
+# locally" = "passes in CI" for every check that depends on the
+# toolchain.
+#
+# Bump procedure: edit the channel string here, run `rustup update`,
+# run `make ci-precheck`, fix any new lints, commit.
+channel = "1.95.0"
components = ["rustfmt", "clippy"]
profile = "minimal"