Simplicity report · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/75ce60c6-3ffd-43f0-ae80-f1a97a89acd3.md

Review of PR #332 "Report unresolved kernel argument address candidates during export" — lens D (simplicity)

Head c3cc87ea6e9a4e205dd3e3e62686eb3d0126b75b, base main, 2 files, +434/−30: heliopause/src/export/capture.rs (+6/−1) and heliopause/src/export/reachability.rs (+428/−29). Reviews: yatesdr requested changes on 2026-11-18, 11-19 and 11-20; no CI checks on this head.

Key findings

The change is small where it matters for this lens: it adds no option, flag, fallback layer or parallel path, works through the existing Reachability maps and the existing eprintln output, and does not touch the retention decision (reference is still called only on a live-interval hit, reachability.rs:139-142). The author already did what the maintainer asked for in the 2026-11-19 review item 4 (one map from address to first site and count, reachability.rs:85).

What is left is duplication and dead surface, not design:

Nothing blocking in this lens.

Rules applied: docs/design-review.md:16 principle 1 ("Keep Helios as simple as possible"), AGENTS.md:170-175 ("Reject unsupported abstractions and churn"), AGENTS.md:176-181 ("Require focused, meaningful validation"), docs/verification.md:22-23 ("Do not add tests that merely restate implementation text or assertions").


Should fix

D1. capture.rs:3137 — the caller repeats the callee's emptiness check

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

unresolved_report begins with the same condition (reachability.rs:206-210):

206    let mut lines = Vec::new();
207    let occurrences = self.unresolved_count();
208    if occurrences == 0 {
209        return lines;
210    }

occurrences == 0 holds exactly when self.unresolved is empty (it is a sum over its entries, reachability.rs:190-195), so the guard cannot change behaviour; the for over an empty Vec is a no-op.

Why it matters: two copies of one rule drift apart. If the report later grows a line that prints with zero candidates (for example "no unresolved candidates"), the caller silently suppresses it. It is the same class of duplication the maintainer rejected in the 2026-11-20 review item 2.

Fix: delete the if and keep the loop. Then unresolved_count has one caller, inside the module, so pub(crate) at reachability.rs:190 can become fn.

D2. reachability.rs:262-266 — the inactive-range rule is computed twice

candidate (reachability.rs:131-145) already does the inactive lookup:

