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/.