Conventions report · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/f91099d5-1e69-47a5-8b23-d8fa6f3d9259.md

PR 549 review — Conventions and duplication (head bca7358)

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

All eight changed files were read in context (docs/api.md, helios/src/cache.rs, cache/lifecycle_tests.rs, cache/tests.rs, scheduler.rs, scheduler/tests.rs, server/metrics.rs, server/runtime.rs). The change is judged against the repository's own rules: docs/design-review.md:16 ("Keep Helios as simple as possible") and 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").

Key findings

  1. Should fix — the scheduler now expresses "which kind of pin" two different ways: the new bool-dispatched pin_prefix/unpin_prefix beside the existing named pin_checkpoint/unpin_checkpoint, and most request pins bypass the new wrapper entirely.
  2. Nit — the two new gauges have no docs/runtime-core-design.md entry, although the comparable existing page gauge does (docs/runtime-core-design.md:873).
  3. The two should-fix findings from the previous round are fixed at this head (cache chain walk folded into pin_with/unpin_with; the three duplicated admission branches gone), and the two documentation nits are fixed. They are listed at the end so they are not re-reported.

Should fix

1. pin_prefix/unpin_prefix duplicate the pin_checkpoint/unpin_checkpoint convention, and four of six request-pin sites bypass both

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) are the repository's established scheduler-level wrapper for a pin kind. They are named, documented ("Pins a GPU-ready checkpoint for the worker's copy-out; eviction and compaction skip it until unpin_checkpoint"), and they are the only path to a copy-out pin: every non-test caller goes through them — helios/src/server/runtime.rs:2360, 2364, 2396, 2480, 2496, 2705, 2710 — and tests use them too (helios/src/scheduler/tests.rs:3463-3483, helios/src/scheduler/sharing/tests.rs:526-528 (not opened)). There is no direct cache.pin/cache.unpin at any copy-out site. One kind, one named entry point.

The departure, in three parts.

  1. Two mechanisms for the same forward. pin_prefix(id, request_pin) selects the kind with a bare bool; pin_checkpoint(id) selects it with its name. At the only call site, self.pin_prefix(id, request_pin)? (scheduler.rs:1638), a reader cannot tell which counter moves without re-reading let request_pin = inbound.is_none(); (scheduler.rs:1636).

  2. The wrapper covers only the admission path. Request pins are taken directly on self.cache at:

    • scheduler.rs:1882 — self.cache.pin_request(id) in finish_inbound (ticket-waiter restore);
    • scheduler.rs:2970 and 2972 — publish_boundary, PublishResult::Created branch;
    • scheduler.rs:2990 and 2991 — publish_boundary, PublishResult::Existing branch;
    • scheduler.rs:3148 — the retirement release in retire.

    pin_prefix/unpin_prefix are called only at scheduler.rs:1638, 1649, 1671 — all inside admission, all driven by scheduler.rs:1636. So request pins have two entry points (the cache method, and the bool wrapper) where copy-out pins have one.

  3. Nothing at a mixed site records the difference. In finish_inbound the ticket-parent pins use the plain API — self.cache.unpin(parent)? at scheduler.rs:1864 and 1900 — while scheduler.rs:1882 in the same function takes a request pin. The PR description states the ticket-parent pins correctly keep the plain API, but no comment or name at either site says so.

Why it matters. The two kinds sit side by side exactly where a mismatch is easiest (scheduler.rs:1864/1882/1900, and 1638/1649/1671 where pin and rollback mirror each other across four lines of error handling). A missed or swapped mirror is silent in a release build: the only check is the #[cfg(test)] drift assertion in Cache::stats (helios/src/cache.rs:826-846), which fires only if a test reads stats afterwards. This is also the class of addition AGENTS.md:188-193 asks a reviewer to question: a second dispatcher for a forward that already has one, contributing no behaviour the first does not provide.

Fix — pick one mechanism.

Verified: helios/src/scheduler.rs:1630-1674, 1864, 1882, 1900, 2018-2043, 2965-2999, 3142-3149; helios/src/server/runtime.rs per the line list above; helios/src/scheduler/tests.rs:3463-3483; helios/src/scheduler/sharing/tests.rs:526-528 (not opened); helios/src/cache.rs:826-846.


Nit

2. The new gauges get no docs/runtime-core-design.md entry

docs/runtime-core-design.md:873 gives flare_snapshot_backing_pages a durable semantic definition — the closest precedent for a new scheduler page-count gauge. flare_request_kv_pages and flare_reserved_kv_pages live only in the new docs/api.md paragraph (docs/api.md:298-310) and the exposition HELP strings (helios/src/server/metrics.rs:1309-1318). Worth one sentence in the design doc only if the request_pins 0↔1 bookkeeping is meant to be a durable specification rather than an exposition detail. Not worth holding the PR for; carried over from earlier rounds.

(The absence of rows for these gauges in the docs/api.md JSON field table is correct, not a finding: that table maps JSON fields, and the PR deliberately keeps the gauges out of the snapshot — consistent with docs/api.md:292-296.)


Checked in this lens and dropped (no finding)


Fixed since the previous round (do not re-report)


Open questions / not settled

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