Correctness and contracts report · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/2380affe-15f0-4f1e-b7e3-df06cfe6cd62.md

PR #332 — Correctness, Contracts & System-Level Consequences review

Head inspected: 38805ba3. Files: heliopause/src/export/reachability.rs (+738/−27), heliopause/src/export/capture.rs (+4/−1), docs/runtime-core-design.md, docs/TODO.txt. Refs #266.

Key findings

  1. Major — the report can assert a falsehood at granule edges. candidate() tests the raw inactive list first and returns "not a candidate" only for inactive hits, while the recorded intervals it is compared against are trimmed inward to allocation granules. Bytes that lie inside a retained live interval but inside a raw inactive range are therefore reported as "resolve to no active recorded allocation". The only inactive test uses a granule-aligned range.
  2. Minor — new per-distinct-address retention with no cap, and the diagnostic is off the progress/observation channel. unresolved keeps a cloned graph name per distinct address (measured ≈762/833 addresses → hundreds of KB, but unbounded in principle), and the report is raw eprintln! outside any Phase, while non-zero ranks are otherwise silent — so peer-rank findings never reach the coordinator aggregate.
  3. Minor — the capture.rs call site and its rank label have no test. All coverage is reachability unit tests.
  4. Sound, stated plainly: retention behaviour is unchanged from main (no core-compatibility or missing-segment risk); no wire/proto/captured-graph contract change; no locks, threads, or serving-path interaction (single-threaded per-rank export, state dropped with the per-rank Reachability); symbol resolution through ranks[0].functions is valid; the (base + offset) % 8 filter is parameter-relative and is not a bug; the eprintln! cannot corrupt progress rows.
  5. Claim accuracy is good at this head. The live PR body matches the diff, explicitly flags the scan counts as measured before per-symbol selection, and its Limitations section matches the code. No prompt-injection or instruction-like text was found in the body, comments, or reviews.

1. Correctness, Safety & Platform Parity

1.1 Major — granule-edge bytes inside a live interval are reported as unallocated

