Skip to main content

Judge

Struct Judge 

Source
pub struct Judge<'a> { /* private fields */ }
Expand description

Judges many subjects at one presented revision with one set of comparisons.

Precondition: claims is crate::evidence::report_at(index, ledger, presented, uncommitted) and rules is crate::rules::report(index, ledger), for the same index, the same ledger and the same uncommitted. At a presented commit the ledger is crate::evidence::freshness::ledger_at of it and uncommitted is crate::evidence::freshness::uncommitted; for the working tree it is empty.

The rules report judges at the working tree, so when the presented tree is not clean a rule-derived proven is re-judged at the presented revision and reads inputs unchanged, as every other route does. At a presented commit, every route the judge computes passes through the monotone rule over the working ledger’s uncommitted run of its test, as the claim report applies it, so a subject never reads greener than evidence show --presented.

use majordomus_cli::evidence::subject::{self, Judge};
use majordomus_cli::evidence::{report_at, Ledger, Presented};
use majordomus_cli::synthetic::SyntheticRepository;

let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
let ledger = Ledger::empty();
let claims = report_at(&ctx.index, &ledger, &Presented::WorkingTree, &[]);
let rules = majordomus_cli::rules::report(&ctx.index, &ledger);
let presented = Presented::WorkingTree;
let mut judge = Judge::new(&s, &claims, &rules, &ledger, &[], repo.root(), &presented);
let key = s.subjects.keys().find(|k| k.starts_with("capability:")).unwrap().clone();
let answer = judge.subject(&key).unwrap();
assert_eq!(answer.presented.revision, "working_tree");
assert!(judge.subject("gate:x").is_err());

Implementations§

Source§

impl<'a> Judge<'a>

Source

pub fn new( subjects: &'a SubjectIndex, claims: &'a EvidenceReport, rules: &'a RulesReport, ledger: &'a Ledger, uncommitted: &'a [Execution], root: &'a Path, presented: &'a Presented, ) -> Self

A judge over one subject index and the two reports made for the same ledger.

use majordomus_cli::evidence::subject::{self, Judge};
use majordomus_cli::evidence::{report_at, Ledger, Presented};
use majordomus_cli::synthetic::SyntheticRepository;

let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
let ledger = Ledger::empty();
let claims = report_at(&ctx.index, &ledger, &Presented::WorkingTree, &[]);
let rules = majordomus_cli::rules::report(&ctx.index, &ledger);
let p = Presented::WorkingTree;
let _judge = Judge::new(&s, &claims, &rules, &ledger, &[], repo.root(), &p);
Source

pub fn with_adjust(self, adjust: &'a Adjust<'a>) -> Self

Pass every route judgement that has a test identity through adjust before any aggregation. The route keeps the weaker of the two states, so an adjuster can weaken a route and never strengthen it. Without it, the judge is the identity adjuster.

use majordomus_cli::evidence::subject::{self, Adjust, Judge};
use majordomus_cli::evidence::{report_at, Ledger, Presented};
use majordomus_cli::synthetic::SyntheticRepository;

let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
let ledger = Ledger::empty();
let claims = report_at(&ctx.index, &ledger, &Presented::WorkingTree, &[]);
let rules = majordomus_cli::rules::report(&ctx.index, &ledger);
let p = Presented::WorkingTree;
let identity: &Adjust<'_> = &|_, _, j| j;
let key = s.subjects.keys().next().unwrap().clone();
let plain = Judge::new(&s, &claims, &rules, &ledger, &[], repo.root(), &p).subject(&key);
let adjusted = Judge::new(&s, &claims, &rules, &ledger, &[], repo.root(), &p)
    .with_adjust(identity)
    .subject(&key);
assert_eq!(plain.unwrap(), adjusted.unwrap());
Source§

impl<'a> Judge<'a>

Source

pub fn subject(&mut self, key: &str) -> Result<SubjectEvidence, UnknownSubject>

Everything the repository can say about the subject key at the presented revision.

use majordomus_cli::evidence::subject::{self, Judge};
use majordomus_cli::evidence::{report_at, Ledger, Presented};
use majordomus_cli::synthetic::SyntheticRepository;

let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
let ledger = Ledger::empty();
let claims = report_at(&ctx.index, &ledger, &Presented::WorkingTree, &[]);
let rules = majordomus_cli::rules::report(&ctx.index, &ledger);
let p = Presented::WorkingTree;
let mut judge = Judge::new(&s, &claims, &rules, &ledger, &[], repo.root(), &p);
let err = judge.subject("feature:no-such").unwrap_err();
assert!(err.to_string().contains("feature:no-such"));

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Judge<'a>

§

impl<'a> !Send for Judge<'a>

§

impl<'a> !Sync for Judge<'a>

§

impl<'a> !UnwindSafe for Judge<'a>

§

impl<'a> Freeze for Judge<'a>

§

impl<'a> Unpin for Judge<'a>

§

impl<'a> UnsafeUnpin for Judge<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more