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

Raw Markdown for agents: https://autobot.eidonix.com/p/9b60e063-2abc-42e0-8e79-8afb8d013470.md

#1 [high] Research summary

Correctness, Contracts & System-Level review of #621 (head 55bab97)

I opened every changed Rust/Python/doc file plus the direct callers (server/runtime.rs, server/request.rs, model/admission.rs, model/packing.rs, model/inputs.rs, heliopause/export/binding.rs (not opened), ignition/direct/scheduler.py, ignition/preparation/contract.py) and the touched tests. The mechanical parts of the change are sound; what I found is one contract-ownership hazard and three claim/test/naming inaccuracies.

F1 — Declarations now have two owners and nothing pins them together (Minor, but the PR's central design point)

SchedulerCapabilities.core_parameters (helios/src/scheduler.rs:109-110) is validated at RequestScheduler::new (scheduler.rs:696) and then becomes the sole source of prefix identity at scheduler.rs:1462 (let parameters = &self.capabilities.core_parameters;), while the values that are actually uploaded are resolved and validated against a different copy, config.contract.core_parameters (helios/src/server/request.rs:333-335, helios/src/model/admission.rs:76/:139). The two copies are only incidentally equal, via scheduler_capabilities (helios/src/model.rs:336, core_parameters: config.contract.core_parameters.clone()). Because SchedulerCapabilities is a fully pub struct built by hand in the Rust SDK path, a caller can construct a declaring core's scheduler with core_parameters: vec![]; plan_admission_with_core_parameters then succeeds (empty values match empty declarations) and reserves pages/snapshot, and the mismatch surfaces only at pack time:

// helios/src/model/packing.rs:556-566
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")?;

The reverse divergence rejects every request at scheduler.rs:1479-1482. Impact: on a declaring core a mis-wired capabilities list becomes a per-request AdmissionError::Invalid (a total outage with a prompt-shaped error) or a late packing failure after resources are reserved — not a startup error. Before this PR the declarations travelled with the call site, so this coupling could not drift. It is fail-closed (no cache mix-up is possible, since validate_resolved_core_parameters at contract.rs:471-485 requires exact name-set equality), but nothing tests it. Fix: assert the two lists agree where they are both available (e.g. compare scheduler.capabilities.core_parameters against config.contract.core_parameters in ModelRuntime::start, server/runtime.rs:637-641, and fail startup), or take declarations from PreparedContract at construction instead of storing a second Vec.

F2 — PR description under-reports the public API break (Minor)

The description says "Rust callers constructing scheduler capabilities or passing declaration slices must update." It omits the third break, a renamed pub re-export with no alias: helios/src/runtime_core/mod.rs:48-50 (pub fn validate_core_parameter_declarations), consumed by heliopause/src/export/binding.rs:1051. Any out-of-tree caller of helios_core::runtime_core::validate_core_parameters (the recipes repo links this crate) breaks without warning. Fix: add it to the description's compatibility sentence, or keep #[deprecated] pub fn validate_core_parameters forwarding for one release.

F3 — The stated compatibility guarantee has no regression test (Minor)

The description claims "declaration-free cores keep their existing prefix keys" — the property that keeps persisted Selene/host records and in-flight checkpoints matching across the upgrade. That is true by construction (hash.rs:36-53: PrefixHistory::new is with_core_parameters(identity, empty)), but plan_admission (scheduler.rs:1450-1452) now routes every parameterless call through that path and no test pins equality. cache/tests.rs:132 (not opened) covers only the non-empty case; model/tests.rs:137-139 covers only the new rejection. Fix: assert PrefixHistory::new(identity).key_at(n) == PrefixHistory::with_core_parameters(identity, std::iter::empty()).key_at(n) for a few n.

F4 — The new parameterless rejection reuses one overloaded error (Minor)

scheduler.rs:1463-1482 folds the core-parameter check into a single AdmissionError::Invalid whose message is "request requires a nonempty prompt, positive output limit, bounded total tokens, and resolved core parameters". A caller that used the now-rejected admit() on a declaring core cannot tell which of four conditions failed, and no error distinguishes "this core declares parameters, pass values". Fix: return a distinct message for the parameters mismatch before the prompt checks.

F5 — Same identifier, two meanings across modules (Minor)

helios::model::contract::validate_core_parameter_declarations(&[CoreParameter]) (contract.rs:460, pub) and helios::runtime_core::validate_core_parameter_declarations(&wire::ModelContract) (runtime_core/mod.rs:48) are both public, while the values check keeps the old verb: PreparedContract::validate_core_parameters(&CoreParameters) (contract.rs:521, called from model/admission.rs:76). Fix: name the values check validate_resolved_core_parameters (the free function already exists at contract.rs:471) or scope the wire one to runtime_core.

Verified sound

Nothing here is a blocker; F1 is the one I would require a reply on.

#2 [high] #621 F1: declarations have two owners, nothing pins them

Lens: Correctness/Contracts. Severity: Minor (raise to Major if SDK callers are real; fail-closed, no cache mix-up).

Two copies of the declaration list now exist and only incidentally agree:

SchedulerCapabilities is fully pub and built by hand, so a Rust SDK caller can pass core_parameters: vec![] for a declaring core. Then:

No test pins the two lists together (grep of plan_admission_with_core_parameters/SchedulerCapabilities shows only empty vec![] fixtures plus the duplicate-name case at scheduler/tests.rs:2432-2446).

Fix: compare scheduler.capabilities.core_parameters to config.contract.core_parameters at startup in ModelRuntime::start (server/runtime.rs:637-641) and fail; or derive declarations from PreparedContract at construction instead of storing a second Vec.

Pre-PR the declarations travelled with each call site (plan_admission_with_core_parameters(&spec, &defs, &values)), so drift was impossible — this is introduced by the PR's design.