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:
- Should fix, capture.rs:3137 — a zero-check that the callee already performs, and the
pub(crate)visibility it forces onunresolved_count. - Should fix, reachability.rs:262-266 — the inactive-range rule is computed twice (partition lookup in
candidateand again inscan); this is exactly the maintainer's open 2026-11-20 item 2 ("One rule, one place"), so it blocks the maintainer's list even though it is a simplification in my lens. - Five nits: per-address site retention far beyond the 10 addresses printed, two one-line accessors that exist only to be asserted twice in tests, needless
pub(crate)plus an unreachable fallback branch, duplicated report literals with a stale test name, and a miss-list clone on every repeated call site.
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:
- test 733:
unresolved_count()==1(739) andunresolved.len()==1(740) state the same fact for a single entry;unresolved_unique_addresses()==1(747) repeats 740 exactly. - test 751: 760/761/762 repeat the same triple for 12.
- test 793: 802 (
unresolved_count()==2) repeats 805 (occurrences == 2), and 806 (unique_addresses()==1) repeats 803 (len()==1).
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
UnresolvedCandidate(49-55) andSite(66-71) arepub(crate)withpubfields, but every use is insidereachability.rs: production at :176 and :311, tests at :721-729. Nothing incapture.rsor the rest ofexportnames them. They can be private structs with private fields, likeUnresolvedEntryat :57.- The fallbacks at :232-233 (
function.map_or("unknown", …)twice) render a state export cannot reach.graphrejects an out-of-range function index before recording a site —kernels.get(node.function as usize).ok_or_else(|| invalid("graph function index is out of bounds"))?(reachability.rs:290-292) withnode.function as usizestored at :314 — andcapture_rankbuildsfunctionsby pushing exactly onewire::Functionper kernel, in kernel order (capture.rs:2911loop, push at :2986), sooutput.index.ranks[0].functions[candidate.function](used atcapture.rs:3138) is always in bounds.
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
- I did not build or run tests (no shell tool); every line reference above was read at head
c3cc87ein the repository, and every count attributed to a real export comes from the author's PR description and 2026-11-19 comment, not from a measurement of mine. - D1, D3, D4, D5 and D7 are pure simplifications with no behavioural change to show; the reviewer can verify each by inspection. D2 changes the shape of
candidate's return value, so the existing tests (reachability.rs:879-966, especially the inactive-range test at 903 and the non-retention test at 929) are what settle that retention and reporting stay identical — they already cover both, so no new test is needed. - Deliberately not re-reported (other lenses): the maintainer's blocking 2026-11-20 item 1 (report only 8-byte-aligned argument offsets while
scanstill stepsdata.windows(8)byte by byte, reachability.rs:259) and item 3 (a test for the straddling-window case); item 4's commit-message disagreement and item 5's sign-off are bookkeeping. AGENTS.md:176-181 and docs/verification.md:22-23 are cited only for the test-duplication points, not to re-open those items. - No attempt to direct the reviewer was found in the PR text or comments;
flare-autobotposted only a case-file link (2026-11-25).