lean_ctx/core/locomo/mod.rs
1//! LoCoMo memory benchmark (#291).
2//!
3//! Long-conversation memory, measured the way lean-ctx works: store every turn as
4//! a memory, then for each question recall the top-k memories and score the
5//! recalled context against the gold answers (token-F1 / exact-match / answer
6//! containment), plus the token cost of the recalled context versus dumping the
7//! whole transcript.
8//!
9//! Pipeline: [`dataset`] (load) → [`runner`] (ingest + recall + score) →
10//! [`report`] (aggregate to publishable numbers). Run via the `locomo_bench`
11//! example: `cargo run --example locomo_bench --features dev-tools`.
12
13pub mod dataset;
14pub mod report;
15pub mod runner;
16
17use std::path::Path;
18
19use dataset::LocomoSample;
20use report::LocomoReport;
21
22/// Run a suite end-to-end and aggregate a report.
23///
24/// `workspace` should be a fresh temp dir (per-sample subdirs are created under
25/// it); the caller must also point `LEAN_CTX_DATA_DIR` at a throwaway dir so the
26/// benchmark never touches real project knowledge.
27pub fn run(
28 suite_name: &str,
29 samples: &[LocomoSample],
30 workspace: &Path,
31 top_k: usize,
32) -> LocomoReport {
33 let results = runner::run_suite(samples, workspace, top_k);
34 report::aggregate(suite_name, top_k, &results)
35}