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

Raw Markdown for agents: https://autobot.eidonix.com/p/c3f60b2c-597e-441d-be4b-b11412bc0f27.md

Correctness, Contracts & System-Level review — PR #621 (head 55bab978)

Key findings

  1. F1 (Minor, the one issue I would require a reply on): the PR makes the core parameter declarations have two independent owners — SchedulerCapabilities.core_parameters for admission/prefix identity and config.contract.core_parameters for resolution/validation of the values actually packed — and nothing checks that they agree. Pre-PR the declarations travelled with the call site, so drift was impossible; this is introduced by the change. It fails closed (no cache mix-up is reachable), but on a declaring core an empty/stale capabilities list turns into a per-request AdmissionError::Invalid — a total outage with a prompt-shaped error message — instead of a startup error. helios/src/scheduler.rs:109-110, :696, :1462, :1473-1483; helios/src/model.rs:336; helios/src/server/request.rs:333-335.
  2. F2 (Minor): the description under-reports the public API break. Besides scheduler capabilities and declaration slices, a pub re-export was renamed with no alias: helios_core::runtime_core::validate_core_parameters → validate_core_parameter_declarations (helios/src/runtime_core/mod.rs:48-50), whose only in-tree consumer is heliopause/src/export/binding.rs:1051.
  3. F3 (Minor): the description's compatibility guarantee — "declaration-free cores keep their existing prefix keys", the property that keeps persisted Selene/host records and in-flight checkpoints matching across the upgrade — is true by construction but pinned by no test; every parameterless call now flows through the new salted path (scheduler.rs:1450-1452 → :1485-1491).
  4. F4 (Minor): the new parameterless rejection folds four unrelated preconditions into one AdmissionError::Invalid with one message, so a caller that used the now-rejected admit() on a declaring core cannot tell that the real problem is "this core declares parameters, pass values" (scheduler.rs:1463-1483).
  5. F5 (Minor): the rename creates a same-name, two-meaning pair across modules: validate_core_parameter_declarations(&[CoreParameter]) (model/contract.rs:460) vs validate_core_parameter_declarations(&wire::ModelContract) (runtime_core/mod.rs:48), while the values check keeps the old verb (contract.rs:521).
  6. Sound (stated plainly, not invented defects): no admission-metric, span or threshold change; no new lock, allocation, queue or memory pressure on any hot path; no new panic surface (the Index at :1488 is provably total); the GraphKind relocation is behaviour-identical; the Python refactor is logic-identical; nothing OS-specific is touched.

1. Correctness, Safety & Platform Parity

F1 — Declarations now have two owners and no startup invariant ties them together — Minor

(SchedulerCapabilities.core_parameters = admission identity; config.contract.core_parameters = resolved values. Fail-closed, so not a blocker; raise to Major if the in-process Rust SDK path is exercised by out-of-tree callers.)

Admission/prefix identity owner — helios/src/scheduler.rs:109-110:

    /// Core-declared FP32 forward parameters validated and hashed into every admission plan.
    pub core_parameters: Vec<crate::model::contract::CoreParameter>,

Validated once, at construction, and then used as the sole source of prefix identity — helios/src/scheduler.rs:696 and :1462:

        crate::model::contract::validate_core_parameter_declarations(&capabilities.core_parameters)?,
...
        let parameters = &self.capabilities.core_parameters;

Resolution/validation owner of the values that are actually uploaded — helios/src/server/request.rs:333-335, re-validated at helios/src/model/admission.rs:74-76:

    let core_parameters = config
        .contract
        .resolve_core_parameters(&opts.core_parameters)?;
...
        config
            .contract
            .validate_core_parameters(&self.core_parameters)?;

The only bridge between the two copies is one clone in helios/src/model.rs:336:

        core_parameters: config.contract.core_parameters.clone(),

