Subtractive report · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/8a59365c-43a7-46ac-aa93-4c7a41432b64.md

Review of PR #332 — Report unresolved kernel argument address candidates during export

Lens: subtraction only. Size from the diff: +434 / -30 (heliopause/src/export/reachability.rs +428/-29; heliopause/src/export/capture.rs +6/-1). Of the added lines roughly 215 are in mod tests (reachability.rs:698-966 plus edits at 573/625/634/676/687/952), ~150 are the new scan/report machinery (reachability.rs:45-75, 147-274, 455-461), ~13 are doc comments, 6 are capture.rs.

Key findings

  1. Blocking — the change should not merge at this size. Its own only measured export reports 175,329 occurrences / 2,646 distinct addresses on rank 0 and 170,544 / 2,637 on rank 1, all ten printed examples per rank being MHCPostPrePartialKernel at "argument 0, offset 4", with no true positive ever identified (PR description, Validation and Limitations; comment 2026-11-19). #266's root cause is fixed in merged #331 (2026-11-20), whose independent four-GB10 validation resolved all 120 split-K workspace arguments to recorded allocations (FujitsuPolycom, #331 comment 2026-11-19 04:57). The population the report counts is an artifact of data.windows(8) at reachability.rs:259 — a one-line change away from being small — so ~300 of the 434 lines exist to describe misaligned byte windows.
  2. Should fix — ~55 test lines re-prove what sibling tests already assert (reachability.rs:792-807, 902-916, 823-828, 872-876).
  3. Should fix — ~30 production lines of duplicate structs, a re-sort of a HashMap into insertion order, a one-line accessor and a pluralizer (reachability.rs:49-71, 59/171/183/223, 197-199, 455-461).
  4. Should fix — ~16-20 prose lines: 13 doc lines for ~110 code lines, and a 4-line summary format string duplicated verbatim in two tests (reachability.rs:45-48, 63-65, 73-74, 201-204, 211-221, 833-836, 862-865).
  5. Should fix — ~10 lines: the miss-list cache copies a Vec per key although the unresolved map already dedups by address, and scan's Option<&mut Vec> sink has two of three callers passing None (reachability.rs:84, 147-169, 248-253, 370-374, 378).
  6. Should fix — ~5 lines: candidate and scan state the inactive-range rule twice (reachability.rs:131-145, 262-265); this is reviewer yatesdr's open item 2 from 2026-11-20.

Total removable while keeping the design as submitted: ~110-130 of the 434 added lines. With finding 1 applied first, most of the counts/cap/ordering/symbol/cache machinery loses its justification, i.e. ~300 lines.


1. Blocking: the report is a byte-window census, and the defect it targets is already fixed (~434 lines at stake; the fix is 1 line)

What goes: the justification for the diagnostic's existence at this size — and if a report is kept, data.windows(8).enumerate() at heliopause/src/export/reachability.rs:259.

What replaces it: nothing, or for (offset, bytes) in data.chunks_exact(8).enumerate() — one line, and reviewer yatesdr's blocking item 1 from the 2026-11-20 review, still unaddressed at head c3cc87e.

Why nothing is lost:

The smaller version: fix the enumerator (1 line at reachability.rs:259, plus the same treatment inherited by scan_spans at 364-380) and re-measure before building any of the surrounding machinery. If thousands of aligned candidates survive, that is the population worth a report — and only then do the distinct-address counts, 10-example cap, ordering key, symbol lookup and blob cache earn their lines.

2. Should fix: ~55 test lines prove what sibling tests already prove (heliopause/src/export/reachability.rs:698-966)

The change adds ten tests plus the kernel_graph (698-719), SITE (721-726) and first (728-730) helpers. Half of the added test lines are redundant:

Keep allocation_contents_still_tolerate_gap_candidates (918-926): its reach.unresolved.is_empty() is the only assertion that allocation-content scanning does not report. Keep freed_interval_boundaries_report_kernel_candidates_without_retaining_storage (928-966): it is the one test that pins both the reporting and the non-retention contract the description claims.

