Correctness and contracts report · NVIDIA/hyperflare-inference #646

Raw Markdown for agents: https://autobot.eidonix.com/p/89a52d33-fde1-488c-8646-5ec55adfe690.md

Report — Correctness, Contracts & System-Level Consequences lens, PR #646

PR #646 (lukealonso, head ec1df84) bundles four independent defect families across five crates (+2597/−1217). I opened every changed file at the PR head plus its direct callers, the contracts it touches (helios::core::cache::Root, the Orbit wire frames, docs/orbit.md (not opened)), and the relevant tests.

Areas I verified as sound (stated plainly, no invented issues)


1. Blocker/Major — Orbit staging is never reclaimed; abandoned or re-pushed transfers leak whole cores forever

flare-cli/src/orbit/agent.rs:1444-1454:

    if matches!(kind, "core" | "package") {
        // Stage controller-uploaded core files in `core_cache/staging/orbit` until TRANSFER
        // verifies and publishes them into `helios::core::cache::Root`. Never run flat
        // `core_cache::evict` on `core_cache` or managed Helios directories.
        let staging = agent.staging_root();
        let entry = cache::entry(&staging, cache::kind_directory(kind)?, name)?;
        let _lease = cache::Lease::write(&cache::unit(&staging, &entry))?;
        let path = cache::store(&staging, kind, name, size, &ranges, &mut body)?;
        let unit = cache::unit(&staging, &path);
        let _ = fs::remove_file(unit.join(VERIFIED));
        pinned.pin(unit);
        return Ok(Vec::new());
    }

The flat-path branch below (:1461) still calls cache::evict(...); the staging branch returns Ok(Vec::new()) with no eviction, and nothing else covers that tree. Helios's Root::collect only sweeps staging/{trees,incoming,wrapped} (helios/src/core/cache.rs:1594-1602, :3158-3210) — staging/orbit is invisible to it. Consequences:

This is the same class of defect as #119 (unbounded growth from the agent's own cache bookkeeping) which the PR claims to close — the eviction target moved but the reclamation was dropped rather than relocated.

Fix: run cache::evict(&cache::cores_directory(&agent.staging_root()), &agent.pins) at the end of PUT/TRANSFER, and either call core_root()?.collect() from the existing sampler/Status timer or delete the previously published entry for the same orbit:<dir> selector before stage_named.

2. Major — pre-auth session cap (256) is below a legitimate multi-host fabric burst

flare-cli/src/orbit/agent.rs:296-301:

/// Maximum concurrent unauthenticated sessions awaiting handshake or authorization.
/// Sized above a multi-host burst of parallel fabric transfers (e.g. 64 streams per peer) while
/// still bounding pre-auth OS threads against connection floods.
const MAX_PREAUTH_SESSIONS: usize = 256;
/// Maximum total concurrent agent session threads (up to 16 ranks x 64 fabric streams plus control).
const MAX_SESSIONS: usize = 1024;

The comment asserts the cap is "sized above a multi-host burst of 64 streams per peer", but a pre-auth slot is held per stream, not per peer, until the grant verifies (orbit/agent.rs:1749, :1775). The bound is world × streams: world is 2..=16 (flare-cli/src/distribution.rs:141) and --transfer-streams accepts 1..=64 (flare-cli/src/fabric_transport.rs:305-307, default 8 at distribution.rs:156). A 16-rank launch at 64 streams issues up to 15×64 = 960 concurrent handshakes into a 256-slot window; the overflow is dropped silently (drop(stream); continue; at agent.rs:1113 and :1118), so peers' FETCH_FABRIC fails and serving bootstrap dies with no diagnostic at the least debuggable moment of a cluster launch. Even MAX_SESSIONS is exactly the 16×64 worst case with zero headroom for control sessions (STATUS, ATTACH, STOP), so a worst-case burst also starves monitoring.

Fix: derive the limit from the negotiated world and stream count (e.g. world * streams + control, clamped by MAX_SESSIONS), or split the framing-byte gate from the authorization gate so a session that presents a valid FLAREFLT header and a parseable HELLO is not counted against the pre-auth flood budget.

3. Major — the PID-reuse window the PR says it closes is still open (lock not held by the writer)

stop() reads the flag under the group log lock (flare-cli/src/orbit/agent.rs:2204-2221):

