Skip to main content

load_context_runs

Function load_context_runs 

Source
pub fn load_context_runs(
    root: &Path,
    suite: &str,
) -> (Vec<EconomicsContextRun>, Vec<String>)
Expand description

Every context measurement recorded under root for suite, oldest first.

The order is by measured_at, then commit, never by file name, so the last entry is the measurement the summary reports. A record under another schema is named in the second list rather than read as if it were this one.

use majordomus_cli::economics::{load_context_runs, CONTEXT_RUN_SCHEMA, DIR};
let dir = tempfile::tempdir().unwrap();
let recorded = dir.path().join(DIR).join("runs/context");
std::fs::create_dir_all(&recorded).unwrap();
std::fs::write(recorded.join("a.json"), record(CONTEXT_RUN_SCHEMA, "2026-09-24")).unwrap();
std::fs::write(recorded.join("b.json"), record(CONTEXT_RUN_SCHEMA, "2026-09-23")).unwrap();
std::fs::write(recorded.join("c.json"), record("economics-context-run/v0", "2026-09-22"))
    .unwrap();
let (runs, errors) = load_context_runs(dir.path(), "context");
let at: Vec<&str> = runs.iter().map(|r| r.measured_at.as_str()).collect();
assert_eq!(at, ["2026-09-23", "2026-09-24"], "oldest first, whatever the file names");
assert_eq!(errors.len(), 1, "the record of another schema is named, not read");