Conventions report · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/33697a0a-bd24-4c60-b356-932dcd828cbc.md

PR #332 review — Conventions and duplication

Repo: NVIDIA/hyperflare-inference · PR https://github.com/NVIDIA/hyperflare-inference/pull/332 · head 1ac7073d (rebased onto c9935887) · 4 files, +599/−37: heliopause/src/export/reachability.rs, heliopause/src/export/capture.rs, docs/TODO.txt, docs/runtime-core-design.md.

Lens: compare each new construct with its closest precedent in the repository and flag departures; flag helpers/abstractions/mechanisms that duplicate something that already exists. Rules read: charter (read_charter, lines 11, 35, 37, 42, 44), AGENTS.md (:47-60 on designed behaviour and docs/TODO.txt for unrun checks), CONTRIBUTING.md (not opened) (DCO only), docs/design-review.md (not opened), docs/runtime-core-design.md (:118-160, :337-346), docs/model-preparation.md (:363 VRAM inventory), and the maintainer reviews on the PR (2026-11-18/19/20) plus the Autobot review of 2026-11-26 and the author's 2026-11-28 response.

Key findings

Nits

1. heliopause/src/export/capture.rs:3219-3223 — the caller re-checks a precondition unresolved_report already enforces

if reach.unresolved_count() > 0 {
    for line in reach.unresolved_report(&output.index.ranks[0].functions) {
        eprintln!("export: rank {}: {line}", request.rank);
    }
}

Reachability::unresolved_report (reachability.rs:230-235) returns an empty Vec when occurrences == 0 and says so in its doc comment (:226-229); the test unresolved_report_is_empty_without_candidates (:989-993) pins that contract. The guard therefore restates the callee's postcondition, walks the map twice for the same fact (here and at :232), and the two copies can only disagree if one side changes. The surrounding function advances each phase unconditionally (graph_phase.finish(...) at :3215-3218, progress.phase(...) at :3224), i.e. the established shape is "advance, then let the callee emit or emit nothing".

Fix: drop the if and iterate the returned lines.

2. heliopause/src/export/reachability.rs:172-194 — blob rebuilds and clones its cache key, and clones the miss vector on both branches

let key = (data.to_vec(), numeric.to_vec()) (:173) is built to probe self.blobs.get(&key) (:174); on a hit the cached misses vector is cloned (:175); on a miss the key is moved into insert but misses is cloned again for the cache (:191). So per kernel argument per graph node the key bytes are copied twice and the miss vector is cloned in both branches. The construct it replaced — a HashSet with if !self.blobs.insert((data.to_vec(), numeric.to_vec())) { return Ok(()) } — copied the key exactly once and cloned nothing. This runs on the scan the author's rerun reports as 22,618 / 19,417 occurrences over thousands of nodes (PR comment 2026-11-28), and the miss list is re-cloned for every node sharing identical argument bytes, which is exactly the repetition the cache exists for.

Precedent for lookup-then-use without rebuilding: Downloader::for_each (capture.rs:1092-1160) reuses its slots rather than reconstructing them, and merge_ranges/subtract_ranges (reachability.rs:12-43) exist precisely so interval work is computed once and shared (capture.rs:23).

Fix: insert only on the miss branch and return a slice/&[(usize, u64)] from the hit branch so misses is not cloned; hash once (e.g. key on a digest) or keep the probe key borrowed. Performance/presentation only; no behaviour at stake. (A benchmark or a count of blob calls per export would quantify it; reading alone establishes the extra copies.)

Same entry, also duplication of a single fact:

3. heliopause/src/export/reachability.rs:824-839 — shared_argument_bytes_record_one_example_per_address is subsumed by two other tests, and the tests use two idioms for one lookup

shared_argument_bytes_record_one_example_per_address (:824-839) asserts unresolved count, distinct count, first-site graph and per-address occurrences — the same assertions as unresolved_examples_are_capped_while_occurrences_are_counted (:782-802), and its only novel element (the same node and kernel fed to two graphs) is already covered by unresolved_report_bounds_examples_and_counts_hidden_occurrences (:876-905), which also feeds graph-a/graph-b and asserts the graph-a first site plus "24 occurrences and 12 distinct addresses" (:894-899). Its one extra fact is occurrences == 2 on a single address (:837), which :899/:900 establish as (2 occurrences) through the rendered report.

The maintainer flagged exactly this shape on 2026-11-18 (item 6: a test that "repeats what unresolved_examples_are_capped_while_occurrences_are_counted ... already proves"). The file also mixes two idioms for the same map: the first() test helper (:760-762) and direct reach.unresolved[&address] indexing (:799-800, :836-837).

Fix: fold the graph-name assertion and the per-address occurrence count into :782-802 (call graph twice there) and delete :824-839; keep one lookup idiom.

4. heliopause/src/export/reachability.rs:487-493 — new module-scope pluralisation helper where the repository inlines the suffix

fn with_count(count: usize, one: &str, many: &str) -> String

Used at :240, :241-245, :261, :272-276, :277. There is no other such helper in the repository (search_code for with_count|fn .*plural matches only this file). The established convention is an inline suffix at the message: flare-cli/src/cache_commands.rs:307 (not opened), :309, :600, :602, :612; flare-cli/src/doctor.rs:365 (not opened), :812; flare-cli/src/inspect.rs:888 (not opened); helios/src/runtime_core/model.rs:619 (not opened) all write if n == 1 { "" } else { "s" } inline. The only other module-scope free functions in this file are merge_ranges/subtract_ranges (:12-43), which are cross-module primitives, so a module-scope helper here suggests a reusable abstraction that has exactly one consumer.

Countervailing point, in fairness: with five call sites, two of which need a two-word noun phrase ("more distinct address"/"more distinct addresses"), the helper is arguably clearer than five inline ternaries. This is a style preference, not a defect. Presentation only.

Constructs checked and cleared (no finding)

Open questions and what I could not settle