Skip to main content

EvidenceLookup

Trait EvidenceLookup 

Source
pub trait EvidenceLookup {
    // Required methods
    fn test(&self, id: &TestId, scope: &[String]) -> TestStanding;
    fn claim(&self, id: &str) -> Option<ClaimStanding>;
    fn deployment(&self, id: &str) -> bool;
    fn object(&self, kind: &str, identity: &str) -> bool;
    fn file(&self, path: &str) -> bool;
}
Expand description

The facts the derivation reads beyond the plan. The repository answers them from the ledger, the claim matrix and the tree; a test answers them from a table.

use majordomus_cli::evidence::TestId;
use majordomus_cli::intent::{ClaimStanding, EvidenceLookup, IntentEvidenceState, TestStanding};
struct NothingRecorded;
impl EvidenceLookup for NothingRecorded {
    fn test(&self, _: &TestId, _: &[String]) -> TestStanding {
        TestStanding { present: true, state: IntentEvidenceState::NotRun, proof: None }
    }
    fn claim(&self, _: &str) -> Option<ClaimStanding> { None }
    fn deployment(&self, _: &str) -> bool { false }
    fn object(&self, _: &str, _: &str) -> bool { false }
    fn file(&self, _: &str) -> bool { false }
}
let id = TestId::of("test/cases/00_x.sh").unwrap();
assert_eq!(NothingRecorded.test(&id, &[]).state, IntentEvidenceState::NotRun);

Required Methods§

Source

fn test(&self, id: &TestId, scope: &[String]) -> TestStanding

What the ledger holds for one test, by its identity: whether its source is in the tree and what its latest run came to. scope is the code the plan declares for the criterion — the scope of every issue that serves it — which the judgement counts among the test’s inputs beside what the claims that test proves name.

use majordomus_cli::evidence::TestId;
use majordomus_cli::intent::{EvidenceLookup, TestStanding};
let id = TestId::of("test/cases/00_x.sh").unwrap();
let standing: TestStanding = ev.test(&id, &["lib/a".to_string()]);
assert!(standing.present || !standing.present);
Source

fn claim(&self, id: &str) -> Option<ClaimStanding>

What a claim’s evidence says, judged as IntentEvidenceState::judged judges it, with the claim report’s verdict behind it; None when no such claim is declared — which is a refusal, not an unproven claim.

use majordomus_cli::intent::EvidenceLookup;
assert!(ev.claim("no-such-claim-exists").is_none());
Source

fn deployment(&self, id: &str) -> bool

Whether a deployment object with this id exists. A deployment criterion resolves through this and is still never counted as met.

use majordomus_cli::intent::EvidenceLookup;
assert!(!ev.deployment("no-such-deployment"));
Source

fn object(&self, kind: &str, identity: &str) -> bool

Whether an object of kind answers to identity (rule matches with or without its @version). This is what makes a governance: entry resolve or fail.

use majordomus_cli::intent::EvidenceLookup;
assert!(!ev.object("rule", "project.no-such-rule"));
Source

fn file(&self, path: &str) -> bool

Whether a repository-relative file exists, for a file: governance entry and for the test sources a criterion names.

use majordomus_cli::intent::EvidenceLookup;
assert!(!ev.file("no/such/file.md"));

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§