Conventions report · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/e77f19c3-2685-4c80-95c5-a06020dab190.md

PR 549 — Conventions and duplication review (head bca7358)

Verdict: should fix — one conventions/duplication finding, no blocking issues.

All eight changed files were read in context at head bca7358 (docs/api.md, helios/src/cache.rs, helios/src/cache/lifecycle_tests.rs, helios/src/cache/tests.rs, helios/src/scheduler.rs, helios/src/scheduler/tests.rs, helios/src/server/metrics.rs, helios/src/server/runtime.rs), and every line number below was re-verified by search at pr/549. The head is unchanged since the previous round: search_history lists bca7358 ("Fix KV-page docs ratio and fold duplicated page tests"), 9cca87ac, 5ed7af86, nothing later; the "last updated today" activity is the author's live-validation comment plus an Autobot review, not code.

Rules applied: docs/design-review.md:16 (principle 1, "Keep Helios as simple as possible"); AGENTS.md:188-193 ("Reject unsupported abstractions and churn… Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost"); AGENTS.md:338-349 (admission, page reservation and eviction are shared runtime policy, not to be duplicated); .agents/skills/repo-prose/SKILL.md:26-29 (not opened), 38-39 (present-state specification; comments explain invariants, not history).

Key findings

  1. Should fix — the scheduler now expresses "which kind of pin" two different ways: a bool-dispatched pin_prefix/unpin_prefix pair (helios/src/scheduler.rs:2019-2033) beside the established named pin_checkpoint/unpin_checkpoint pair (helios/src/scheduler.rs:2037-2043), and six request-pin sites bypass the new wrapper entirely.
  2. Nit — the moved request-pin release in retire re-fetches prefix and error_code with two extra self.request(handle)? lookups of values already bound a few lines above (helios/src/scheduler.rs:3144-3145 vs 3110 and 3113).
  3. Nit — the two new gauges have no docs/runtime-core-design.md entry, although the comparable flare_snapshot_backing_pages does (docs/runtime-core-design.md:873-877).
  4. Findings from earlier rounds (double chain walk in pin_request, three duplicated admission branches, two docs/api.md prose errors) are fixed at this head and are listed separately at the end so they are not counted twice.

Should fix

1. pin_prefix/unpin_prefix is a second pin-dispatch mechanism; six request-pin sites bypass it

Where: helios/src/scheduler.rs:2018-2033.

/// Pins `id` for an active request, or for a host admission ticket's parent.
fn pin_prefix(&mut self, id: CheckpointId, request: bool) -> Result<()> {
    if request { self.cache.pin_request(id) } else { self.cache.pin(id) }
}
fn unpin_prefix(&mut self, id: CheckpointId, request: bool) -> Result<()> {
    if request { self.cache.unpin_request(id) } else { self.cache.unpin(id) }
}

The precedent it departs from: pin_checkpoint/unpin_checkpoint (helios/src/scheduler.rs:2035-2043), which are named per kind, documented ("Pins a GPU-ready checkpoint for the worker's copy-out; eviction and compaction skip it until unpin_checkpoint"), and are the only path to a copy-out pin — every caller goes through the wrapper (helios/src/server/runtime.rs:2360, 2364, 2396, 2480, 2496, 2705, 2710; tests helios/src/scheduler/tests.rs:3463, 3464, 3479, 3483 and helios/src/scheduler/sharing/tests.rs:526, 528). No copy-out site calls cache.pin/cache.unpin directly. So for one pin kind the repo has a one-name-per-kind convention, and this PR introduces a second, boolean-shaped one for the other kind — and does not even keep request pins behind it.

Verified inventory at bca7358 (search over helios/src):

Why it matters: a mismatched pair (request pin taken, plain unpin released, or vice versa) is silent in a release build. The only check is the #[cfg(test)] full-scan assertion inside Cache::stats (helios/src/cache.rs:826-846), which fires only if some test happens to read stats after the mismatch. It also pushes against docs/design-review.md:16 and AGENTS.md:188-193, which ask a reviewer to reject an added forwarding layer that does not remove a demonstrated source of defects. This is duplication of dispatch, not new capability: the PR's behaviour is unchanged by deleting it.

Fix (pick one):

Either way the invariant to state is the one pin_checkpoint already states: one named entry point per pin kind, and no kind chosen at a call site.


Nits

2. retire re-fetches prefix and error_code it already bound

Where: helios/src/scheduler.rs:3144-3149.

if let Some(prefix) = self.request(handle)?.prefix {
    if !publish || self.request(handle)?.error_code.is_some() {
        self.record_publication(prefix);
    }
    self.cache.unpin_request(prefix)?;
}

Both values were already read from the single let request = self.request(handle)?; at scheduler.rs:3093: request.error_code.is_none() at scheduler.rs:3109-3110, and let prefix = request.prefix; at scheduler.rs:3113 (still live at 3123). Nothing between 3113 and 3144 mutates the slot — only publish_with_retention and touch, both on self.cache — so the two extra lookups cannot observe a different value; this is duplication, not defensiveness. The stated intent in the comment at 3142-3143 ("Release the request pin before the slot is emptied") needs only the reordering, not the re-fetch.

Precedent in the same function and its neighbours: retire binds request once and reads fields off it (3093-3117); finish_inbound binds let request = self.request_mut(handle)?; once (scheduler.rs:1883); publish_boundary binds once at 2974 and 2994.

Fix: bind the flag next to refresh_recency (e.g. let failed = request.error_code.is_some(); at scheduler.rs:3109-3112) and use if let Some(prefix) = prefix { if !publish || failed { … } … }. No behaviour change; four fewer slot lookups and one fewer shadowing binding.

3. New gauges have no design-doc entry

flare_request_kv_pages and flare_reserved_kv_pages are documented only as prose in docs/api.md:298-310 and as HELP strings in helios/src/server/metrics.rs:1309-1318, with no counterpart in docs/runtime-core-design.md, where the comparable page gauge lives: "The flare_snapshot_backing_pages metric counts page ids excluded by owned snapshots…" (docs/runtime-core-design.md:873-877). The omission is defensible (this is exposure-only, and api.md is the metric reference), so this is a nit at most; the fix, if taken, is one sentence in the KV-capacity section next to line 873 stating that request-held and reserved pages are reported separately from flare_cached_kv_pages and overlap it by pinned tail pages.


Fixed at this head — do not re-report

Checked in this lens and dropped (no finding)

Open questions / not settled

Link: https://github.com/NVIDIA/hyperflare-inference/pull/549