#1 [high] PR #496 overview: coalesced Selene disk reads — evidence and architecture
PR #496 "Coalesce shared ancestor reads across concurrent Selene disk fetches" by FujitsuPolycom, head f9c9191, base main, 2 files +2808/-914 (selene/src/disk_store.rs +2803/-913; docs/prefix-cache-offload.md +5/-1). Only comment is the autobot case-file notice; no human review yet.
What: splits Staged's read path — caller-owned host reads (read_into, host_inbound) stay private/unchanged; GPU restores (fetch, pump_device_inbound) share one disk-thread file handle per (path, expected Header) and one staged window per (path, header, first, count, row); segments are sliced on 64-page WINDOW_PAGES file boundaries (plan_aligned_windows) so restores with different skip_pages produce identical suffix windows; windows are ref-counted (disk_referenced/upload_referenced/followers); last user waits for close (settled) before Fetched.
Evidence: benchmark table on GB10 SM121 single-pass flare run vs main 425ab2d4, physical NVMe bytes 18,026->4,286 MB (4.21x), 18,093->4,563 (3.97x), Flash-Next 7,944->1,981 (4.01x), 3.54x, 2-host RoCE 4.04x/3.45x, DeepSeek TP4 1.00x; TTFT medians reported. Unit suites at c0c4f798 (474 tests), 7 coalescing tests also on Windows IOCP. Live SM121 checks include the Qwen3.8-27B TP1 61.3K regression 8/9 -> 7/9. Description discloses: benchmark measured BEFORE the linear demand-index and close-count edits; single-pass SM121 runs not repeated after edits.
Scope verdict (architecture lens): belongs — charter "What gets merged" allows a measured performance issue; AGENTS.md:165-166; goal "Store prefix-cache checkpoints in host memory and share them across Flare instances via Selene". No new flags/env/knobs, no format/Header change, no per-model branch, failure isolation preserved (private errors fail one restore; shared record_read errors fail all attached after drain, TransportEvent::Fetched still routes record_read to index.drop_row).
#2 [high] Finding: logical vs physical bytes conflated -> inbound_rate inflation
selene/src/disk_store.rs: SharedWindow.read_bytes accumulates physical reply bytes once per window (:1530 win.read_bytes += reply.bytes, init :1979); every follower completing an upload adds the WHOLE window to its own record (:1829 record.bytes += win.read_bytes). Per-record bytes become the Ok payload of TransportEvent::Fetched (:2235 None => Ok(record.bytes)), consumed in DiskStore::apply as self.stats.bytes_in += bytes (:3626) and self.inbound_rate.observe(*bytes, job.started.elapsed()) (:3628).
Why it matters: inbound_rate is an input to admission, not just a stat. DiskStore::hit uses bytes as f64 / self.inbound_rate.get().max(1.0) for estimated_seconds (:3587); selene/src/store.rs:423-438 worth_fetching/worth_transfer compares it to prefill cost; consumers helios/src/server/runtime.rs:2772 and helios/src/server/metrics.rs:532. Under a coalesced burst the rate sample divides ~logical bytes by ~4x shorter physical elapsed time, inflating inbound_rate by roughly the fan-out (PR's own table: 4.21x, 3.97x, 4.01x). A later lone restore that will NOT be coalesced is then under-priced and may be fetched when prefill was cheaper. Also stats.bytes_in shows no reduction at all, so the headline physical-read win is invisible in operator counters; docs/prefix-cache-offload.md:1501-1502 defines "Inbound latency" and "Copy-out bandwidth" as coming from store counters.
Fix direction: observe the rate from physical window bytes (count a window once at window/segment completion), keep bytes_in as logical restored bytes and document the distinction; add a test comparing StoreStats.inbound_rate for 1 vs 8 concurrent restores of the same prefix against measured device bytes.
#3 [high] Finding: unexplained accuracy regression 8/9 -> 7/9 at 61.3K
PR #496 description "Live SM121 checks": Qwen3.8-27B-NVFP4 TP1, 9-fact numerical retrieval, temperature=0, cold-VRAM restart: main 9/9 at 30.1K, and at 61.3K main 8/9 (or 8/9->7/9 on the retrieval prompt) vs THIS PR 7/9. Everything else claimed byte-exact (DeepSeek TP4 9/9 at 23.1K/47.1K). No conclusion offered ("recipe-clamped").
Why it matters: it is the only end-to-end check exercising the shared-window fan-out on a real model, and it is the one that got worse. Deterministic temperature=0 means it is a real answer change unless the harness is noisy. AGENTS.md:106-108 requires explaining differences between runs and keeping material failures visible.
Possible defect sites if real: plan_aligned_windows offset/count mapping for a follower whose first page is not 64-aligned (selene/src/disk_store.rs:700-738), and the trailing partial chunk / row flag (row && chunk_end == end, :730). Suggested test: follower attaches to an already-created shared window with non-64-multiple skip_pages plus a shared final partial chunk, asserting byte-exact device pages/row vs the private path.
Fix requested: re-run the 61.3K prompt N times on both revisions and report variance/name the differing fact and the conclusion, or move the check under "Not covered" as inconclusive. Severity: should fix (may collapse to a description fix).
#4 [high] Findings: docs §2.4 overstates mechanism, stale signatures, misplaced rustdoc
-
docs/prefix-cache-offload.md:337-342 (+5/-1). New sentence: "Concurrent
fetchjobs reading the same record file share one open file handle and coalesce aligned 64-page windows while staged so one disk read fans out to each attached fetch's GPU upload before its staging slots are released; caller-ownedread_intoreads run independently." Missing: (a) the two material limits the PR description itself discloses — a window already released before a later arrival attaches is read again, and skip_pages % WINDOW_PAGES != 0 splits up to one extra partial window (AGENTS.md:194-199 material limitations); (b) the invariant that licenses sharing (records immutable + pinned in DiskStore for the life of every restore) — design-review principle 16 "no hidden context"; it exists only in the PR conversation. (c) "aligned 64-page" doesn't say aligned to what: absolute file page boundaries (they're WINDOW_PAGES, defined at docs:85 / referenced at docs:398 "windows of at most 64 pages plus the multi-slot row"). (d) Same paragraph keeps stale signatureswrite_from(key, metadata, buffers)/read_into(key, buffers); actual signatures are write_from(id, header, temporary, path, pages, row, sums) at selene/src/disk_store.rs:1242-1251 and read_into(id, path, expected, first_page, pages, row) at :1268-1276 (pre-existing, but the sentence is being edited). (e) One 60-word sentence carries three behaviours; repo doc style elsewhere is one behaviour per sentence (compare docs:328-336). Also failure-scope (shared open/read error fails all attached; private child/upload error fails one) is in the PR body but not in §2.4 or the §2.12 invariants list (docs:853). -
Module doc selene/src/disk_store.rs:14-24: says "at most [
WINDOWS_IN_FLIGHT] windows of one record staged at a time" and "Nothing here waits", but device restores now hold shared windows past their own completion until followers finish and can be complete-but-not-reported while waiting for seg.settled() (:2221-2232). Header should state the two-window credit, follower sharing, and settle-before-Fetched. -
Misplaced rustdoc selene/src/disk_store.rs:228-234: the comment for
Resources::allocate("Slots forpagespage records and, whenrow, all row pieces;Noneleaves the pool unchanged...") now sits abovefree_slots, which takes no arguments — published docs are wrong andallocate(the subtle all-or-nothing contract) is undocumented. On main the comment is aboveallocate(main selene/src/disk_store.rs:216-218). Fix: move it back; give free_slots a one-liner.
#5 [high] Findings: duplication, unnamed window key, per-pump cost, redundant state, counters
A) plan_aligned_windows (selene/src/disk_store.rs:700-738) duplicates plan_windows (:670-695): same signature impl IntoIterator<Item=(u32,usize,bool)> -> Vec<WindowPlan>, same WindowPlan fields, same row-on-last-window and pages==0/row-only rules; only difference is chunk end clamped to ((cursor / WINDOW_PAGES) + 1) * WINDOW_PAGES (:721-722). Identical output when first is aligned — i.e. the divergence is exactly the misaligned-skip_pages case the new tests cover. selene/src/memory.rs:1333-1367 windows() is a third expression of the same splitter policy. Charter line: "look for the smallest footprint in shared code". Fix: give plan_windows an alignment parameter and delete the copy (or use plan_aligned_windows for read_into too — the only test asserting host split points is windows_split_segments_at_the_window_size_and_carry_the_row_last at :6221-6253).
B) Shared-window identity re-expressed five times, never named: acquire_shared_segment lookup (:1368-1373), find_reusable_window field compare (:1578-1583), demand map key (PathBuf,u32,usize,bool) + inner Vec<(Header,usize)> linear scan in build_pending_demand (:1647-1679), same key rebuilt in pick_next_pending_plan (:1705-1718), and twice in the decrement blocks (:1890-1899, :1996-2006). Header derives PartialEq/Eq only, no Hash (selene/src/shared/record.rs:136-154). Fix: one WindowKey { path: Arc<Path>, expected/digest, first, count, row } next to SharedWindowId/SharedSegmentId (:1000-1003).
C) Per-pump alloc + quadratic scan in the attach path: PathBuf clone per pending plan (:1668), per candidate in pick_next_pending_plan (:1710), again in both decrement blocks; find_reusable_window scans every shared_windows value per pending plan (:1576-1599) and is called from find_best_existing_window_for (:1602-1624) inside the attach loops. The PR itself adds the indexed precedent (pending_page_reads, :1030). Fix: HashMap<WindowKey, SharedWindowId> beside shared_windows, and store shared segment id / Arc in DeviceSegmentRef (:1108-1113) instead of PathBuf.
D) attach loop written twice + credit check three times: Pass 2 (:1845-1861) and Pass 4 (:1874-1903) duplicate the same needs_credit closure (record.error.is_none() && record.active.len() < WINDOWS_IN_FLIGHT, :1847-1852 and :1876-1881, again inline at :2122-2124) and the find_best_existing_window_for+attach_existing_window loop; Pass 4 only adds the demand decrement. Fix: fn has_window_credit(&self, id) -> bool and fn attach_pending(&mut self, id, demand: Option<&mut Demand>) -> bool.
E) Smaller-than-needed state: host inbound modelled as Vec with always-zero index (Owner::HostInbound(id, usize) :258, read_into inserts Owner::HostInbound(id,0) :1285, single-element vec :1293-1294, apply_disk tolerates missing segment :799-801, pump loops :875/892/978) → single Segment + Owner::HostInbound(JobId) removes Segment::reads_left (:649, decremented :832, compared :877 where self.done == self.plans.len() at :892 already covers it). PlanState::Done (:1093-1098) is never branched on — every read is != Pending (:1606, :1660, :1698) or == Pending (:1796); Done is only assigned (:1833) — a started: Vec would do. SharedWindow duplicates segment identity: path/expected (:1073-1074) repeat SharedSegment.path/expected (:1024-1025) and are compared at :1582-1583 plus cloned per window at :1966-1967; comparing win.segment == seg_id would drop both fields. Also SharedWindow.id/SharedSegment.id duplicate their HashMap keys (:1071 vs :1961).
F) Test-only counters: disk_opens/disk_window_reads/coalesced_windows fields on always-compiled Resources with #[cfg_attr(not(any(test, feature="test-support")), allow(dead_code))] (:192-200; the only three uses of that attribute in selene/src — verified by search). Crate convention is to compile the whole member out: selene/src/disk.rs:104-116 Faults under #[cfg(any(test, feature="test-support"))]. Accessors already gated (:1213-1236). They also exist outside StoreStats (selene/src/store.rs:185-244), the crate's declared home for counters; StoreStats has disk_records/disk_bytes/inbound_rate/outbound_rate but no physical-open or coalesced-window counters, and docs:1501-1502 gates qualification on store counters. Fix: gate the fields; consider a follow-up adding disk_opens/coalesced_windows to StoreStats.
#9 [high] DELIVERABLE: full report for PR #496
========================================================= FULL REPORT — PR #496 (head f9c9191, base main, +2808/-914)
BLOCKERS
- Resolve the 61.3K deterministic retrieval result before merge.
- Finding: the PR's own "Live SM121 checks" report Qwen3.8-27B-NVFP4 TP1 at 61.3K scoring 8/9 on main and 7/9 with this change, on a 9-fact numerical retrieval prompt at temperature=0 after a cold-VRAM restart, while DeepSeek TP4 is 9/9 at 23.1K and 47.1K. No conclusion is drawn beyond "recipe-clamped".
- Request: repeat the 61.3K prompt several times on main and at head f9c9191 and report the variance and the differing fact; if the gap holds, fix it before merge; if it is harness or recipe-clamp noise, say so explicitly and move the check under "Not covered" as inconclusive.
- Why: it is the only end-to-end check that exercises the shared-window fan-out on a real model, and it is the one that got worse. A real defect would live in plan_aligned_windows' chunk/offset mapping for a follower whose first page is not 64-aligned (selene/src/disk_store.rs:700-738) or in the trailing partial chunk's row flag (:730). Cheapest guard if it does not reproduce: a test where a follower attaches to a window another restore created, with a non-64-multiple skip_pages and a shared final partial chunk, asserting byte-equal device pages and row against the private path. (AGENTS.md:106-108: explain differences between runs, keep material failures visible.)
SHOULD FIX
- Coalesced reads double-count bytes into the measured inbound rate, which prices future restores.
- Finding: a window accumulates its physical reply bytes once (:1530
win.read_bytes += reply.bytes, init :1979), but every follower adds the whole window to its own record (:1829record.bytes += win.read_bytes). That per-record count is the success payload of TransportEvent::Fetched (:2235), which feedsstats.bytes_in += bytes(:3626) andinbound_rate.observe(*bytes, job.started.elapsed())(:3628). Under a coalesced burst the sample divides ~logical bytes by a ~4x shorter physical elapsed time, so inbound_rate inflates roughly with the fan-out (the PR's own 4.21x/3.97x/4.01x). inbound_rate is not a statistic: DiskStore::hit prices restores atbytes / inbound_rate(:3587) and worth_fetching/worth_transfer gate admission on it (selene/src/store.rs:423-438; consumers helios/src/server/runtime.rs:2772, helios/src/server/metrics.rs:532). A later lone restore that will not be coalesced is then under-priced and may be fetched when prefill was cheaper. Symmetrically, stats.bytes_in shows none of the 4.21x physical-read win, and docs/prefix-cache-offload.md:1501-1502 defines "Inbound latency"/"Copy-out bandwidth" as store-counter measurements. - Request: observe the rate on physical window bytes — one sample per window (or per segment) at its own completion, with the window's own start time — and keep
bytes_inas the logical restored-byte counter, documenting the distinction in §2.4 and §4. Add a test that compares StoreStats.inbound_rate for 1 vs 8 concurrent restores of the same prefix against measured device bytes, and one asserting bytes_in is unchanged by coalescing. - Why: otherwise the performance policy that decides whether to restore at all is measured on a quantity the change makes non-physical, and only a test can pin the size of the error.
- Docs and rustdoc overstate the mechanism and drop the invariant that licenses it.
- Finding (docs/prefix-cache-offload.md:337-342): the new sentence says concurrent fetches "share one open file handle and coalesce aligned 64-page windows…" with (a) neither of the two limits the PR description itself discloses — a window already released before a later arrival attaches is read again, and skip_pages % WINDOW_PAGES != 0 now splits up to one extra partial window; (b) not the invariant that makes sharing safe — published records are immutable and pinned for the life of every restore (it exists only in the PR conversation); (c) "aligned 64-page" without saying aligned to absolute file page boundaries, and "64" instead of WINDOW_PAGES; (d) stale signatures
write_from(key, metadata, buffers)/read_into(key, buffers)where the real ones are write_from(id, header, temporary, path, pages, row, sums) (selene/src/disk_store.rs:1242-1251) and read_into(id, path, expected, first_page, pages, row) (:1268-1276); (e) one 60-word sentence carrying three behaviours where the section's style elsewhere is one behaviour per sentence. Also failure scope (shared open/read error fails every attached restore; private child/upload error fails one) belongs in §2.4 or the §2.12 invariant list (docs:853). - Finding (module doc selene/src/disk_store.rs:14-24): the header now describes sharing but still claims windows are bounded to "at most WINDOWS_IN_FLIGHT windows of one record staged at a time" and "Nothing here waits", while device restores run out-of-order plans over reference-counted windows that stay staged past their own completion and can be complete-but-not-reported while waiting for seg.settled() (:2221-2232).
- Finding (selene/src/disk_store.rs:228-234): the rustdoc for Resources::allocate ("Slots for
pagespage records and, whenrow, all row pieces;Noneleaves the pool unchanged…") now sits above the newly inserted free_slots, which takes no arguments; the published docs describe the wrong function andallocate, whose all-or-nothing contract is the subtle one, is undocumented. On main the comment is above allocate (main selene/src/disk_store.rs:216-218). - Request: state the two disclosed limits and the immutability+pin invariant, name WINDOW_PAGES at the point the alignment rule is introduced, fix the two signatures, split the sentence; rewrite the two module-doc claims (two-window credit, follower sharing, settle-before-Fetched); move the allocate comment back and give free_slots its own one-liner.
- Why: AGENTS.md:194-199 and design-review principle 16 require material limitations and the safety invariant in the specification of record, not only in the PR thread; a misplaced rustdoc ships a wrong contract.
- Tie the benchmark to the code under review, and stop presenting expected costs as results.
- Finding: the table was measured before the linear demand-index and close-count edits now at head; the only notice is a parenthesis in the setup line, and the "Not covered" bullet repeats it in a different emphasis. Those edits change pass-2 demand attach ordering — exactly what produces shared windows. Separately, "Existing users pay per-pump demand indexing when free slots exist and at most one extra window split when skip_pages % 64 != 0" sits at the end of Result with no measurement, and overstates it: build_pending_demand returns an empty table before doing any work when device_inbound.len() <= 1 (:1651-1653), so the cost applies to multi-fetch pumps only.
- Request: re-run one TP1 simultaneous and one staggered trial at head (or state plainly that the numbers are from an earlier commit and that head differs only by demand-index bookkeeping and close accounting), and label the cost sentence as an expected, unmeasured bound with the single-fetch fast path noted.
- Why: AGENTS.md:95-96 and :103-112 — separate expectation from measurement, and connect each claim to the artifact actually tested.
- One window planner, one window identity.
- Finding: plan_aligned_windows (:700-738) is plan_windows (:670-695) with a single added clamp (
chunk_end = end.min(((cursor / WINDOW_PAGES) + 1) * WINDOW_PAGES), :721-722): same signature, same output type, same row-on-last-window and row-only rules, and identical output wheneverfirstis aligned — the divergence is exactly the misaligned skip_pages case the new tests cover. memory.rs:1333-1367 windows() is a third expression of the same policy. Separately the sharing key (path, expected Header, first, count, row) is re-expressed by hand five times — segment lookup in acquire_shared_segment (:1368-1373), field matching in find_reusable_window (:1578-1583), the demand map key plus an inner Vec<(Header, usize)> scan in build_pending_demand (:1647-1679), the same key rebuilt in pick_next_pending_plan (:1705-1718), and twice in the demand decrement blocks (:1890-1899, :1996-2006) — while the PR already names the other two layers (SharedSegmentId :1000, SharedWindowId :1003). Header derives PartialEq/Eq but not Hash (selene/src/shared/record.rs:136-154), which is why there is a linear scan. - Request: fold the aligned split into plan_windows behind an alignment parameter (or use plan_aligned_windows for read_into too; the only test pinning host split points is windows_split_segments_at_the_window_size_and_carry_the_row_last, :6221-6253) and delete the copy; introduce one WindowKey type next to SharedWindowId with a Hash-able header identity, and keep HashMap<WindowKey, SharedWindowId> beside shared_windows plus HashMap<WindowKey, usize> for demand; store the shared segment id or Arc in DeviceSegmentRef instead of PathBuf.
- Why: charter line 9 ("smallest footprint in shared code") and design-review principle 8 — five hand-written copies of the predicate that decides whether two restores may share a window is how a follower ends up attached to the wrong expected header. It is also the enabling change for the next item.
- Remove the per-pump allocation and quadratic scan in the attach path, and the duplicated attach loop.
- Finding: build_pending_demand clones a PathBuf per pending plan (:1668) and a Header per bucket push (:1674); pick_next_pending_plan clones the path per candidate plan (:1710) and so do both decrement blocks (:1890, :1996); find_reusable_window scans every value in shared_windows (:1576-1599) for every pending plan and is called from find_best_existing_window_for (:1602-1624) inside the attach loops — an allocation and an O(windows x plans) scan per pump in ordinary multi-fetch serving, which the PR itself avoids elsewhere with the pending_page_reads index (:1030). Pass 2 (:1845-1861) and Pass 4 (:1874-1903) also run the identical needs_credit predicate (
record.error.is_none() && record.active.len() < WINDOWS_IN_FLIGHT, repeated at :1847-1852, :1876-1881 and inline at :2122-2124) and the identical find_best_existing_window_for + attach_existing_window loop, differing only in Pass 4's demand decrement. - Request: with WindowKey in place, index windows and demand so the lookups are hashes and the clones are refcount bumps; extract
fn has_window_credit(&self, id) -> boolandfn attach_pending(&mut self, id, demand: Option<&mut Demand>) -> booland call them from both passes and the Pass 5b credit check. - Why: the description concedes the per-pump indexing cost; the implementation pays more than the description claims, and a single credit predicate cannot drift the way two copies can (AGENTS.md:188-193 is satisfied by removing this cost, not by adding to it).
- Record the design decision for the new shared inbound lifecycle.
- Finding: the change replaces Staged's single inbound lifecycle — the invariant that made "Nothing here waits" true — with two (host vs device) inside shared cache policy: five new lifecycle types, a five-state file machine, two reference counts per window, out-of-order plan completion and a "close only when settled" rule (:1000-1160, :2205-2255). AGENTS.md:204-206 asks for an explicit maintainer decision before changing an invariant like this, and the PR does not discuss the main alternative.
- Request: get a recorded maintainer sign-off on doing the coalescing inside Staged rather than inside the disk thread (which already owns the file handle), or the author's justification for preferring Staged; keep the rest of the change as is.
- Why: the technical content is sound in review, but a change of this shape to shared cache invariants should rest on a design decision rather than on review-time inference.
NITS
- Staged::close under-reports abandoned work (selene/src/disk_store.rs:2485-2489 vs busy() :2344-2351). It sums the four job pipelines then takes
.max(usize::from(self.busy())), and busy() is also true for a non-empty shared_segments, shared_windows or owners — a leaked window or segment alone reports "1 disk transport jobs did not complete". The old code counted owners.len() (main selene/src/disk_store.rs:1419). Count owned disk jobs, or reword the message to what is counted. - The three new counters are compiled into release behind
#[cfg_attr(not(any(test, feature = "test-support")), allow(dead_code))]on the fields (:192-200) while their accessors are already cfg-gated (:1213-1236); the only three uses of that attribute in selene/src. The crate's convention is to compile the member out (selene/src/disk.rs:104-116 Faults). Gate the fields and increments the same way. Related: disk_opens / disk_window_reads / coalesced_windows live outside StoreStats (selene/src/store.rs:185-244), the declared home for counters that docs:1501-1502 gates qualification on — worth a follow-up adding disk_opens and coalesced_windows there. - GatedCopier returns a positional four-tuple of Arc<Mutex<..>> handles that every call site destructures (:8059-8064, :8364, :8488, :8608), where the crate's fixtures in selene/src/testing.rs (StoppedCopier :178, SimulatedGpu :225) return named two-element pairs; six coalescing tests also repeat the same pool/store construction although write_shared_ancestor_tree (:8136) and poll_all_fetches (:8172) already exist. Use a named struct and one store_for_fixture helper.
- Redundant state to drop: PlanState::Done is never branched on — every read is
!= Pending(:1606, :1660, :1698) or== Pending(:1796) and Done is only assigned (:1833), so a started flag suffices. HostInbound is aVec<Segment>of length one with an always-zero index (Owner::HostInbound(JobId, usize) :258, :1285, :1293-1294, tolerant lookup :799-801) — a single Segment and Owner::HostInbound(JobId) removes the index and Segment::reads_left (:649, :832, :877). SharedWindow.path/.expected (:1073-1074) duplicate SharedSegment's (:1024-1025) and are cloned per window (:1966-1967); comparing win.segment would drop both. The id fields on SharedWindow/SharedSegment duplicate their map keys (:1071 vs :1961, :1022). - Naming axis mixing and long-sentence prose: records are named by destination (HostInbound :759, DeviceInbound :1117) but windows by sharing discipline (HostWindow :746, SharedWindow :1070), so a reader must check both axes to pair them (PrivateWindow/SharedWindow or Host/Device); and the new §2.4 sentence carries three behaviours where the surrounding section uses one sentence each.
WHAT WAS CHECKED AND FOUND SOUND (no action)
Slot lifetime and release (single release point sweep_shared_windows :1755-1771; segment removal only when no users and settled :2213-2230; per-test assertions pool.free_slots() == pool.slot_count()); failure isolation (record.fail :1563-1565, fail_segment_users :1449-1473, fail_window :1475-1487, with_record_read :1503/:1540, Fetched still routes record_read to index.drop_row :3634-3640); the host path is behaviourally unchanged (plan_windows :1283, HostWindow slicing :914-923, unwind :976-996); keeping read_into off the shared path is the right call for caller-owned buffers; no existing shared-handle/demand mechanism was duplicated; no record-format, Header, on-disk or re-export change, so existing checkpoint files load unchanged; no flags, env vars, config knobs, cfg-gated production paths or per-model branches, so the AGENTS.md rejection criteria (171-187) are not tripped; the tests exercise real paths (SimulatedGpu byte-exact, counters incremented at the real submit sites) per AGENTS.md:194-199; the 8-pass ordering argument is justified per pass; the size is not churn.
#10 [high] DELIVERABLE: summary report / GitHub post for PR #496
========================================================= SUMMARY REPORT — PR #496 (GitHub post, ≤10 bullets)
Reviewed head f9c9191 against main (+2808/−914, selene/src/disk_store.rs + docs/prefix-cache-offload.md). The approach belongs in the repository (measured, served-workload speedup; no flags, no format change, failure isolation preserved) and the lifetime work is sound. One blocker, then mostly accounting, docs and duplication.
Blockers
- The 61.3K retrieval result must be settled. The PR reports 8/9 (main) vs 7/9 (this PR) on a temperature=0 retrieval prompt at 61.3K. Repeat it a few times on both revisions and report the variance and the differing fact, fix it if it holds, or mark it inconclusive under "Not covered". It is the only end-to-end signal for the fan-out and the only check that got worse; the likely sites are plan_aligned_windows' chunk mapping for non-64-aligned first pages and the trailing partial-chunk row flag.
Should Fix
- inbound_rate is now measured on logical bytes. Each follower credits the whole window to its record (disk_store.rs:1829), so the rate sample divides coalesced-elapsed time into a ~4x larger byte count and
hit()/worth_fetchingthen under-price lone restores. Observe the rate once per physical window, keepbytes_inlogical and document it, and add a 1-vs-8-restore rate test. - Docs claim more than the mechanism and are wrong in two places. §2.4 needs the two limits the description discloses, the immutable+pinned invariant, WINDOW_PAGES file-boundary alignment, and the real
write_from/read_intosignatures; the module doc still says "at most WINDOWS_IN_FLIGHT windows" and "Nothing here waits"; theallocaterustdoc now sits onfree_slots(:228-234). - Tie the benchmark to head and don't state expectations as results. The table predates the demand-index/close-count edits; re-run one simultaneous and one staggered TP1 trial at head (or label the table's commit), and mark "existing users pay per-pump demand indexing…" as an expected bound (it only applies to multi-fetch pumps, :1651-1653).
- One planner, one window key. plan_aligned_windows is plan_windows plus one clamp — fold them; and the sharing key (path, header, first, count, row) is hand-written five times (:1368, :1578, :1647, :1710, :1890/:1996) — name it WindowKey and index it, which also removes the per-pump PathBuf clones and the O(windows×plans) find_reusable_window scan.
- De-duplicate the attach loop and record the design call. Pass 2 and Pass 4 repeat the same credit predicate and attach loop (:1845-1861, :1874-1903) — extract has_window_credit/attach_pending; and get a recorded maintainer decision for putting a second inbound lifecycle (host vs device) inside Staged rather than in the disk thread, which already owns the handle.
Nits
Staged::closecounts shared windows/segments into "N disk transport jobs did not complete" (:2485-2489) — count owned jobs or reword.- The three new counters are ungated
allow(dead_code)fields (:192-200) instead of#[cfg(any(test, feature = "test-support"))]likedisk.rs's Faults; consider surfacing disk_opens/coalesced_windows in StoreStats. GatedCopierreturns a positional four-tuple (:8059) where the crate's fixtures return named pairs; six tests repeat the same fixture construction.- Drop state nothing branches on:
PlanState::Done(:1093, :1833),HostInbound's single-elementVec<Segment>with an always-zero index (:1285),SharedWindow.path/.expectedduplicating its segment (:1073), and id fields duplicating map keys. - Naming mixes axes (HostInbound/DeviceInbound vs HostWindow/SharedWindow); split the new 60-word §2.4 sentence into one behaviour each.
#12 [high] DELIVERABLE (final): summary report / GitHub post for PR #496
========================================================= SUMMARY REPORT — PR #496 (GitHub post, 10 bullets max) Case file: https://autobot.eidonix.com/api/v1/cases/774e16ea-5f84-4ff8-9166-74ab6876cc37.html Head f9c9191 vs main, +2808/−914 (selene/src/disk_store.rs, docs/prefix-cache-offload.md).
Opener (1-2 sentences): The approach belongs in the repo — a measured, served-workload speedup with no new flags, no format change, and failure isolation preserved — and the shared-window lifetime work holds up under review. One thing must be resolved before merge; the rest is accounting, docs and duplication.
Blockers
- Settle the 61.3K retrieval result (or say it is inconclusive). The description reports 8/9 on main vs 7/9 with this change on a temperature=0 retrieval prompt, with no conclusion drawn. Re-run that prompt a few times on both revisions and report the variance and the differing fact; fix it if the gap holds, otherwise mark the check inconclusive under "Not covered". It is the only end-to-end signal for the new fan-out, and the plausible defect sites are narrow: plan_aligned_windows' chunk/offset mapping for a non-64-aligned first page and the trailing partial chunk's row flag.
Should Fix
inbound_rateis now measured on logical bytes and does not self-correct. Each follower credits the whole window to its own record (:1829), so the rate sample divides coalesced elapsed time into a ~4x byte count;hit()prices restores off that rate andworth_fetchinggates on it. Fix: one rate sample per physical window,bytes_instays logical and documented, plus a 1-vs-8-restore test.- Docs and rustdoc claim more than the mechanism. §2.4 needs the two limits the description already discloses, the immutable+pinned invariant,
WINDOW_PAGESfile-boundary alignment, and the realwrite_from/read_intosignatures; the module doc still says "at most WINDOWS_IN_FLIGHT windows" and "Nothing here waits"; theallocaterustdoc now sits onfree_slots(:228-234). - Tie the benchmark to head; do not state expectations as results. The table predates the demand-index/close-count edits — re-run one simultaneous and one staggered TP1 trial at head, or label the table's commit — and mark "existing users pay per-pump demand indexing…" as an expected bound that only applies to multi-fetch pumps (:1651-1653).
- One planner, one window key. plan_aligned_windows is plan_windows plus one clamp (fold them), and the sharing key (path, header, first, count, row) is hand-written five times (:1368, :1578, :1647, :1710, :1890/:1996) — name it
WindowKeyand index it, which also removes the per-pump PathBuf clones and the O(windows×plans)find_reusable_windowscan. - De-duplicate the attach loop; record the design call. Pass 2 and Pass 4 repeat the same credit predicate and attach loop (:1845-1861, :1874-1903) — extract
has_window_credit/attach_pending; and get a recorded maintainer decision for putting a second inbound lifecycle (host vs device) insideStagedrather than in the disk thread that already owns the handle.
Nits
Staged::closecounts shared windows/segments into "N disk transport jobs did not complete" (:2485-2489) — count owned jobs or reword the message.- Gate the three new counters like
disk.rs'sFaults(#[cfg(any(test, feature = "test-support"))], :192-200) instead ofallow(dead_code), and consider addingdisk_opens/coalesced_windowstoStoreStats. GatedCopierreturns a positional four-tuple (:8059) where the crate's fixtures return named pairs; six tests repeat the same fixture construction.- Drop state nothing branches on:
PlanState::Done(:1093, :1833),HostInbound's single-elementVec<Segment>with an always-zero index (:1285),SharedWindow.path/.expectedduplicating its segment (:1073), id fields duplicating map keys. - Naming mixes axes (
HostInbound/DeviceInboundvsHostWindow/SharedWindow); split the new 60-word §2.4 sentence into one behaviour each.
Closing line: Everything else checked out — slot lifetime and release, failure isolation, the unchanged host path, no format or re-export change, real-path tests. Full detail is in the case file.
#13 [high] DELIVERABLE (final, 10 bullets): summary report / GitHub post for PR #496
========================================================= SUMMARY REPORT — PR #496 (GitHub post; hard cap: 10 bullets = 1 blocker + 5 should-fix + 4 nits) Case file: https://autobot.eidonix.com/api/v1/cases/774e16ea-5f84-4ff8-9166-74ab6876cc37.html Head f9c9191 vs main, +2808/−914 (selene/src/disk_store.rs, docs/prefix-cache-offload.md).
Opener: The approach belongs in the repo — a measured, served-workload speedup with no new flags, no format change and failure isolation preserved — and the shared-window lifetime work holds up under review. One thing must be resolved before merge; the rest is accounting, docs and duplication.
Blockers
- Settle the 61.3K retrieval result, or declare it inconclusive. The description reports 8/9 on main vs 7/9 with this change on a temperature=0 retrieval prompt, and draws no conclusion. Re-run it a few times on both revisions and report the variance and the differing fact; fix it if the gap holds, otherwise move the check under "Not covered" as inconclusive (and add a follower-attaches-to-a-partial-aligned-window byte-exactness test, which is the narrow plausible site).
Should Fix
inbound_rateis now measured on logical bytes, and the error does not self-correct. Each follower credits the whole shared window to its own record (:1829), so the rate sample divides coalesced elapsed time into a ~4x byte count;hit()prices restores off that rate andworth_fetchinggates on it, and because the median stays above its seed until three more samples arrive it mis-prices subsequent restores. Fix: one rate sample per physical window,bytes_instays logical and documented, plus a 1-vs-8-restore rate test.- Docs and rustdoc claim more than the mechanism. §2.4 needs the two limits the description already discloses, the immutable+pinned invariant,
WINDOW_PAGESfile-boundary alignment and the realwrite_from/read_intosignatures; the module doc still says "at most WINDOWS_IN_FLIGHT windows" and "Nothing here waits"; theallocaterustdoc now sits onfree_slots(:228-234). - Tie the benchmark to head; do not state expectations as results. The table predates the demand-index/close-count edits — re-run one simultaneous and one staggered TP1 trial at head, or label the table's commit — and mark "existing users pay per-pump demand indexing…" as an expected bound that applies only to multi-fetch pumps (:1651-1653).
- One planner, one window key. plan_aligned_windows is plan_windows plus one clamp (fold them); the sharing key (path, header, first, count, row) is hand-written five times (:1368, :1578, :1647, :1710, :1890/:1996) — name it
WindowKeyand index it, which also removes the per-pump PathBuf clones and the O(windows×plans)find_reusable_windowscan. - De-duplicate the attach loop and record the design call. Pass 2 and Pass 4 repeat the same credit predicate and attach loop (:1845-1861, :1874-1903) — extract
has_window_credit/attach_pending; and get a recorded maintainer decision for placing a second inbound lifecycle (host vs device) insideStagedrather than in the disk thread that already owns the handle.
Nits
Staged::closecounts leaked shared windows/segments into "N disk transport jobs did not complete" (:2485-2489) — count owned jobs or reword the message.- Test hygiene: gate the three new counters like
disk.rs'sFaults(:192-200) instead ofallow(dead_code)and consider surfacingdisk_opens/coalesced_windowsinStoreStats;GatedCopierreturns a positional four-tuple (:8059) where this crate's fixtures return named pairs, and six tests repeat the same fixture construction. - Drop state nothing branches on:
PlanState::Done(:1093, :1833),HostInbound's single-elementVec<Segment>with an always-zero index (:1285),SharedWindow.path/.expectedduplicating its segment (:1073), and id fields duplicating their map keys. - Naming mixes axes (
HostInbound/DeviceInboundvsHostWindow/SharedWindow); split the new 60-word §2.4 sentence into one behaviour per sentence.
Closing: Everything else checked out — slot lifetime and release, failure isolation, the unchanged caller-owned host path, no format or re-export change, and tests that exercise the real path. Full detail and evidence are in the case file.
#14 [high] Research summary
Both deliverables are written to the scratchpad.
Full report (entry 9, with addendum entry 11): Blockers (1) — the PR's own evidence reports 8/9 on main vs 7/9 with this change on a temperature=0 retrieval prompt at 61.3K, undiagnosed; ask for a repeat run and either a fix or an explicit "inconclusive" under Not covered. Should Fix (6) — coalesced logical bytes inflate inbound_rate, which is the divisor DiskStore::hit prices restores with and worth_fetching gates on (Rate keeps the median and only decays below its seed, so the error persists); docs §2.4 and the module doc overstate the mechanism, omit the two limits the description discloses and the immutable+pinned invariant, and keep two non-existent signatures, plus a misplaced allocate rustdoc now on free_slots; the benchmark table predates head and an unmeasured expected cost is stated as a result; plan_aligned_windows duplicates plan_windows and the sharing key is hand-written five times; per-pump PathBuf clones and an O(windows×plans) scan plus a doubled attach loop; and a request for a recorded maintainer decision on placing a second inbound lifecycle inside Staged. Nits (5) — close() under-reports abandoned jobs, test-only counters ungated and outside StoreStats, GatedCopier's positional 4-tuple, dead state (PlanState::Done, single-element Vec<Segment>, duplicated window fields/ids), naming-axis mixing and a 60-word sentence. A "checked and sound" list is included so the author is not asked to change what holds up.
Summary report (entry 13): exactly 10 bullets — 1 blocker, 5 should-fix, 4 nits — each one line of finding plus a tldr request, with a case-file link, an opener acknowledging the change belongs in the repo, and a closing pointer to the case file for evidence. Verdict: not mergeable as is, but close — the design and lifetimes are sound and the remaining work is one unresolved measurement, one accounting fix, docs, and de-duplication.
#15 [high] Limits of this review / open questions the author must answer
Honest scope of the review behind entries 1-13. No compiler, GPU or test run was available: every finding is established from source, not from executing anything. cargo build/test was not run, so the claim that the three allow(dead_code) attributes are unnecessary (nit 2 of the full report) rests on the crate's convention (selene/src/disk.rs:104-116) rather than on a warning-free build; the author can confirm with cargo build --release --manifest-path selene/Cargo.toml.
Not reviewed / not verified:
- The new test module past ~line 8420 in selene/src/disk_store.rs (so follower-attachment assertions are taken from the PR description, not read).
- The #497 interaction: both PRs touch
Staged::pump_all(selene/src/disk_store.rs:2268-2289); merge order ("merge this PR first, then rebase #497") is asserted in the description and not checkable from this branch. - helios GPU-offload path, Windows IOCP serving, discrete PCIe GPUs, live
CompositeStore/PooledStoreGPU serving — none run by the author, none reviewed here beyond the host-path code in disk_store.rs. - Whether
Headercan cheaply gain aHash/digest form (selene/src/shared/record.rs:136-154 derives PartialEq/Eq only) determines whether theWindowKeyrequest is small or structural — a maintainer/author call. - Whether coalescing belongs in
Stagedor in the disk thread (which already owns the file handle) is a maintainer design decision; the PR does not discuss the alternative. - The numeric size of the inbound_rate inflation: code shows the direction and the mechanism (see addendum entry 11), only a 1-vs-8-restore test shows the factor.
- Pending-row-read FIFO matching (
pending_row_reads, :1030-1032, :1512) is correct only if every intendedReadRowis submitted on the same disk id; a dropped submission could stalldisk_outstandingand hitCLOSE_TIMEOUT. Not traced to a conclusion — worth mentioning only if asked.
Three responses the author may give that would close findings cleanly: (a) re-runs showing the 61.3K gap is noise; (b) a maintainer sign-off on the Staged-side lifecycle; (c) confirmation that plan_windows was kept segment-relative for host reads deliberately (a one-line comment would then settle the duplication request).
#18 [high] At head 0c04b1e2: last round's blocker and 5 of 6 should-fixes are resolved
Verified at head 0c04b1e2 (base c0c4f798), 3 files +3358/−933.
RESOLVED — blocker B1 (8/9 vs 7/9 at 61.3K): author re-ran 5 cold-VRAM repeats (seed 1234..1238, 60,534 tokens, top_logprobs=5) against one shared disk checkpoint; main and head produced identical FP32 top-5 logprobs and token IDs on all 5 (6/9, 8/9, 7/9, 9/9, 4/9). Explained: Flare has no greedy temperature=0 (helios clamps into the core's positive sampling range) and the earlier single-pass script used distinct per-build prompt nonces. Added misaligned_follower_attaching_to_shared_partial_tail_and_row_matches_private_restore (byte-equal SimulatedGpu pages/row vs private baseline, skip_pages=13, partial <64 tail + partial leaf chunk with row). PR discussion 2026-11-25 02:41.
RESOLVED — S1 inbound_rate: InboundWindowSample { bytes, elapsed } carries only physical window read_bytes/read_elapsed (disk_store.rs:1596-1620, sample pushed :1617-1620); DiskStore::apply early-returns into self.inbound_rate.observe (:3632-3635) before stats.progress += 1; stats.bytes_in stays logical (:3669); the old per-record observe in the Fetched arm is gone. Test coalesced_restores_keep_inbound_rate_physical_and_bytes_in_logical (1 vs 8, simultaneous + staggered). Docs state the split (docs:362-366, :1528-1531).
RESOLVED — S3 benchmark provenance: table now keyed main c0c4f798 vs 0c04b1e2; costs labelled "As an expected bound" with the device_inbound.len() <= 1 fast path noted; un-rerun multi-host RoCE moved to Not covered.
RESOLVED — S4/S5: plan_windows(segments, align_to_window) (:679-727) replaced the twin splitters; HeaderIdentity/SegmentKey/WindowKey (:1001-1064) + window_index HashMap give O(1) find_reusable_window (:1646-1663); has_window_credit (:1683-1687) and attach_pending (:1711-1730) replaced the duplicated attach loops.
RESOLVED — nits: counters now #[cfg(any(test, feature = "test-support"))] (:200-208, accessors :1279-1295); PlanState::Done → started: Vec<bool>; SharedWindow.path/.expected removed (holds segment+key); allocate rustdoc back on allocate (:241-243) and free_slots has its own line (:236-239); module doc rewritten (:7-27) with per-fetch window credits, follower sharing, close-before-Fetched.
RESOLVED — S6 (partly): the Staged-vs-DiskThread rationale is now argued in the PR Why ("DiskThread sees only file offsets and raw host addresses and finishes once direct I/O and xxh3 complete, whereas shared staging slots must stay pinned until every follower's async Copier upload completes"). Remaining ask is only a maintainer record of the decision (AGENTS.md:204-206), not a code change.
Cross-lens verdict: architecture, simplicity and correctness lenses all report NO blocking findings at this head.
#19 [high] New findings created by this revision (head 0c04b1e2)
-
HeaderIdentityhand-writes Hash (SHOULD FIX). disk_store.rs:1001-1050;impl Hashat :1014-1050 destructures Header with..(:1030) and hashes 14 fields. The equality contract it must track lives in another module:impl PartialEq for Headerat shared/record.rs:136-152 (exhaustive list),impl Eq:154; Header defined :116-134 with privateversionexcluded (:118-119) — correctly excluded here. Adding a Header field → compile error in record.rs but NOT here; the field silently drops out of the hash, two equal headers hash differently,window_index.getmisses, coalescing silently stops — perf regression, no test failure, nothing pins hash/eq agreement. Also the ONLY hand-written Hash in selene/src (crate precedent is derive: PrefixKey vocab.rs:30; RankSizes record.rs:89; DiskRecord disk_store.rs:72; SegmentKey/WindowKey :1052/:1058). Simplicity lens: could hash onlyself.0.key(PrefixKey derives Hash, unique per record); collisions only cost a bucket, PartialEq still compares the whole header. -
TransportEvent::InboundWindowSamplerides the cross-rank completion enum (SHOULD FIX). Enum doc says "Completion the transport reports to the disk store" (:83); every other variant carries a JobId. Consequences: (a)Kind::ofmust panic — shard.rs:476-478unreachable!("window rate samples stay local to rank zero"), whereas the enum's own convention for unrepresentable kinds isErr(invalid(..))(shard.rs:462); (b) that panic is upheld only by two hand-written guards —absorb_localshard.rs:722-725 pushes andcontinues,Peer::forwardshard.rs:1148-1150 drops; (c) the existing test helperevents.sort_by_key(|event| Kind::of(event).1)at shard/tests.rs:339 would panic if a fetch ran in those tests (survives only because they issue stores/unlinks); (d) test helpers must filter it by hand (disk_store.rs:6341) and tests match it out explicitly (:9145). CONCRETE COST:CompositeStore::polldoesself.stats.progress += 1for EVERY transport event before dispatch (composite.rs:1376), and that counter is documented as "Completion and capacity-release events" (store.rs:202) and gates the maintenance pass —maintenance_progress != progress→spill_parked(...)+self.disk.maintain()(composite.rs:1418-1424). Each physical window read now bumps progress and re-runs both, once per window per restore.DiskStore::applydeliberately does NOT bump progress for it (:3632-3636), so the two stores' progress counters diverge. Fix: carry the sample out of band (aStageddrain method, a field onFetched, or a counter the store reads — precedentBudget::progress()input.rs:146-152), and exclude it from composite.rs:1376. -
pick_next_pending_planrestatesLayout::record_slots(SHOULD FIX). disk_store.rs:1766-1777:let layout_row_slots = ...layout().row_slots();let needed = plan.count + if plan.row { layout_row_slots } else { 0 };.record_slots(pages, row)=pages + usize::from(row) * row_slots()exists at geometry.rs:180-182 and is used byResources::allocate(disk_store.rs:245), memory.rs:468, composite.rs:810/:1167. The admission guard predicts whatallocatewill do with a different formula, so they can diverge. Secondary:lock(&self.resources.transfers)taken once per candidate record per pump iteration and again right after byallocate(:1987). Fix:let needed = lock(&self.resources.transfers).layout().record_slots(plan.count, plan.row);hoisted next tofree. -
§2.4 docs (SHOULD FIX, down from wider doc ask). docs/prefix-cache-offload.md:337-366 is now ONE ~30-line/250-word bullet carrying ~12 facts (signatures, shared handle, WINDOW_PAGES alignment, per-follower upload, slot lifetime, read_into isolation, immutability+pin invariant, close-before-Fetched, demand scheduling, live-window limit, extra-partial-window bound, error scope, two metrics). Content is now accurate and complete — the earlier asks are all met (see note on resolutions). What remains: repo-prose (.agents/skills/repo-prose/SKILL.md:71,:84) wants ordinary readable sentences; AGENTS.md:52-60 gives a document one purpose. And the bytes_in/inbound_rate contract is stated TWICE — docs:362-366 and again at :1528-1531 in §4. Keep the behavioural half in §2.4, the measurement statement only in §4, with a pointer.
-
NIT —
inbound_ratenow measures pure disk-thread time.disk::Reply.elapsedis set only aroundworker.execute(job)(disk.rs:448-450) — one O_DIRECT read + xxh3, no wait for a free slot, no copier queue time, no GPU upload. Previously the rate was record bytes overjob.started.elapsed()fromDiskStore::fetchtoFetched(that field is gone; Fetched now only doesstats.bytes_in += bytes, :3669). Sincehit()divides by the rate (estimated_seconds: bytes / self.inbound_rate.get().max(1.0), :3625) andworth_fetching/worth_transfergate on it (store.rs:422-438), restore estimates are now optimistic by the staging/upload share even for a single restore — the opposite direction from the inflation this revision fixed.CompositeStoreprices the disk part on its owndisk_inbound_rateobserved fromread_intocompletions overdisk_started.elapsed()(composite.rs:994-1004), so the two stores measure different quantities under the same name. -
NIT —
Staged::closeabandonedno longer matches its message (disk_store.rs:2513-2544).internal= max over owners.len(), maintenance.len(), shared_segments.len(), shared_windows.len() (:2522-2527);abandoned = store_jobs.max(internal)(:2528) reported as "{abandoned} disk transport jobs did not complete" (:2541-2543). Map sizes are not jobs;maintenance_jobsis derived fromowners(:2513-2517) andowners.len()is folded intointernal, so maintenance is double-counted. Previously it wasowners.len(), one entry per owned disk job — what the message says. Correctness lens still rates this resolved (no under-report); simplicity/conventions lens rate it a message-vs-count nit. -
Other nits: dead guard
if demand.is_empty() { 0 } else { ... }at :1781-1787 (map_or(0) already yields 0);memory.rs::windows()(:1333-1367) is now the last surviving third copy of the WINDOW_PAGES splitter vsplan_windows(:679-727); two differentsettled()predicates in one file —Segment::settled(:661-664, file-handle terminal state) vsSharedSegment::settled(:1106-1109, disk jobs drained); three verbatim "unindex iff the index still points at it" blocks (:1525-1527, :1543-1545, :1837-1839); two identical follower-detachretainclosures (:1813-1816, :1900-1904) matching on the(record, plan_index)pair that isWindowFollower's identity (:1119-1123);SharedSegment.id/SharedWindow.idduplicate their HashMap keys (:1083, :1131);disk_read_countedflags exist only to make a test counter count windows not jobs (:743, :1140, six cfg blocks);HostInboundis a one-elementVec<Segment>with an always-zero index plus a redundantSegment::reads_left;GatedCopier::wrapreturns a positional 4-tuple (:8092-8122) vs the crate's named pairs in testing.rs. -
Description nits (prose lens): (a) "Emit one InboundWindowSample per completed physical window read" — the sole emitter is the shared device-fetch path; caller-owned
read_intoemits none, so scope the sentence; (b) Flash-Next Read Reduction values 3.99x/3.52x do not match the MB columns (ratio of tabulated means is 4.010/3.535) and the caption does not say whether the column is a ratio of means or a mean of per-trial ratios; (c) "No core re-export or format change is required" is true for re-exports, butTransportEventis a public enum in a public module and gained a variant — say so. All four TTFT percentage deltas check out; the 27B rows' 4.22x/3.76x check out.
#20 [high] DELIVERABLE (final): full report for PR #496 at 0c04b1e2
========================================================= FULL REPORT — PR #496 "Coalesce shared ancestor reads across concurrent Selene disk fetches" Head 0c04b1e2, base main c0c4f798 · 3 files, +3358/−933 (selene/src/disk_store.rs, selene/src/shard.rs, docs/prefix-cache-offload.md) Case file: https://autobot.eidonix.com/api/v1/cases/774e16ea-5f84-4ff8-9166-74ab6876cc37.html
VERDICT
No blockers. The change belongs in the repository, is in the right layer, and its evidence is the kind the charter demands. Every blocker and should-fix from the previous round is either fixed at this head or has been narrowed to a small follow-up. What remains are four code/doc improvements worth making before merge (or in a fast follow) and six nits.
RESOLVED SINCE THE PREVIOUS ROUND (do not re-raise)
- Blocker: 8/9 vs 7/9 at 61.3K. Resolved. Five cold-VRAM repeats against one shared 60,534-token disk checkpoint (seed 1234..1238, top_logprobs=5) produced identical FP32 top-5 logprobs and token IDs on main and at head across all five (6/9, 8/9, 7/9, 9/9, 4/9). Cause identified: Flare has no greedy temperature=0 (helios clamps into the core's positive sampling range), and the earlier single-pass script used distinct per-build prompt nonces. The narrow plausible defect site is now pinned by
misaligned_follower_attaching_to_shared_partial_tail_and_row_matches_private_restore(byte-equal SimulatedGpu pages and row vs a private baseline, skip_pages=13, partial <64-page ancestor tail plus a partial leaf chunk carrying the row). Good closure of a hard ask. - inbound_rate on logical bytes. Resolved:
InboundWindowSamplecarries only physical windowread_bytes/read_elapsed(disk_store.rs:1596-1620, pushed :1617-1620),applyfeeds the sampler and returns beforestats.progress += 1(:3632-3635),stats.bytes_instays logical (:3669), the old per-record observe is gone. Testcoalesced_restores_keep_inbound_rate_physical_and_bytes_in_logicalcovers 1 vs 8 simultaneous and staggered. - Benchmark provenance; expected cost stated as a result. Resolved: table keyed to
main c0c4f798vs0c04b1e2; costs labelled "As an expected bound" with thedevice_inbound.len() <= 1fast path noted; un-rerun multi-host RoCE moved to Not covered. - One planner, one window key, one attach helper. Resolved:
plan_windows(segments, align_to_window)(:679-727) replaced the twin splitters;HeaderIdentity/SegmentKey/WindowKey(:1001-1064) with awindow_indexHashMap give O(1)find_reusable_window(:1646-1663) and remove the per-pump PathBuf clones;has_window_credit(:1683-1687) andattach_pending(:1711-1730) replaced the duplicated attach loops. - Earlier nits. Resolved: counters gated under
#[cfg(any(test, feature = "test-support"))](:200-208, accessors :1279-1295);PlanStatereplaced bystarted: Vec<bool>;SharedWindow.path/.expectedremoved;allocate's rustdoc restored (:241-243) andfree_slotsgiven its own line (:236-239); module doc rewritten to describe per-fetch window credits, follower sharing and close-before-Fetched(:7-27). - Design rationale. The Staged-vs-DiskThread argument is now in the PR Why on technical grounds and satisfies design-review in substance; only the maintainer record remains (see Should Fix 5).
BLOCKERS
None.
SHOULD FIX
1. A rank-local rate sample was added to the cross-rank completion enum, and it amplifies the composite's maintenance cadence
Finding. TransportEvent::InboundWindowSample { bytes, elapsed } (disk_store.rs:97-101) was added to the enum whose own doc reads "Completion the transport reports to the disk store" (:83), where every other variant is a job completion carrying a JobId. This one carries no id — it is a per-window bandwidth sample for Staged's own rate. Consequences:
shard::Kind::ofnow has to panic on it:unreachable!("window rate samples stay local to rank zero")(shard.rs:476-478). The enum's own convention for an unrepresentable kind is an error, not a panic (Err(invalid("unknown prefix record event kind")), shard.rs:462).- The panic is upheld only by two hand-written
matches!guards that must stay in sync:Sharded::absorb_localpushes the sample straight toself.eventsand continues (shard.rs:722-725), andPeer::forwardskips it (shard.rs:1148-1150). - Anything else that maps
Kind::ofover aSharded's event list panics — including the existing test helperevents.sort_by_key(|event| Kind::of(event).1)(selene/src/shard/tests.rs:339), which survives today only because those tests issue stores and unlinks and no fetch. - Test code also has to filter it by hand (disk_store.rs:6341) and match it out of the stream explicitly (:9145).
- Concrete cost:
CompositeStore::polldoesself.stats.progress += 1for every transport event before dispatch (selene/src/composite.rs:1376). That counter is documented as "Completion and capacity-release events" (selene/src/store.rs:202) and gates the maintenance pass —maintenance_progress != progress→spill_parked(...)+self.disk.maintain()(composite.rs:1418-1424). With this change each physical 64-page window read bumps progress and re-runs both, once per window per restore — the opposite of the hot-path relief the PR is after.DiskStore::applydeliberately does not bump progress for this variant (:3632-3636), so the two stores' progress counters now advance at different rates for the same work.
Request. Carry the sample out of band instead of as a completion variant: a Staged drain method for a pair of window byte/elapsed accumulators (the store already reads Staged state directly for in_flight() and pool()), a field on the existing Fetched event for the coalesced case, or the crate's existing precedent for a rate signal that is not an event (Budget::progress(), selene/src/input.rs:146-152). Whichever shape, exclude it from CompositeStore's stats.progress so that counter means "completions". A test asserting Kind::of is total over every TransportEvent (or a property test over the enum) would settle the panic path permanently; today only reading the two guards shows it.
Why. This is "solve the right problem in the right place" and "reject unsupported abstractions" (charter line 9; AGENTS.md:188-193). A variant with no job id is not a transport completion, and adding it makes the cross-rank protocol mapper responsible for a rank-local statistic: Kind::of goes from total to partially defined over its own input domain, with its totality depending on two guards far away from it. The fix needs no new machinery. Note the mechanism is correct and is not in question — physical-rate observation, the vanished per-record observe, and the two rank guards are all right; this is about where the signal is carried. It is also what the description's "No core re-export or format change is required" overlooks: TransportEvent is a public enum in a public module and gained a variant.
2. HeaderIdentity hand-writes Hash, duplicating an equality contract defined in another module
Finding. HeaderIdentity(Arc<Header>) implements PartialEq by delegation with an Arc::ptr_eq fast path (disk_store.rs:1006-1010), then writes Hash by hand: it destructures Header, hashes fourteen fields one at a time, and the destructure ends in .. (:1014-1050, .. at :1030). The contract it must mirror is exhaustive and lives 1,200 lines away in a different module — impl PartialEq for Header (selene/src/shared/record.rs:136-152), Header defined :116-134, impl Eq :154, private version excluded at :118-119 (correctly excluded here too). Adding a field to Header therefore produces a compile error in record.rs but not here: the new field silently drops out of the hash, two headers that compare equal hash differently, window_index.get(&key) misses, and coalescing silently stops working — a performance regression with no test failure, since nothing in the suite pins hash/eq agreement.
It is also a convention departure: a repository-wide search for impl (std::hash::)?Hash for in selene/src returns exactly this one hit. The crate derives instead: PrefixKey derives PartialEq, Eq, Hash, PartialOrd, Ord (selene/src/vocab.rs:30), RankSizes derives (shared/record.rs:89), DiskRecord derives (disk_store.rs:72), and this PR's own SegmentKey/WindowKey derive (disk_store.rs:1052, :1058). The manual impl exists only because Header does not derive Hash. Separately, HeaderIdentity restates Header identity where the PR already has a per-record unique key: Header.key is a PrefixKey, which derives Hash, and the path is derived from it.
Request. Move the hashing next to the equality it must track: impl Hash for Header in shared/record.rs (same field list, version still excluded), and let SegmentKey/WindowKey derive. Then HeaderIdentity disappears and the two contracts cannot drift. Minimum acceptable alternative if the author prefers the wrapper: impl Hash for HeaderIdentity { fn hash<H: Hasher>(&self, state: &mut H) { self.0.key.hash(state) } } — Hash need only be consistent with Eq, not complete; collisions only cost a bucket because PartialEq still compares the whole header — plus a comment saying why the full field list was chosen. Either way, add the missing a == b ⇒ hash(a) == hash(b) property test.
Why. A Hash that must be hand-kept in step with an equality defined elsewhere, using a non-exhaustive pattern so the compiler cannot help, is exactly the "duplicate representation" docs/design-review.md:74 asks a change to account for — and the failure mode is silent and performance-only, which is the class of bug this PR's own benchmark is designed to catch.
3. pick_next_pending_plan restates Layout::record_slots instead of calling it
Finding. disk_store.rs:1766-1777 computes the slot cost of a candidate window by hand:
let free = self.resources.free_slots();
let layout_row_slots = self.resources.pool.as_ref()
.map(|_| lock(&self.resources.transfers).layout().row_slots())?;
...
let needed = plan.count + if plan.row { layout_row_slots } else { 0 };
Layout::record_slots(pages, row) already encodes exactly this — pages + usize::from(row) * self.row_slots() (selene/src/geometry.rs:180-182, row_slots :173-178) — and it is the crate's single definition of what a record costs in staging slots: Resources::allocate uses it (disk_store.rs:245), as do memory.rs:468 and composite.rs:810/:1167. This admission guard exists to predict whether allocate will succeed (:1778); expressing the prediction with a different formula means the guard can disagree with the allocator, and it will the moment record_slots learns to account for anything beyond pages + row. Secondary: lock(&self.resources.transfers) is taken once per candidate record per pump iteration here and then immediately again by allocate (:245).
Request. let needed = lock(&self.resources.transfers).layout().record_slots(plan.count, plan.row);, hoisted next to free outside the plan loop; drop if demand.is_empty() { 0 } else { ... } at :1781-1787 (see Nit 3).
Why. A guard that predicts the allocator must use the allocator's own arithmetic; two formulas for one cost is a latent mismatch, and the crate already has the helper.
4. The new §2.4 bullet is one 250-word paragraph and states the metrics contract twice
Finding. docs/prefix-cache-offload.md:337-366 is a single 30-line bullet carrying roughly twelve facts: the write_from/read_into signatures, the shared open handle, WINDOW_PAGES file-boundary alignment, per-follower GPU upload, slot lifetime, read_into independence, the immutability+pin invariant, close-before-Fetched, sibling-demand scheduling, the live-window limit, the extra-partial-window bound, error scope, and the two metrics. Its content is now accurate and complete — every earlier doc ask is met. What remains is shape and duplication: .agents/skills/repo-prose/SKILL.md:71/:84 ask for ordinary readable sentences and no "you had to be there" density, and AGENTS.md:52-60 gives a document one purpose at a time, whereas this mixes mechanism, correctness invariant, scheduling heuristic and metrics. The bytes_in/inbound_rate contract is also stated twice — docs:362-366 and again nearly verbatim at :1528-1531 in §4 — and one contract in two homes is what drifts.
Request. Keep one paragraph of mechanism in §2.4 (shared handle; aligned WINDOW_PAGES fan-out to every attached upload; independent read_into), move failure scope and the two limits to a short bullet list in the style of :333-336, keep the metrics statement only in §4 (:1528-1531) and leave a pointer from §2.4.
Why. This is the paragraph a future reader will trust to learn the transport's contract; a run-on makes three distinct behaviours look like one mechanism, and duplicated prose drifts (AGENTS.md:43-49 prose review; design-review principle 16: write without hidden context).
5. Record the design decision for the new shared inbound lifecycle (process, not code)
Finding. The change replaces Staged's single inbound lifecycle — the invariant behind "Nothing here waits" — with two (host vs device) inside shared cache machinery: a five-state shared-file machine, reference-counted shared windows with separate disk and upload counts, out-of-order plan completion, and a close-only-when-settled rule (disk_store.rs:1066-1160, :1824-2278). The PR Why now argues the choice on technical grounds — DiskThread sees only file offsets and raw host addresses and finishes once direct I/O and xxh3 complete, whereas SlabPool slots must stay pinned until every follower's asynchronous Copier upload completes — which discharges the design-review ask in substance. What remains is that an invariant this central not be settled implicitly by merge (AGENTS.md:204-206).
Request. Get a recorded maintainer sign-off on doing the coalescing inside Staged rather than inside the disk thread that already owns the file handle. No code change is requested.
Why. The technical content held up under review, but a change of this shape to shared cache invariants should rest on a recorded decision rather than on review-time inference.
NITS
1. inbound_rate now measures pure disk-thread time, so estimated_seconds prices restores optimistically
disk::Reply.elapsed is set only around worker.execute(job) (selene/src/disk.rs:448-450) — one O_DIRECT read plus xxh3, with no wait for a free slot, no copier queue time and no GPU upload. Before this revision the rate was observed as record bytes over job.started.elapsed() from DiskStore::fetch to Fetched, spanning queueing and the upload; that field is gone and the Fetched arm now only does stats.bytes_in += bytes (disk_store.rs:3669). Since hit() divides by the rate (estimated_seconds: bytes as f64 / self.inbound_rate.get().max(1.0), :3625) and worth_fetching/worth_transfer gate on it (store.rs:422-438), restore estimates are now optimistic by the staging/upload share even for a single restore — the opposite direction from the inflation this revision fixed. CompositeStore prices its disk part on its own disk_inbound_rate observed from read_into completions over disk_started.elapsed() (composite.rs:994-1004), so the two stores measure different quantities under one name. Request: either document inbound_rate explicitly as device read bandwidth and keep a separate end-to-end restore estimate for estimated_seconds, or include the per-record wait in the sample. A test comparing estimated_seconds against a measured single-restore wall time would settle it.
2. Staged::close's abandoned count no longer matches its message
disk_store.rs:2522-2544: internal is a .max() over owners.len(), maintenance.len(), shared_segments.len() and shared_windows.len(), and abandoned = store_jobs.max(internal) is reported as "{abandoned} disk transport jobs did not complete". shared_segments/shared_windows are map sizes, not jobs — one leaked shared window in an otherwise idle store yields abandoned == 1 and a claim that a disk transport job did not complete — while four abandoned outbound jobs plus six leaked windows reports six. maintenance_jobs is also counted twice: it is derived from owners (:2513-2517) and owners.len() is folded into internal. Previously the number was owners.len(), one entry per owned disk job, which is what the message says. Request: keep the message counting owners.len(), and if leaked staging state is worth catching, report it separately ("{n} shared windows/segments leaked").
3. Repeated blocks, duplicate fields and state nothing branches on
- The "unindex this window, but only if the index still points at it" body appears verbatim three times — :1525-1527, :1543-1545, :1837-1839. The
self.window_index.get(&win.key) == Some(&win_id)guard is the subtle part (it stops a newer window that reused the key from being unindexed) and it is stated three times. Extractfn unindex_window(&mut self, key: &WindowKey, id: SharedWindowId). - The follower-detach
retainclosure appears twice identically (:1813-1816, :1900-1904), matching on the(record, plan_index)pair that isWindowFollower's identity (:1119-1123) and is constructed a third time at :1690-1695. GiveWindowFolloweramatches/removemethod. Worth a one-line comment that only Pass 1 creditsrecord.bytes += win.read_bytes(:1901), because the other path detaches from a record that is being failed. - Two different lifetime predicates share the name
settled()in one file:Segment::settled(:661-664, "has this file handle reached a terminal state") andSharedSegment::settled(:1106-1109, "have this segment's disk jobs drained"). Rename one (file_settled/drained). SharedSegment.id(:1083) andSharedWindow.id(:1131) duplicate the keys they are stored under; iteratefor (&id, seg) in &self.shared_segmentsat the four use sites and delete both fields.- Dead guard:
if demand.is_empty() { 0 } else { ... }inpick_next_pending_plan(:1781-1787) —map_or(0, ..)on an empty map already yields 0. HostInbound.segmentsis aVec<Segment>with an always-zero index (Owner::HostInbound(JobId, usize), :267/:1351), soapply_diskmust tolerate an impossible missing segment (:789-791). A singlesegment: Segmentremoves the index, the tolerance, andSegment::reads_left(:658/:822/:867), which duplicates thedone == plans.len()check at :882.disk_read_countedonHostWindow(:743) andSharedWindow(:1140) exists only so thedisk_window_readscounter counts windows rather than jobs (sixcfgblocks). Either document the unit at the counter ("one per window, not perReadPages/ReadRowjob") and delete the flags, or state the flags' purpose on the fields.
4. memory.rs::windows() is now the last surviving third copy of the splitter, and GatedCopier breaks the fixture convention
memory.rs::windows()(selene/src/memory.rs:1336-1367) re-expresses the sameWINDOW_PAGESpolicyplan_windowsencodes (disk_store.rs:689-700, :719):pages.chunks(WINDOW_PAGES), row attached only to the last chunk, a row-only record getting exactly one window, an empty link getting none. Its output type differs (VecDeque<copier::Job>vsVec<WindowPlan>), so full convergence is a refactor rather than a rename; the minimum is a cross-reference comment on both sides and a test pinning the shared policy (design-review.md:74).GatedCopier::wrap(disk_store.rs:8092-8122) returns a positional four-tuple ofArc<Mutex<…>>handles; every call site destructures positionally and three discard the tail with_(:8406, :8530, :8984). The crate's fixture precedent returns named pairs (StoppedCopier,SimulatedGpu::shared_mapped, selene/src/testing.rs:178/:225). A named struct (hold,held,fail) lets each site say which gate it wants and stops a new gate renumbering every site. Test-only, no production impact.
5. PR description nits
- "Emit one
TransportEvent::InboundWindowSampleper completed physical window read" is scoped wider than the code: the sole emitter is the shared device-fetchstaging path (apply_shared_disk, disk_store.rs:1617-1620, reached viaOwner::SharedSegmentat :2339-2341). Caller-ownedread_intorestores emit none, so for aDiskStorewhose restores run throughread_into(the composite path)inbound_rateis not fed by those reads. Say "per completed shared device-fetchstaging window" and state what feeds the rate for caller-owned reads. - Two Flash-Next "Read Reduction" ratios do not match the MB columns: 7,944.9 → 1,981.1 is 4.010 but the table says 3.99x; 7,958.0 → 2,251.5 is 3.535 but it says 3.52x. The 27B rows (4.22x, 3.76x) and all four TTFT deltas check out. Add a caption sentence saying whether the column is a ratio of the tabulated means or a mean of per-trial ratios, and make the two values consistent.
- "No core re-export or format change is required" is true for re-exports, but
TransportEventis a public enum in a public module and gained a variant (disk_store.rs:97-101) — which is precisely what forces theunreachable!()at shard.rs:476-478. Say the enum gained a rank-0-local variant instead.
CHECKED AND SOUND (no action requested)
- Slot and file lifetimes. A shared window is freed only when
followers.is_empty() && disk_referenced == 0 && upload_referenced == 0(sweep_shared_windows, :1824-1843); attach paths incrementfollowers; every disk submission incrementsdisk_referencedand every uploadupload_referenced; the decrement paths inapply_shared_disk(:1594) andapply_device_transferrun before any release decision, so a reply can never arrive for a freed window. Segment removal needs no users andsettled()(Pass 5e, :2213-2230).allocate(plan.count, plan.row)matchesrecord_slots, and each new test assertspool.free_slots() == pool.slot_count()— the right property rather than a mock. - Failure isolation. A private child or follower GPU-upload error fails only that restore (
record.fail, :1538-1553, :1652-1660). A shared segment open or read error is converted withwith_record_read()and fails every attached restore after in-flight I/O drains (fail_segment_users:1509-1536,fail_window:1620-1638), andDiskStore::applystill routesis_record_read()failures toindex.drop_row(:3676-3682). The "don't swallow the error" rule holds. - Host path unchanged.
read_intokeepsplan_windows(..., false)(:1349), private per-restore opens and unaligned packing;CompositeStore::start_readuses only that path, so live composite serving sees no behavioural change. Keeping caller-owned host reads off the shared path is the right call — those buffers have caller-defined lifetimes (design-review principle 6). - No compatibility break. Records stay immutable and pinned;
Headerand the on-disk layout are untouched; no core re-export change;HeaderIdentity's field list mirrorsHeader'sPartialEqexactly, so the sharing key cannot collide two headers that compare unequal (Nit/Should Fix 2 is about maintainability, not a current collision);WINDOWS_IN_FLIGHTstill derives fromcrate::shared::WINDOW_CREDITS(:60). Files written before this PR load unchanged. - No scope expansion, no architectural violation, no knob. No CPU/non-NVIDIA path, no backend swap, no orchestration, no serving-path change; no CUDA in
selene, no model knowledge, no per-model special case, no env var, no recipe field. Sharing is derived from(path, expected Header)identity (HeaderIdentity/SegmentKey, :1001-1064, acquisition :1425-1462) so it generalises as the charter requires. The only new conditional compilation is the diagnostic counters. - Correctness of the concurrency argument.
build_pending_demandshort-circuits atdevice_inbound.len() <= 1(:1651), so a lone restore behaves exactly as before;has_window_credit/attach_pendingkeep every attach within the two-window budget before a finished slot can release;pump_allruns maintenance, outbound, host-inbound, then device (:2291-2312), consistent with the stated #497 merge-order note;pending_row_readspushes only insidesubmit_disk'sOk(())arm, so the FIFO reply matching cannot be left with an unmatched entry. - Tests exercise the real path. Byte-exact
SimulatedGpupage and row assertions in every coalescing test (e.g. :8368-8379), counters incremented at the realsubmit_disk/submit_transfersites rather than in mocks (AGENTS.md:194-199). The shared fixtureswrite_shared_ancestor_treeandpoll_all_fetchesare used by five of the seven new tests, so they are not scaffolding. - Scale. +3313/−931 in
disk_store.rsis large but not churn under AGENTS.md:188-193: the host path must stay private, the device path genuinely needs per-file and per-window reference state, and the eight passes ofpump_device_inboundeach carry an ordering argument the others depend on (attach before sweep, reads before uploads, close beforeFetched). No different shape is being requested.
OPEN QUESTIONS
- The numeric size of the
estimated_secondsoptimism (Nit 1) needs a run or an instrumented test; the code shows only the direction. - Whether
Headershould gainHash/a digest form at all, versus hashingPrefixKeyonly (Should Fix 2) — a maintainer/author call; either fix removes the drift hazard. - Whether one of the two layering fixes for Should Fix 1 (
Stageddrain method vs counters inStoreStats) is preferred — internal API shape, a maintainer call. Folding the physical counters intoStoreStats(#185-244) would also make coalescing visible to operators, which today it is not outside tests. - The #497 rebase of
pump_all: both PRs touch it; whoever merges second must confirm the merged order still runshost_inboundandpump_device_inboundahead of writes and maintenance. Not checkable from this branch. - Out of scope and unverified here, as the description itself states: multi-host RoCE serving, 2-GPU
split_pools, discrete PCIe GPUs, Windows serving, liveCompositeStore/PooledStoreGPU serving. - This review had no toolchain, GPU or test run available; every finding is established from source at the head commit. No instructions were embedded in the reviewed material.
#21 [high] DELIVERABLE (final): summary report / GitHub post for PR #496 at 0c04b1e2
========================================================= SUMMARY REPORT — PR #496 (GitHub post; 10 bullets = 5 should-fix + 5 nits, no blockers) Head 0c04b1e2 vs main c0c4f798 · 3 files, +3358/−933 Case file: https://autobot.eidonix.com/api/v1/cases/774e16ea-5f84-4ff8-9166-74ab6876cc37.html
Recommendation: Approve with Should-Fix (no blockers)
The last round's blocker and five of six should-fixes are resolved at 0c04b1e2, and the 61.3K parity gap closed cleanly: five cold-VRAM repeats against one shared 60,534-token checkpoint gave identical FP32 top-5 logprobs and token IDs on main and at head, the sampling-mode cause is named, and a byte-exact misaligned-follower test now pins the only plausible defect site. The change belongs in the repo, adds no flags, changes no format, and keeps failure isolation. What is left is small: one layering fix, one maintainability fix, one arithmetic restatement, docs, and a recorded design sign-off.
Should Fix
- Take the rate sample off the cross-rank completion enum.
TransportEvent::InboundWindowSamplecarries noJobIdbut joins the enum documented as "completion the transport reports", which forces anunreachable!()inKind::ofupheld by two hand-written guards, panics any otherKind::ofcaller (including the shard test helper), and makesCompositeStore::pollbumpstats.progress— and so re-runspill_parked+disk.maintain()— once per physical window. Carry it out of band (aStageddrain method or a field onFetched) and keepprogressmeaning "completions". - Move
HeaderIdentity's hand-writtenHashnext to the equality it tracks. It hashes 14 fields through a..pattern, so a newHeaderfield silently drops out of the hash and coalescing stops working with no test failure; it is also the only manualHashinselene/srcwhere the crate derives. GiveHeaderaHashimpl beside itsPartialEq(or hash onlyPrefixKey) and add ana == b ⇒ hash(a) == hash(b)test. - Call
Layout::record_slotsinstead of restating it. The admission guard inpick_next_pending_planrecomputespages + row_slotsby hand whileResources::allocate— the function it is predicting — usesrecord_slots; two formulas for one cost will diverge. One-line change, hoisted besidefree. - Split the §2.4 bullet and stop stating the metrics contract twice. The new 30-line, ~250-word paragraph is accurate but carries twelve behaviours, and the
bytes_in/inbound_ratestatement is repeated at :1528-1531. Keep mechanism prose in §2.4, limits and failure scope as bullets, metrics only in §4. - Get the design decision recorded. The Staged-vs-DiskThread argument now in Why is sound; ask a maintainer to record the choice to put a second inbound lifecycle inside
Stagedrather than in the disk thread that owns the handle (AGENTS.md:204-206). No code change.
Nits
inbound_ratenow measures pure disk-thread time (disk::Reply.elapsedwraps onlyworker.execute), sohit()'sestimated_secondsprices restores optimistically by the staging/upload share — the mirror of the inflation just fixed, and inconsistent withCompositeStore's own disk rate. Document it as device bandwidth or include the per-record wait.Staged::close'sabandonedis amaxover map sizes and job counts, so a lone leaked window reports "1 disk transport jobs did not complete"; count owned jobs or report leaked staging separately. Same paragraph:demand.is_empty()guard is dead, and the twosettled()predicates share a name for different lifetimes.- Three verbatim "unindex if still ours" blocks and two identical follower-detach closures — extract
unindex_windowand giveWindowFolloweramatches/remove; drop theidfields that duplicate their map keys. - Shrink the host-inbound and fixture state: single
Segmentinstead of a one-elementVecwith an always-zero index (also dropsreads_left); documentdisk_read_countedor delete it;GatedCopier::wrapshould return a named struct, not a positional four-tuple. - Description nits: scope the sample to shared device-
fetchwindows (read_intoemits none), reconcile the two Flash-Next read-reduction ratios (4.01x/3.54x from the MB columns, not 3.99x/3.52x) and say whether the column is a ratio of means, and note thatTransportEvent— a public enum — did gain a variant.
Closing: everything else checked out — slot and file lifetimes, failure isolation, the unchanged caller-owned host path, no format or re-export change, and tests that assert byte-exact GPU pages at the real submit sites. Evidence and per-angle detail are in the case file.
#22 [high] Research summary
I reviewed the new head 0c04b1e2 against last round's report and wrote both deliverables to the scratchpad: entry #20 (full report) and entry #21 (summary report / GitHub post), with supporting notes in #18 (resolutions) and #19 (new findings).
Verdict changed from "Changes Requested" to "no blockers". Last round's single blocker — the 8/9 → 7/9 retrieval result at 61.3K — is genuinely closed: five cold-VRAM repeats against one shared 60,534-token checkpoint produced identical FP32 top-5 logprobs and token IDs on main and at head (6/9, 8/9, 7/9, 9/9, 4/9), the sampling-mode cause is named (Flare has no greedy temperature=0; distinct per-build prompt nonces), and the narrow plausible defect site is now pinned by a byte-exact misaligned-follower test. Five of six should-fixes are also fixed in code, which I verified line by line: InboundWindowSample carries only physical window bytes and bytes_in stays logical; plan_windows(.., align_to_window) replaced the twin splitters; WindowKey/window_index and has_window_credit/attach_pending removed the duplication; the benchmark is keyed to the head commit; the counters are cfg-gated; the module doc, allocate rustdoc and module contract are corrected.
Four should-fix findings are new at this head, created by those fixes: (1) InboundWindowSample was added to the cross-rank completion enum, forcing an unreachable!() in Kind::of upheld by two hand-written guards and making CompositeStore::poll bump stats.progress — and so re-run spill_parked + disk.maintain() — once per physical window; (2) HeaderIdentity's 37-line hand-written Hash restates Header's PartialEq from another module through a .. pattern, so a new field silently breaks coalescing with no test failure, and it is the only manual Hash in selene/src; (3) pick_next_pending_plan recomputes pages + row_slots by hand instead of calling Layout::record_slots, which the allocator it predicts does call; (4) the new §2.4 bullet is one 250-word paragraph stating the metrics contract twice. A fifth should-fix is process-only: a maintainer should record the Staged-vs-DiskThread decision (no code change requested). Five nits follow, led by inbound_rate now measuring pure disk-thread time, which makes estimated_seconds optimistic in the opposite direction from the inflation just fixed.
The summary report is 10 bullets — no blocker section, 5 should-fix, 5 nits — with one-line findings plus tldr requests and a case-file link, and it opens by acknowledging the closure of the previous round so the author knows what not to redo.
#23 [high] Evidence inventory at head 0c04b1e2 (PR description numbers the report must cite)
Supersedes the evidence in entry #1, which describes the older head f9c9191. All numbers below are from the PR description at head 0c04b1e2, base main c0c4f798.
BENCHMARK SETUP (as stated): flare run on NVIDIA GB10 (SM121), --prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk; --max-concurrency 16 --prefix-cache-disk-limit 40G on Qwen3.8-27B-NVFP4, --max-concurrency 8 --prefix-cache-disk-limit 24G on Qwen3.8-Flash-Next. Each trial warms one ~61K-token shared prefix plus 8 child branches (~256 unique tail tokens each) to disk, restarts flare run so GPU memory starts empty, then sends 8 concurrent /v1/chat/completions follow-ups. Metric is ingress-to-first-token TTFT; 27B rows are means over 2 interleaved repeats.
TABLE (Before main -> After 0c04b1e2):
Qwen3.8-27B-NVFP4TP1, 60.5K, Simultaneous: physical NVMe read 18,177.5 -> 4,306.7 MB (-76.3%), 4.22x, burst median TTFT 7,974.6 -> 5,662.8 ms (-29.0%).Qwen3.8-27B-NVFP4TP1, 60.5K, +25 ms stagger: 18,194.2 -> 4,843.6 MB (-73.4%), 3.76x, TTFT 6,883.6 -> 5,951.9 ms (-13.5%).Qwen3.8-Flash-NextTP1, 61.0K, Simultaneous: 7,944.9 -> 1,981.1 MB (-75.1%), 3.99x, TTFT 3,327.5 -> 3,225.0 ms (-3.1%).Qwen3.8-Flash-NextTP1, 61.0K, +25 ms stagger: 7,958.0 -> 2,251.5 MB (-71.7%), 3.52x, TTFT 3,137.7 -> 3,049.9 ms (-2.8%).
ARITHMETIC CHECK (done): all four TTFT percentages and the two 27B ratios check out. The two Flash-Next ratios do not match the MB columns — 7,944.9/1,981.1 = 4.010 and 7,958.0/2,251.5 = 3.535 — which is the description nit in entry #19 item 8(b).
RATE/LEDGER EVIDENCE: rank-0 flare_host_cache_inbound_bytes_per_second stays physical across coalesced restores — 6.07 GB/s single vs 7.71 GB/s 8-way simultaneous and 6.02 GB/s 8-way staggered on Qwen3.8-27B-NVFP4; 7.17-9.01 GB/s single on Qwen3.8-Flash-Next. flare_host_cache_bytes_in_total tracks logical restored bytes (8x single). This is the author's live confirmation that the S1 fix behaves as intended and should be acknowledged in the report as resolved.
PARITY EVIDENCE (closes the previous blocker): 5 cold-VRAM restart repeats, seed 1234..1238, 60,534 prompt tokens, top_logprobs=5, one shared disk checkpoint, main (c0c4f798) vs 0c04b1e2 on Qwen3.8-27B-NVFP4 TP1 — identical FP32 top-5 logprobs and token IDs on all 5 repeats (6/9, 8/9, 7/9, 9/9, 4/9 on a 9-fact retrieval prompt); first-token top-5 logprobs match in-VRAM GPU hits ("9" -0.756374 vs "3" -1.256374). Cross-seed score variation attributed to positive-temperature sampling because helios clamps request temperature into the core's positive sampling range and Flare does not support greedy temperature = 0. Also: four concurrent unique-prefix decode streams spilling checkpoints over 30 s on Qwen3.8-Flash-Next TP1 had 0 errors, 100.0 -> 100.6 tok/s.
SUITE COUNTS AT THIS HEAD: 476 selene tests on x86_64 and ARM64 Linux (O_DIRECT + io_uring, 0 warnings without test-support); 13 coalescing tests on Windows IOCP (full Windows selene still gated on /dev/urandom per docs/TODO.txt); 21 single-GPU SM121 helios offload:: tests (FLARE_RUN_CUDA_TESTS=1 --include-ignored; split_pools needs 2 local GPUs); pytest tests/preparation/test_core_boundary.py.
NOT COVERED (author-declared): multi-host RoCE serving, 2-GPU split_pools, discrete PCIe GPUs, Windows serving, live CompositeStore/PooledStore GPU serving.
COMPANION PR: #497, both base directly on main, merge in either order; whoever merges second reconciles Staged::pump_all so host_inbound and pump_device_inbound run ahead of writes and maintenance. Discord: Dooner present.
#24 [high] Report blueprint: structure, verdict and lens grades at 0c04b1e2
POINTERS (write the final report from these):
- Entry #20 = FULL REPORT (final). Structure: verdict; resolved-since-last-round; Blockers (none); Should Fix 1-5; Nits 1-5; checked-and-sound; open questions.
- Entry #21 = SUMMARY REPORT (final, exactly 10 bullets: 5 should-fix + 5 nits, no blocker section, opens "Approve with Should-Fix (no blockers)", includes the case-file link).
- Entry #19 = the five new findings with every file:line citation (threads 1-8).
- Entry #18 = what was resolved at this head (do not re-raise) and the cross-lens verdicts.
- Entry 22/latest = evidence inventory at this head (benchmark table, parity result, suite counts, Not covered).
- Entries #1-#8 describe the OLD head f9c9191; use them only for background, never for verdicts or line numbers.
- Case-file link used in the summary: https://autobot.eidonix.com/api/v1/cases/774e16ea-5f84-4ff8-9166-74ab6876cc37.html
LENS GRADES AT THIS HEAD (from this round's agent reports):
- Architecture/scope B: "No blocking findings." Should fix = the InboundWindowSample layering; nit = inbound_rate now pure disk-thread time; held = maintainer record of the Staged-vs-DiskThread decision. Scope verdict: belongs — charter "What gets merged" allows a measured performance issue (AGENTS.md:165-166; goal "Store prefix-cache checkpoints in host memory and share them across Flare instances via Selene"); no rejection criterion tripped (no scope expansion :171-175, no architectural violation :176-181, no per-model case/flag/knob, no format or re-export break, failure isolation preserved :182-187).
- Conventions/duplication C: should fix = HeaderIdentity manual Hash; InboundWindowSample in the completion enum; pick_next_pending_plan restating record_slots. Nits = memory.rs::windows third splitter, close() abandoned count + two settled() predicates, repeated unindex blocks/follower-detach closures, GatedCopier 4-tuple, the 250-word §2.4 bullet stating metrics twice. Description nit: "No core re-export or format change" overstates because TransportEvent gained a variant.
- Simplicity D: "Verdict: clean. No blocking, no should-fix findings in this lens." Seven nits, each a small deletion. Explicitly does NOT ask for the 8-pass pump to be reshaped; estimates ~215-230 removable lines (~6% of the change).
- Correctness: "No blocking or should-fix findings." All three prior items verified fixed. Nits: composite.rs:1376 progress tick for samples; a shared window whose ReadRow is deferred under disk-queue saturation can sit un-sampled until a later pump (invariant "phase == Reading ⇒ a pending submission or outstanding reply" is load-bearing and undocumented, disk_store.rs:2113-2116).
- Prose: no blocking or should-fix; three description nits (sample scoped wider than code; two Flash-Next ratios mismatch + caption ambiguity; "no format change" wording). Docs §2.4/§4 verified accurate; commit message fine.
HOW THE OLD FINDINGS MAP (so the post does not repeat itself): old blocker B1 -> resolved; old S1 bytes/rate -> resolved, replaced by the layering finding; old S2 docs -> narrowed to the paragraph-shape/duplication finding only (all content asks met); old S3 benchmark -> resolved; old S4/S5 -> resolved; old S6 -> narrowed to the maintainer-record ask; old nits 1-5 -> nit 1 is fixed in substance but re-graded to a message-vs-count nit, nit 2 and 4 largely fixed (counters gated, PlanState gone, SharedWindow fields gone), nit 3 GatedCopier remains, nit 5 naming-axis partly remains (two settled() predicates).
HONEST LIMITS to keep in the report: no toolchain, GPU or test run was available to this review — every finding is established from source at the head commit (do not claim a warning-free build was verified). Not reviewed: the ~5,300-line test module past the fixtures that were read, the #497 rebase interaction, and the five author-declared not-covered configurations. No instructions were embedded in the reviewed material.
#6 [medium] Nit findings: close() abandoned count, GatedCopier tuple, naming axis
selene/src/disk_store.rs:2475-2508 Staged::close: let abandoned = (outbound.len() + host_inbound.len() + device_inbound.len() + maintenance.len()).max(usize::from(self.busy())) (:2485-2489), while busy() (:2344-2351) is true when ANY of outbound/host_inbound/device_inbound/shared_segments/shared_windows/owners is non-empty. So a leaked shared window or segment alone reports abandoned == 1 even when the four summed pipelines are empty, and the error says "{abandoned} disk transport jobs did not complete" (:2501-2505). Pre-change code (main selene/src/disk_store.rs:1419) counted self.owners.len() — owned disk jobs. Fix: count owned jobs (owners.len(), or owners.len()+maintenance.len()) or reword the message. Diagnostics only: the error is still returned and the pool still leaked (:2495-2499), no lifetime change. Verdict: nit / minor should-fix — it is the line a shutdown warning or CI failure is read from, and it under-reports exactly in the coalesced case this PR introduces.
Other nits:
- GatedCopier fixture in disk_store's test module (:8051-8080, GatedCopierParts :8059-8064) returns a positional 4-tuple of Arc<Mutex<..>> handles destructured at each call site (:8364, :8488, :8608) vs the crate convention in selene/src/testing.rs (StoppedCopier :178, SimulatedGpu :225, both returning a 2-element pair). Also six new coalescing tests repeat the same pool/store construction block although write_shared_ancestor_tree (:8136) and poll_all_fetches (:8172) already exist.
- Naming axis mixing: HostInbound (:759) / DeviceInbound (:1117) named by destination but HostWindow (:746) / SharedWindow (:1070) named by sharing discipline (HostInPhase :741, SharedWindowPhase :1052). PrivateWindow/SharedWindow or Host/Device consistently.
- 60-word doc sentence splitting (docs:339-342) — see entry on docs.
#7 [medium] Findings: PR description prose (expected costs, benchmark provenance)
PROSE / DESCRIPTION items (AGENTS.md:72-140, docs/design-review.md principle 16, repo-prose skill "separate measurements from hypotheses"):
- "Existing users pay per-pump demand indexing when free slots exist and at most one extra window split when
skip_pages % 64 != 0" sits at the end of Result with no measurement → expectation stated as result (AGENTS.md:95-96). Also overstates: build_pending_demand returns an empty table before any work when device_inbound.len() <= 1 (selene/src/disk_store.rs:1651-1653) and pick_next_pending_plan takes the layout lock once per call (:1691-1695), so the cost applies to multi-fetch pumps only. Fix: label as expected/unmeasured bound and note the single-fetch fast path. - Benchmark provenance is a parenthesis: "measured before the linear demand-index and close-count edits" — table is not the head commit f9c9191 (unit suites were run at c0c4f798). "Not covered" separately says the SM121 runs were not repeated after the demand-index edit, which conflicts in emphasis. Fix: state plainly in the benchmark paragraph that the numbers are from an earlier commit of this branch (those edits change scheduling — pass 2 demand attach ordering — which is exactly what produces shared windows), or re-run at least one TP1 simultaneous and one staggered trial at head. The honest disclosure is why architecture lens rated it a nit, not a blocker (AGENTS.md:194-199).
- Commit message: single commit, imperative, matches neighbouring selene subjects, body reproduces the 4-part argument. Nothing to fix.
- "Not covered" section is genuine (helios FLARE_RUN_CUDA_TESTS=1, discrete PCIe GPUs, Windows serving, live CompositeStore/PooledStore GPU serving). Companion-PR logistics handled correctly per AGENTS.md:126-128 (merge #496 first, then rebase #497; both share the 425ab2d4 baseline). Both PRs touch Staged::pump_all (merging/pump_all order at :2268-2289 runs outbound, host_inbound, then device).
- No prose defect in the new type/state comments: SharedFileState (:1005-1017), SharedSegment/reusable/settled (:1019-1050), SharedWindow (:1065-1091) matches sweep_shared_windows (:1755), plan_aligned_windows (:697-699), pass comments Pass 1..5e, test names state the property. Model example of good documentation.
#8 [medium] Verified sound: lifetimes, failure isolation, host path, tests
What held up (do not ask the author to change):
- Slot lifetime: a shared window is released only when followers.is_empty() && disk_referenced == 0 && upload_referenced == 0 (sweep_shared_windows :1755-1771); segment removal requires active.is_empty() (Pass 5e :2213-2230); detach refuses while an upload is busy (:1737-1741); allocate(plan.count, plan.row) matches record_slots. No double release; Resources::release idempotent via slots.take() (:247-251). Each new test asserts pool.free_slots() == pool.slot_count().
- Host path unchanged: read_into keeps plan_windows (:1283), private per-restore opens, caller-buffer slicing in HostWindow (:914-923), sub-window resubmission (:931-970), unwind drains before reporting (:976-996). CompositeStore sees no change — good call: caller-owned buffers have caller-defined lifetimes (design-review principle 6).
- read_into deliberately NOT coalesced: correct, not a missed opportunity.
- No existing shared-handle/demand mechanism was duplicated (shard::Sharded has only a plain fetch, selene/src/shard.rs:900).
- Failure isolation: private child/upload errors via record.fail (:1563-1565); shared open/read errors via fail_segment_users (:1449-1473) and fail_window (:1475-1487) after in-flight I/O; with_record_read() applied (:1503, :1540); TransportEvent::Fetched keeps routing record_read to index.drop_row (:3634-3640).
- No format/Header/on-disk change, no core re-export change; sharing keys on (path, expected Header) so records written by main read unchanged. WINDOWS_IN_FLIGHT still derives from crate::shared::WINDOW_CREDITS (:60).
- No new flags, env vars, config knobs, cfg-gated production paths, or per-model branches.
- Tests exercise the real path (SimulatedGpu byte-exact page/row assertions :8453-8570), and the counters are incremented at the actual submit_disk sites (:910, :946, :963, :1946, :2082, :2109), not in mocks — satisfies AGENTS.md:194-199.
- The 8-pass pump_device_inbound ordering carries a correctness argument per pass (attach before sweep, release before start, submit reads then uploads) — simplicity lens explicitly did NOT ask for a different shape, only for the duplicated attach loop to go.
- The +2803/-913 size is not churn under AGENTS.md:188-193.
#11 [medium] Addendum to Should Fix #1: Level::Rate inflates and does not self-correct
ADDENDUM to Should Fix #1 (rate mechanics). selene/src/levels.rs:36-76: Rate keeps the median of the last three completed samples, and get() applies upward decay ONLY when median < seed (INITIAL_STAGED_DISK_RATE = 3e9, selene/src/store.rs:418). So an inflated median that sits ABOVE the seed does not decay back: it is returned as-is until three more samples arrive to push the median down. A single coalesced burst therefore mis-prices every restore for at least the next three completed restores, which strengthens the "should fix" call: this is not a transient blip in a dashboard. Also Rate::observe ignores zero-byte/zero-elapsed samples (:58-60), so a fix cannot simply skip the coalesced sample without also ensuring the physical sample is submitted — use one sample per window (or per segment) with its own start instant.
Severity rationale for the final report: not a blocker (no data is wrong, no lifetime is broken, and the write-up already discloses no byte-reduction claim for this counter), but it changes a scheduled policy's input; correctness lens A1 and architecture finding 1 both rated it "should fix".
#16 [medium] Verdicts and severity rationale across the five review lenses
Five prior lenses: A correctness, B architecture/scope, C conventions/duplication, D simplicity, E prose.
- A (correctness): no blocking defect in the paths read; A1 logical-vs-physical bytes -> inbound_rate (should fix), A2 the 8/9 -> 7/9 gap (should fix, may collapse to a description fix), A3
Staged::closecount (nit). Confirmed sound: slot lifetime, demand ordering, host path unchanged, failure isolation, Fetched emission, pump_all order. - B (architecture/scope): change belongs (charter "What gets merged" allows a measured performance issue; AGENTS.md:165-166; goal: share prefix-cache checkpoints via Selene). No rejection criterion tripped (no scope expansion 171-175, no architectural violation 176-181, no per-model branch/flag/env, no format or re-export change, weakened-guarantee rule 182-187 respected). Should fix: bytes metering; the new ownership protocol needs a recorded design decision and a corrected module contract; doc overstates. Nits: benchmark provenance, coalescing unobservable outside tests.
- C (conventions/duplication): should fix only — duplicated planner, unnamed
WindowKeyidentity, per-pump allocation/quadratic scan. Nits: GatedCopier tuple/placement, ungated counters, close() count, naming axis, prose. - D (simplicity): explicitly NO blocking or should-fix finding — "do not add frameworks/switches" (AGENTS.md:188-193) is satisfied and the +2803/−913 size is not churn; the eight items are all nits with smaller versions (one planner, one attach helper, single
Segment,startedflag, drop duplicated window fields, gate counters, split the doc sentence, description overstates per-pump cost). - E (prose): nothing blocking, three should-fix — misplaced
allocaterustdoc, unexplained 8/9→7/9, expected costs stated as results — plus nits on benchmark provenance, "aligned" unresolved, and error scope missing from §2.4/§2.12.
Where lenses disagreed: D rated the planner duplication and the per-pump cost nits, C rated both should-fix, B rated the design-decision item should-fix and the bytes item should-fix; the full report takes the higher grade where two lenses overlap and keeps D's stack-reduction suggestions as nits so the author is not asked to reshape the 8-pass pump. Only A/B/E together produced the single blocker: nothing in any lens found a memory-safety, lifetime or data-corruption defect in the code as written — the blocker is an unresolved measurement in the PR's own evidence, not a proven bug, which is why the request is "settle it or declare it inconclusive" rather than "fix this defect".