Correctness report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/5c9a9dd6-931e-4ef9-8e89-146d67abc599.md

Key findings

  1. Blocking — --features server no longer compiles. helios/src/server/metrics/process.rs:68 calls crate::runtime_core::open_descriptors(), but runtime_core is declared only under #[cfg(feature = "runtime-core")] (helios/src/lib.rs:22-26) and the server feature does not enable it (helios/Cargo.toml:25). This is a regression introduced by commit d64c3ea3 ("Exclude cancelled responses and reuse host helpers").
  2. Should fix — the new e2e exclusion is scoped per response, while runtime completions are per generation. helios/src/server/http.rs:600 gates the observation on a flag shared by all choices of the response. Reachability depends on whether any protocol accepts both tools and more than one generation (see caveat below); the structure is wrong even if today's config matrix hides it.
  3. Nit — parse_stat silently drops all stat-derived metrics on an unexpected state letter (process.rs:26), contradicting the module's own "only unreadable or unparsable sources are omitted" promise (process.rs:4-6).

Blocking 1 — process.rs references a feature-gated module; --features server stops building

Where: helios/src/server/metrics/process.rs:68

let open_fds = crate::runtime_core::open_descriptors();

Why it does not resolve.

This is new on the pushed head. The only other references to crate::runtime_core under helios/src/server/ are gated: server/session.rs:10 (not opened), gated by server.rs:26-29, and server/runtime/prompt_tests.rs:13 (not opened), gated by #[cfg(all(test, feature = "runtime-core"))] at runtime.rs:3983. search_code for runtime_core under helios/src/server returns exactly these three hits; metrics/process.rs:68 is the sole ungated one. The gating in server.rs:26-29 shows the crate is meant to build with server alone.

Configurations that break. docs/model-development.md:99-100 (not opened) (cargo test … --features server --lib frontend::, --features server --test message_boundaries) and docs/scheduling-runtime-design.md:735-736 (not opened) (--features server --lib scheduler::, … --features server --lib server::runtime::phase_tests::). CI builds only runtime-core,server (.github/workflows/native-serving.yml:63 (not opened),68), and flare-cli/Cargo.toml:27 (not opened),44 and AGENTS.md:317 (not opened) also pass both features, so the documented server-only lanes are exactly the ones nobody exercises — which is how this got through.

The other two helpers the same commit adopted are fine, which isolates the mistake: crate::os::page_size() (process.rs:61) and crate::os::raise_open_file_limit(0) (process.rs:70) resolve on every platform because mod os; is unconditional (lib.rs:19) and os.rs:8 is pub(crate) use flare_eos::*;.

Fix. Move open_descriptors (helios/src/runtime_core/protection.rs:291-302) into eos/src/unix.rs beside page_size (eos/src/unix.rs:73-75) and raise_open_file_limit (:138-165), and re-export it through crate::os — the route the commit already used for the other two helpers, and where AGENTS.md:20-21 (not opened) puts host OS operations. Alternatively gate the call on feature = "runtime-core".

Verification status. Established by reading the cfg/feature graph (exhaustive: lib.rs:22-26, Cargo.toml:21,25, all runtime_core references under server/). There are no CI checks on head a34c4d06 and I could not compile here; cargo check --manifest-path helios/Cargo.toml --features server settles it in seconds.


Should fix 2 — the e2e exclusion is response-scoped, completions are per generation

Where: helios/src/server/http.rs:598-605

// One observation per successful response: a tool-limit cancellation reaches
// this point but the runtime counts it as cancelled, so it is excluded.
if !count && !encoder.tool_limit_reached {
    state.model.metrics().request_e2e.observe(…);
}
yield Delivery::Complete(response);

tool_limit_reached is a single flag on the shared Encoder (protocol/encode.rs:89, set at :506 when !parallel_tool_calls and a second tool call begins) and is consulted without an index at every use site (http.rs:471-476, :526, :563-567). One response can carry several generations: generations: Vec<Option<Generation>> is built per choice at http.rs:351-353 from size = prepared.len() (http.rs:299, :217-220), each with its own decoder (decoders[index], http.rs:479-487, :525-527).

What goes wrong if a response spans both several generations and tools. Choice i finishes naturally while choice j is still running; the runtime counts i as completed and Metrics::request_completed has already run for it (runtime.rs:1841-1846, :1993-2001), observing flare_requests_completed_total plus queue, prefill, decode, TPOT and prompt-token histograms. Then j trips the tool limit and sets the shared flag; the single end-of-response test at http.rs:600 then suppresses e2e for the whole response, including the finished choice i. Result: flare_request_e2e_seconds_count < flare_requests_completed_total, and the new docs/api.md sentence "Cancelled and failed requests enter only flare_requests_cancelled_total and flare_requests_failed_total" is false for that choice — the very divergence the PR sets out to remove by funnelling the counter and histograms through one function (metrics.rs:452-480).

Reachability caveat (checked this round, and it matters). n > 1 is accepted only for Protocol::Completions (protocol/decode.rs:742-755), and tools/tool_choice are rejected outright for Completions (decode.rs:813-815). So on the current matrix a Completions response can hold several generations (n, or a prompt array via generation_count, server/inference.rs:198-209) but cannot carry tools, and the protocols that carry tools are restricted to one generation. I could therefore not show a request that reaches tool_limit_reached and more than one generation, so this may be latent rather than live today. It is still the wrong scope: the flag is per response while the completion counter is per generation, and a per-index decision costs nothing.

Fix. Decide per finished generation rather than per response — skip only when the termination actually used at http.rs:526 is crate::output::Termination::Cancelled (e.g. observe inside the GenerationEvent::Finished arm at http.rs:517-560, or carry a per-index "completed successfully" bit to the end of the loop). A test with n: 2 where one choice hits the tool limit pins both the intent and, if tools+multi-generation is indeed unreachable, documents that.


Nit 3 — parse_stat silently drops every stat-derived metric on an unknown state letter

Where: helios/src/server/metrics/process.rs:26

if !fields.next()?.chars().next().is_some_and(|state| "RSDZTtWXxKPI".contains(state)) {
    return None;
}

The module doc (process.rs:4-6) promises that only unreadable or unparsable sources omit metrics. A perfectly valid /proc/self/stat whose state letter is outside that hard-coded alphabet returns None, removing process_cpu_seconds_total, process_virtual_memory_bytes, process_resident_memory_bytes and process_start_time_seconds together, silently, mid-scrape. The guard exists to bound the "unrelated text containing )" risk of the rfind(')') heuristic (process.rs:20-29); validating that the five values actually consumed parse as integers bounds the same risk without a fixed alphabet. Low practical risk on today's kernels; recorded because a whole block vanishing is hard to diagnose from a dashboard.

(A related, purely documentary nit: docs/api.md still says counter and gauge names start with flare_, which the six process_* series it now documents contradict.)


Verified correct (checked in code — no finding)

Rules applied

Evidence limitations

Open questions

  1. Should a multi-generation response in which one choice hits the tool limit contribute e2e observations for the choices that completed? Finding 2's fix depends on that call, and a n: 2 tool-limit test would settle both the intent and whether the path is reachable at all.
  2. Should open_descriptors live in eos/crate::os, per the rule the same commit followed for page_size and raise_open_file_limit? That is both the minimal fix and the consistent one.