pub fn freshness(
recorded: Recorded<'_>,
inputs: Option<&[String]>,
test_source: &str,
test_moved: bool,
comparison: Option<&Comparison>,
presented_tree: TreeState,
) -> JudgementExpand 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:
| # | condition | state |
|---|---|---|
| 1–3 | no test, unrunnable, nothing recorded | no_test, unrunnable, not_run |
| 4 | the run was a skip | not_run |
| 5 | it failed, timed out or errored | failing |
| 6 | a pass git could not compare | stale |
| 7 | a pass the presented revision does not contain | stale |
| 8 | a pass whose test moved, no declared input changed | stale, naming the test |
| 9 | a pass, a declared input changed | stale, naming those inputs |
| 10 | a pass, changed' empty, both trees clean | proven |
| 11 | as 10, the recorded tree not clean | inputs_unchanged |
| 12 | as 10, the presented tree not clean | inputs_unchanged |
| 13 | a pass, changed' not empty, no declared input among it | inputs_unchanged |
| 14 | as 13, but the route declares no inputs | stale |
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"));