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: ContentHashContent address of the speculative tree state under test.
label: StringWhat 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: DurationWall-clock ceiling. Exceeding it is Verdict::TimedOut, which
is a provider outcome and not a statement about the change.
may_write_cache: boolWhether 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
impl Job
Sourcepub fn new(subject: ContentHash, command: Vec<String>) -> Self
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.
Sourcepub fn cache_key(&self) -> ContentHash
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.