#1 [high] Research summary
Correctness / Contracts / System-Level review — PR #647 (e029dc8)
I read every changed hunk in eos/src/ioring.rs, heliopause/src/{allocator,processes,python}.rs, all nine heliopause/src/export/* files, helios/src/core/{conversion,conversion/edit,protection,reader}.rs, the eight ignition/preparation files, the touched tests, plus direct callers/contracts (helios/manifest.md, helios/proto/runtime_core.proto (not opened), helios/src/core/{cache,reader,export,synthesis}.rs, helios/src/offload via search, ignition/preparation/model_core.py (not opened), host_ranks.py (not opened), tests/preparation/test_export_transfer.py (not opened)). Eight findings, three of them material; the core-signing repair itself is sound.
1. compilation.py "clamp to storage.nbytes()" is a no-op — Major
ignition/preparation/compilation.py:184-199 (diff hunk @@ -179,18 +180,37 @@)
end = begin + span * value.element_size()
ranges.setdefault(key, []).append((begin, end, node))
storage_nbytes = int(value.untyped_storage().nbytes())
limits[key] = max(limits.get(key, 0), storage_nbytes, end)
...
a_end = min(storage_nbytes, (end + alignment - 1) // alignment * alignment)
The clamp bound is max(observed storage nbytes, end), so whenever a view's computed end already exceeds the storage (exactly the over-estimate case the PR is fixing, since span = 1 + sum((size-1)*stride) deliberately includes holes), the bound is raised to end and min() is a no-op. The description claims "_storage_regions … could extend past storage.nbytes(), while … _lower_storage slices clamped multi-dtype uint8 bases"; the multi-dtype slice in _lower_storage is likewise applied only if len(dtypes[key_for(node)]) > 1 and region_bytes % value.element_size() != 0, so a single-dtype region still passes an over-long base to aten.view.dtype. Impact: the out-of-bounds view.dtype/slice lowering that motivated the change can still be emitted. Fix: keep the true untyped_storage().nbytes() per key and clamp with min(true_storage_nbytes, …); if a real traced view legitimately exceeds it, fail loudly rather than widening the clamp.
2. kv_codec_gpu.cu 64-bit widening is partial and truncates silently — Major
ignition/preparation/kv_codec_gpu.cu hunk @@ -1565,41 +1565,41 @@ (~1576/1582/1587) and @@ -1632,15 @@ (~1635)
chunk_pkt_offs[i] = (U)pos;
...
lane_byte_offs[i] = (U)low_bytes;
...
*low_base_out = (total_pkt < (uint64_t)orig_bytes) ? (U)low_base : 0u;
...
B *dst = d_pkt + (size_t)(*low_base_ptr) + (size_t)lane_byte_offs[lane_id];
pos, low_bytes and low_base are now uint64_t, but they are immediately narrowed back to U (32-bit) in the two arrays and in low_base_out, and the compact kernel still takes const U *low_base_ptr. Per-chunk and lane offsets inside a packet plan therefore wrap at 4 GiB; because total_pkt < orig_bytes may still hold, the guard does not catch it, so lanes are written to wrapped destinations — silent corruption rather than a clean failure. The PR text claims it "widens plan accumulators and *low_base_ptr offsets to uint64_t". Impact: the concrete defect the change claims to fix is only partly fixed, and the remaining truncation is unobservable (no kernel execution ran; evidence is nvcc compile + ELF-symbol check only). Fix: widen chunk_pkt_offs/lane_byte_offs/low_base_out/low_base_ptr end-to-end (and the matching u64 slots in helios/src/offload/transfer/gpu_codec.rs (not opened)), or reject plans whose offsets exceed u32::MAX explicitly.
3. Cached-export Pass-1 skip widens from "reused weight spans" to "all numeric ranges" — Major (undeclared, untested)
heliopause/src/export/capture.rs:3419-3426
let cache_scan = request.weight_payload.is_some() && request.options.cache.is_some();
let skip_numeric = if cache_scan {
merge_ranges(request.numeric.clone())
} else {
super::weight_reuse::numeric_ranges(request, &allocations)?
};
numeric_ranges returns Ok(Vec::new()) unless request.options.reuse_weights.is_some() (weight_reuse.rs:218-220), so the previous skip set was empty for cached exports without --reuse-weights. Now every cached export skips all of request.numeric — both the D2H copy and, via the skip_numeric argument threaded into the pointer scan, pointer scanning of any numeric-classified buffers (which include 64-bit integer buffers). data_spans for cached exports no longer records those bytes. The description only says "skips request.numeric D2H in Pass 1 when cache_scan is true while still pointer-scanning non-numeric bytes"; the widening, the data_spans change, and the loss of numeric-range pointer scanning are not stated, and pr_files shows no test file covering capture.rs (tests changed: forward_artifact_sharing, peer_storage_groups, persistent, storage_lifetimes, tuning_shards). Fix: keep numeric_ranges(request, …)'s reuse-only semantics for the skip set, or state the new invariant in the description and add a capture-level test asserting data_spans for a plain cached export.
4. Payload transfer loses both sender- and receiver-side integrity checks — Major
heliopause/src/export/transfer.rs:600-620 and :1008-1040
let file = super::io::open_read(path)?;
let before = super::io::Identity::of(&file)?;
files.insert(path.clone(), Source {
size: before.size,
sha256: hex.clone(),
let mut digest = info.payload.is_none().then(Sha256::new);
...
if let Some(digest) = digest
&& format!("{:x}", digest.finalize()) != info.sha256
{
return Err(invalid("rank payload digest mismatch"));
}
Two removals, not one: (a) the pre-transfer scan is gone together with the post-scan Identity::of(&file) != before re-check that guarded against the object being replaced/mutated between the identity snapshot and the send (the remaining before is used only for size); (b) for every payload entry the receiver now computes no digest at all and no longer checks the declared sha256, so the wire field's meaning changes from "bytes you are receiving" to "the id you should look up later". The compensating check at install (install_payload_object → cache adopt_companion/store_slice) exists, so no silent corruption lands in the cache, but a corrupted/truncated in-flight payload now costs a full transfer before failing, and any other consumer of info.sha256 is reading a different contract. Fix: keep a cheap post-open Identity::of re-check on the sender (or drop before entirely so the unused snapshot is not mistaken for a guard), and in receive_rank verify the received object against info.payload at install time explicitly rather than relying on a distant call site.
5. DirectRing forces synchronous single-job I/O on the contended path — Minor
heliopause/src/export/io.rs:828-830, with :236-245
if jobs.len() == 1 {
return transfer_single_direct(file, jobs[0], write);
}
let count = ((source.length - offset).div_ceil(BLOCK as u64) as usize)
.min(self.depth)
.min(32);
while buffers.len() < count {
match self.try_buffer()? {
Some(buffer) => buffers.push(buffer),
None => break,
IoBudget buffers are shared (self.pool under a mutex, latency .. try_buffer returns None when allocated == depth), so when the budget is contended — multi-rank export — buffers collapses to one and every batch takes the new blocking libc::pread/pwrite path instead of the ring. The scan reader thread then cannot overlap I/O with the consumer, which is the opposite of the intent on exactly the busy path; the uncontended fast path is unaffected. Fix: reserve the synchronous path for a genuine one-shot (e.g. IoBudget::depth == 1 or an explicit single flag) rather than for jobs.len() == 1.
6. retain_sources return value silently changes scope — Minor
heliopause/src/export/binding.rs:819-855
let already_held: std::collections::BTreeSet<helios_core::core::PayloadId> = self
.leases
.lock()…
…
let count = retained.len();
…
self.retain_payload_leases(crate::export::PayloadLeases(retained))
…
Ok(count)
retained now excludes ids already leased, so the returned number is "newly leased this call", not "payloads leased for this rank". Callers ignition/preparation/model_core.py:67 (not opened) and host_ranks.py:496 (not opened) receive a value that drops to 0 for every rank after the first that shares payloads (which is the normal multi-rank case the dedupe targets); tests/preparation/test_export_transfer.py:244 (not opened) only pins the empty case. Any caller using the count as an "did this rank have weight payloads" signal inverts. Fix: return the post-insert self.leases.lock().len() (or document the new semantics and update callers).
7. ReadRing::flush now clamps kernel over-reporting instead of rejecting it — Minor
eos/src/ioring.rs:152-160
// Account for every entry the kernel accepted before propagating a
// submission error so Drop drains in-flight DMA before freeing buffers.
let submitted = (submitted as usize).min(self.queued);
self.queued -= submitted;
self.in_flight += submitted;
check(status)?;
The lifetime ordering fix itself is correct: accounting happens before check(status)?, so Drop/cancel_and_drain drains anything the kernel accepted. But the .min(self.queued) clamp converts a driver/duration mismatch (kernel claims more entries submitted than were queued) into a silent short-accounting: queued becomes 0, in_flight is short by the excess, and the subsequent if self.queued != 0 "incomplete submission" error cannot fire. Previously the same condition surfaced as an underflow/panic. Windows-only path, unexercised on Linux. Fix: return io::ErrorKind::InvalidData when submitted as usize > self.queued after adding the accepted entries to in_flight.
8. map_groups accepts any dropped view, not just omitted draft weights — Minor
heliopause/src/export/weight_reuse.rs:576-595
for old in &prior.views {
if current_names.contains(old.name.as_str()) || old.nbytes == 0 {
continue;
}
…
.push((old.offset, end));
The exclusion set is keyed on name absence, not on draft/speculative role, so a view that disappears for any other reason (recipe rename, engram plan change, a genuinely partial capture) is now subtracted from the cached initializers instead of tripping "is not covered by one declared weight group; export with weights". That check was the last guard that a --reuse-weights reuse is byte-complete for every retained view. The new test (map_groups_skips_omitted_draft_weights_and_clips_coalesced_initializers) only exercises the draft case. Fix: scope the omission to views whose prior group/dtype marks them as draft/speculative (or compare against the declared --no-mtp drop set) and keep the coverage error for everything else.
Verified sound (no finding)
- Core signing repair.
protection::sign_rewritten_envelope[_with_limit](protection.rs:1506-1554) refreshesbody_digestfrom the encoded bodies, re-reads every rank body viaread_rank_body(rank, body_store)(so spilled bodies resolve), and signs withsign_envelope;conversion.rs:2190-2317indexes ranks per deployment once, skipsflare.body.*andflare.manifestwhen copying the container, re-emitssigned.external_bodiesviareader::external_body_tensor, anddrop(metadata)beforefs::rename(correct on Windows).edit.rs:182-190routes through the same helper. External bodies keepMemoryBodyStore/Containersha256+length checks (protection.rs:451-499,reader.rs:38-54), so the rewrite cannot launder a body. ReadRingin-flight bookkeeping on the happy/partial-submit paths,NativeExportStagelock order (directory→leases in bothretain_payload_leasesandclose),RankSupervisorjoin handle isolation,Claimed::claim's complement arithmetic (I walked the merged/remove/insert sequence by hand),convert_prepared'sHashMapfirst-wins equivalence with the previous.find(), andwindow_host_layout's narrow-WDDM placement/overflow rejection (including the0x80_0000_0000full-address-space rejection test).PersistentWorker.metricsis documented (helios/manifest.md:106-112,runtime_core.proto:839-841(not opened)) and consumed (runtime_core/serving.rs:130(not opened),runtime_core/mod.rs:1272(not opened)), sobinding.rs's new resolution makes the exporter consistent with the ABI rather than inventing a field; the new both-or-neither hard error is the correct shape but is a new export failure mode for inputs that set only one of the pair.
Evidence/claim accuracy notes
- All reported test totals were gathered on
origin/main8da73911, not on heade029dc8; the description itself flags this, so the head commit has no independent attestation, and CI is failing on head. - No end-to-end benchmark backs the performance half (
capture.rsskip,DirectRingreuse, hashing removal,Claimedcomplexity), which the charter (#210) requires for a performance claim; live GPU/WDDM/multi-host paths were not run at all. --reuse-weights --no-mtpacceptance and thehost_extentsnapshot key (allocator.rs↔core_storage.py:103) are new cross-language behaviour changes with no documentation update indocs/.
#2 [high] PR #647 review findings — Correctness/Contracts/System-Level lens (8 findings)
Lens: Correctness, Contracts & System-Level Consequences. Head e029dc8, base main. All findings verified by opening files at pr/647.
FINDING 1 — Major — compilation.py storage clamp is a NO-OP
ignition/preparation/compilation.py:184-199 (hunk @@ -179,18 +180,37 @@)
quote:
end = begin + span * value.element_size()
ranges.setdefault(key, []).append((begin, end, node))
storage_nbytes = int(value.untyped_storage().nbytes())
limits[key] = max(limits.get(key, 0), storage_nbytes, end)
...
a_end = min(storage_nbytes, (end + alignment - 1) // alignment * alignment)
Why: bound is max(observed nbytes, end) where end = begin + span*elem and span = 1 + sum((size-1)*stride) deliberately includes holes, so when end > storage nbytes the min() clamp is a no-op — exactly the over-estimate case the PR claims to fix. _lower_storage slices only if len(dtypes[key]) > 1 and region_bytes % value.element_size() != 0 (compilation.py:685-695), so single-dtype over-long regions still feed aten.view.dtype.
Impact: claimed out-of-bounds lowering not fixed.
Fix: store true untyped_storage().nbytes() per key and clamp to it; fail loudly if a real view exceeds storage.
FINDING 2 — Major — kv_codec_gpu.cu 64-bit widening partial, silent truncation ignition/preparation/kv_codec_gpu.cu hunk @@ -1565,41 +1565,41 @@ (~1576/1582/1587) and @@ -1632,15 @@ (~1635) quote: chunk_pkt_offs[i] = (U)pos; lane_byte_offs[i] = (U)low_bytes; *low_base_out = (total_pkt < (uint64_t)orig_bytes) ? (U)low_base : 0u; B *dst = d_pkt + (size_t)(*low_base_ptr) + (size_t)lane_byte_offs[lane_id]; Why: pos/low_bytes/low_base are uint64 but narrowed back to U (32-bit) into the arrays and low_base_out; kv_compact_packet_gpu still takes const U *low_base_ptr. Offsets wrap at 4 GiB and the total_pkt<orig_bytes guard can still pass => lanes written to wrapped destinations (silent corruption). PR text claims low_base_ptr offsets were widened. Impact: concrete defect only partly fixed; no kernel execution evidence (all 16 GPUs occupied; only nvcc compile + zero global/constant ELF symbols + tests/test_kv_codec.py 4/4). Fix: widen chunk_pkt_offs/lane_byte_offs/low_base_out/low_base_ptr end-to-end (and matching u64 slots in helios/src/offload/transfer/gpu_codec.rs), or reject plans exceeding u32::MAX.
FINDING 3 — Major — capture.rs skip set widens from reuse-only spans to ALL numeric ranges heliopause/src/export/capture.rs:3419-3426 quote: let cache_scan = request.weight_payload.is_some() && request.options.cache.is_some(); let skip_numeric = if cache_scan { merge_ranges(request.numeric.clone()) } else { super::weight_reuse::numeric_ranges(request, &allocations)? }; Why: numeric_ranges returns Ok(Vec::new()) unless reuse_weights is set (weight_reuse.rs:218-220), so previously the skip set was empty for cached exports WITHOUT --reuse-weights. Now all numeric ranges are skipped (D2H and pointer scan via skip_numeric threaded into the scan at capture.rs:3458-3461), and data_spans no longer records those bytes. Description mentions only the D2H skip. pr_files shows no capture.rs test. Fix: restore reuse-only semantics or document + add a capture test asserting data_spans for a plain cached export.
FINDING 4 — Major — transfer.rs drops both sender post-scan identity re-check and receiver digest for payload objects
heliopause/src/export/transfer.rs:600-620 and :1008-1040
quote A:
let file = super::io::open_read(path)?;
let before = super::io::Identity::of(&file)?;
files.insert(path.clone(), Source { size: before.size, sha256: hex.clone(),
quote B:
let mut digest = info.payload.is_none().then(Sha256::new);
if let Some(digest) = digest
&& format!("{:x}", digest.finalize()) != info.sha256
{ return Err(invalid("rank payload digest mismatch")); }
Why: the removed scan also removed the post-scan Identity::of(&file)? != before re-check (before is now used only for size) and, for payload entries, the receiver computes no digest and checks no declared sha256 — the wire field's meaning changes to a lookup id. Mitigated by install-time adoption (install_payload_object -> cache adopt_companion/store_slice verifies declared identity), so no silent cache corruption, but a corrupted in-flight payload costs a full transfer before failing and any other consumer of info.sha256 reads a different contract.
Fix: keep post-open Identity re-check on sender; verify received object against info.payload explicitly at install.
FINDING 5 — Minor — DirectRing forces synchronous single-job I/O on the contended path heliopause/src/export/io.rs:828-830 with :236-245 quote: if jobs.len() == 1 { return transfer_single_direct(file, jobs[0], write); } plus: count = (...).min(self.depth).min(32); while buffers.len() < count { match self.try_buffer()? { Some(b)=>push, None=>break } } Why: IoBudget buffers come from a shared mutex-guarded pool and try_buffer returns None when allocated == depth, so under contention (multi-rank export) buffers collapses to 1 and every batch takes blocking pread/pwrite instead of the ring — losing overlap exactly on the busy path. Uncontended path fine. Fix: gate the synchronous path on a genuine one-shot (depth==1 / explicit flag), not jobs.len()==1.
FINDING 6 — Minor — retain_sources return value silently rescoped to "newly leased" heliopause/src/export/binding.rs:819-855 quote: let already_held: BTreeSet = self.leases.lock()...keys().copied().collect(); ... let count = retained.len(); self.retain_payload_leases(crate::export::PayloadLeases(retained)) ... Ok(count) Why: ids already held are skipped, so the count is 0 for every rank after the first sharing payloads (the normal multi-rank case the dedupe targets). Callers: ignition/preparation/model_core.py:67, host_ranks.py:496; only the empty case is pinned (tests/preparation/test_export_transfer.py:244). Fix: return self.leases.lock().len() after insert, or document + update callers.
FINDING 7 — Minor — ReadRing::flush clamps kernel over-reporting instead of rejecting eos/src/ioring.rs:152-160 quote: let submitted = (submitted as usize).min(self.queued); self.queued -= submitted; self.in_flight += submitted; check(status)?; Why: the lifetime fix is correct (accounting before check(status)? so Drop drains accepted DMA), but the .min clamp turns "kernel claims more submitted than queued" into silent short accounting: queued becomes 0 so the subsequent "incomplete Windows I/O ring submission" error cannot fire. Windows-only, unexercised on Linux. Fix: return io::ErrorKind::InvalidData when submitted as usize > self.queued (after adding accepted entries to in_flight).
FINDING 8 — Minor — map_groups accepts ANY dropped view, not just draft weights heliopause/src/export/weight_reuse.rs:576-595 quote: for old in &prior.views { if current_names.contains(old.name.as_str()) || old.nbytes == 0 { continue; } ... .push((old.offset, end)); Why: exclusion keyed on name absence, not draft/speculative role, so a view dropped for any other reason (recipe rename, partial capture) is subtracted from cached initializers instead of tripping "is not covered by one declared weight group; export with weights" — the last guard that reuse is byte-complete. New test only covers the draft case. Fix: scope omission to draft/speculative-marked views or the declared --no-mtp drop set; keep the coverage error otherwise.
VERIFIED SOUND (no finding):
- Core signing repair: protection::sign_rewritten_envelope[_with_limit] (protection.rs:1506-1554) refreshes body_digest, re-reads rank bodies via read_rank_body(rank, body_store), signs with sign_envelope. conversion.rs:2190-2317 indexes ranks per deployment once, skips container::ALIGNMENT_PREFIX / reader::EXTERNAL_BODY_PREFIX / reader::MANIFEST when copying, re-emits signed.external_bodies via reader::external_body_tensor, drops metadata before fs::rename (Windows). edit.rs:182-190 uses the same helper. External bodies keep sha256+length validation (protection.rs:451-499, reader.rs:38-54). Container/Access are exact, no marker leakage.
- ReadRing happy/partial-submit bookkeeping; NativeExportStage lock order directory->leases in both retain_payload_leases and close; RankSupervisor join-handle isolation + GIL detach in python.rs; Claimed::claim complement arithmetic; convert_prepared HashMap first-wins == previous .find(); window_host_layout narrow-WDDM placement and overflow rejection (incl. 0x80_0000_0000 full-VA rejection test).
- PersistentWorker.metrics is documented (helios/manifest.md:106-112) and consumed (helios/src/runtime_core/serving.rs:130, runtime_core/mod.rs:1272, proto runtime_core.proto:839-841), so binding.rs's resolution makes the exporter match the ABI; the new both-or-neither hard error is a new export failure mode for half-set inputs.
CLAIM/EVIDENCE ACCURACY:
- All reported test totals were collected on origin/main 8da73911, NOT head e029dc8 (description says so); CI failing on head; zero reviews/comments/labels.
- No end-to-end benchmark for the performance half (capture skip, DirectRing reuse, hash removal, Claimed complexity) — charter #210 unmet; description admits "not benchmarked end-to-end".
- Live VRAM/WDDM/multi-host GPU paths unrun (all 16 GPUs occupied, CUDA_ERROR_OUT_OF_MEMORY); Windows IoRing paths unexercised on Linux.
- New cross-language/behaviour changes with no docs: host_extent snapshot key (allocator.rs flare_core_snapshot <-> core_storage.py:103), --reuse-weights --no-mtp acceptance, transfer sha256 semantics.