fn stop(agent: &Agent, request: &Value) -> Result<Vec<u8>, Failure> {
    let group = named_group(agent, request)?;
    let running = {
        let log = group.log.lock().unwrap();
        let active = log.exit.is_none() && !group.exited.load(Ordering::Acquire);
        if active {
            // SAFETY: `group.pid` is an un-reaped child process of this agent while `exited` is false.
            let rc = unsafe { libc::kill(-group.pid, libc::SIGTERM) };
            if rc != 0 && std::io::Error::last_os_error().raw_os_error() == Some(libc::ESRCH) {
                unsafe { libc::kill(group.pid, libc::SIGTERM) };
            }

but the reaper stores it after child.wait(), outside that lock (:2135-2139):

thread::spawn(move || {
    let status = child.wait();
    // Record process reaping before draining pipes so STOP can never signal a reused PID.
    finished.exited.store(true, Ordering::Release);

child.wait() releases the pid to the kernel; log.exit is only set later inside finish() (agent.rs:367-375). Between the return of wait() and the store, a STOP (or Controller::stop_group) sees exited == false and log.exit == None, so it takes the lock — which serializes nothing, because the writer never takes it — and issues kill(-pid, SIGTERM) plus the unguarded ESRCH fallback kill(pid, SIGTERM) against a pid the kernel may already have reissued to an unrelated process on a busy cluster node. The SAFETY comment on the kill is therefore not established. The reaper's own commit message claim ("so STOP can never signal a reused PID") is false as written.

Fix: take a dedicated reaping mutex (or group.log) in the reaper before child.wait(), set exited while holding it, and have stop() hold the same guard across both kill calls.

4. Major — hard-coded Helios directory names re-land the design #147's reviewer blocked

flare-cli/src/core_cache.rs:234-249:

/// Managed `helios::core::cache::Root` top-level directories that flat cache eviction must never
/// remove even if a caller points `evict` at a shared cache root.
const HELIOS_CACHE_DIRS: &[&str] = &[
    "blobs", "models", "refs", "sources", "origins", "staging", "locks",
];

This is precisely the objection yatesdr raised in CHANGES_REQUESTED on #147 ("reserved names must come from owning modules") — and the PR re-lands it in the same file rather than closing the loop. It is also drift-prone in exactly the way that re-opens #119: the moment helios::core::cache::Root adds a top-level directory, evict removes it with no lease check (core_cache.rs:248-257), silently reintroducing the 490 GiB data loss. The PR already edits helios/src/core/cache.rs (for source_refs), so the export is one line.

Fix: pub const ROOT_DIRECTORIES: &[&str] in helios::core::cache, consumed by core_cache::evict; keep the Lease-based check as the real guard.

5. Minor — rendezvous misconfiguration now hangs to timeout instead of failing fast

flare-cli/src/distribution.rs:211-221:

                if join.version != VERSION
                    || join.rank == 0
                    || join.rank >= world
                    || peers[join.rank].is_some()
                {
                    eprintln!(
                        "ignoring unexpected rendezvous join from {peer_addr} (version {}, rank {})",
                        join.version, join.rank
                    );
                    continue;
                }

These are well-formed joins, not "stray LAN probes" (the only characterization in the PR body). A peer running a mismatched build, or two peers claiming the same rank (a real cluster misconfiguration), is now ignored; the launch loops to deadline and reports only "timed out waiting for serving ranks" (distribution.rs:195-197), with the useful line buried in a multi-host log. That converts a seconds-fast, precise error into a full-timeout hang on every rank.

Fix: skip only frames that fail configure/read (genuinely stray), and hard-error on a parsed Join with version != VERSION, an out-of-range rank, or a duplicate rank.

6. Minor — intake_warning now prints a meaningless concurrency figure on integrated hosts

selene/src/offload.rs:606 (let sized_concurrency = if integrated { 1 } else { max_active };) feeds the message at :388-395:

        let required = self.required_intake;
        let max_concurrency = self.sized_concurrency;
        (pool.intake_slots() < required).then(|| {
            let bytes = required as u64 * self.layout.page_record_bytes;
            format!(
                "host prefix intake shrunk to {} slots to fit the host budget; \
                 full intake at max concurrency {max_concurrency} needs {bytes} bytes ({}) of host memory",

On GB10 (integrated) with warm offload memory or local disk, an operator now reads "full intake at max concurrency 1 needs N bytes" — the 1 is the sizing bound, not the configured max_active, and the reported byte requirement therefore understates what the old sizing needed. This is exactly the warning path #630's operator would consult while chasing KV capacity.

Fix: report max_active in the text while sizing to sized_concurrency, or reword to "bounded to two streaming windows on an integrated-memory device".

7. Minor — [paths].core_cache is not applied to flare agent install, contrary to the PR text

flare-cli/src/config.rs:138-140:

            cli::Command::Agent(args) => {
                args.core_cache.get_or_insert(cache);
            }

only fills the top-level Command::Agent field, while the install path reads the subcommand's own field (flare-cli/src/main.rs:147-157):

                Some(cli::AgentCommand::Install {
                    join_code,
                    accept_first,
                    listen,
                    core_cache,
                }) => orbit::agent::install(
                    &listen,
                    join_code.as_deref(),
                    accept_first,
                    core_cache.as_deref(),
                ),

So flare agent install with only [paths].core_cache writes a unit containing no --core-cache (orbit/agent.rs:2316-2323), while the running service picks the config value up — the unit and the runtime disagree. The description explicitly claims "Command::Agent and AgentCommand::Install accept --core-cache … and apply [paths].core_cache", and the new test (config.rs:762+) only exercises flare agent, so the claim is untested as well as untrue.

Fix: mirror the arm inside cli::AgentCommand::Install, and extend the test to cover install.

8. Minor — verification markers are best-effort, so a published entry can report itself unverified

flare-cli/src/orbit/agent.rs:802-816:

        let entry = staging.commit().map_err(|e| Failure::from(e.to_string()))?;
        let _ = fs::remove_dir_all(staged_dir);
        let _ = fs::write(
            entry.directory().join(VERIFIED),
            format!("{} {}\n", grant.primary(), grant.core.length),
        );
        if real_core {
            let _ = crate::distribution::write_verified_marker_for(

Both marker writes discard their errors. ENOSPC is a realistic failure here (the same code path just wrote tens of GiB), and the result is an entry that is published and source-referenced but reported "verified": false by Agent::cores() (orbit/agent.rs:1020-1022) — and therefore by flare orbit cores and by placement — despite TRANSFER having verified every byte. Conversely, when VerifiedCore::open fails (real_core == false) the entry is still published with a zero envelope and no .flare-verified.json (not opened) at all. The nodes[0]-verification fix this PR advertises is only as strong as these two ignored writes.

Fix: propagate the marker error (unpublish/abort rather than publish a half-marked entry) and fail the publish when real_core is false.

9. Minor — free_bytes scope change makes the pre-transfer space check miss one of two filesystems

flare-cli/src/orbit/agent.rs:917 (and :2281):

            free_bytes: free_bytes(&self.core_cache),

The controller gates a transfer with a single needed total (orbit/controller.rs:1404-1406, :2008-2018) covering core bytes and the executable, but the executable is still written under self.cache (orbit/agent.rs put legacy branch, :1456-1463). So the check now describes the core filesystem correctly for cores but validates the binary portion against the wrong mount — cores were previously under-reported, binaries are now. This is the one admission metric whose span changed in this PR and it is not called out in the description.

Fix: report both free values in HELLO/STATUS (or take the minimum), or co-locate bin/ on the core-cache filesystem.

10. Minor — --hosts silently overrides --gpus when picking the deployment to download

flare-cli/src/main.rs:448-456:

        let entry = hub::download(
            text,
            &hub_options,
            if !args.hosts.is_empty() { args.hosts.len() + 1 } else { args.gpus.len() },

With both flags supplied (a 2-host launch whose rank zero serves 4 local GPUs), --gpus 4 is discarded and a TP2 deployment is fetched, which then fails or misloads at launch with no warning. The new tensor_parallel = hosts.len() + 1 inference is otherwise a good fix, but it should not silently outrank an explicit flag.

Fix: error when hosts.len() + 1 != gpus.len().

11. Minor — assign_visibility turns a previously-silent misbinding into a startup failure for named-but-filtered devices

flare/src/hardware.rs:184-193 now matches numeric entries against device.ordinal (the correct fix), but inventory() still drops devices whose capability and platform are both unknown (hardware.rs:145-148). On such a host, CUDA_VISIBLE_DEVICES=0 — where ordinal 0 is the dropped device — now returns "does not identify one detected NVIDIA GPU" and aborts inventory rather than binding the remaining devices. Acceptable behaviour, but it is a new hard-failure mode for that accelerator class and deserves a release note.


Metric / rate / admission-pricing span check

Two spans changed:

        if all_present {
            downloads.push(entry);
            return Ok(json!({"received": 0, "verified": false})
                .to_string()
                .into_bytes());
        }

The controller then prints "holds the verified core" (orbit/controller.rs:2000-2004) on the strength of the call, not the field. Any consumer that counts verified bytes/entries from this reply now undercounts exactly the PR's headline win (prestaged orbit push slices reused by orbit run). Either return verified: true for the reuse path (it is verified — just not verified now) or add a distinct reused: true field and document that verified means "verified during this call".

Tests & claim accuracy

Open questions / could not find

  1. Is there any intended GC path for <core-cache>/staging/orbit outside this PR (a flare orbit gc or sampler hook) that I did not find? If not, item 1 is a Blocker for long-lived clusters.
  2. Was MAX_PREAUTH_SESSIONS = 256 derived from a real 4-Spark run, or from the "64 streams per peer" comment without multiplying by peers? The comment and the code disagree.
  3. Why was #361's proposed ranks/<id> namespace replaced by models/<model>/<entry> with -2/-3 collision suffixes — the suffixing is what makes item 1's duplication permanent.
  4. What is the intended rule for pre-existing flat ~/.cache/flare/cores/<export>… agent caches? The docs rewrite stops describing them; no migration or deletion rule is stated, and #361's acceptance criteria ask for one.
  5. Whether the #147 and #497 authors (efegokemir, FujitsuPolycom) have been told this supersedes/rewrites their work — the PR text says "closes #147" and no comment exists on that PR.