Skip to main content

freshness

Function freshness 

Source
pub fn freshness(
    recorded: Recorded<'_>,
    inputs: Option<&[String]>,
    test_source: &str,
    test_moved: bool,
    comparison: Option<&Comparison>,
    presented_tree: TreeState,
) -> Judgement
Expand description

The one truth table: what a recorded run proves at the presented revision.

Pure: every fact it needs is an argument. inputs is what the route names — a claim’s source, implementation and test source, a rule’s test source and definition — or None for a route that declares none. test_moved is whether the test’s source no longer hashes to the recorded digest. presented_tree is TreeState::Clean for the working tree, whose changes are already in comparison, and the measured tree for a commit.

Let changed' be the comparison’s paths without the ledger’s own. The first row that matches decides:

#conditionstate
1–3no test, unrunnable, nothing recordedno_test, unrunnable, not_run
4the run was a skipnot_run
5it failed, timed out or erroredfailing
6a pass git could not comparestale
7a pass the presented revision does not containstale
8a pass whose test moved, no declared input changedstale, naming the test
9a pass, a declared input changedstale, naming those inputs
10a pass, changed' empty, both trees cleanproven
11as 10, the recorded tree not cleaninputs_unchanged
12as 10, the presented tree not cleaninputs_unchanged
13a pass, changed' not empty, no declared input among itinputs_unchanged
14as 13, but the route declares no inputsstale
use majordomus_cli::evidence::freshness::{freshness, Comparison, Recorded, TreeState};
use majordomus_cli::evidence::{Execution, ProofState};
use majordomus_cli::git::Containment;

let e: Execution = serde_json::from_value(serde_json::json!({
    "test": "suite:07_scope", "runner": "suite", "source": "test/cases/07_scope.sh",
    "outcome": "pass", "seconds": 1, "commit": "a".repeat(40), "working_tree": "clean",
    "digest": "sha256:0", "at": "2026-09-26T00:00:00Z", "origin": "local",
    "command": "bash test/run.sh 07_scope"
}))
.unwrap();
let inputs = vec!["docs/SCOPE.md".to_string()];
let other_history = Comparison {
    containment: Containment::DoesNotContain,
    changed: Some(Default::default()),
};
let j = freshness(
    Recorded::Ran(&e),
    Some(&inputs),
    "test/cases/07_scope.sh",
    false,
    Some(&other_history),
    TreeState::Clean,
);
// a run on a commit the presented revision does not contain proves some other history
assert_eq!(j.state, ProofState::Stale);
assert!(j.detail.unwrap().contains("does not contain"));