Code correctness report · NVIDIA/hyperflare-inference #742

Raw Markdown for agents: https://autobot.eidonix.com/p/dacf8e60-e048-4b39-a86d-ba406e89b1db.md

Deep Code Correctness / Invariants / Hot-Path Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages)

Scope: 9 files, ~150 changed lines across selene + helios (+ tests/docs). Below the 12-file / 900-LOC partition threshold, so audited directly (no sub-agents). All findings verified against the tree at 5021b7a.

Verdict

No verified Blocker or Major code defects, and no hot-path performance regressions. The change is a pure cap on one already-existing sizing expression (pages → pages.min(max_sequence_pages)), applied consistently at all three sites that must agree, and it is provably conservative rather than permissive. Details of what I verified are below, followed by two Minor observations.

1. Callee / enum / design-invariant resolution

2. Order-of-operations / state-transition tracing

3. Adversarial boundary inputs (concrete substitutions)

4. Hot-path big-O

All touched code is startup-only: max_sequence_pages and capture_chain_pages are O(1), called once per allocate_caches, and once per capture_growth invocation inside the existing O(log(max_pages)) binary search (:789-797). No per-step, per-request, or per-victim path is touched; no allocation added. The clamp strictly reduces the number of SlabPool slots populated and CUDA-registered (offload.rs:722-754), so the change is a startup-time and host-RSS improvement, not a regression.

Minor observations (non-blocking, offered as hardening only)

Minor 1 — #[non_exhaustive] is claimed but not applied, so the .. is purely forward-looking. selene/src/offload.rs:332-347:

#[derive(Clone, Copy, Debug)]
pub struct PrepareInputs {
    pub max_active: usize,
    pub input_staging: u64,
    pub shard: Option<(usize, usize)>,
    pub integrated: bool,
    pub max_sequence_pages: Option<NonZeroU64>,
}

The destructuring at :623-629 was changed to .., but PrepareInputs has no #[non_exhaustive], so external struct-literal construction still breaks on any added field. The .. buys nothing today. Not a bug — helios and selene-manager are the only constructors and they compile — but if the intent is API stability, #[non_exhaustive] (or a builder) is needed. Counterexample: any out-of-tree crate writing PrepareInputs { max_active, input_staging, shard, integrated } breaks on this PR regardless of the ...

Minor 2 — the documented guarantee is weaker than the invariant actually needed on the restore path. selene/src/offload.rs:343-346 documents the field as "no single sequence chain exceeds limit pages." That is the correct justification for capture. I checked the sibling path that reads slot counts back out (fetch_chain, selene/src/memory.rs:2201-2320, pin_export_chain, :4030-4100, and export_chain, :4105-4125) and the bound is not consulted there at all, so nothing in restore can over-read a truncated chain — fetch_chain validates slots.len() != ticket.pages.len() || slots.len() != chain.pages (:2275-2281) and pin_export_chain validates chain.total_pages against endpoint.consumed_tokens / page_tokens (:4078-4082). The doc comment is therefore accurate for what the field does; my note is only that a future caller adding a multidoc/parallel-chain consumer must not read "single sequence" as "any chain the store may hold." No action required for this PR.

Things I could not fully verify within the turn budget