resolve_scheduler

Function resolve_scheduler 

Source
pub fn resolve_scheduler(
    spec: &SchedulerSpec,
) -> Result<(Option<PathBuf>, ResolveSource)>
Expand description

Resolve a scheduler binary from a SchedulerSpec.

Returns the resolved path (if any) paired with the ResolveSource naming the discovery branch that produced it. The source is load-bearing for downstream provenance: only ResolveSource::AutoBuilt guarantees the binary matches the current workspace tree; every other variant locates a pre-existing file whose git hash is UNKNOWN to this process.

Variant mapping:

  • Eevdf / KernelBuiltin { .. }(None, NotFound) (no user-space binary).
  • Path(p)(Some(p), Path) (explicit caller-named path; validated for existence).
  • Discover(name) → cascade through KTSTR_SCHEDULER env (EnvVar), $PATH lookup when KTSTR_CARGO_TEST_MODE is active (PathLookup), sibling of current_exe (SiblingDir), target/debug/ (TargetDebug), target/release/ (TargetRelease), on-demand build (AutoBuilt). In the orchestrated (non-cargo-test) flow the on-demand build runs FIRST and a build FAILURE REFUSES (returns the error) rather than serving a stale pre-built binary, unless KTSTR_SCHEDULER_ALLOW_STALE_FALLBACK is set. Exhausting every branch is a hard error. The PATH lookup is only enabled in cargo-test mode so the existing nextest / cargo ktstr test discovery cascade remains canonical (sibling-of-test-binary first) — pulling a system-wide scx_layered ahead of a workspace-built one would corrupt gauntlet runs whose results must reflect the in-tree scheduler revision.