#1 [high] Should fix: inactive-range classification duplicated in candidate() and scan()
heliopause/src/export/reachability.rs:131-135 (candidate) and :262-266 (scan) each compute the identical inactive-range predicate:
let inactive = self.inactive.partition_point(|&(start, _)| start <= value);
inactive > 0 && value < self.inactive[inactive - 1].1
candidate returns Ok(true) for that case; scan recomputes it as in_free_block (line 265) and ORs it into !self.candidate(pointer)? || in_free_block (line 266).
Verified the second copy is logically dead: when in_free_block is true, candidate (called first, and it does not mutate inactive) also returns true, so !candidate is false and the expression reduces to true || in_free_block; when in_free_block is false the expression is exactly !candidate. So !self.candidate(pointer)? || in_free_block == !in_interval_membership(value) always. The duplicate buys nothing and costs a second binary search for every 8-byte window of every kernel argument (millions per graph on the reported exports: 175,329 / 170,544 occurrences).
Why it matters: is exactly the maintainer's open item 2 in the 2026-11-20 review ("One rule, one place. candidate already treats an inactive range as a hit, and scan repeats the inactive lookup ... State that rule once"), and it is the module's own convention: interval predicates are defined once (merge_ranges/subtract_ranges, reachability.rs:12-43) and reused across capture.rs (:23, :1252, :1334, :1408). Two copies of a range predicate invite drift — and capture.rs already has a differently granule-aligned notion of the same thing in live_pieces (capture.rs:1196-1240, alignment applied at :1211-1212), so a third variant is easy to confuse.
Fix: make the classifier return the classification once, e.g. fn classify(&mut self, value: u64) -> ExportResult<Candidate> where Candidate is Inactive | Retained | Unallocated; candidate() keeps its current retention behaviour (reference only for Retained), and scan reports for Inactive | Unallocated. Then delete in_free_block and the second partition_point. Behaviour is unchanged: values in an inactive range are still not retained and are still reported (test kernel_argument_inactive_ranges_are_reported_but_numeric_ranges_stay_lenient, reachability.rs:903-916, keeps passing; note that simply deleting in_free_block and keeping !self.candidate(...) would break it, because candidate returns true for inactive values).
Severity: should fix (blocking per the maintainer's open item, but it is a verified no-op change).
#8 [high] Research summary
Reviewed both changed files (heliopause/src/export/reachability.rs and heliopause/src/export/capture.rs) in context through the conventions-and-duplication lens, against the charter, AGENTS.md, CONTRIBUTING.md, docs/design-review.md, the repo-prose skill, and the maintainer's three review rounds on #332.
Main finding (should fix, and it is the maintainer's still-open 2026-11-20 item 2): the inactive-range predicate is written twice — candidate (reachability.rs:131-135) and scan (reachability.rs:262-266, via in_free_block). I verified from the code that the second copy is logically dead: !self.candidate(pointer)? || in_free_block always equals !candidate, because candidate already returns true for inactive values and does not mutate inactive. So scan pays a second partition_point per 8-byte window for no effect, and the file keeps two copies of a rule that capture.rs already implements a third, granule-aligned way (live_pieces, capture.rs:1196-1240). Fix is to have one classifier return the classification (inactive / retained / unallocated) and delete in_free_block — behaviour-preserving, since deleting the copy alone would break the inactive-range test.
Nits: capture.rs:3137 re-checks unresolved_count() > 0 although unresolved_report already returns an empty Vec; blob (reachability.rs:147-188) clones its cache key up to three times per kernel argument and clones misses in both branches, and the map is still reached through two count accessors (unresolved_count, unresolved_unique_addresses) where one would do; with_count (reachability.rs:455) is a new module-level pluralisation helper where flare-cli and helios both inline the singular/plural suffix; the new per-rank export message is undocumented next to the comparable VRAM-inventory description (docs/model-preparation.md:1471) and the reachability spec (docs/runtime-core-design.md:118-156); and shared_argument_bytes_record_one_example_per_address (reachability.rs:793-807) repeats :751-770 plus :845-870, with two idioms for the same map lookup.
I explicitly cleared several constructs against precedent (HashMap cache swap, explicit order field plus sort, per-rank eprintln! like transfer.rs:429/1152, symbols from the recorded function index, the optional out-parameter on scan) — all consistent. No blocking defect from this lens beyond the still-open duplication item. Findings are in scratchpad entries 1-7.
#9 [high] Summary: PR #332 conventions/duplication review — findings and coverage
PR #332 (mark-yong, head c3cc87e, +434/-30, 2 files). Lens: conventions and duplication. PR state: open, "changes requested" from yatesdr across three rounds (2026-11-18, 2026-11-19, 2026-11-20). Items 1-4 of the latest round are the live ones; items 2 (one rule, one place for the inactive range) and 4 (bookkeeping: one map) are the duplication items in this lens.
File coverage: heliopause/src/export/reachability.rs read in full (1-988, including all new tests); heliopause/src/export/capture.rs read at the changed site (3133-3141) plus its surrounding function (2760-3230), the function-index construction it depends on (2824-2998), encode_kernel (816-896, which writes node.function = index), live_pieces (1196-1240), prepare_allocations (1395-1429), Downloader::for_each/consume (1080-1172), and the module preamble (1-40). Rules read: AGENTS.md, CONTRIBUTING.md (DCO only), docs/design-review.md, docs/runtime-core-design.md:55-200, docs/model-preparation.md:1440-1500, .agents/skills/repo-prose/SKILL.md.
FINDINGS CARRIED (detail in the numbered entries):
- Should fix — inactive-range predicate duplicated in
candidateandscan; thescancopy is provably dead. (entry 1, same title) - Nit — capture.rs:3137 guard duplicates
unresolved_report's own empty check. (entry 2) - Nit —
blobclones its cache key up to three times per call, clonesmissesin both branches, and two count accessors for one map. (entry 3) - Nit —
with_count(reachability.rs:455) is a new pluralisation helper where the repo inlines suffixes. (entry 4) - Nit — the new per-rank export message is undocumented next to model-preparation.md:1471 / runtime-core-design.md:118-156. (entry 5)
- Nit — duplicate/overlapping new tests and two lookup idioms. (entry 7)
- No finding — constructs verified consistent with precedent. (entry 6)
VERDICT for the report: no blocking convention defect of its own; the only item in this lens that a maintainer has called blocking is the duplicated inactive-range rule (finding 1), which is a verified no-op change. Nothing in the diff duplicates an existing helper that should have been reused outright (kernel_symbols is gone; merge_ranges/subtract_ranges are still the shared range primitives).
Caveats to state honestly in the report: cargo test/clippy were not run (no tooling access here), and the two-graph report-ordering and singular hidden-count cases are asserted only in tests I read, not ran. The claim that !candidate || in_free_block == !candidate rests on reading candidate (reachability.rs:131-145): it reads self.inactive and may call self.reference, which never mutates inactive; a unit test that asserts reporting of an inactive value while also asserting no retention would settle it if a reader wants proof beyond reading.
#2 [medium] Nit: caller guard duplicates unresolved_report's own empty check
heliopause/src/export/capture.rs:3137-3141:
if reach.unresolved_count() > 0 {
for line in reach.unresolved_report(&output.index.ranks[0].functions) { eprintln!(...) }
}
Reachability::unresolved_report (reachability.rs:205-210) already returns an empty Vec when occurrences == 0, and its doc comment (201-204) says so. The caller therefore repeats the callee's precondition, and the two can only disagree if one changes.
Convention in the same function: phases are driven unconditionally and the callee decides what to emit (graph_phase.finish(...), capture.rs:3133; progress.phase), and unresolved_report_is_empty_without_candidates (reachability.rs:872-876) already pins the empty result as the module's contract. So the guard is redundant; drop the if and iterate the returned lines.
Severity: nit.
#3 [medium] Nit: blob cache clones its key three times per call and keeps two count accessors
heliopause/src/export/reachability.rs:147-188 (blob) introduces a cache shape with no precedent in this module and duplicates the existing dedup key handling by hand:
blobs: HashMap<(Vec<u8>, Vec<(usize, usize)>), Vec<(usize, u64)>>(line 84) clones the whole key twice per call:let key = (data.to_vec(), numeric.to_vec())(148),self.blobs.get(&key)(149), thenself.blobs.insert(key, misses.clone())(166) — three allocator copies of argument bytes per graph node, plusmisses.clone()(150 / 166), for every node of every graph. The previous code did oneHashSetinsert of the same key (oldblob, seen in the diff) and no per-call miss vector, so this adds two large copies per kernel argument on a path that already runs over ~2,650 distinct addresses × thousands of nodes.- Established pattern in this file and its neighbours for "look up, insert if absent, use it": the module already has one
partition_point-based interval helper pair (merge_ranges/subtract_ranges, lines 12-43) used by both this file and capture.rs, and capture.rs keeps its equivalent repeated work out of hot loops (Downloader::for_eachreuses slots, capture.rs:1092-1160). The idiomatic Rust here is the entry API on a borrowed key: hash the key once withraw_entry-style lookup, or storeblobs: HashMap<u64 /*digest*/, Vec<(usize,u64)>>, or usematch self.blobs.entry_ref/get(&key).unwrap_or_elseand onlyinsertin the miss branch — the current code clonesmissesin both branches (150 and 166-167), so the cached clone is paid even when the entry exists.
Also duplicated fact: unresolved_count (190-195) and unresolved_unique_addresses (197-199) both scan/size the same map and both exist only to be summed into the same report line (211-221). unresolved_count() is called twice per report (also capture.rs:3137). The maintainer's 2026-11-19 item 4 asked that the miss lists, counts and example list collapse into "one map from address to its first site and occurrence count"; the map is now one, but the two accessors are still two ways to ask about the same collection. unresolved_unique_addresses() has exactly one production caller (line 217) and one test (747/762/806) — inlining self.unresolved.len() there and keeping unresolved_count removes the second wrapper.
Severity: nit (performance nit for the key cloning; naming/duplication nit for the second accessor).
#6 [medium] Checked and consistent: no finding for these constructs
Constructs checked against repository precedent and found consistent (no finding):
blobschange fromHashSettoHashMap<key, misses>(reachability.rs:84): the module already usesHashMap/HashSetside by side (line 8), and the key type is unchanged, so the cache contract is not duplicated elsewhere.- Report order via an explicit
order: usizefield plusexamples.sort_unstable_by_key(|(_, entry)| entry.order)(reachability.rs:57-61, 222-223): the crate has noindexmapdependency (no match forindexmapanywhere; heliopause/Cargo.toml has none), and preserving order with an index + sort matches capture.rs:598 (ordered.sort_by_key(|&(id, _)| id)) and core.rs:180. eprintln!for the report (capture.rs:3139) rather thanStartupProgress: precedent exists for cross-rank lines written straight to stderr (transfer.rs:429 and :1152eprintln!("rank export failed: {error}")), and progress rows are rank-0 only (capture.rs:2774-2778), so a labelled per-rank stderr line is the established way to keep other ranks' output.stderr_rows()has no banner animation, so the lines are not redrawn over (helios/src/startup.rs:127-135, 499-517).- Symbols from the recorded function index in
unresolved_report(&[wire::Function])(reachability.rs:205, 227-233) instead of aCUfunction-keyed side map:wire::Node/wire::Kernelare already this module's vocabulary (reachability.rs:276-281), andnode.functionis documented as the index intofunctions(capture.rs:889). This follows the maintainer's 2026-11-19 item 4 and removes no existing helper (kernel_symbolsno longer exists — grep forkernel_symbolsreturns no matches). scan(... base, misses: Option<&mut Vec<_>>)out-parameter (reachability.rs:248-253): the file/crate precedent for scanner callbacks isFnMutvisitors (Downloader::for_each, capture.rs:1092-1096;consume, :1161-1165; blob.rs:89-99), butscanalso mutatesselfand must short-circuitExportResult, so an optional out-parameter avoids a closure that would borrowself. The&& letchain at :266-269 matches the crate's Rust edition usage (e.g. helios/src/scheduler.rs:1688, selene/src/memory.rs:936).- Source scanning of
data.windows(8)byte-by-byte (reachability.rs:259) is unchanged existing behaviour and is exercised byarbitrary_chunk_widths_preserve_pointer_hits_across_numeric_ranges_and_gaps(:491-536); the maintainer's 2026-11-20 item 1 asks to restrict reporting to 8-byte-aligned offsets, which is a correctness/noise concern outside this lens. UnresolvedCandidate/Sitearepub(crate)but onlySiteand the candidate map are used outside the module boundary in tests; no leaked public API.
#4 [low] Nit: new module-level pluralisation helper rather than inline suffixes
heliopause/src/export/reachability.rs:455-461 adds fn with_count(count: usize, one: &str, many: &str) -> String purely for the new report, with two call sites (215, 218) and one usage for the hidden count (242). No precedent exists in the repository, so this is a new construct; the closest in-repo conventions are:
- flare-cli/src/cache_commands.rs:305-310 and :686, :840, :1173: inline
if n == 1 { "" } else { "s" }suffix selection next to the message, no helper. - helios/src/startup.rs:441-446 and flare-cli/src/inspect.rs format counts directly, with no pluralisation helper at all; grep for
fn plural|pluralize|noun_pluralfinds nothing repository-wide. Because the whole report is one message in one function, the existing convention is to build the words inline (e.g.format!("{} occurrence{}", n, if n == 1 { "" } else { "s" })) rather than introduce a general helper that takes two nouns. A free function at module scope is also the only one of its kind in this file (merge_ranges/subtract_rangesare reused across modules, capture.rs:23), so the placement suggests a reusable abstraction where none is.
Note the helper has no unit test of its own; it is only exercised through the two report tests (reachability.rs:833-836 singular, :862-864 plural) and the plural-only hidden-count path (:869). That is adequate coverage, so this is presentation-only.
Severity: nit.
#5 [low] Nit: the new per-rank export message is not documented where the export's other messages are
The new diagnostic is user-visible export output, but no repository document describes it. Precedents that document exactly this kind of export printout:
- docs/model-preparation.md:1471-1487 ("Every model export prints a VRAM inventory for each rank after final publication, including exports without
--verbose...") specifies the other unconditional per-rank export message in full detail. - docs/runtime-core-design.md:118-156 specifies the reachability scan itself, including that numeric-span values are leaves and that untyped storage "is scanned for address candidates. This can retain false positives and retains complete backing segments, including unused bytes within a reachable segment" (:152-154), and :140-146 specifies how inactive blocks are excluded from payload reads.
AGENTS.md:52-60 requires documents to state the designed behavior, and the repo-prose skill (.agents/skills/repo-prose/SKILL.md:26-29) says documentation is a present-state specification, so a newly printed export message belongs in the same place the VRAM inventory is specified. As written, a reader of model-preparation.md cannot know that an export may print export: rank N: kernel argument scan: ... lines, or that they are non-blocking, which is the single most important thing about them (the message body does say the values may be stale pointers or numeric constants, but nothing says the export still succeeds).
Fix: one short paragraph next to the VRAM-inventory description in docs/model-preparation.md stating what the scan reports, that it does not fail the export or retain the inactive storage, and its blind spots (values outside the recorded envelope and values that alias live storage are not reported) — matching the limitations the PR description already lists.
Severity: nit (documentation completeness; the maintainer's open review items do not ask for it).
#7 [low] Nit: duplicate test for distinct-address counting and two lookup idioms in tests
Test-side duplication in heliopause/src/export/reachability.rs. The maintainer already flagged this class of problem in the 2026-11-18 review item 6 (a test that "repeats what unresolved_examples_are_capped_while_occurrences_are_counted ... already proves"), and the same shape is back:
unresolved_examples_are_capped_while_occurrences_are_counted(:751-770) asserts unresolved_count, unresolved.len(), per-addressorder, andoccurrences == 1for 12 distinct addresses.shared_argument_bytes_record_one_example_per_address(:793-807) is the same assertions on one address, differing only in that it feeds the same node/kernel to two graphs. The two-graph, one-map property is already covered independently by the report testunresolved_report_bounds_examples_and_counts_hidden_occurrences(:845-870), which checks"24 occurrences and 12 distinct addresses"and thegraph-afirst site.first(...)accessor (:728) exists only for these tests;reach.unresolved[&address].firstis used directly elsewhere (:767-768, :805), so the file has two idioms for the same lookup.
Fix: fold the graph-name assertion into unresolved_examples_are_capped_while_occurrences_are_counted (call graph twice and check graph-a on the first site) and drop shared_argument_bytes_record_one_example_per_address; pick one access idiom.
Coverage gaps worth naming (not duplicates): no test asserts the report's order ordering across graphs beyond graph-a/graph-b first-site, and nothing tests with_count's singular form for the hidden-count line (only the plural … 14 more occurrences not shown, :869).
Severity: nit.