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
- 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
MHCPostPrePartialKernelat "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 ofdata.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. - Should fix — ~55 test lines re-prove what sibling tests already assert (reachability.rs:792-807, 902-916, 823-828, 872-876).
- 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).
- 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).
- Should fix — ~10 lines: the miss-list cache copies a
Vecper key although theunresolvedmap already dedups by address, andscan'sOption<&mut Vec>sink has two of three callers passingNone(reachability.rs:84, 147-169, 248-253, 370-374, 378). - Should fix — ~5 lines:
candidateandscanstate 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 problem is fixed elsewhere. #266's cause was a transient cuBLAS/cuBLASLt workspace left in the capture stream's cache; merged #331 ("Isolate cuBLAS warmup workspaces from CUDA graph capture", merged 2026-11-20) removes that path. FujitsuPolycom's independent export on four GB10s from #331 reports "all 120 cuBLAS split-K workspace arguments identified in #266 resolved to the same recorded allocation on each rank" (#331 comment 2026-11-19 04:57). The charter's "Solve the right problem in the right place … look for a way to solve it without new code at all" applies directly.
- The PR's own evidence shows the population is not pointers. All ten examples per rank, on both ranks, are
argument 0, offset 4— an offset that cannot hold a CUDA pointer, since "argument bytes are encoded per parameter (encode_kernel). CUDA places a pointer at an 8-byte-aligned offset within its parameter, so a value at offset 4 spans two fields and is not a pointer" (yatesdr, 2026-11-20). These values exist only becausescanslides one byte at a time (reachability.rs:259), so each aligned 8-byte field is also read at its seven misaligned offsets. #266's stale arguments sit at offset 256 of a 384-byte parameter and at offset 0 of argument 1. - Independent confirmation of the artifact: FujitsuPolycom's #331 run found "864 unaligned byte-window matches and one aligned match per rank" (#331 comment 2026-11-19 04:57) — the same census, in a codebase where the defect is fixed.
- The report cannot establish provenance even when narrowed. The description says the result is "a non-blocking diagnostic for possible stale arguments, not proof that every graph argument has a live owner"; reachability.rs:211-214 prints "may be a stale pointer or a numeric constant". #266's follow-up asked for detection "where pointer provenance can be established without misclassifying numeric kernel parameters" (original-el8, 2026-11-13, quoted in my research notes) — this does not establish provenance for anything.
- Charter: "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 speculative compatibility or fallback layers." A 434-line pipeline whose only measured output is ~2,600 uninterpretable addresses per rank meets neither.
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:
shared_argument_bytes_record_one_example_per_address(792-807), -16 lines. Its claim ("the same blob in two graphs counts twice under one address and keeps the first graph's name") is already driven byunresolved_report_bounds_examples_and_counts_hidden_occurrences(844-870), which runs the same node and kernel throughgraph-aandgraph-band asserts 24 occurrences over 12 distinct addresses plusgraph "graph-a"on the first example. This is the exact overlap yatesdr flagged in the first round ("repeated_argument_bytes_report_every_call_site… repeats whatunresolved_examples_are_capped_while_occurrences_are_countedalready proves, except the graph name", 2026-11-18 item 6); the test was renamed, not removed.kernel_argument_inactive_ranges_are_reported_but_numeric_ranges_stay_lenient(902-916), -15 lines. Its second half (numeric exclusion suppresses the report) duplicatesnumeric_argument_holes_are_conservative(568-575) andkernel_argument_candidate_offset_counts_from_the_argument_start(772-790), which already pass&[(0, 8)]throughgraph. Its first half (an inactive range is reported) duplicates the inactive case offreed_interval_boundaries_report_kernel_candidates_without_retaining_storage(928-966).- The second
wire::Functioninunresolved_report_names_the_kernel_and_its_symbol(823-828), -6 lines. "wrong-module"/"wrong-symbol" exists only to prove thatfunctions.get(0)returns index 0 — std library behaviour, not this code. unresolved_report_is_empty_without_candidates(872-876) vs. the guard in capture.rs:3137, -4 lines either way.capture.rs:3137callsunresolved_reportonly whenunresolved_count() > 0, so the test asserts an early return (reachability.rs:207-210) that production code cannot reach. Keep one place: delete theif reach.unresolved_count() > 0guard in capture.rs and keep the early return, or delete the early return and keep the guard. Both is one decision made twice.kernel_argument_boundaries_and_external_values_follow_the_recorded_contract(878-900), -11 lines. Allocated/gap boundary values are already covered byfreed_interval_...(928-966); the out-of-envelope rows exercisepointer >= floor && pointer < ceiling, which is unchangedmaincode (the diff only renamespointertocandidate).
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.
- Three types carry the site fields twice (49-71), -16 lines.
UnresolvedCandidate(49-55) andSite(66-71) hold the same four fields, andblobcopies 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, }Sitethen disappears fromblob's signature, fromgraph's call site (311-316) and from the two module-level docs. orderexists only to undo a HashMap (59, 171, 183, 223), -4 lines.let order = self.unresolved.len();plusexamples.sort_unstable_by_key(|(_, entry)| entry.order)re-imposes insertion order on aHashMap. AVec<UnresolvedEntry>keyed by a smallHashMap<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.orderis only ever read in tests (line 767).unresolved_unique_addresses(197-199), -4 lines. A function body that isself.unresolved.len(), called once at 217 — and asserted four times in tests purely because it exists. Inline it.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)
- reachability.rs:45-48, 63-65, 73-74, 201-204, -8 lines. 13 doc lines for ~110 code lines.
UnresolvedCandidate's doc (45-48) restates the "may be a stale pointer or a numeric constant" that the format string at 211-214 prints;Site's doc (63-65) restates its four fields;unresolved_report's doc (201-204) lists the three-part body. One line each is enough: what invariant the reader cannot see from the code (the same rule the repo's prose guidance states, "state invariants, not narration"). - reachability.rs:73-74, -2 lines, and it becomes wrong if finding 3 lands. "The examples retain the first call site for each address in graph and node order" describes
orderplussort_unstable_by_key; droporderand the comment is false. - reachability.rs:211-221 plus the verbatim copies at 833-836 and 862-865, -8 lines. The 4-line format string spells out in prose what two counts say, and two tests repeat it character for character, consuming 8 lines between them. The caveat is already in the description and in the struct doc.
"kernel argument scan: {occurrences} occurrence(s), {addresses} address(es) outside every live allocation"is one line, and each test's copy becomes one line. - capture.rs:3137-3141 (nit, 0 lines).
eprintln!("export: rank {}: {line}", ...)stacks two prefixes on one line, sinceunresolved_reportalready emits "kernel argument scan:". Have the function return the prefixed summary and let the caller loop — one place decides the format. - Nothing in docs needs removing or adding. docs/runtime-core-design.md:118-156 describes retention, numeric spans and the envelope rules; the diagnostic changes no documented behaviour, so no doc edit belongs in this change.
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.
blobs: HashMap<(Vec<u8>, Vec<(usize, usize)>), Vec<(usize, u64)>>(84), withmisses.clone()at 150 and 166, -6 lines.mainhad aHashSetthat only remembered which blobs were already scanned (reachability.rs:52 on main). The change turns it into a cache of every miss per blob and clones the vector on both the hit and the store path. At the measured population (2,646 distinct addresses on rank 0 alone, each a(usize, u64)pair, times every repeated argument blob) that is tens of thousands of pairs retained for the whole scan. Theunresolvedmap already merges repeats by address (.entry(address).and_modify(|e| e.occurrences += 1)at 172-174), so dropping the miss list and recording inline loses no count — the cache buys CPU with memory that outlives the scan, and it is the largest retained structure the diagnostic adds.misses: Option<&mut Vec<(usize, u64)>>(252), -4 lines.scanhas three call sites, two of which passNone(370-374, 378) and still must pay theas_deref_mut()dance at 267. Eitherscanreturns its misses (ExportResult<Vec<(usize, u64)>>) orscan_spanspasses a throwawayVec; theOptionparameter disappears either way.
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
pointer→candidaterename: no caller outside the impl (search_code '\.pointer\(').graph()'s newnameparameter: sole production caller capture.rs:3102; no other crate usesReachability(capture.rs:23 importsmerge_ranges/subtract_rangesonly; weight_reuse.rs:226 (not opened),521 usesmerge_ranges).blobsfield type change: private, no external reader.- The
kernel_symbolshandle→symbol map that yatesdr asked to remove in the 2026-11-19 review is already gone at head; nothing orphaned. UNRESOLVED_EXAMPLES = 10: a const with one value is the right shape; nothing to remove.- The "… N more occurrences not shown" line is the only thing reconciling the cap with the total; it stays.
- No flags, config, docs or tests elsewhere in the repository become dead.
Open questions / not verified
- Whether any aligned candidate in the Vision-Exp export is a stale pointer: the author states the run "does not establish … whether the mHC values are constants or stale pointers", and it is a two-GPU MXFP4/A8 export, not the four-GPU DeepSeek V4.1 failure from #266. Narrowing the enumerator (finding 1) is the cheapest way to find out.
- I did not run the tests or an export; all line references are from head c3cc87e (reachability.rs, capture.rs) and
main's reachability.rs:52/155 for the pre-change comparison. - #266 remains open; nothing here argues it is closed, only that this PR's machinery is not the instrument that closes it (charter: "Bug fixes need to address the root cause").