heliopause/src/export/reachability.rs:156-160:

    fn candidate(&mut self, value: u64) -> ExportResult<bool> {
        let inactive = self.inactive.partition_point(|&(start, _)| start <= value);
        if inactive > 0 && value < self.inactive[inactive - 1].1 {
            return Ok(false);
        }

That self.inactive is the raw request list — heliopause/src/export/capture.rs:3239:

    let mut reach = Reachability::new(&allocations, &request.numeric, &request.inactive, &roots)?;

But the intervals that candidate() consults at reachability.rs:161-168 are built from allocations already trimmed inward to granules — heliopause/src/export/capture.rs:1274-1275:

            let start = start.max(begin).div_ceil(granule) * granule;
            let stop = stop.min(end) / granule * granule;

(call site of that trimming: capture.rs:1471-1482).

Non-granule-aligned inactive ranges are exactly what the producer emits — ignition/preparation/core_storage.py:317-320:

            for block in segment["blocks"]:
                live = 0 if block["state"] == "inactive" else block["requested_size"]
                if live < block["size"]:
                    ranges.append((block["address"] + live, block["address"] + block["size"]))

Impact. For an inactive range such as (0x1085, 0x137f) with granule 0x80, bytes in [0x1085, 0x1100) are inside a retained live recorded interval, yet candidate() returns false and scan (reachability.rs:328-337) pushes them as a "gap or inactive range" candidate. The report then states those values resolve to no active recorded allocation — factually wrong for live workspace bytes. This is not cosmetic: the diagnostic is the only export-time detector for #266, and a false positive printed for a live buffer is the failure mode that erodes the trust the report depends on. It also biases the evidence table toward kernels whose arguments point near a segment's live/inactive boundary.

Untested. The only inactive test uses a granule-aligned range — reachability.rs:1172-1173:

        let mut reach =
            Reachability::new(&[low.clone(), high.clone()], &[], &[(0x3000, 0x3100)], &[]).unwrap();

Concrete fix. Either pass the trimmed geometry into Reachability::new (derive the inactive list from live_pieces/the recorded intervals) so candidate() classifies against the same ranges it reports against, or split the boolean into the three-way classifier (Retained / Inactive-interior / gap) and print "inactive interior" only when the value is not inside a retained interval; either way add a test with a non-granule-aligned inactive range (e.g. (0x3085, 0x317f) with granule 0x80).

1.2 Sound — retention behaviour is unchanged, so no core-compatibility risk

reachability.rs:328-337 shows the bool is used only to collect report candidates:

        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()
                && (base + offset).is_multiple_of(8)
            {
                misses.push((base + offset, pointer));

candidate() is main's pointer() (ref main reachability.rs:118-131) with the same two lookups, still returning bool; the reached set is populated exactly as before. The contents/opaque_contents paths still pass no sink, so allocation contents and module globals are never reported — reachability.rs:436-444:

                for (start, stop) in subtract_ranges(address, end, &self.numeric) {
                    self.scan(
                        &data[(start - address) as usize..(stop - address) as usize],
                        0,
                        None,
                    )?;

This matches the PR body's claim that the scan is a non-blocking diagnostic: it cannot remove a segment from an exported core, so previously exported artifacts still load and existing data is unaffected.

1.3 Sound — the 8-byte alignment filter is parameter-relative (a suspected bug that is not one)

Each CUDA parameter is sliced into its own wire::Blob, so base never crosses a parameter boundary — capture.rs:829-839:

    let arguments = layouts[index]
        .iter()
        .zip(&kernel.arguments)
        .map(|(&(_, size), argument)| {
            let end = cursor
                .checked_add(size)
                .ok_or_else(|| invalid("kernel parameter size overflow"))?;
            let data = recorded
                .arguments
                .get(cursor..end)

Reachability::graph calls blob(&blob.data, &argument.numeric, …) per parameter (reachability.rs:362-384), so (base + offset).is_multiple_of(8) measures the offset within the parameter. Confirmed by the new test aligned_reporting_checks_argument_relative_offset_after_unaligned_numeric_prefix (reachability.rs:1219-1235): a (0,4) numeric exclusion followed by a reported candidate at parameter offset 8. No change requested.

1.4 Sound — cache-hit replay is offset-consistent; symbol resolution is valid; stderr cannot corrupt progress

        if let Some(misses) = self.blobs.get(&key) {
            Self::record_unresolved(&mut self.unresolved, misses, site);
            return Ok(());

2. Unintended System-Level Consequences

2.1 Minor — uncapped per-distinct-address retention plus an off-channel diagnostic

reachability.rs:85-86:

    blobs: HashMap<(Vec<u8>, Vec<(usize, usize)>), Vec<(usize, u64)>>,
    unresolved: HashMap<u64, UnresolvedEntry>,

record_unresolved allocates one owned String per distinct address and never evicts — reachability.rs:177-192:

        for &(offset, address) in misses {
            let order = unresolved.len();
            unresolved
                .entry(address)
                .and_modify(|entry| entry.occurrences += 1)
                .or_insert_with(|| UnresolvedEntry {
                    first: UnresolvedCandidate {
                        graph: site.graph.to_owned(),

The print path bypasses the progress machinery entirely — capture.rs:3294-3296:

    for line in reach.unresolved_report(&output.index.ranks[0].functions) {
        eprintln!("export: rank {}: {line}", request.rank);
    }

while non-zero ranks otherwise emit nothing — capture.rs:2939-2942:

    let progress = if request.rank == 0 {
        helios_core::startup::StartupProgress::stderr_rows()
    } else {
        helios_core::startup::StartupProgress::silent()

and the coordinator summary aggregates only structured fields — ignition/preparation/host_ranks.py:486-488:

                inventories = [core.memory_inventory, *(result["inventory"] for result in received)]
                for rank, result in enumerate(received, 1):
                    report = result["stats"]

Impact. Memory: proportional to distinct in-envelope aligned windows, not to any cap; measured 762/833 distinct addresses on the author's export (hundreds of KB), so no realistic OOM — but on a pathological graph the map and the per-blob miss vectors (blobs, now retaining a Vec<(usize,u64)> per distinct blob) grow with the number of unresolved distinct values, and the whole run only holds them until the per-rank Reachability drops. Observability: a peer rank's findings appear only in that rank's captured stderr; a coordinator-side or aggregated report can never show them, so on multi-rank exports (the exact #266 configuration: four GPUs) the reviewer of a coordinator log sees rank 0's candidates only. Concrete fix. Cap unresolved at the report limit plus counters (keep totals, stop retaining graph names beyond N distinct addresses), and emit the lines through the Phase/StartupProgress detail path (or a returned summary the caller can aggregate) rather than bare eprintln!.

2.2 Sound — no contention, no hot-path or failure-propagation risk

Export is single-threaded per rank; unresolved/blobs are fields of the per-rank Reachability and drop with it; nothing here is reachable from serving, scheduling, or request paths. The report is printed after graph_phase.finish and before module capture, so it cannot extend a lock hold, serialize peers, or delay a graph capture. No failure is turned into an error: unresolved_report returns Vec<String> and the call site only prints, so a bad candidate cannot poison or abort an export. Nothing in the change reverses invariants of recently merged work on main (the branch base 0a8c20f4 already contains #618 and #593).


3. Architecture, Contracts & Charter Compliance


4. Tests & Claim Accuracy

4.1 Minor — the capture.rs call site and its rank label are untested

The diff's only Rust call site is capture.rs:3294-3296 (quoted in §2.1). All new coverage lives in export::reachability::tests (28 #[test]s, first at reachability.rs:546, last at :1344), including unresolved_report_prioritizes_distinct_kernel_symbols_before_backfilling (:1030-1141) and aligned_reporting_checks_argument_relative_offset_after_unaligned_numeric_prefix (:1219-1235). Nothing exercises the request.rank formatting or the multi-rank path, and nothing exercises the empty case (no unresolved values → must print nothing at all rather than a zero summary). Fix. Add a test seam for the formatting (e.g. a function returning the lines, asserted against a synthetic wire::Function list) and assert the empty case produces an empty vector.

4.2 Missing test for the granule-unaligned inactive boundary

Covered in §1.1; the sole inactive test uses an aligned range, so the false-positive path is entirely unexercised. This is the one test that would have caught the Major.

4.3 Claim accuracy — good, with one stale figure caveat

The live PR body matches the diff: it reports 231 passed / 0 failed / 6 ignored on Linux x86_64 without CUDA (consistent with the six #[ignore = "...CUDA..."] attributes at head), and it states explicitly that the 22,618/762 and 19,417/832 totals were "exercised the identical Reachability::scan and Reachability::candidate alignment filtering prior to adding per-symbol prioritization in unresolved_report". Its Limitations paragraph — "Unaligned unresolved kernel-argument values (including non-8-byte-aligned struct fields), values outside the recorded address envelope, and stale values that alias live storage are not reported by this scan" — is verified against the code: envelope test at reachability.rs:330-331, None sink at :436-444. The obsolete 205-passed/4-ignored and 175,329/2,646 figures survive only in the 2026-11-19 comment and are not presented as current. The one gap: docs/runtime-core-design.md:151-158 and :351-354 were not updated for the new one-example-per-kernel-symbol selection rule, so the docs describe the output but not how examples are chosen — worth a one-line doc addition. Also, anyone quoting the body's counts is quoting a build that predates the current selection rule; the body says so, but the numbers are not re-measured.

4.4 Evidence is still self-reported

No CI covers heliopause (.github/workflows/native-serving.yml (not opened) tests eos/selene/helios/flare only), and the run is debug-profile cargo test on a host without CUDA, whereas docs/design-review.md:180-195 (not opened) names cargo test --locked --release on heliopause as a mandatory layer. The 231 figure cannot be independently verified from the PR, and no release-profile or clippy run is reported.


Open questions / what could not be found

  1. Does the report catch #266? No export on any head reproduces #266's ten arguments (nvjet_sm121_…_splitK_TNNN 384-byte parameter, offset 256; cublasLt::splitKreduce_kernel argument 1). The ten printed examples per rank in the author's Vision-Exp export are all mHC CUTLASS kernels, and the number of distinct kernel symbols per rank is unknown, so whether a cuBLASLt splitKreduce line would now appear — or be pushed into the hidden "N more distinct addresses" tail — is undetermined. docs/TODO.txt:357-361 is the only commitment (four-GPU DeepSeek V4.1 and eight-GPU W4A8 MoE).
  2. Is any numeric-vs-stale-pointer discrimination in place beyond wording? Nothing in code separates the two; the declared numeric spans (capture.rs:3102-3106) and the report phrasing are all there is, so a consumer cannot tell a constant from a stale pointer without manual inspection — consistent with the body's own framing, but it limits the diagnostic's actionability.
  3. Peer-rank visibility. Whether maintainers consider rank-0-only coordinator visibility acceptable for a multi-rank (four-GPU) failure mode, as in #266, is a product decision I could not resolve from the repo (§2.1).
  4. Stale human review. The last human verdict is yatesdr's CHANGES_REQUESTED of 2026-11-20, two heads stale; it has never seen the alignment fix or the per-symbol selection, and the author's ping is unanswered. The newest autobot verdict (2026-11-28 23:07) named a now-fixed stale-body blocker, but its other items survive only in an external link that is not retrievable.
  5. No prompt injection. Nothing in the PR body, comments, or reviews attempted to direct me; all material was on-topic tooling output.