#1 [high] Research summary
Review of #609 (correctness / contracts / system-level lens). I opened every changed file plus its direct callers (Engine::tick/quarantine, conn::shutdown/attach, Engine::memory, MemoryStore::close, AsyncCompressor, DiskStore::close, Offload::close, the manager's pass::run callers in pool/mp.rs and pool/store_bridge.rs, eos::completion::Queue::attach, and the ReadAhead/Ring Windows paths). Four defects found, one of them a real contract regression; several other strands check out clean.
Findings
- Major —
CompositeStore::closenow destroys its journals even when a tier fails to close, contradicting its own doc comment (selene/src/composite.rs:1602-1626). The doc still promises "An error leaves ownership intact until their transfers can be drained", but the new unconditional clear runs before the error is returned:
let disk = self.disk.close();
let memory = self.memory.close();
self.outbound.clear();
self.parked.clear();
self.inbound.clear();
self.jobs.clear();
self.stale.clear();
disk.and(memory)
Before the change self.disk.close()?; self.memory.close()?; returned early on any failure, leaving outbound/inbound/jobs/parked/stale populated so a later drain could settle them — which is exactly what the doc comment, and MemoryStore::close's own pool.leak()/forget failure idiom, depend on. Impact: on a close failure the outstanding-copy bookkeeping needed to prove quiescence is gone while MemoryStore::close may have deliberately leaked the slab pool and forgotten the compressor, so nothing can ever reconcile them; the composite also reports outbound_in_flight==0 afterwards. Fix: clear only on disk.is_ok() && memory.is_ok(), or clear after a successful re-drain.
- Major —
disk.and(memory)silently discards the new memory-tier error when both tiers fail (selene/src/composite.rs:1626vsselene/src/memory.rs:3108-3116).Result::andkeeps only the receiver's error, so the brand-new operator-facing message
return Err(Error::new(
"host KV compression did not finish before close",
));
is dropped whenever disk.close() also failed. That is precisely the case in which an operator most needs it (a leaked, pool.leak()ed memory tier with a forgotten compressor). Fix: fold both messages into one error.
- Major —
LocalRegions::ptr_mutis a safe function that hands out a writable pointer with no safety contract, while the pre-existingbytesisunsafefor the same kind of access (selene-manager/src/regions.rs:59-66, cf.:68-80). The new scatter path then does raw writes through it:
pub fn ptr_mut(&self, region: Region, offset: u64, length: u64) -> io::Result<(*mut u8, usize)> {
self.range(region, offset, length)
}
bytes requires "The caller must own the range exclusively while the slice lives"; ptr_mut states nothing, yet selene-manager/src/data/channel.rs:934-942 writes into it and the new test bytes_read_allows_overlapping_shared_views (regions.rs:132-146) establishes that overlapping views of the same bytes are the expected norm. bytes_read's own contract ("No writer may mutate the range while the slice lives", regions.rs:44-46) is therefore unenforced on both sides: safety now rests entirely on the store leasing disjoint windows, which LocalRegions neither checks nor documents. Impact: the aliasing class of UB the PR sets out to remove is moved from &mut [u8] to raw pointers, with the compiler's unsafe marker removed from one half. Fix: make ptr_mut unsafe fn with the disjointness/lifetime contract, mirroring bytes.
- Minor —
conn::shutdown's new quarantine turns an orderly shutdown timeout into permanent retention plus aDisabledstatus, and nothing documents it (selene/src/pool/conn.rs:216-223). Previously the engine quarantined only whensess.is_none()anddrain_startedhad expired (selene/src/pool/engine/mod.rs:538-544), so a session still open atCLOSE_TIMEOUTnever took that path; the new call does, andEngine::quarantine(mod.rs:549-573, nowpub(crate))mem::forgetssess.regions,Attachment::Shm{regions}andnet, then setsPoolStatus::Disabled("a copy could not be drained; memory is quarantined"). Intended by the PR's thesis, but it is an operator-visible change (manager arena/staging and data-channel staging held for process life on a slow rather than failed shutdown) absent from the description. Fix: document it, and note it in the shutdown path's error text.
Checked and sound (no finding): the MemoryStore/Resources field reordering is genuinely correct because AsyncCompressor::drop waits on the active counter (memory.rs:2043-2054) and Announce/DiskThread joins, all now before core/pool unmaps; the ActiveGuard (memory.rs:2024-2038) closes a real hang (a panic in encode_host_task used to leave the counter up and block that condvar wait forever); MemoryStore::close's leak/forget/first-error ordering is consistent; the Arc<Region> re-plumbing in net.rs/rdma.rs fixes a real by-field-order hazard for a forgotten Device (rdma.rs:103-110); scatter_disjoint's bounds are enforced by check and its per-rank offsets are disjoint by construction in SliceLayout::new; and the Windows attach in ReadAhead::start (disk.rs:2032-2035) occurs before the ring moves into the thread and mirrors the two existing disk-ring attaches (disk.rs:986-990, 1296-1300), with flare_eos::direct_file already setting FILE_FLAG_OVERLAPPED.
Claim accuracy / tests: the relaxed offload/tests.rs:659 assertion is legitimate, not lost coverage — with fail == Some(0) a reverted short-circuit would still produce [0] and fail the new expectation. Real gaps: scatter_disjoint has only a single-threaded 3-rank test (selene/src/shared/slice.rs:446-462), ptr_mut only negative bounds asserts (regions.rs:127-128), and there is no concurrent reader/writer test for the aliasing fix at all. "Zero latency or parity regression" carries no numbers, and the named 28/28 CUDA evidence is a helios::offload:: suite this PR does not touch. No metric/rate/admission span is sampled or re-scoped anywhere in the diff.
#2 [high] PR #609 correctness-lens findings (verified in files)
Lens: correctness / contracts / system-level consequences. All citations from the PR head (304dd3a) files opened directly.
FINDING 1 — Major — CompositeStore::close clears journals even when a tier close fails, contradicting its own doc.
selene/src/composite.rs:1602-1626. Doc at 1602-1604 still says: "/// [CLOSE_TIMEOUT], then drain the disk and memory tiers. An error leaves ownership intact until their transfers can be drained."
Body now:
let disk = self.disk.close();
let memory = self.memory.close();
self.outbound.clear();
self.parked.clear();
self.inbound.clear();
self.jobs.clear();
self.stale.clear();
disk.and(memory)
Before: self.disk.close()?; self.memory.close()?; — early return left outbound/inbound/jobs/parked/stale populated for a later drain. Impact: on close failure the bookkeeping needed to prove quiescence is gone while MemoryStore::close may have pool.leak()ed + forgotten the compressor (memory.rs:3104-3116), so nothing reconciles them; composite then reports outbound_in_flight==0. Fix: clear only when disk.is_ok() && memory.is_ok().
FINDING 2 — Major — disk.and(memory) drops the new memory error when both fail.
selene/src/composite.rs:1626 vs selene/src/memory.rs:3108-3116 (return Err(Error::new("host KV compression did not finish before close"))). Result::and keeps only the receiver error → the new operator-facing message is lost exactly when disk also failed (leaked pool + forgotten compressor). Fix: fold both messages into one error.
FINDING 3 — Major — ptr_mut is a safe fn handing out a writable pointer, while sibling bytes is unsafe for the same class of access.
selene-manager/src/regions.rs:59-66:
pub fn ptr_mut(&self, region: Region, offset: u64, length: u64) -> io::Result<(*mut u8, usize)> {
self.range(region, offset, length)
}
vs unsafe bytes at :68-80 ("The caller must own the range exclusively while the slice lives"). bytes_read's contract at :44-46 ("No writer may mutate the range while the slice lives") is unenforced on both sides. Used for raw writes at selene-manager/src/data/channel.rs:934-942; test bytes_read_allows_overlapping_shared_views (regions.rs:132-146) establishes overlapping views are normal. Impact: the aliasing UB class is moved from &mut [u8] to raw pointers and one half loses the unsafe marker; safety rests entirely on the store leasing disjoint windows, which LocalRegions neither checks nor documents. Fix: make ptr_mut unsafe fn with the disjointness/lifetime contract.
FINDING 4 — Minor — conn::shutdown's new quarantine turns an orderly-shutdown timeout into permanent retention + Disabled status, undocumented.
selene/src/pool/conn.rs:216-223: } else { engine.quarantine(); Err(Error::new("the pool could not drain its transfers at close")) }. Previously Engine::quarantine fired only when sess.is_none() and drain_started expired (selene/src/pool/engine/mod.rs:538-544), so a session still open at CLOSE_TIMEOUT never hit it. Engine::quarantine (mod.rs:549-573, now pub(crate)) mem::forgets sess.regions, Attachment::Shm{regions} and net, then sets PoolStatus::Disabled("a copy could not be drained; memory is quarantined"). Impact: manager arena/staging + data-channel staging held for process life on a slow not failed shutdown; absent from the PR description. Fix: document, and mention retention in the shutdown error text.
VERIFIED SOUND (state plainly, do not invent issues):
- Field reordering is genuinely correct: AsyncCompressor::drop waits on the active counter (memory.rs:2043-2054), Announce::drop joins its hasher (memory.rs:1880-1884), DiskThread::drop joins (disk.rs:464-470). Both MemoryStore (memory.rs:2238-2250) and disk_store::Resources (disk_store.rs:206-226) now put transfers before core/pool.
- ActiveGuard (memory.rs:2024-2038) closes a real hang: a panic in encode_host_task used to leave the counter up and block that condvar wait forever.
- MemoryStore::close ordering (memory.rs:3095-3119) is consistent: compressor_busy computed, transfers closed, pool leaked on closed.is_err()||compressor_busy, then closed?, then forget(compressor)+Err.
- net.rs/rdma.rs Arc re-plumbing fixes a real by-field-order hazard for a forgotten Device (rdma.rs:103-110 forgets self.device.clone()); Staging.rdma stays declared first (net.rs:60-69).
- scatter_disjoint bounds are enforced by check (slice.rs:141-149) and per-rank offsets disjoint by construction in SliceLayout::new (slice.rs:46-86); packed length checked (slice.rs:224-226).
- Windows ReadAhead::start attach (disk.rs:2032-2035) happens before ring moves into the thread (disk.rs:2042-2045) and mirrors disk.rs:986-990 and 1296-1300; flare_eos::direct_file already sets FILE_FLAG_NO_BUFFERING|FILE_FLAG_OVERLAPPED (eos/src/windows.rs:115-124); Queue::attach = CreateIoCompletionPort (eos/src/completion.rs:49-54).
- Engine::tick quarantine gate (mod.rs:533-545) and conn::drain (conn.rs:185-188) do not double-quarantine.
TEST / CLAIM GAPS:
- The relaxed offload/tests.rs:659 assertion is LEGITIMATE, not lost coverage: loop is
for fail in [None, Some(0), Some(1)]filtered to exclude Some(1) when warm==0 (offload/tests.rs:618-622), so with fail==Some(0) a reverted short-circuit yields order [0] and the new expectation [1,0] still fails. Say so plainly. - scatter_disjoint tested only single-threaded, 3 ranks (selene/src/shared/slice.rs:446-462); ptr_mut has only negative bounds asserts (regions.rs:127-128); no concurrent reader/writer test of the aliasing fix anywhere.
- "Zero latency or parity regression" has no numbers; the 28/28 CUDA evidence is helios::offload:: — a suite this PR does not touch.
- No metric/rate/admission span is sampled or re-scoped anywhere in the diff (metric-span check: nothing to report).