Skip to main content

Execution

Struct Execution 

Source
pub struct Execution {
    pub test: String,
    pub runner: Runner,
    pub source: String,
    pub outcome: Outcome,
    pub seconds: u64,
    pub commit: String,
    pub working_tree: String,
    pub digest: String,
    pub at: String,
    pub origin: Origin,
    pub command: String,
    pub run: Option<RunRef>,
}
Expand description

One recorded run of one test: the whole of what this repository durably remembers about it.

Every field is provenance. A result with no commit is an anonymous green, which is the thing a badge must never be derived from.

use majordomus_cli::evidence::{digest_of, Execution, Origin, Outcome, Runner, TestId};

let id = TestId::of("apps/majordomus-cli/tests/why.rs").unwrap();
let run = Execution {
    test: id.as_string(),
    runner: Runner::Crate,
    source: id.source(),
    outcome: Outcome::Pass,
    seconds: 12,
    commit: "0".repeat(40),
    working_tree: "clean".into(),
    digest: digest_of(b"fn main() {}"),
    at: "2026-09-11T00:00:00Z".into(),
    origin: Origin::Ci,
    command: id.reproduce(),
    run: None,
};

// it is a value in a tracked JSON file, so it has to survive the file unchanged
let back: Execution = serde_json::from_str(&serde_json::to_string(&run).unwrap()).unwrap();
assert_eq!(back, run);
assert_eq!(back.test, "crate:why");
assert_eq!(back.command, "cargo test --test why");

§Example

One recorded run, with the provenance the runner did not carry: which commit, which tree state, the digest of the test’s own source, when, and how to run it again.

use majordomus_cli::evidence::{Execution, Origin, Outcome, Runner};
let e = Execution {
    test: "suite:07_scope".into(),
    runner: Runner::Suite,
    source: "test/cases/07_scope.sh".into(),
    outcome: Outcome::Pass,
    seconds: 3,
    commit: "a04b65c9".into(),
    working_tree: "clean".into(),
    digest: "sha256:00".into(),
    at: "2026-09-11T00:00:00Z".into(),
    origin: Origin::Local,
    command: "bash test/run.sh 07_scope".into(),
    run: None,
};
assert!(e.outcome.proves());

Fields§

§test: String

The test, in TestId::as_string form.

§runner: Runner

Which runner produced it.

§source: String

The test’s own source, repository-relative.

§outcome: Outcome

What it said.

§seconds: u64

How long it took, in whole seconds.

§commit: String

The full commit id the run was made against.

§working_tree: String

clean, dirty or unknown: whether the tree the run measured was the commit.

§digest: String

sha256:<hex> of the test’s own source as it was when the run was recorded. An execution whose test no longer hashes to this did not run the test that is there now.

§at: String

When it was recorded, RFC 3339, UTC.

§origin: Origin

Where the run happened.

§command: String

The exact command that runs this one test again.

§run: Option<RunRef>

The continuous-integration run the execution was recorded in, when it was recorded in one that could name itself. Absent for a local run, and absent from every row recorded before runs were named, which is why the ledger’s version did not change.

Implementations§

Source§

impl Execution

Source

pub fn digest_matches(&self, root: &Path) -> Option<bool>

Does the test’s source still hash to what was recorded?

None when the source is not there to hash — which is itself a finding, reported by the path checks, not silently read as a match.

This is the staleness check that survives a revert: an edit made and undone around a run leaves no diff against any commit, and the recorded digest still says the test that ran is not the test that is there.

use majordomus_cli::evidence::{digest_of, Execution, Origin, Outcome, Runner, TestId};

let repo = tempfile::tempdir().unwrap();
let id = TestId::of("test/cases/07_scope.sh").unwrap();
std::fs::create_dir_all(repo.path().join("test/cases")).unwrap();
std::fs::write(repo.path().join(id.source()), "echo ok\n").unwrap();

let run = Execution {
    test: id.as_string(),
    runner: Runner::Suite,
    source: id.source(),
    outcome: Outcome::Pass,
    seconds: 1,
    commit: "0".repeat(40),
    working_tree: "clean".into(),
    digest: digest_of(b"echo ok\n"),
    at: "2026-09-11T00:00:00Z".into(),
    origin: Origin::Local,
    command: id.reproduce(),
    run: None,
};
assert_eq!(run.digest_matches(repo.path()), Some(true));

std::fs::write(repo.path().join(id.source()), "echo something else\n").unwrap();
assert_eq!(run.digest_matches(repo.path()), Some(false));

// and a source that is gone cannot be compared, which is not the same as agreeing
std::fs::remove_file(repo.path().join(id.source())).unwrap();
assert_eq!(run.digest_matches(repo.path()), None);

Trait Implementations§

Source§

impl Clone for Execution

Source§

fn clone(&self) -> Execution

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Execution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Execution

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Execution

Source§

impl JsonSchema for Execution

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Ordered for Execution

A ledger holds one execution per test, so the test identifies it; the label and the identity are the same string because there is nothing else to read it by.

Source§

fn order_key(&self) -> OrderKey<'_>

The four parts this item is ordered by. Borrowed from the item: building a key allocates nothing, so sorting a large collection costs the comparisons and no more.
Source§

impl PartialEq for Execution

Source§

fn eq(&self, other: &Execution) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Execution

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Execution

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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