pub struct TaskLookup<'ws> {
pub project: &'ws Project,
pub task_def: &'ws Task,
pub key: CacheKey,
pub manifest: Option<Manifest>,
}Expand description
Run one task per its workspace declaration, cache-aware.
Lifecycle:
RunObserver::on_task_startedfires.crate::cache_key::build_cache_keyderives the key fromtask‘s declared inputs, env contribution, and hard-edge predecessors’ captured stream hashes.haz_cache::Cache::lookupis consulted:- On a hit,
haz_cache::Cache::restorematerialises the manifest’s outputs at their workspace-absolute paths;stdoutandstderrflow through the observer; the function returnsRunSource::CacheHitwith the manifest’s recorded stream hashes. - On a miss, the function builds a
crate::process::SpawnPlanfrom the task’shaz_domain::action::TaskActionand the effective env (CACHE-008runtime view: allow-listed host values plus task overrides, override wins), spawns throughspawner, captures both streams to memory, awaits exit, emits the streams through the observer, classifies perEXEC-009. On success the outputs are enumerated andhaz_cache::Cache::storepersists the entry. On failure no store fires.
- On a hit,
RunObserver::on_task_finishedfires with the terminalCompletedRecord.
The function is async because spawning, waiting, and stream
capture all use the tokio runtime. Filesystem and cache calls
are sync and run on the calling worker thread; callers that want
to off-load the cache-key derivation (which hashes input file
bytes) and the store phase (which hashes output file bytes) from
an async context can wrap the function in
tokio::task::spawn_blocking – both phases dominate the
runtime cost of a single-task lifecycle.
created_at_unix is caller-supplied so the function stays a
pure function of its arguments: tests pin the value, the
scheduler passes the current wall-clock time.
§Errors
Returns a RunTaskError for any executor-level failure
(cache-key derivation, restore, spawn, wait, stream read,
output resolution, store). Task-level failures (non-zero exit
or signalled exit) are reported as
Ok(CompletedRecord { state: Failed, .. }) per EXEC-009;
the cache is not consulted for store in that branch
(CACHE-018).
Carrier for the borrows + computed values
cache_lookup_phase hands back to the caller (typically the
scheduler in crate::run_graph::run_graph).
The struct lets EXEC-007 step 1 (cache lookup) be performed
independently of EXEC-007 step 2 (restore) and step 3 (spawn);
the scheduler interposes its mutex-compatibility check between
the lookup and the spawn branch.
Lifetime 'ws ties the project and task_def borrows to the
workspace borrow held inside the supplying RunContext.
Fields§
§project: &'ws ProjectBearing project of task (looked up once so neither
downstream branch has to repeat the search).
task_def: &'ws TaskBearing task definition (action, mutex, env, etc.).
key: CacheKeyComputed cache key.
manifest: Option<Manifest>Manifest of the matching cache entry, if any. Some(_)
drives the restore branch; None drives the spawn branch.