Skip to main content

lean_ctx/core/shadow/
mod.rs

1//! Counterfactual cost and quality reporting for completed tasks.
2
3pub mod baseline;
4pub mod comparison;
5pub mod persistence;
6pub mod recommendation;
7pub mod runtime;
8
9pub use comparison::ShadowReport;
10pub use recommendation::ShadowTask;
11
12use baseline::simulate_baseline;
13use comparison::compare;
14use recommendation::measure_treatment;
15
16/// Runs the LeanCTX treatment beside a deterministic baseline without context reduction. Each
17/// task is compared with its own host-chosen model; only context changes count as savings.
18#[derive(Debug, Default)]
19pub struct ShadowEngine;
20
21impl ShadowEngine {
22    pub fn run_comparison(tasks: &[ShadowTask]) -> ShadowReport {
23        let baselines: Vec<_> = tasks.iter().map(simulate_baseline).collect();
24        let treatments: Vec<_> = tasks.iter().map(measure_treatment).collect();
25        compare(&baselines, &treatments)
26    }
27}
28
29pub fn run_comparison(tasks: &[ShadowTask]) -> ShadowReport {
30    ShadowEngine::run_comparison(tasks)
31}
32
33#[cfg(test)]
34mod runtime_tests;
35#[cfg(test)]
36mod tests;