131    fn candidate(&mut self, value: u64) -> ExportResult<bool> {
132        let inactive = self.inactive.partition_point(|&(start, _)| start <= value);
133        if inactive > 0 && value < self.inactive[inactive - 1].1 {
134            return Ok(true);
135        }

scan repeats it (reachability.rs:259-271):

261            if pointer >= floor && pointer < ceiling {
262                let inactive = self
263                    .inactive
264                    .partition_point(|&(start, _)| start <= pointer);
265                let in_free_block = inactive > 0 && pointer < self.inactive[inactive - 1].1;
266                if (!self.candidate(pointer)? || in_free_block)
267                    && let Some(misses) = misses.as_deref_mut()
268                {
269                    misses.push((base + offset, pointer));
270                }
271            }

The reported predicate is !candidate(pointer) || in_free_block. candidate returns true for an inactive value (:133-134) and for a live-interval value (:139-142), and false for a gap (:144). Inactive ranges lie inside recorded segments, so an inactive value takes the :133 branch and in_free_block is true there; a live value has in_free_block == false. The composite therefore reads "in an inactive range, or in a gap", which is precisely the decision candidate makes if its false return is read as "report".

Why it matters: two partition_point sweeps per address-shaped window over the whole scanned corpus (175k occurrences per rank on the author's export, PR description), and a second place to update when the inactive rule changes. This is the maintainer's still-open item 2 from the 2026-11-20 review.

Fix: let candidate return whether the value must be reported — inactive → Ok(true), inside an interval → reference(&name)?; Ok(false), otherwise → Ok(true) — and reduce scan to:

if self.candidate(pointer)?
    && let Some(misses) = misses.as_deref_mut()
{
    misses.push((base + offset, pointer));
}

Retention is unchanged (reference is still called only on a live-interval hit), the five lines at 262-266 and the second lookup go, and candidate stays the single place that states the rule. candidate is called only from scan (grep: the only hit at head is reachability.rs:266).


Nits

D3. reachability.rs:57-61, 170-186, 224-238 — a full first site is retained for every distinct address, but only ten are printed

UNRESOLVED_EXAMPLES is 10 (reachability.rs:75) and the report takes ten addresses (reachability.rs:224), yet blob stores an UnresolvedCandidate — including graph: String cloned with site.graph.to_owned() (reachability.rs:177) and four usizes — for every distinct address (reachability.rs:170-186). The author's own export produced 2,646 and 2,637 distinct addresses per rank (PR description table), so about 2.6k site records and heap-backed graph names per rank are written and never read.

Why it matters: unbounded bookkeeping for a bounded output, on the same pass that already has a measured occurrence count of ~175k.

Fix: keep the map shape the maintainer asked for and bound the payload:

struct UnresolvedEntry { first: Option<UnresolvedCandidate>, order: usize, occurrences: usize }

fill first only while self.unresolved.len() < UNRESOLVED_EXAMPLES (compute it before the entry/get_mut call so self.unresolved is not borrowed twice), and in the report skip entries whose first is None. Repeat hits then also stop paying the site.graph.to_owned() clone. order and the sort at 222-223 must stay unless print order may become HashMap order; the alternative that removes order too (a bounded Vec of examples plus the map for counts) uses two containers, so the Option is the smaller change. Note that test at reachability.rs:767 asserts reach.unresolved[&address].order == index, i.e. it pins this bookkeeping field rather than a behaviour; print order is already proven by reachability.rs:867 (lines[1].ends_with("0x3058")).

D4. reachability.rs:190-199 — two one-line accessors with a single production caller each, and duplicate assertions

unresolved_count (190-195) sums occurrences; unresolved_unique_addresses (197-199) is self.unresolved.len(). Their only production callers are unresolved_report (207, 217) and capture.rs:3137 — the guard that D1 removes. After D1 the first has one caller and can be private; the second can be inlined as self.unresolved.len().

They also generate duplicate assertions:

Fix: delete unresolved_unique_addresses; keep unresolved_count private to the module; in tests assert reach.unresolved.len() and reach.unresolved[&address].occurrences once each, and let the unresolved_report_* tests (which already assert "24 occurrences and 12 distinct addresses", reachability.rs:862) carry the rendered-total behaviour. docs/verification.md:22-23 and AGENTS.md:170-175 are the rules.

D5. reachability.rs:49, 66, 227-233 — needless pub(crate), and an unreachable "unknown (unknown)" path

Fix: let function = &functions[candidate.function]; and use function.symbol / function.module, deleting both map_or calls; the two tests that pass &[] (reachability.rs:858, 875) then pass a one-element list instead of asserting kernel unknown (unknown) at :866. If the guard is kept, one comment must state that functions has to stay in kernels order — that silent coupling is what the maintainer asked to be removed in the 2026-11-19 review item 4.

D6. reachability.rs:751, 833-835, 862-864 — a duplicated report literal and a test name that promises a cap it does not check

The 300-character summary sentence is written out verbatim twice (833-835 and 862-864). The wording has already changed twice during review (rank label, symbol, inactive ranges), and every further change now edits two literals.

unresolved_examples_are_capped_while_occurrences_are_counted (751) never calls unresolved_report and never has more than 12 all-shown addresses; capping is actually proven at 845 (lines.len() == 12, lines[11] == " … 14 more occurrences not shown", :859-869).

Fix: in the first test assert the counts and the single example line separately (lines[0].starts_with("kernel argument scan: 1 occurrence and 1 distinct address ") plus the exact graph …: 0x3008 line), keep the full-sentence assertion only in 845, and rename 751 to what it asserts, e.g. distinct_addresses_are_counted_once_with_their_offset.

D7. reachability.rs:147-170 — the cached miss list is cloned on every repeated call site

On main the same function started with if !self.blobs.insert((data.to_vec(), numeric.to_vec())) { return Ok(()) } (reachability.rs at main, :133-135) — repeated argument bytes were scanned once and then skipped. Now (head :148-169) every call site rebuilds the key with data.to_vec() / numeric.to_vec() and, on a hit, takes misses.clone() (:149-150) because the None arm needs &mut self for self.scan(…).

Why it matters: bounded by miss-list length, so this is cleanup rather than a defect, but it is a new per-node copy in a scan that already runs 175k occurrences per rank.

Fix: fill the cache in place and read it back by reference:

if !self.blobs.contains_key(&key) {
    self.blobs.insert(key.clone(), Vec::new());
    let mut misses = Vec::new();
    for (start, end) in subtract_ranges(0, data.len() as u64, &excluded) {
        self.scan(&data[start as usize..end as usize], start as usize, Some(&mut misses))?;
    }
    self.blobs.insert(key.clone(), misses);
}
for &(offset, address) in &self.blobs[&key] { … }

Open questions and limits