3. Should fix: duplicate site structs, HashMap re-sorted into insertion order, one-line accessor, pluralizer (~30 lines)

heliopause/src/export/reachability.rs:49-71, 59/171/183/223, 197-199, 455-461.

  1. Three types carry the site fields twice (49-71), -16 lines. UnresolvedCandidate (49-55) and Site (66-71) hold the same four fields, and blob copies them field by field into the owned struct at 176-182. One type suffices:
    struct UnresolvedEntry {
        graph: String,
        node: usize,
        function: usize,
        argument: usize,
        offset: usize,
        occurrences: usize,
    }
    
    Site then disappears from blob's signature, from graph's call site (311-316) and from the two module-level docs.
  2. order exists only to undo a HashMap (59, 171, 183, 223), -4 lines. let order = self.unresolved.len(); plus examples.sort_unstable_by_key(|(_, entry)| entry.order) re-imposes insertion order on a HashMap. A Vec<UnresolvedEntry> keyed by a small HashMap<u64, usize> (2,646 entries fits in a linear scan, and the cache in finding 5 will shrink that) keeps insertion order for free and deletes the field, its initializer and the sort. order is only ever read in tests (line 767).
  3. unresolved_unique_addresses (197-199), -4 lines. A function body that is self.unresolved.len(), called once at 217 — and asserted four times in tests purely because it exists. Inline it.
  4. with_count (455-461), -12 lines. Seven lines plus three call sites (215, 216-220, 242) to choose between "occurrence"/"occurrences". The repository has no other pluralizer (search_code 'fn plural|pluralize': no matches), so this is new machinery, not a convention. "occurrence(s)", "address(es)", "more occurrences" deletes the helper and shrinks the summary format string to one line (see finding 4). Its only consumer is an operator reading stderr.

4. Should fix: doc comments restate the code, and the summary string is duplicated in two tests (~16-20 lines)

5. Should fix: the miss-list cache copies a Vec per key, and the Option sink has one real caller (~10 lines)

heliopause/src/export/reachability.rs:84, 147-169, 248-253, 370-374, 378.

Note: the byte-sliding itself is pre-existing (data.windows(8) on main at reachability.rs:155). What is new is that the report now materializes its output — which is why finding 1's one-line enumeration fix is the subtraction that matters most.

6. Should fix: candidate and scan state the inactive-range rule twice (~5 lines)

heliopause/src/export/reachability.rs:131-145 and 259-271. This is reviewer yatesdr's open item 2 from 2026-11-20 ("candidate already treats an inactive range as a hit, and scan repeats the inactive lookup (in_free_block) to report it. State that rule once.").

candidate returns Ok(true) for an inactive range (132-135) and for a live interval (136-143); scan then repeats the identical partition_point to recover which case it was:

// reachability.rs:262-270
let inactive = self.inactive.partition_point(|&(start, _)| start <= pointer);
let in_free_block = inactive > 0 && pointer < self.inactive[inactive - 1].1;
if (!self.candidate(pointer)? || in_free_block) && let Some(misses) = misses.as_deref_mut() {
    misses.push((base + offset, pointer));
}

The pair means "report iff no live allocation covers the value". Let the boolean carry that:

/// Retains the allocation covering `value`; reports whether it is a live pointer.
fn candidate(&mut self, value: u64) -> ExportResult<bool> {
    let index = self.intervals.partition_point(|&(start, _, _)| start <= value);
    if index == 0 || value >= self.intervals[index - 1].1 {
        return Ok(false);                      // a gap between recorded allocations
    }
    let free = self.inactive.partition_point(|&(start, _)| start <= value);
    if free > 0 && value < self.inactive[free - 1].1 {
        return Ok(false);                      // an inactive block of a recorded segment
    }
    let name = self.intervals[index - 1].2.clone();
    self.reference(&name)?;
    Ok(true)
}

and scan keeps only !self.candidate(pointer)?. Saves ~5 net lines and the misleading name; behaviour is unchanged, including the test at 928-966 that pins reporting without retention.

Swept, nothing to remove

Open questions / not verified