Subtractive scratchpad · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/9b022b7e-ef6c-48b6-8f3e-4fdc9806ed4e.md

#1 [high] Blocking: 434-line diagnostic whose only measured run reported 2,646 misaligned non-pointers per rank and no true positive

Size: heliopause/src/export/reachability.rs +428/-29, heliopause/src/export/capture.rs +6/-1 (434/-30 total; ~215 of the added lines are tests, ~150 are the new report/scan machinery).

Why it is unnecessary at this size:

Smallest footprint: nothing at all (serving is protected by #331; flare inspect --memory-map plus the #266 reporter's package-decoding script already produce the actionable answer — it found exactly the 10 split-K arguments on the faulting package and "only the W4A8 constants" on the 4096 package). If a diagnostic is kept, the enumerator must be data.chunks_exact(8) (or offsets filtered by base % 8 == 0) instead of data.windows(8), which is a one-line change that removes most of the population the pipeline exists to count; only then is a report with occurrence/distinct counts, a 10-example cap, an ordering key and symbol lookup justified. As submitted, the machinery reports ~2,600 entries per rank that its own validation describes as uninterpretable.

Charter citations: "Look for the smallest footprint in shared code, or a way to solve it without new code at all"; "Bring real evidence ... 'An agent suggested it,' linter warnings, or hypothetical users aren't enough to justify a change"; "Reject unsupported abstractions and churn ... Do not add frameworks, extension points, speculative compatibility, fallback layers".

#2 [high] Should fix: candidate/scan state the inactive-range rule twice (10-16 lines)

heliopause/src/export/reachability.rs:131-145 (candidate) and 259-271 (scan).

candidate returns Ok(true) for a value in an inactive range (131-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", so the boolean can carry that directly and the duplicate lookup disappears:

/// 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 in scan:

for (offset, bytes) in data.windows(8).enumerate() {
    let pointer = u64::from_le_bytes(bytes.try_into().unwrap());
    if pointer >= floor && pointer < ceiling && !self.candidate(pointer)?
        && let Some(misses) = misses.as_deref_mut()
    {
        misses.push((base + offset, pointer));
    }
}

Saves the 3-line duplicate plus the 3-line in_free_block computation (~5 lines net), removes the misleading name, and closes reviewer yatesdr's open item 2 from the 2026-11-20 review ("One rule, one place ... scan repeats the inactive lookup ... State that rule once"). Behaviour is unchanged: inactive ranges are still reported and never retained (test freed_interval_boundaries_report_kernel_candidates_without_retaining_storage, reachability.rs:929-966).

Related dead weight: the half of kernel_argument_inactive_ranges_are_reported_but_numeric_ranges_stay_lenient (reachability.rs:902-916) that re-proves inactive reporting is covered by that same test; the numeric half is covered by numeric_argument_holes_are_conservative (568-575) and kernel_argument_candidate_offset_counts_from_the_argument_start (772-790).

#8 [high] Research summary

Reviewed PR #332 (2 files, +434/−30) through the subtraction lens; notes are in the scratchpad (entries 1–7).

Blocking (whole-change size). The 434-line diagnostic should not merge at this size. Issue #266's root cause is already fixed by merged #331, and #266's own follow-up asked for export-time detection only "where pointer provenance can be established without misclassifying numeric kernel parameters" — which this change states it cannot do ("may be a stale pointer or a numeric constant"). Its single measured export reports 2,646 distinct addresses per rank with all ten examples from MHCPostPrePartialKernel and no identified true positive, and all of them sit at offset 4, i.e. they are artifacts of data.windows(8) stepping one byte at a time. With chunks_exact(8) (reviewer yatesdr's still-open blocking item) most of the population this pipeline enumerates, orders, caps, caches and counts disappears — and so does the need for most of the machinery.

Should fix, by lines saved:

  1. ~55 test lines prove what sibling tests already prove (three overlapping tests; the capture.rs:3137 guard duplicates the report's own empty check).
  2. ~30 production lines: UnresolvedCandidate/Site/UnresolvedEntry carry the same four site fields three times; the order field exists only to re-sort a HashMap back into insertion order; unresolved_unique_addresses is a one-line accessor used once; a 7-line with_count pluralizer.
  3. ~16–20 lines of prose: 13 lines of doc comment for 110 lines of code (three restating the code), a 4-line pumped summary sentence duplicated verbatim in two test strings.
  4. ~10 lines: the blob miss cache changed from HashSet to a map of Vec pairs cloned twice per key although the unresolved map already deduplicates by address; an Option<&mut Vec> sink threaded through scan has one real caller.
  5. ~5 lines: state the inactive-range rule once instead of candidate + in_free_block doing the same lookup twice — closes reviewer item 2 from 2026-11-20 with a shown replacement.

Total removable on the current design: roughly 110–130 of the 434 added lines, and nearer 300 if the blocking enumeration fix lands first. Nothing the change supersedes is left dead elsewhere in the repository.

#9 [high] Report-ready summary: ranked findings with line savings and the smaller enumeration

Change size (from the diff): heliopause/src/export/reachability.rs +428/−29; heliopause/src/export/capture.rs +6/−1. Total +434/−30. Of the added lines, ~215 are in mod tests (reachability.rs:698-966 plus the 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 comment, and 6 are capture.rs.

Ranked findings (report in this order):

  1. BLOCKING — whole change, 434 lines. See entry 1. Evidence: #331 merged fixes #266's cause; #266 follow-up asks for detection only where provenance can be established; this PR's own export found 2,646 meaningless addresses per rank with no true positive; FujitsuPolycom's #331 run saw 864 unaligned byte-window matches per rank. Smaller version: nothing, or one line — for (offset, bytes) in data.chunks_exact(8).enumerate() replacing data.windows(8).enumerate() at reachability.rs:259 (and the same for scan_spans' inherited behaviour), which is reviewer yatesdr's open blocking item 1 from 2026-11-20. Only with that fix do the counts, cap, ordering key, symbol lookup and cache earn their lines.

  2. SHOULD FIX — ~55 test lines. entry 4. Drop shared_argument_bytes_record_one_example_per_address (reachability.rs:792-807), the inactive and numeric halves of kernel_argument_inactive_ranges_are_reported_but_numeric_ranges_stay_lenient (902-916), the second wire::Function in 823-828, and either the occurrences == 0 early return (207-210) or the capture.rs:3137 guard — not both. KEEP allocation_contents_still_tolerate_gap_candidates (918-926) and freed_interval_boundaries_report_kernel_candidates_without_retaining_storage (928-966).

  3. SHOULD FIX — ~30 production lines. entry 3: collapse UnresolvedCandidate+Site+UnresolvedEntry (49-61, 66-71) to one site type with graph, node, function, argument, offset, occurrences; drop order (59, 171, 183, 223) and the sort_unstable_by_key (223) by keeping insert order in a Vec; inline unresolved_unique_addresses (197-199); replace with_count (455-461) with "occurrence(s)"/"address(es)"/"more occurrences".

  4. SHOULD FIX — ~10 lines. entry 5: drop the miss-list cache or keep HashSet (blobs, 84, 147-169, misses.clone() at 150 and 166) since the unresolved map already dedups by address; make scan (248-274) return its misses instead of taking Option<&mut Vec> (three call sites, two pass None: 370-374, 378).

  5. SHOULD FIX — ~16-20 prose lines. entry 6: trim the four doc blocks (45-48, 63-65, 73-74, 201-204) from 13 to ~4 lines; shorten the summary format string (211-221) and its two verbatim copies in tests (832-836, 861-865).

  6. SHOULD FIX — ~5 lines. entry 2: one rule, one place — candidate (131-145) returns whether the value is a live pointer directly, scan drops in_free_block (262-265) and the duplicate partition_point. Closes reviewer item 2 from 2026-11-20; includes the ready code.

  7. Nit — capture.rs:3138-3139 stacks two prefixes ("export: rank N: kernel argument scan: ..."); keep one. 0 lines.

Totals to quote: with the design as submitted, ~110-130 of the 434 added lines are removable (55 tests + 30 structs/helpers + 16-20 prose + 10 cache/sink + 5 duplicate rule). With finding 1's one-line enumeration fix first, the counts/cap/order/symbol/cache machinery loses most of its justification, i.e. ~300 of the 434 lines.

Candidates I checked and DROPPED (do not report):

#3 [medium] Should fix: duplicate site structs, re-sort of a HashMap, single-use accessors, pluralizer (~30 lines)

heliopause/src/export/reachability.rs:45-75, 170-186, 224-236, 238, 455-461.

  1. UnresolvedCandidate (49-55) + Site<'a> (66-71) + UnresolvedEntry (57-61) carry the same four fields (graph/node/function/argument) twice. Site exists only to be copied field-by-field into the owned UnresolvedCandidate at 176-182:
struct UnresolvedEntry { graph: String, node: usize, function: usize, argument: usize, offset: usize, occurrences: u64 }

and blob(&mut self, data: &[u8], numeric: &[(usize, usize)], graph: &str, node: usize, function: usize, argument: usize) — or keep one borrowed Site and have blob own the copy only on first insert (or_insert_with(|| Site { graph: graph.to_owned(), ..site })). Removes ~12 lines between the two structs plus 4 lines of Site in the two module-level docs. unresolved_count (190-195) then becomes sum::<u64> over .occurrences — or is deleted entirely (see below).

  1. unresolved_unique_addresses (197-199) is self.unresolved.len() in a function body used once (line 217); inline it. -4 lines.

  2. order (59, 171, 183, 223) exists to re-sort a HashMap back into insertion order: let order = self.unresolved.len(); and examples.sort_unstable_by_key(|(_, e)| e.order). A Vec of entries plus an address→index HashMap (or a plain Vec<UnresolvedEntry> scanned linearly for 2,646 entries) keeps insertion order for free and deletes the field, its initializer and the sort. -4 lines. order is only ever asserted in tests (reach.unresolved[&address].order, line 767).

  3. with_count (455-461, 7 lines + 2 call sites) exists because the summary has one plural and the hidden line has another ("more occurrence(s)"). Dropping the singular form ("occurrence(s)", "address(es)", "more occurrences") deletes the helper and both call-site expansions: -12 lines including the test string. The repository has no general pluralizer (search_code 'fn plural|pluralize': no matches), and this diagnostic's only consumers are operators reading stderr.

Total here: ~30 lines of production code with no behaviour change.

#4 [medium] Should fix: ~55 test lines prove what sibling tests already prove; capture.rs guard duplicates the report's empty check

heliopause/src/export/reachability.rs:698-966 (tests) and capture.rs:3137-3141.

Tests: the change adds 10 tests (kernel_graph helper 698-719, SITE 721-726, first 728-730, then 732-966). Roughly half the added test lines prove facts one existing or sibling test already proves:

Total tests: ~55-60 removable lines of the ~215 added.

capture.rs: if reach.unresolved_count() > 0 { for line in reach.unresolved_report(..) } (3137-3141) is a 5-line block whose guard duplicates the occurrences == 0 early return inside unresolved_report (207-210). One place suffices: for line in reach.unresolved_report(&output.index.ranks[0].functions) { eprintln!(...) }. -2 lines.

#5 [medium] Should fix: miss-list cache clones Vec pairs twice per key and the Option sink in scan has one real caller (~10 lines)

heliopause/src/export/reachability.rs:147-169 (blob) and 248-274 (scan).

blob now stores Vec<(usize, u64)> of every miss per distinct (data, numeric) key and then lists them:

// reachability.rs:84
blobs: HashMap<(Vec<u8>, Vec<(usize, usize)>), Vec<(usize, u64)>>,

Two costs worth naming:

  1. misses.clone() twice per new key (150, 166). With the export's measured population (2,646 distinct addresses on rank 0 alone, each a (usize, u64) pair) the cache holds tens of thousands of pairs per rank for the whole scan, and it grew from HashSet (main, reachability.rs:52) to a map of vectors. The cache exists only to skip re-scanning identical blobs; keeping HashSet and re-listing the misses on each repeat would drop the payload (the map is HashSet<(Vec<u8>, Vec<(usize,usize)>)> plus for (offset, address) in misses recomputed... ) — simplest subtraction: do not cache the miss list at all, since the unresolved map already deduplicates by address and increments occurrences for repeats; the cache's only job is CPU, and it buys it with memory that outlives the scan. -6 lines (let misses = match ..., misses.clone() x2) if the cache is dropped and blob scans and records inline. No behaviour change: repeated addresses are already merged by .entry(address).and_modify(|e| e.occurrences += 1).
  2. misses: Option<&mut Vec<(usize, u64)>> is threaded through scan for three callers, two of which pass None (370-374, 378). scan is only called from two places: blob (with a sink) and scan_spans (without). A separate scan_misses that returns Vec<(usize, u64)>, or making scan take &mut Vec and having scan_spans pass a throwaway Vec, removes the Option and the as_deref_mut() dance (3 lines plus the two None arguments). Better: scan returning ExportResult<Vec<(usize,u64)>> needs no parameter at all.

Together: ~10 lines and the largest retained structure in the diagnostic.

Note the pre-existing windows(8)-byte-sliding is not introduced here (main has it at reachability.rs:155) but the report now materializes its output; yatesdr's blocking item 1 (chunks_exact(8)) is the fix that makes this cache and the whole enumeration small.

#6 [medium] Nit-to-should-fix: doc comments restate the code and the 4-line summary sentence is duplicated in two test strings (~16-20 lines)

Docs/comments in the diff and what they cost:

  1. reachability.rs:45-48 (UnresolvedCandidate doc, 4 lines), 63-65 (Site doc, 3 lines), 73-74 (UNRESOLVED_EXAMPLES doc, 2 lines), 201-204 (unresolved_report doc, 4 lines): 13 lines of doc comment for ~110 lines of code, and three of the four restate the code. UNRESOLVED_EXAMPLES doc says "The examples retain the first call site for each address in graph and node order" — that sentence is exactly what order + sort_unstable_by_key implement, and the ordering requirement came from review; if the field goes (see entry 3) the comment is wrong. Also the repo-prose skill requires comments to state invariants, not to narrate (SKILL.md:38-39). One line per item suffices: -8 lines.

  2. The summary sentence in the report (211-221) is a 4-line format string that spells out in prose what the counts say: "N occurrences and M distinct addresses fall inside the recorded address envelope but outside every live recorded allocation, so each may be a stale pointer or a numeric constant". Reviewers asked (yatesdr 2026-11-20 item 1) for the counts, not a paragraph, and the same string is duplicated verbatim in two tests (832-836, 861-865) where it consumes 8 of those tests' lines. "kernel argument scan: {occurrences} occurrence(s), {addresses} address(es) outside every live allocation" cuts the format string to one line and both test strings to one each: -8 lines. Nothing lost: the "may be stale pointer or numeric constant" caveat is a description sentence (PR "Change" section) and repeats in the doc comment at 45-48.

  3. capture.rs:3137-3141 prints "export: rank {}: {line}" per rank, and reachability.rs already builds the prefix meaning ("kernel argument scan:") — two prefixes in one line. Pick one. -0 lines but a simpler contract: unresolved_report returns the summary line already prefixed, the caller loops. (Nit; ranked last.)

  4. Nothing in docs/ needs updating: docs/runtime-core-design.md:118-156 describes retention, numeric spans, and "This can retain false positives and retains complete backing segments" — the diagnostic does not change any documented behaviour, so no doc addition is required either. (Recorded so the final report can say the change leaves no dead documentation behind.)

#7 [low] Note: nothing dead left behind outside the two changed files

Checked for things the change supersedes or leaves behind:

Conclusion of the sweep: no orphaned flags, config, docs or callers. The subtraction surface is entirely inside the two changed files.