resolve_scheduler

Function resolve_scheduler 

Source
pub fn resolve_scheduler(
    spec: &SchedulerSpec,
    manifest_dir: &str,
) -> 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 branch that produced it. The source is load-bearing for downstream provenance: only ResolveSource::AutoBuilt guarantees the binary matches the declaring crate’s workspace tree; every other variant locates a pre-existing file whose git hash is UNKNOWN to this process.

manifest_dir is the declaring crate’s CARGO_MANIFEST_DIR (from Scheduler::manifest_dir), forwarded to crate::build_and_find_binary so the on-demand Discover build runs in the scheduler’s OWN workspace.

Variant mapping:

  • Eevdf / KernelBuiltin { .. } → (None, NotFound) (no user-space binary).

  • Path(p) → (Some(p), Path) (explicit caller-named path; validated for existence).

  • Discover(name) → four steps:

    1. exact parent manifest lookup (Manifest). Presence is authoritative: invalid or missing data is a hard error and cannot fall through.
    2. KTSTR_SCHEDULER env override (EnvVar) — a global, name-agnostic binary path applying to every Discover scheduler.
    3. cargo-test mode only: $PATH lookup (PathLookup), so an installed scheduler resolves without a workspace build.
    4. cargo build -p <name> in the declaring crate’s workspace (AutoBuilt), in BOTH modes.

    Cargo owns freshness: it rebuilds when the scheduler’s sources (incl. src/bpf/*.bpf.c via its build.rs) change, is a no-op when they are up to date, and fails when the scheduler cannot build. A failed build is a hard error, full stop — a scheduler that will not build is a failed test, never a silently-stale pre-built binary. The error carries the SchedulerBuildRefused marker so dispatch forces a hard FAIL even under expect_err: a host-side build fault must not invert to PASS. The $PATH lookup is gated to cargo-test mode so gauntlet runs always land on the workspace-built scheduler revision rather than a system-wide install.