Skip to main content

weaken_by_records

Function weaken_by_records 

Source
pub fn weaken_by_records(
    judgement: Judgement,
    execution: Option<&Execution>,
    records: &[EvidenceRunRecord],
    presented_commit: Option<&str>,
    contains: impl Fn(&str, &str) -> Containment,
) -> Judgement
Expand description

A judgement, weakened by the run records that ran the same test: the second source of the one monotone rule, crate::evidence::freshness::weakened_by.

It holds no predicate of its own. Each execution of a record that ran execution’s test becomes one Supplementary, placed by contains(descendant, ancestor): after the evidence when the record’s commit contains the evidence commit, and in the presented history when the presented commit contains the record’s. The most recent record comes first. The result is the input state or stale, never anything stronger.

use majordomus_cli::evidence::{weaken_by_records, EvidenceRunRecord, Execution, Judgement, ProofState};
use majordomus_cli::git::Containment;
let exec = |outcome: &str, commit: &str| -> Execution { serde_json::from_value(serde_json::json!({
    "test": "suite:01_a", "runner": "suite", "source": "test/cases/01_a.sh",
    "outcome": outcome, "seconds": 1, "commit": commit, "working_tree": "clean",
    "digest": "sha256:0", "at": "2026-09-26T12:00:00Z", "origin": "ci",
    "command": "bash test/run.sh 01_a"
})).unwrap() };
let (e, r) = ("e".repeat(40), "f".repeat(40));
let evidence = exec("pass", &e);
let record: EvidenceRunRecord = serde_json::from_value(serde_json::json!({
    "schema": 1, "id": "ci:x", "origin": "ci", "commit": r, "working_tree": "clean",
    "recorded_at": "2026-09-26T12:00:00Z", "ledger": "repo",
    "executions": [exec("fail", &r)]
})).unwrap();
let proven = Judgement { state: ProofState::Proven, changed: vec![], detail: None };
let j = weaken_by_records(proven, Some(&evidence), &[record], Some(&r), |_, _| Containment::Contains);
assert_eq!(j.state, ProofState::Stale);