Skip to main content

Job

Struct Job 

Source
pub struct Job {
    pub subject: ContentHash,
    pub label: String,
    pub command: Vec<String>,
    pub environment: BTreeMap<String, String>,
    pub directory: Option<PathBuf>,
    pub deadline: Duration,
    pub may_write_cache: bool,
}
Expand description

One unit of work, addressed by content so a shared cache can hit.

Fields§

§subject: ContentHash

Content address of the speculative tree state under test.

§label: String

What this job is testing, for reports and for an operator reading a failure. Typically the change id.

Deliberately outside Job::cache_key: two jobs testing byte-identical trees with the same command are the same work whichever change produced them, and that is precisely the case a shared cache exists to collapse. A label inside the key would make every job unique and the cache useless.

§command: Vec<String>

The command, as argv. Never a shell string: the same rule crate::differential already follows, for the same reason.

§environment: BTreeMap<String, String>

Exactly what the child process sees. Never inherited from this process, so a job’s result cannot depend on the environment of whoever happened to run the queue.

§directory: Option<PathBuf>

Where the command runs.

None leaves the choice to the provider, which is what a self-provisioning executor wants: a microVM materializes Job::subject itself and the host has no path to name. A provider that runs on this machine has nothing to materialize from, so a caller with a checkout on disk – the merge train, the forge bridge – names it here. Without this field the seam could only run commands that are correct from any directory, which is no build command at all.

§deadline: Duration

Wall-clock ceiling. Exceeding it is Verdict::TimedOut, which is a provider outcome and not a statement about the change.

§may_write_cache: bool

Whether this job’s artifacts may be written to a shared build cache.

False for untrusted and fork builds. This is the CREEP-class mitigation (“only trusted executors write the action cache”) expressed as a property of the job rather than as a deployment note, because a deployment note is not enforcement.

Implementations§

Source§

impl Job

Source

pub fn new(subject: ContentHash, command: Vec<String>) -> Self

A job with the documented defaults: a full deadline, an empty environment, and no permission to write the shared cache.

Cache-write permission is opt-in rather than opt-out on purpose. The failure mode of the safe default is a slow build; the failure mode of the other one is a poisoned artifact.

Source

pub fn cache_key(&self) -> ContentHash

Content address of the work, for a shared cache to key on.

Covers what determines the output — the tree, the command, the environment, the directory — and deliberately not deadline or may_write_cache, which govern how the job may run rather than what it computes. Two jobs that differ only in how long they are allowed to take are the same question.

Job::directory is in the key and Job::label is not, which is the same test applied twice: a label is not observable to the command, and the working directory is. Toolchains write absolute paths into what they build — rustc puts them in debug info — so two identical trees checked out at different paths can produce artifacts that differ. One key over both of them is the false sharing Job::may_write_cache exists to bound, arrived at from the honest direction instead of the malicious one.

Trait Implementations§

Source§

impl Clone for Job

Source§

fn clone(&self) -> Job

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 Job

Source§

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

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

impl PartialEq for Job

Source§

fn eq(&self, other: &Job) -> 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 Eq for Job

Source§

impl StructuralPartialEq for Job

Auto Trait Implementations§

§

impl Freeze for Job

§

impl RefUnwindSafe for Job

§

impl Send for Job

§

impl Sync for Job

§

impl Unpin for Job

§

impl UnsafeUnpin for Job

§

impl UnwindSafe for Job

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.