SchedulerCapabilities is a fully pub, hand-constructible struct, so a caller can build a declaring core's scheduler with core_parameters: vec![]. Admission then compares the empty declaration list against the non-empty resolved values and rejects every request, at helios/src/scheduler.rs:1473-1482:

            || crate::model::contract::validate_resolved_core_parameters(
                parameters,
                core_parameters,
            )
            .is_err()
        {
            return Err(crate::Error::admission(
                crate::AdmissionError::Invalid,
                "request requires a nonempty prompt, positive output limit, bounded total tokens, and resolved core parameters",

because the checker demands exact cardinality and name-set equality (helios/src/model/contract.rs:475-483):

    if values.len() != parameters.len()
        || parameters.iter().any(|parameter| {
            values
                .get(&parameter.name)
                .is_none_or(|&value| !parameter.validate_value(value))

A same-shaped but stale declaration list passes admission and hashes values resolved from the other list; the only consistency check is between the admission record and the plan derived from it, in helios/src/model/packing.rs:556-571:

            if binding.source == ValueSource::CoreParameter {
                let value = admission
                    .core_parameters
                    .get(&binding.parameter)
                    .copied()
                    .ok_or("core-parameter admission is incomplete")?;
                let planned = live
                    .core_parameters()
                    .get(&binding.parameter)
                    .copied()
                    .ok_or("core-parameter admission plan is incomplete")?;
                if value.to_bits() != planned.to_bits() {

which cannot see drift between the two lists, because both sides come from the plan.

Impact. On a declaring core, a mis-wired capabilities list is not a startup failure: it is either a 100% request-rejection outage carrying a message that blames the prompt, or a late packing failure after pages and snapshot were reserved (scheduler.rs:1484 precedes packing). No cache corruption is reachable — the identity hashes values under the declared names, and a value/name mismatch is refused — so this is an availability/observability defect, not a correctness one.

Fix (concrete). Either (a) compare scheduler.capabilities.core_parameters against config.contract.core_parameters once in ModelRuntime::start (helios/src/server/runtime.rs:637-641) and fail startup, or (b) do not store a second Vec at all — take the declarations from PreparedContract at scheduler construction so a single owner remains. Add a unit test that a declaring contract plus empty capabilities fails at RequestScheduler::new, not at admission.

No other correctness or platform-parity issue found

2. Unintended system-level consequences

No effect on locks, contention, memory or failure blast radius — verified, not assumed.

3. Architecture, contracts & charter compliance

pub fn validate_core_parameter_declarations(value: &wire::ModelContract) -> crate::Result<()> {
    protobuf::validate_core_parameter_declarations(value)
}

The recipes/heliopause crates link helios_core, so an out-of-tree caller of the old name breaks at compile time with no deprecation window. Fix: add this to the description's compatibility sentence, or keep #[deprecated] pub fn validate_core_parameters forwarding for one release.

    pub fn validate_core_parameters(&self, values: &crate::model::CoreParameters) -> Result<()> {
        validate_resolved_core_parameters(&self.core_parameters, values)

A caller reading validate_core_parameters now has no way to tell "declarations" from "values" from the name alone. Fix: name the values method validate_resolved_core_parameters (the free function already exists at :471), or scope the wire wrapper.

4. Tests & claim accuracy

    pub fn plan_admission(&mut self, spec: &RequestSpec) -> Result<AdmissionPlan> {
        self.plan_admission_with_core_parameters(spec, &Default::default())
    }

and :1485-1491 then builds PrefixHistory::with_core_parameters(self.identity, parameter_values) over an empty iterator. No test asserts that this equals the pre-PR declaration-free key sequence — which matters because mismatch would silently invalidate every persisted checkpoint on upgrade. Fix: assert key_at(n) equality for several n between the parameterless construction and an explicit empty-parameter-list construction, cross-checked against a fixed historical key.

Verified sound (explicitly, so these are not re-litigated)

Open questions / could not be found

  1. Untested drift between the two declaration owners (F1). No test, startup assertion or doc note pins SchedulerCapabilities.core_parameters to config.contract.core_parameters; helios/src/server/request.rs:333-335 (resolution) and helios/src/scheduler.rs:1462 (admission) consult different copies.
  2. No observable CI run on 55bab978; every suite result remains self-reported.
  3. Previously flagged bot review blocker is stale at head. It alleged a main conflict in helios/src/scheduler/policy_tests.rs (prefill_catalog_engine lacking core_parameters); at head all five SchedulerCapabilities literals in that file set or inherit the field (:117, :1167, :3125, :4489, :5990) and the helper only delegates (:5652). It has not been retracted, so a human reader may take it at face value.
  4. Out-of-repo "Full Review" link in that bot comment was not fetched (off-repository, and its one substantive claim is the stale item above); all Autobot case-file/Full-Review/Value-Proposition artifacts are generated material, not human review.