#1 [high] Research summary
Review of PR #496 (lens C: conventions and duplication) against the charter, AGENTS.md, docs/design-review.md and .agents/skills/repo-prose/SKILL.md (not opened). I read the whole diff (docs/prefix-cache-offload.md, selene/src/disk_store.rs) and each new construct in its surrounding code, plus the existing precedents it parallels (plan_windows, memory.rs::windows, Segment/InboundRecord, selene/src/testing.rs fixtures, StoreStats, the cfg(any(test, feature = "test-support")) instrumentation in selene/src/disk.rs). I could not build or run the suite (no compiler/hardware here), so every finding is from the code only.
Findings, by severity:
-
Should fix —
plan_aligned_windows(selene/src/disk_store.rs:700) duplicatesplan_windows(:672) almost line for line: same signature, sameWindowPlanoutput, same zero-page/row-only handling, differing only in that the chunk end is clamped to the nextWINDOW_PAGESboundary.selene/src/memory.rs:1336 windows()is a third copy of the same splitter. One function with an alignment mode (or afirst-alignment parameter) keeps the three call sites consistent; as written a change to row placement or empty-link handling must be made in three places. -
Should fix — the shared-window identity tuple
(path, expected Header, first, count, row)is re-expressed four times without a shared type: segment lookup bypath+expected(:1368),SharedWindowfield match infind_reusable_window(:1578), the demand-table key plus innerVec<(Header, usize)>scan (:1647–1677), and the demand-key reconstruction in the two decrement blocks (:1890 and :1996). The PR already introduces named ids (SharedSegmentId,SharedWindowId) in the same spirit; a singleWindowKey(with theHeaderreduced to a comparable digest, sinceshared::record::HeaderderivesPartialEqbut notHash) would make the identity definition one thing and let the demand map and window lookup share it. -
Should fix — per-pump allocation in the poll loop:
build_pending_demandclones aPathBufper pending plan and per bucket push (:1668), andpick_next_pending_plan(:1710) plus the two decrement blocks (:1890, :1996) cloneseg_ref.pathagain on every lookup. That is a heap allocation per plan perpump_device_inboundcall in steady-state serving, which the PR body itself acknowledges as new cost for existing users.find_reusable_windowalso scans everyshared_windowsvalue for every pending plan of every record (Passes 2 and 4). An index fromWindowKeytoSharedWindowId, alongside thepending_page_readsmap the PR already added, removes both the clones and the quadratic scan. -
Nit —
GatedCopier(:8051) andReverseWindows(:7732) are test copiers defined insidedisk_store.rs's test module, andGatedCopier::wrapreturns the positional 4-tupleGatedCopierParts(:8059) ofArc<Mutex<...>>handles. The established fixture precedent isselene/src/testing.rs(StoppedCopier:178,SimulatedGpu:225 withshared_mapped/sharedconstructors returning a two-element pair). IfGatedCopieris used by more than this test module it belongs beside those; either way a small named struct with fields beats a four-element positional tuple. The six new coalescing tests also repeat the same pool/store construction block (:8253–8330 and five more);write_shared_ancestor_treeandpoll_all_fetchesalready exist as fixture helpers and a matchingstore_for_fixturewould remove that repetition. -
Nit — the new counters (
disk_opens,disk_window_reads,coalesced_windows, :192–200) are unconditionalResourcesfields whose accessors, not the fields, are gated, requiring#[cfg_attr(not(any(test, feature = "test-support")), allow(dead_code))]— an attribute used nowhere else in selene/src (only two occurrences in helios/src). The precedent in this crate is to compile the whole test-only member out:selene/src/disk.rs:321,:437,selene/src/disk.rs:309keepfaultsunder#[cfg(any(test, feature = "test-support"))]. Gating the three fields the same way removes the threeallow(dead_code)attributes and the counter increments from release builds. Separately, the crate's stated home for counters isStoreStats(selene/src/store.rs:185–244, "counters every store maintains", reported by/metrics); a physical-open and physical-read count is exactly the kind of number an operator needs to see that coalescing is happening, and it currently reaches tests only. -
Nit —
Staged::close(:2485–2489) now computesabandonedas the sum of outbound/host_inbound/device_inbound/maintenance lengths,.max(usize::from(self.busy())), butbusy()also countsshared_segmentsandshared_windows, so the number can be a floor of 1 that is not a job count. The previous code counted owned disk jobs (owners.len()), and the message still reads "{abandoned} disk transport jobs did not complete". Either count what the message claims (owned disk jobs) or reword the message to what is counted. -
Nit — naming axis mixing in the new types: the record split is
HostInbound(:759) /DeviceInbound(:1117), but the window split isHostWindow(:746) /SharedWindow(:1070), and the phase enumsHostInPhase/SharedWindowPhase. The host path's counterpart ofSharedWindowis named by the other axis, so a reader pairing the two paths has to check both.PrivateWindow/SharedWindoworHostWindow/DeviceWindowwould keep one axis. -
Nit (prose, per the repo-prose skill) — the section 2.4 addition (docs/prefix-cache-offload.md:338–342) states the coalescing rule but not the constraint that makes it valid, namely that published record files are immutable and pinned for the duration of every restore referencing them; that is the invariant a reader needs before accepting that one handle and one staged window can serve several GPU uploads. The module doc comment (selene/src/disk_store.rs:17–21) has the same gap. The doc also says "aligned 64-page windows" while the rest of the section speaks of
WINDOW_PAGES/64 pages plus the multi-slot row (line 398); naming the constant where the alignment rule is introduced would tie the two statements together.
Nothing in the diff duplicates a helper that already did the job (no existing coalescing or shared-handle mechanism in selene/src, shard::Sharded has only a plain fetch at shard.rs:900), and the separator — Staged::read_into staying on the private path — is stated in both the code and the doc, consistent with the design-review principle 6 requirement that lifetimes be explicit. The duplication and instrumentation findings above are the lens-C issues; the highest-value ones are 1–3.
#2 [high] PR #496 lens C: conventions and duplication findings
PR #496 (open, head f9c9191, base main, 2 files +2808/−914: selene/src/disk_store.rs, docs/prefix-cache-offload.md). Reviewer lens C: conventions & duplication. Rules read: charter, AGENTS.md, docs/design-review.md, .agents/skills/repo-prose/SKILL.md. No build/test run possible here; all findings from code.
FINDINGS
-
should fix — plan_aligned_windows (selene/src/disk_store.rs:700) duplicates plan_windows (:672): identical signature, identical WindowPlan output, identical zero-page/row-only handling; only difference is chunk end clamped to next WINDOW_PAGES boundary (:721-722). Third copy of the same splitter is memory.rs:1336
windows(). Fix: one function with alignment parameter. -
should fix — the shared-window identity (path, expected Header, first, count, row) is re-expressed 4×: acquire_shared_segment matching (:1368-1373), find_reusable_window field match (:1578-1583), build_pending_demand key + inner Vec<(Header,usize)> scan (:1647-1677), and demand-key reconstruction at :1890 and :1996. No shared WindowKey type although the PR introduces SharedSegmentId/SharedWindowId. selene/src/shared/record.rs:110-117: Header derives PartialEq but not Hash, so a digest-based key is needed for hashing.
-
should fix — per-pump heap allocation: build_pending_demand clones PathBuf per pending plan/bucket push (:1668); pick_next_pending_plan clones seg_ref.path per lookup (:1710); decrement blocks clone again (:1890, :1996). find_reusable_window (:1576-1599) scans all shared_windows for every pending plan of every record in Passes 2 and 4. Fix: index WindowKey -> SharedWindowId like the PR's own pending_page_reads map.
-
nit — test copiers GatedCopier (:8051) and ReverseWindows (:7732) live in disk_store.rs test module; GatedCopier::wrap returns positional 4-tuple GatedCopierParts (:8059-8064). Precedent: selene/src/testing.rs StoppedCopier :178, SimulatedGpu :225 (shared_mapped/shared return a 2-element pair). Also the 6 new coalescing tests repeat pool/store construction (:8253-8330 etc.) while write_shared_ancestor_tree (:8136) and poll_all_fetches (:8172) already exist as helpers.
-
nit — counters disk_opens/disk_window_reads/coalesced_windows are unconditional Resources fields (:192-200) with only accessors gated (:1214-1229), requiring #[cfg_attr(not(any(test, feature="test-support")), allow(dead_code))] — pattern used nowhere else in selene/src (only helios/src/runtime_core/payload.rs:130, protection.rs:2657). Precedent: selene/src/disk.rs:309/:321/:437 gate the whole
faultsmember. Also StoreStats (selene/src/store.rs:185-244, "counters every store maintains", /metrics) is the crate's home for counters; physical open/read counts are operator-visible signal that only reaches tests. -
nit — Staged::close (:2485-2489)
abandoned= outbound+host_inbound+device_inbound+maintenance lengths .max(usize::from(self.busy())), but busy() also counts shared_segments/shared_windows, so it can be a floor of 1 that is not a job count; message still says "{abandoned} disk transport jobs did not complete". Previously counted owners.len(). -
nit — naming axis mixing: HostInbound (:759) / DeviceInbound (:1117) vs HostWindow (:746) / SharedWindow (:1070), and HostInPhase / SharedWindowPhase. HostWindow's counterpart is SharedWindow, named on the other axis.
-
nit (prose, repo-prose skill) — docs/prefix-cache-offload.md:338-342 states the coalescing rule without the invariant that makes it valid (published record files are immutable and pinned across every restore referencing them); module doc selene/src/disk_store.rs:17-21 has the same gap. Doc says "aligned 64-page windows" while the section speaks of WINDOW_PAGES plus the multi-slot row (doc line 398); name the constant where the alignment rule is introduced.
NEGATIVES / CHECKED, NOT A FINDING
- No pre-existing coalescing or shared-handle mechanism duplicated: shard::Sharded has only a plain fetch (selene/src/shard.rs:900).
- read_into stays on the private path (disk_store.rs:1268-1297) and the separator is stated in code and doc, consistent with design-review principle 6 (explicit lifetimes). Not a convention departure.
- Resources::free_slots() (:230) is a new small helper but no existing one does the job; resources.disk_space()/transfer_space() are its precedents.
- debug_assert! at :1923 is fine; used in selene elsewhere (memory.rs:534, composite.rs:647).
- Doc-side omission of test-support counters from /metrics is arguable either way; framed as nit above.
#4 [high] Should fix: HeaderIdentity hand-writes Hash mirroring a remote PartialEq
SELENE/src/disk_store.rs:1001-1050 — HeaderIdentity(Arc<Header>) implements PartialEq by delegation but writes Hash by hand, destructuring Header and hashing 14 fields one by one.
The contract it mirrors is impl PartialEq for Header in selene/src/shared/record.rs:136-152, an exhaustive field list in a different module ~1200 lines away (Header defined record.rs:116-134, Eq at :154).
Why it matters: the Hash destructure ends with .. (disk_store.rs:1030) and record.rs's PartialEq list is exhaustive. Adding a field to Header forces an edit in record.rs (compile error) but NOT here — the new field silently drops out of the hash, so two headers that compare equal can hash differently, window_index.get(&key) misses, and coalescing silently stops working (perf regression, no test failure; nothing in the suite exercises hash/eq agreement).
Precedent for the alternative: the crate derives both — PrefixKey derives PartialEq, Eq, Hash, PartialOrd, Ord (selene/src/vocab.rs:30), RankSizes derives PartialEq, Eq (record.rs:89), DiskRecord derives (disk_store.rs:72). Result 35 confirms this is the ONLY impl Hash written by hand anywhere in selene/src.
Fix: move Hash beside PartialEq in shared/record.rs (#[derive(Hash)] on Header, or a record::HeaderKey digest type defined next to it) so the two contracts cannot drift; then HeaderIdentity shrinks to the Arc + ptr_eq fast path. Alternative the PR already implies: key on an existing content digest rather than hashing the struct.
#5 [high] Should fix: new sample variant in the completion enum forces special-cases and inflates composite progress
selene/src/disk_store.rs:83-110 — the enum's own doc says "Completion the transport reports to the disk store", yet the new variant InboundWindowSample { bytes, elapsed } (:97-101) is a rate sample, not a completion, and every consumer must now special-case it:
- selene/src/disk_store.rs:3632-3638 —
applyearly-returns beforeself.stats.progress += 1, then the match needsTransportEvent::InboundWindowSample { .. } => unreachable!()to stay exhaustive. - selene/src/shard.rs:476-478 —
Kind::ofreturnsunreachable!("window rate samples stay local to rank zero"). This panic is load-bearing on two forwarding guards that must stay in sync: shard.rs:722-724 (absorb_localpushes to self.events andcontinues) and shard.rs:1148-1150 (Peer::forwardskips). A future caller that routes a sample throughKind::ofpanics instead of getting an error — the crate's convention at shard.rs:462 isreturn Err(invalid("unknown prefix record event kind")). - The wire
Kindenum (shard.rs:441-464) has no code for it, so a peer can never transmit it; the variant exists only on rank 0.
Concrete side effect, verified: CompositeStore (selene/src/composite.rs:1373-1386) drains transport events and does self.stats.progress += 1 at :1376 for every event before dispatch. That progress feeds the maintenance gate at composite.rs:1418-1424 (maintenance_progress != progress → spill_parked(...) + self.disk.maintain()). So each physical window read now re-runs both, once per 64-page window, per restore — the very maintenance cadence StoreStats.progress documents as "Completion and capacity-release events" (selene/src/store.rs:202).
Fix options: state in the variant doc that it is a sample and not a completion and make that structural (a separate fn drain_samples / out-parameter, or a field on Fetched), and exclude it from composite progress. The precedent for a rate signal that is not an event is the existing Budget::progress() counter (selene/src/input.rs:146-152) read by the store, rather than a unit variant of the completion enum.
Note the physical-rate mechanism itself is sound — DiskStore::apply observes inbound_rate at :3632-3634 and Fetched no longer observes it (:3669), which is exactly what the PR claims. This finding is about where the signal is carried.
#9 [high] Resolved-since-last-review list and the one remaining duplication (memory::windows)
Re-checked at 0c04b1e2. Previously reported as should-fix; mostly resolved, with one third copy remaining.
RESOLVED (do not re-report):
- Finding "plan_aligned_windows duplicates plan_windows": fixed — now one
plan_windows(segments, align_to_window: bool), selene/src/disk_store.rs:679-727, with a doc comment (:679-681) explaining whyread_intopassesfalse(:1349) andfetchpassestrue. - Finding "window identity re-expressed 5x, O(n) demand scan": fixed —
SegmentKey(:1052-1056),WindowKey(:1058-1064),window_index: HashMap<WindowKey, SharedWindowId>(:1229),build_pending_demandreturnsHashMap<WindowKey, usize>(:1734-1755),find_reusable_windowis an O(1) index lookup (:1646-1663). - Finding "per-pump PathBuf clone + O(windows x plans) scan": fixed —
SegmentKey.pathisArc<Path>(:1054) so cloning a key does not copy the path. - Finding "test-only counters behind allow(dead_code)": fixed — the three counters are proper
#[cfg(any(test, feature = "test-support"))]fields (:200-208). - Finding "Pass 2 / Pass 4 attach-loop duplication": fixed —
has_window_credit(:1683-1687) andattach_pending(:1711-1730) are extracted and shared (:1916-1918, :1932-1935). - Finding "doc prose lacks the immutable/pin invariant, says '64-page' not WINDOW_PAGES": fixed — docs/prefix-cache-offload.md:346-350 now states the immutability + index-pin + close-before-Fetched invariant, and :342/:356 use
WINDOW_PAGES. - Doc signatures now match code: doc says
write_from(id, header, temporary, path, pages, row, sums)/read_into(id, path, expected, first_page, pages, row)(docs:337-338); code agrees exactly (disk_store.rs:1308-1317, :1334-1342).
STILL PRESENT (third copy of the splitter):
memory.rs::windows() selene/src/memory.rs:1333-1367 remains a third expression of the same WINDOW_PAGES splitter with the same policy: pages.chunks(WINDOW_PAGES) (:1344), row attached to the last chunk (row: if last { row.clone() } else { None }, :1353), a row-only record gets one window (:1356-1365), an empty link gets none (empty chunks → falls through). That is the same three-way rule disk_store.rs plan_windows encodes at :689-700 (zero pages + row → one window) and :719 (row: row && chunk_end == end). Its output type differs (VecDeque<copier::Job> vs Vec<WindowPlan>), so full convergence is a refactor; the minimum is a test pinning the shared policy, or a comment on plan_windows naming memory::windows as its twin. Severity: nit now that the disk-side duplication is gone.
#12 [high] Report of 2026-11-25, run 254 — PR #496 lens C at head 0c04b1e2
Review of PR #496 — lens C: conventions and duplication
Head reviewed: 0c04b1e2 (base main c0c4f798). 3 files, selene/src/disk_store.rs, selene/src/shard.rs, docs/prefix-cache-offload.md. Rules applied: charter lines 9 ("smallest footprint in shared code") and 43/57; AGENTS.md:52-60 (document purposes), :82-102 (why/what/benefit/evidence), :188-193 (reject unsupported abstractions); docs/design-review.md:74 ("account for duplicate representations"); .agents/skills/repo-prose/SKILL.md:71,:84. Not runnable here (no toolchain/GPU), so every finding is established from code.
Verdict: should-fix issues only. No blockers. Six of my previous should-fix/nit findings are resolved at this head (see entry 9) — most notably the plan_aligned_windows/plan_windows duplication, the five-time hand-written window identity, the per-pump PathBuf clones and O(windows x plans) scan, and the Pass 2/Pass 4 attach-loop duplication. Three new should-fix items come from the fixes themselves.
Should fix:
- disk_store.rs:1001-1050 —
HeaderIdentityhand-writesHashover 14Headerfields in a destructure ending in..(:1030), mirroringimpl PartialEq for Headerat shared/record.rs:136-152 in another module. The only hand-writtenHashin selene/src. A field added toHeaderbreaks the compile in record.rs but silently drops out of the hash here → equal headers hash differently →window_indexmisses → coalescing silently stops. Fix: moveHashbesidePartialEqin shared/record.rs, or key on an existing digest. - disk_store.rs:97-101 + 3632-3638, shard.rs:476-478, composite.rs:1376 —
TransportEvent::InboundWindowSampleis a rate sample in an enum documented as "Completion ... reports" (:83). Every consumer special-cases it: twounreachable!()(disk_store.rs:3638, shard.rs:477) guarded by two skip checks that must stay in sync (shard.rs:722-724, :1148-1150); the wireKind(shard.rs:441-464) has no code for it. Concrete cost:CompositeStorebumpsself.stats.progressfor every transport event (composite.rs:1376), that progress surfaces inCompositeStore::stats()(:1482) and gates maintenance (:1418-1424), so each physical window read re-runsspill_parked+disk.maintain(). Fix: carry the sample out-of-band (a drain method or a field onFetched), precedentBudget::progress(input.rs:146-152); exclude from composite progress. The underlying physical-rate mechanism itself is correct (apply:3632-3634 observes;Fetched:3669 no longer does). - disk_store.rs:1766-1777 —
pick_next_pending_planrecomputes slots asplan.count + if plan.row { row_slots } else { 0 }whereLayout::record_slots(geometry.rs:180-182) already does it, and takes the transfers mutex per candidate plan.Resources::allocate(:243-254) usesrecord_slots, so theneeded > freeguard must agree with it.
Nits:
4. disk_store.rs:2513-2544 — close()'s abandoned is .max() over map sizes, so it can report one "disk transport job" for a leaked window (no jobs) or under-report 4 jobs behind 6 leaked windows; message at :2542 always says "disk transport jobs".
5. disk_store.rs:662-664 vs :1106-1109 — two different settled() predicates in the same file, both live.
6. disk_store.rs:1525-1527 / :1543-1545 / :1837-1839 — identical "unindex if index still points at it" block three times; :1813-1816 / :1900-1904 — identical follower-detach retain closure twice; :1690-1695 pushes the same (record, plan_index) identity.
7. memory.rs:1333-1367 windows() remains the third copy of the WINDOW_PAGES splitter (row on last chunk :1353, row-only one window :1356-1365, empty none) now that the disk-side pair is unified — the remaining one.
8. disk_store.rs:8092-8122 — GatedCopier::wrap returns positional GatedCopierParts 4-tuple; 3 of 5 call sites discard by position (:8406, :8530, :8984 _; :8650 _, _). Precedent SimulatedGpu::shared_mapped/StoppedCopier (testing.rs:178, :225) — named handles.
9. docs/prefix-cache-offload.md:337-366 — one 30-line ~250-word bullet carrying nine facts, and the bytes_in/inbound_rate contract is stated twice (:362-366 and :1528-1531).
Checked and sound (not findings): read_into staying private is the right call (explicit lifetimes, design-review principle 6); Resources::free_slots follows disk_space/transfer_space; debug_assert! at :1950 matches selene usage; no pre-existing coalescing/shared-handle helper is duplicated (shard.rs:900 fetch is plain); HeaderIdentity's Arc::ptr_eq fast path is correct; doc signatures now match code exactly (doc :337-338 vs disk_store.rs:1308-1342).
Unsettled: whether Header can derive Hash given its __ private version field is excluded from PartialEq (record.rs:118-119, correctly excluded from the new hash too); nothing here can be settled by a test without a toolchain.
#13 [high] Research summary
Reviewed PR #496 at head 0c04b1e2 through the conventions-and-duplication lens, re-checking every prior finding against the rewritten code and reading each new construct in context. Full report is scratchpad entry #12, with per-finding detail in entries #4–#11 and a resolved/sound ledger in #9.
Verdict: should-fix only, no blockers. Six of my previous findings are genuinely resolved at this head: plan_aligned_windows is folded back into one plan_windows(…, align_to_window); the five-times-hand-written window identity is now named SegmentKey/WindowKey with an O(1) window_index; the per-pump PathBuf clones and O(windows×plans) scan are gone (Arc<Path> keys); the Pass 2/Pass 4 attach loop is extracted into has_window_credit/attach_pending; test-only counters are properly cfg-gated; and the docs now state the immutability/pin invariant with signatures that match the code exactly.
Three new should-fix items, all created by the fixes: (1) HeaderIdentity hand-writes Hash over 14 Header fields with a .. rest-pattern, mirroring impl PartialEq for Header 1,200 lines away in another module — the only hand-written Hash in selene/src, and one where a new Header field would silently break coalescing instead of failing to compile; (2) the new InboundWindowSample is a rate sample placed inside TransportEvent, an enum documented as completions, forcing two unreachable!()s and two skip guards, and it makes CompositeStore count disk-window samples as progress, which gates its maintenance pass; (3) pick_next_pending_plan recomputes pages + row*row_slots by hand rather than calling the existing Layout::record_slots, so its admission guard can disagree with the allocator it guards.
Six nits remain, the substantive one being that memory.rs::windows() is now the last surviving third copy of the WINDOW_PAGES splitter policy, plus close()'s .max()-of-map-sizes message, two same-named settled() predicates, three repeated window-index/follower-detach idioms, the positional GatedCopier 4-tuple, and a 250-word §2.4 bullet that states the metrics contract twice.
Everything is from code reading; no toolchain or GPU was available, so nothing was compiled or run and no finding rests on a test result.
#17 [high] Correction at head 0c04b1e2: HeaderIdentity's .. fails safe (collisions, not broken coalescing)
CORRECTION to entry #16 finding 1 and entry #4.
At head 0c04b1e2 the omission is already live, not hypothetical: Header at selene/src/shared/record.rs:116-134 has no packed field, but main (post-#504, commit 716df00f) added pub packed: Option<Arc<packed::Layout>> at main's shared/record.rs:127 and included it in impl PartialEq for Header at main:146. HeaderIdentity::hash (disk_store.rs:1014-1050) destructures with .. at :1030 and hashes 14 fields, so packed is not hashed.
Direction of the error matters, and I had it wrong:
- HashMap soundness needs
a == b ⇒ hash(a) == hash(b). SinceHeader'sPartialEq(record.rs:136-152) is stricter than the hash (14 of 14 fields it lists, exhaustive today), a new field added toPartialEqand omitted fromhashkeeps the implication true. The hash becomes coarser: headers differing only inpackedcollide into one bucket and are still told apart byeq. So the effect is bucket collisions / a slowerwindow_index(disk_store.rs:1229, lookups :1647), NOT "coalescing silently stops working" as entry #16 §1 says. - The unsound direction is the reverse: any field in
hashthatPartialEqexcludes, e.g. the privateversion(record.rs:118-119 in the PR tree) which is explicitly documented "not semantic identity". Today it is excluded from both; the..rest-pattern makes a future edit here silent in either direction, which is the real hazard.
So the finding stands but must be re-framed: HeaderIdentity is the only hand-written Hash in selene/src (grep impl (std::hash::)?Hash for → disk_store.rs:1014 alone), while the crate derives instead (PrefixKey vocab.rs:30, SegmentKey/WindowKey disk_store.rs:1052/1058, levels.rs:9, plan.rs:22, store.rs:17/115, shard.rs:441, slab.rs:36). It duplicates Header's equality contract from another module and needs maintenance on every Header field change with no compiler help. The fix is unchanged and still cheap: give Header a Hash (next to its PartialEq at record.rs:136-154) that mirrors the field list, or hash the canonical form already used by shard::shape (selene/src/shard.rs:1242-1249, header.canonical_encoding()), and add an a == b ⇒ hash(a) == hash(b) test. Severity stays should-fix on conventions grounds (single hand-written Hash, cross-module contract duplication); drop the "coalescing stops with no test failure" sentence from the report — that claim is not supportable.
Everything else in entry #16 was re-verified at the same head commit and is unchanged: no new commits since (PR head still 0c04b1e2), InboundWindowSample still at disk_store.rs:97-101 with unreachable!() at shard.rs:476-478 and the two guards at shard.rs:722-725 / :1148-1150; CompositeStore::poll still bumps stats.progress for every transport event at composite.rs:1376 ahead of the maintenance gate at :1418-1429; pick_next_pending_plan still recomputes plan.count + row*row_slots at disk_store.rs:1777 where Layout::record_slots (geometry.rs:180-182) exists and is what Resources::allocate uses (disk_store.rs:245); memory.rs::windows() (memory.rs:1336-1367) is still the third splitter beside plan_windows (disk_store.rs:682-727); Staged::close still reports the .max() chain (:2522-2545) as "disk transport jobs".
#18 [high] Research summary
Re-reviewed PR #496 (head 0c04b1e2, unchanged — no new commits since my last report) through the conventions-and-duplication lens, re-verifying every prior finding against the code and correcting one. The verdict is unchanged: no blockers, three should-fix findings, six nits; the full report is my scratchpad entry #16, with the correction recorded as entry #17.
The correction matters. My previous report said that HeaderIdentity's hand-written Hash (selene/src/disk_store.rs:1014-1050, .. rest-pattern at :1030) would make coalescing "silently stop" if a Header field were added. That is the wrong direction: because Header's PartialEq (selene/src/shared/record.rs:136-152) enumerates every field while the hash omits any new one, the a == b ⇒ hash(a) == hash(b) implication still holds and the only effect is extra hash collisions in window_index — the unsafe direction is the reverse (a hashed-but-not-compared field such as the private version). And the omission is not hypothetical: main has already grown packed: Option<Arc<packed::Layout>> on Header (main's shared/record.rs:127, compared at :146) after this branch, so the .. is dropping a real field today. The finding survives as a conventions issue — it is the only hand-written Hash in selene/src while every other key type derives (PrefixKey vocab.rs:30 (not opened), SegmentKey/WindowKey disk_store.rs:1052/1058), and it duplicates a contract owned 1,200 lines away in another module — with the same fix: put Hash beside Header's PartialEq (or hash canonical_encoding, as shard::shape at shard.rs:1242-1249 does) and add an equal-implies-equal-hash test.
The other two should-fix findings re-verified unchanged: TransportEvent::InboundWindowSample (disk_store.rs:97-101) is a rate sample inside an enum documented as completions (:83), forcing unreachable!() at shard.rs:476-478 plus two hand-written guards (:722-725, :1148-1150), and it makes CompositeStore::poll bump stats.progress per physical window (composite.rs:1376) ahead of the maintenance gate (:1418-1429); and pick_next_pending_plan recomputes plan.count + row*row_slots by hand (:1777) where Layout::record_slots (geometry.rs:180-182) is already what the allocator it guards uses (disk_store.rs:245). Nits stand as before — the surviving third WINDOW_PAGES splitter in memory.rs::windows (memory.rs:1336-1367), Staged::close's .max() chain reported as "disk transport jobs" (:2522-2545), duplicate settled() predicates, three repeated unindex blocks and two repeated follower-detach closures, the positional GatedCopier 4-tuple, and the 250-word §2.4 bullet that states the bytes_in/inbound_rate contract a second time (§4, docs:1528-1531). No toolchain or GPU here, so nothing was compiled or run.
#19 [high] FINAL corrected report — PR #496 lens C (conventions & duplication), head 0c04b1e2
Review of PR #496 — lens: conventions and duplication (FINAL, corrected)
Head 0c04b1e2, base main c0c4f798. No new commits since the previous round. Changed files: selene/src/disk_store.rs (+3313/−931), selene/src/shard.rs (+10/−0), docs/prefix-cache-offload.md (+35/−2). Case file: https://autobot.eidonix.com/api/v1/cases/774e16ea-5f84-4ff8-9166-74ab6876cc37.html
Verdict: should-fix only. No blockers. This supersedes entry #16, whose finding 1 stated the wrong failure mode (see "Correction" below). Per-finding detail: #4–#11; resolved/sound ledger: #9; coverage ledger: #14; description accuracy: #15; correction: #17.
Rules applied: charter line 9 ("Solve the right problem in the right place… smallest footprint in shared code"), lines 24, 35, 42-43; AGENTS.md:52-60 (one purpose per document), :72-140 (why/what/benefit/evidence, untested scope), :188-193 (reject unsupported abstractions and churn — "Refactoring must directly support the requested behavior or remove a demonstrated source of defect or cost"), :201-207 (maintainer decision required for an architectural invariant); docs/design-review.md:74 ("account for duplicate representations"); .agents/skills/repo-prose/SKILL.md:71, :84 (ordinary readable sentences). No toolchain or GPU was available: nothing was compiled or run; every finding is established from source.
Correction to the previous round
My earlier report claimed HeaderIdentity's .. rest-pattern means "a new Header field silently drops out of the hash and coalescing stops with no test failure". Wrong direction, and worth stating precisely:
HashMapsoundness needsa == b ⇒ hash(a) == hash(b).Header'sPartialEq(selene/src/shared/record.rs:136-152) is exhaustive; the hash covers fewer fields, so adding a field toPartialEqwhile the hash omits it keeps the implication true — the hash merely becomes coarser and colliding entries are still separated byeq. Effect: bucket collisions / slowerwindow_index(disk_store.rs:1229, lookups :1647), not lost coalescing.- The genuinely unsound direction is the reverse: a field included in
hashbut excluded fromPartialEq, i.e. the privateversionfield (record.rs:118-119, documented "not semantic identity"). Today it is excluded from both. - The omission is nonetheless live, not hypothetical:
mainhas since addedpub packed: Option<Arc<packed::Layout>>toHeader(main's shared/record.rs:127) and compares it inPartialEq(main's :146). This branch'shash(14 fields,..at :1030) does not hash it.
So finding 1 stands as a conventions/robustness issue, not as a correctness bug.
Should fix
1. The only hand-written Hash in selene/src, mirroring an equality contract owned in another module
File: selene/src/disk_store.rs:1001-1050 (impl :1014-1050; .. at :1030). Precedent: selene/src/shared/record.rs:136-154 (impl PartialEq for Header exhaustive, impl Eq); derives everywhere else — PrefixKey (vocab.rs:30), SharedSegmentId/SharedWindowId (:995/:998), SegmentKey (:1052), WindowKey (:1058), levels.rs:9, plan.rs:22, store.rs:17/:115, shard.rs:441, slab.rs:36, pool/types.rs:12. Grep impl (std::hash::)?Hash for over selene/src returns exactly this one hit.
HeaderIdentity(Arc<Header>) implements PartialEq by delegation (:1006-1010) then hashes ten-plus-four fields by hand. Adding or reclassifying a Header field is a compile error in record.rs and silent here; the .. makes the omission invisible in review. Fix: implement Hash next to Header's PartialEq in shared/record.rs (or hash the canonical encoding already used by shard::shape, shard.rs:1242-1249 via Header::canonical_encoding, record.rs:260/348) and add a test that equal headers hash equally.
2. A rate sample placed in the cross-rank completion enum
File: selene/src/disk_store.rs:83 ("Completion the transport reports to the disk store"), variant :97-101. Consumers that must special-case it: Kind::of shard.rs:476-478 (unreachable!), absorb_local shard.rs:722-725 and Peer::forward shard.rs:1148-1150 (skip guards that must stay in sync), DiskStore::apply disk_store.rs:3632-3638 (early return plus a second unreachable! arm), CompositeStore::poll composite.rs:1376 bumping stats.progress for every event before the maintenance gate at :1418-1429 (spill_parked + disk.maintain()).
Precedent for out-of-band progress/rate signalling in the same crate: Budget::progress / DiskBudget::progress (selene/src/input.rs:80-81, :146-148) and StoreStats.progress (store.rs:201-202) — a counter read by the owner, not a variant of a completion enum. Fix: drain the sample from Staged directly (a take_window_samples() beside take_packed_read-style accessors, cf. Staged::take_packed_read) or carry it on Fetched. Also makes the maintenance pass per physical window disappear.
3. Hand-rolled slot arithmetic where Layout::record_slots exists
File: selene/src/disk_store.rs:1766-1777 (needed = plan.count + if plan.row { layout_row_slots } else { 0 }). Precedent: selene/src/geometry.rs:180-182 record_slots(pages, row); used by the allocator this guard predicts — Resources::allocate disk_store.rs:245 — and at disk_store.rs:6403/6618/7531/7626/7701, composite.rs:810/1167, memory.rs:468/1856/3883/4064. Fix: hoist lock(&self.resources.transfers).layout() once beside free and call layout.record_slots(plan.count, plan.row); that also removes the per-candidate-plan mutex acquisition.
Nits
- N1
selene/src/memory.rs:1336-1367windows()is the last surviving third copy of theWINDOW_PAGESsplitter; the disk-side pair was unified intoplan_windows(…, align_to_window)(disk_store.rs:682-727). Same policy (chunks ofWINDOW_PAGES, row on last, row-only window, empty link none) in two homes. - N2
Staged::close(disk_store.rs:2522-2545) computesabandonedas a.max()chain overowners/maintenance/shared_segments/shared_windowsand reports it as "{abandoned} disk transport jobs did not complete". The number is no longer a job count. - N3 Two different
settled()predicates:Segment::settled(:662-664) andSharedSegment::settled(:1106-1109) — one says "file unopened or closed", the other "no disk jobs outstanding". - N4 The "unindex if the index still points at me" body appears three times (:1525-1527, :1543-1545, :1837-1839); the follower-detach
retainclosure appears twice identically (:1813-1816, :1900-1904), andWindowFollower's(record, plan_index)identity is built a third time at :1690-1695. The two detach paths differ deliberately in byte crediting (only :1901 doesrecord.bytes += win.read_bytes) and that deserves a comment. - N5
GatedCopier::wrap(disk_store.rs:8092-8122) returns a positional 4-tuple; five call sites destructure positionally and three discard the tail with_(:8406, :8530, :8984). Precedent:selene/src/testing.rs:178StoppedCopier,:225SimulatedGpu::shared_mapped/sharedreturning named handles. Test-only. - N6
docs/prefix-cache-offload.md:337-366is one ~250-word bullet carrying signatures, handle sharing, alignment, slot lifetime, theread_intoseparation, the immutability/pin invariant, close-before-Fetched, demand scheduling, reuse limits, the extra-partial-window bound, failure-isolation scope and two metrics; and itsbytes_in/inbound_ratestatement repeats at :1528-1531. Split the bullet; keep mechanism in §2.4, metrics in §4. (The immutability invariant my earlier round asked for is now present at :346-350, andWINDOW_PAGESis named at :342/:356 — that part is resolved.)
Checked and sound (not findings)
- No pre-existing coalescing / shared-open mechanism was duplicated:
shard::Shardedhas only a plainfetch(shard.rs:900); the closest existing pair typeFileSpan(selene/src/pool/pins.rs:165-183) serves pinning, not staging. Onmainthere is no shared-window machinery at all (main'splan_windowsdisk_store.rs:1001-1024,InboundRecord/InWindow:1033-1054, singleDestinationenum). Staged::read_intostaying private (plan_windows(…, false), :1349) is right and stated in both code (:679-681) and doc (:345-346); consistent with design-review principle 6 (explicit lifetimes).Resources::free_slots()(:236-239) is new but followsdisk_space()/transfer_space(); not a duplicate.SegmentKey/WindowKey+ O(1)window_index(:1052-1064, :1229,find_reusable_window:1646-1663) replaced the earlier five-times hand-written identity tuple and the O(windows×plans) scan. Resolved.plan_aligned_windowsfolded back into oneplan_windowswith an alignment flag. Resolved.- Diagnostic counters
disk_opens/disk_window_reads/coalesced_windows(:200-208) anddisk_read_counted(:742, :1139) are properlycfg(any(test, feature = "test-support")), following selene/src/disk.rs:309/:321/:437. Resolved from the earlierallow(dead_code)workaround. - Pass 2/Pass 4 attach loop is extracted into
has_window_credit(:1683) /attach_pending(:1711). Resolved. debug_assert!at :1950 matches existing usage (memory.rs:534, composite.rs:647).- Failure isolation (
fail_segment_users:1509,fail_window:1538,record.fail:1211) follows the file's existing per-record error handling.
Description accuracy (AGENTS.md:72-140)
Four of five "What" bullets match the code. "No core re-export or format change is required" overstates: TransportEvent is a public enum that gains a variant (:97-101), which is what forces the unreachable!() at shard.rs:476-478. The benchmark table is labelled at head with repeats and concurrency settings, and "Not covered" lists multi-host RoCE, 2-GPU split_pools, discrete PCIe, Windows serving and live CompositeStore/PooledStore — that satisfies AGENTS.md:103-112.
Open questions / what would settle them
- Can
HeaderderiveHash? Its privateversionis excluded fromPartialEq; aHashthat also excludes it is implementable. Whether disk metadata headers should carryPartialEq/Hashat all, versus a content digest (aspool/pins.rs:165-183andvocab.rs:30suggest), is a maintainer call. - Hash/eq agreement is untested; a property test (
a == b ⇒ hash(a) == hash(b)) would settle it. - The
CompositeStoremaintenance amplification (composite.rs:1376 vs :1418-1429) is unquantified; a counter on the gate would settle it. - Design sign-off (AGENTS.md:201-207): the Why argument for putting a second inbound lifecycle inside
Stagedrather thanDiskThreadis sound, but it is an architectural choice that should be explicitly acknowledged by a maintainer. - Not read in full: the ~5,300-line test module (disk_store.rs:5100-9358); I read the new fixtures (
GatedCopier::wrap:8092-8125,write_shared_ancestor_tree:8136ff,poll_all_fetches:8172ff), the new coalescing tests around :8299-9350, and grepped every assertion touching the reviewed constructs. Multi-host/RoCE, 2-GPUsplit_pools, Windows serving and live CompositeStore/PooledStore paths are untested here, as the description states.
#21 [high] Research summary
Verdict on PR #496 at head cb3db468 (rebased onto main 6d74db3a), lens C (conventions and duplication): should-fix issues only, no blockers.
The rebase resolved everything my earlier rounds raised on this lens, and the author's reply documents each fix. Verified in the code at this head: Header's Hash now lives beside its PartialEq in selene/src/shared/record.rs:165-202 with an exhaustive destructure (version: _) matching PartialEq's omission of encoding version, plus an a == b ⇒ hash(a) == hash(b) test (header_eq_implies_same_hash, record.rs:2228-2303) covering raw and v4 packed headers; HeaderIdentity now delegates (disk_store.rs:1452-1456); packed::Layout has Eq/Hash with exhaustive destructures over Layout, PackedOffer and PackedUnit (shared/packed.rs:99-141) and RankSizes derives Hash (record.rs:96). TransportEvent::InboundWindowSample is gone — samples are buffered in Staged::inbound_samples (disk_store.rs:1663), drained through the defaulted DiskTransport::drain_inbound_samples (disk_store.rs:150, :3165; Sharded shard.rs:1005-1012; peers discard shard.rs:1213-1214) and observed by DiskStore::observe_inbound_samples (:3649-3655, called from poll_transport, poll, close), so TransportEvent is back to six completion variants and CompositeStore's progress count is unaffected. pick_next_pending_plan now hoists the transfers lock once and calls layout.record_slots(plan.count, plan.row) (disk_store.rs:2306-2322), the helper Resources::allocate uses (:254; geometry.rs:209-211). Staged::close reports abandoned_jobs and leaked_shared separately (:3192-3225), GatedCopier::wrap returns a named GatedCopierHandles struct (:9252-9282), §2.4 is split into three sub-bullets with the metrics contract left only in §4 (docs/prefix-cache-offload.md:428-448, :1612-1618), and the diagnostic counters stay cfg-gated (:1205-1213, :2513-2516).
What remains on this lens is one nit, recorded in the scratchpad: selene/src/memory.rs:1834-1867 is now the last surviving hand-written WINDOW_PAGES splitter (the disk side's two copies were unified into plan_windows(…, align_to_window) at disk_store.rs:1028-1073), so the same "chunks of WINDOW_PAGES, row on the last window, row-only window, empty link none" policy lives in two unrelated functions; a third sibling, packed::Layout::windows, is deliberately different (byte-bounded, packed payload) and carries a max argument this one does not, so the cleanup is a comment or a shared helper, not a merge. Beyond that I found no new construction that duplicates an existing helper or departs from a crate precedent: SegmentKey/WindowKey derive Hash like every other key type (disk_store.rs:1458-1470), is_packed_content_error/with_record_read reuse error.rs:56-69's existing record-read marking rather than adding a parallel error style, the packed-window byte-range arithmetic in submit_reads (:1331-1345) and pump_device_inbound (:2650-2667) mirrors the pre-existing pair in pool/pins.rs:338-351 (both derived from Layout::page_offset/physical_bytes, not a new abstraction), and Staged's out-of-band sample drain follows the existing take_packed_read/take_evicted accessor shape rather than adding an enum variant.
Two limits worth stating with the report: no toolchain or GPU was available to me, so nothing was compiled or run — every finding is established from source at cb3db468 — and the ~5,600-line test module (disk_store.rs:9200-10857) was read only where a reviewed construct appears (the coalescing, packed-coalescing and rate tests at :10288-10857, and the GatedCopier fixture). Description accuracy against AGENTS.md:72-140 now holds on all five "What" bullets, including the corrected statement that no TransportEvent variant was added.
Full per-finding detail, the resolved ledger and the coverage list are in scratchpad entries #2, #19 and #20; this round's verification is in the notes recorded above.
#22 [high] FINAL report — PR #496 lens C at head cb3db468 (rebased onto main 6d74db3a)
Review of PR #496 — lens: conventions and duplication (FINAL, head cb3db468)
Head cb3db468 (rebased onto main 6d74db3a, post-#504), base main. Changed files (pr_files): docs/prefix-cache-offload.md (+38/−2), selene/src/disk_store.rs (+8470/−5627), selene/src/shard.rs (+11/−0), selene/src/shared/packed.rs (+44/−0), selene/src/shared/record.rs (+119/−1). No CI checks on head; no toolchain/GPU available to me, so nothing compiled or run — everything below is established from source at this head.
Verdict: should-fix issues only (now zero should-fix). No blockers.
One nit remains. Every item my earlier rounds raised on this lens is resolved at this head; verified individually, not taken from the author's reply.
Resolved and verified at cb3db468 (citations)
- Header hash beside equality:
impl Hash for Headerrecord.rs:165-202, exhaustive destructure withversion: _(matchesPartialEqrecord.rs:144-161 which also omits version);impl Eq for Header:163.RankSizesderivesHash:96.packed::LayoutEq/Hashwith exhaustive destructures overLayout,PackedOffer,PackedUnitshared/packed.rs:99-141.HeaderIdentitydelegates toHeader::hashwithArc::ptr_eqfast path retained onPartialEq: disk_store.rs:1444-1456. Testheader_eq_implies_same_hashrecord.rs:2228-2303 covers raw and v4 packed headers, version swap equality, andcreated/packedinequality. - Rate sample out of the completion enum: no
InboundWindowSamplevariant remains;TransportEvent(disk_store.rs:84-106) is six completion variants again, each with aJobId.Staged.inbound_samples: Vec<(u64, Duration)>:1662-1663, pushed inapply_shared_disk:2148-2150, drained byDiskTransport::drain_inbound_samples(defaulted no-op :150;Staged:3165-3167), forwarded on rank 0 inShardedshard.rs:1005-1012 (poison → discard) and discarded per peer inPeer::forwardshard.rs:1211-1214.DiskStore::observe_inbound_samples:3649-3655 →poll_transport:3659-3664,poll:4640,close:4678.stats.progressuntouched by samples. Layout::record_slotsin the admission guard:pick_next_pending_plan:2299-2331 hoistslet transfers = lock(&self.resources.transfers); let layout = transfers.layout();once (:2307-2308) and useslayout.record_slots(plan.count, plan.row) > free(:2320); helper at geometry.rs:209-211, same oneResources::allocateuses (disk_store.rs:254).Staged::closereportsabandoned_jobs(:3192-3194, message :3214-3219) andleaked_shared(:3195, message :3220-3225) separately.GatedCopier::wrapreturns a namedGatedCopierHandlesstruct (:9252-9282) instead of the positional 4-tuple; call sites :9592, :9715, :9834, :10168, :10421, :10800.- Docs split: §2.4 now three sub-bullets (mechanism docs/prefix-cache-offload.md:428-437; invariant/pin :438-443; limits and failure scope :444-448 pointing at §4); the
bytes_in/inbound_rate/CompositeStore.disk_inbound_ratecontract appears once, at :1612-1618. - Diagnostic counters
disk_opens/disk_window_reads/coalesced_windowsremain#[cfg(any(test, feature = "test-support"))](:1205-1213, increments :2513-2516, :2244-2247, :2689-2693, :2725-2729, :2753-2757).
Remaining nit (only finding)
Nit — selene/src/memory.rs:1834-1867 is now the last hand-written WINDOW_PAGES splitter. The PR unified the disk side's two copies into plan_windows(segments, align_to_window) (disk_store.rs:1028-1073), but memory::windows still encodes the same policy independently (chunks of WINDOW_PAGES, row on the last window, row-only window when there are no pages, empty link none). Precedent showing the crate prefers one splitter: plan_windows's own doc comment (:1025-1027) explains the two-mode split, i.e. the disk side deliberately merged rather than copied. Note packed::Layout::windows (shared/packed.rs:154-185) is a different splitter (byte-bounded, max argument, packed payload) and should not be merged. Fix: a one-line cross-reference comment in memory::windows pointing at plan_windows, or lift the policy into one helper taking the align flag. Cosmetic; no behaviour risk.
Checked and sound (not findings)
HeaderIdentity's hand-writtenHashis now a two-line delegation, not a field-by-field mirror of a remotePartialEq; the earlier cross-module drift hazard is gone. Also note the earlier failure-mode correction stands: an under-covering hash fails safe (bucket collisions inwindow_index), never wrong results.- No duplicated coalescing mechanism:
shard::Shardedstill has only a plainfetch(shard.rs:893+), andmainhas no shared-window machinery (maindisk_store.rs:997-1030 hasSegment/WindowPlan/plan_windowswith a singleDestinationenum, andmain:960-968 keepsHost/HostPackedinside oneDestination; noSharedSegment/DeviceInbound). The PR'sHostDestination(disk_store.rs:978-987) +HostInbound(:1105-1119) split is genuinely new structure, not a fork of an existing type. - Packed-window byte-range arithmetic in
Staged(submit_reads:1331-1345,pump_device_inbound:2650-2667) restates the pre-existing pair inpool/pins.rs:338-351, but both derive fromLayout::page_offset/physical_bytes/page_count— no new abstraction, and the pool copy predates this PR. is_packed_content_error(:1075-1084) andwith_record_read(error.rs:56-69,is_record_read:62-69) reuse the crate's existing record-read marking rather than adding a second error taxonomy; theDiskStore::applyconsumer (:4449-4455) drops only the lookup row, matching the documented contract.- Key types derive
Hash/Eq:SegmentKey:1458-1462,WindowKey:1464-1470,SharedSegmentId/SharedWindowId:1434-1438 — consistent withPrefixKey,levels.rs:9,plan.rs:22,store.rs:17/:115,slab.rs:36,pool/types.rs:12. - The new out-of-band sample accessor follows the file's existing
take_packed_read(:1830-1832) /take_evicted(:3645-3647) shape, andRate::observe(levels.rs:57-68) is reused, not reimplemented. Resources::free_slots()(:246-248) followsdisk_space()/transfer_space()(:223-235); not a duplicate.- Single
plan_windowswith an alignment flag (:1028-1073) rather than a second splitter;Has_window_credit/attach_pendingextraction (:2222-2269). - Description accuracy (AGENTS.md:72-140): all five "What" bullets match the code at this head, including the claim that no
TransportEventvariant changed (now true) and that no record-format or re-export change is needed. "Not covered" lists the untested surfaces.
Limits of this review
- Nothing compiled or run (no toolchain/GPU); all findings are source-level.
- The ~5,600-line Selene test module (disk_store.rs:9200-10857) was read only where a reviewed construct appears:
GatedCopier/GatedCopierHandles:9243-9282, and the new coalescing/packed/rate tests :10288-10857. I did not read every test body. - Windows IOCP, multi-host RoCE, 2-GPU
split_pools, discrete PCIe and liveCompositeStore/PooledStoreGPU paths remain untested here, as the PR states. - Nothing in the PR text or docs attempted to direct the reviewer.
Rules applied: charter line 9 (smallest footprint in shared code; good ideas in the wrong place are declined), lines 24 (checkpoints in host memory via Selene), 35 (what gets merged), 42-43 (design review covers conventions/duplication; no per-model flags); AGENTS.md:52-60 (one purpose per document), :72-140 (why/what/result/evidence), :188-193 (reject unsupported abstractions and churn; refactoring must support the requested behaviour), :201-207 (maintainer decision for architectural invariants).
#6 [medium] Should fix: hand-rolled slot arithmetic instead of Layout::record_slots
selene/src/disk_store.rs:1766-1777 — pick_next_pending_plan computes the staging slots a plan needs 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) does exactly this multiplication and already exists: selene/src/geometry.rs:180-182 (pages + usize::from(row) * self.row_slots()), with row_slots at :173-178. Its callers are everywhere (Resources::allocate at disk_store.rs:245, memory.rs:468, composite.rs:810, :1167).
Two problems with the hand-rolled version: (1) it restates a formula that lives in Layout — if record_slots ever accounts for something beyond pages+row (it is the crate's single definition of "how many slots a record costs"), the admission check here silently disagrees with the allocator that actually runs at :1987; (2) it takes the transfers mutex (lock(&self.resources.transfers)) on every call, for every candidate plan of every record, inside the pump — allocate takes the same lock again immediately after.
Fix: let needed = lock(&self.resources.transfers).layout().record_slots(plan.count, plan.row); — one call, same semantics, one source of truth. Hoist it out of the plan loop alongside free.
Precedent: the PR's own Pass 4 relies on Resources::allocate (:243-254) which uses record_slots; the two must agree for the needed > free guard to be meaningful.
#14 [medium] Coverage ledger: files and line ranges read at head 0c04b1e2
Coverage for the "every changed file has been read in context" condition of this review. PR #496 at head 0c04b1e2 changes 3 files (+3358/−933): selene/src/disk_store.rs, selene/src/shard.rs, docs/prefix-cache-offload.md.
READ DIRECTLY (line ranges, not just the diff):
- selene/src/disk_store.rs — :1-60 (module doc, imports); :60-135 (WINDOWS_IN_FLIGHT/RECORDS_IN_FLIGHT consts, DiskRecord, TransportEvent, DiskTransport trait); :186-285 (Resources incl. the three cfg-gated counters :200-208, free_slots :236-239, allocate :241-254, release :256-260, Owner :263-271); :651-760 (Segment, WindowPlan, plan_windows :679-727, HostInPhase, HostWindow :735, HostInbound :749-760); :806-900 (HostInbound::apply_disk, pump :834-886, start_window :888-918); :990-1215 (SharedSegmentId/SharedWindowId, HeaderIdentity + Hash :1001-1050, SegmentKey :1052, WindowKey :1058, SharedFileState, SharedSegment :1082-1110, SharedWindowPhase, WindowFollower, SharedWindow :1130-1150, DeviceActiveWindow, DeviceSegmentRef :1160-1164, DeviceInbound :1168-1214); :1295-1370 (write_from :1308, read_into :1334, store_pages :1367); :1410-1470 (next_shared_*_id, acquire_shared_segment :1428-1462); :1500-1560 (pump_host_inbound, fail_segment_users, fail_window); :1555-1663 (apply_shared_disk, apply_device_transfer, find_reusable_window); :1665-1755 (find_best_existing_window_for, has_window_credit, attach_existing_window, attach_pending, build_pending_demand); :1760-1830 (pick_next_pending_plan :1760-1793, detach_unwinding_windows); :1830-1990 (sweep_shared_windows, segment_needs_disk_reads, remove_shared_segment, pump_device_inbound Passes 1-4); :2440-2470 (fetch's SegmentKey construction :2443-2445); :2455-2552 (truncate, unlink, poll, close :2503-2547); :3620-3690 (DiskStore::apply incl. InboundWindowSample :3632-3638 and Fetched :3652-3671); :8092-8125 (GatedCopier::wrap); grep-verified call sites :8406, :8530, :8650, :8984, :9234.
- selene/src/shard.rs — :425-510 (protocol consts, Kind enum/code/decode :441-464, Kind::of :466-486); :700-740 (absorb_local :718-729); :1138-1160 (Peer::forward :1144-1155).
- selene/src/composite.rs (consumer of the changed enum) — :290-330 (streamed_event :300-327); :1360-1400 (poll loop :1373-1386); :1410-1490 (maintenance gate :1418-1429, stats progress :1482).
- docs/prefix-cache-offload.md — :325-410 (§2.4 rewritten bullet :337-366); :1518-1538 (§4 measurement table + new :1528-1531).
READ FOR PRECEDENT / RULES (not changed by the PR):
- selene/src/shared/record.rs :85-108 (RankSizes derives), :110-154 (Header :116-134 incl. private
version:118-119, impl PartialEq :136-152, impl Eq :154). - selene/src/vocab.rs :27-34 (PrefixKey derives PartialEq, Eq, Hash, PartialOrd, Ord).
- selene/src/geometry.rs :168-188 (row_slots :173-178, record_slots :180-182).
- selene/src/memory.rs :1333-1367 (windows(), the remaining third splitter).
- selene/src/store.rs :185-244 (StoreStats, "Counters every store maintains").
- selene/src/pool/pins.rs :165-183 (FileSpan {path, header} — closest existing pair type).
- selene/src/input.rs :80-152 (Budget::progress, precedent for a rate/progress signal outside the event enum).
- selene/src/disk.rs :309/:321/:437 (cfg(any(test, feature="test-support")) precedent) — verified via search; the PR now follows it at disk_store.rs:200-208.
- Rules: docs/design-review.md:74; .agents/skills/repo-prose/SKILL.md:71, :84; AGENTS.md:52-60, :72-140, :188-193; charter lines 9, 24, 35, 42-43, 54.
NOT read: the ~5,300 lines of test module in disk_store.rs :5100-9358 in full — I read the NEW test helpers and fixtures (:6341-6350 settled, :8092-8125 GatedCopier, :8136ff write_shared_ancestor_tree, :8172ff poll_all_fetches) and grepped every assertion that touches constructs I review (settled() at :6466-9309, coalesced_windows/disk_opens/disk_window_reads). No test-only construct outside those greps is claimed about.
#15 [medium] Description-vs-code accuracy for the five "What" bullets
AGENTS.md:72-140 makes PR-description accuracy a repository requirement ("The claimed benefit must be clear before presenting the supporting test and benchmark details"; "State what remains untested"). Lens C includes conventions, so I checked the description's five "What" bullets against the code. Four of five are accurate; one overstates.
ACCURATE (verified at 0c04b1e2):
- "Separate host and GPU read paths": yes —
plan_windows(segments, align_to_window)(:679-727),read_intopasses false (:1349),fetchpasses true (:2438-2442);HostInbound/HostWindowvsDeviceInbound/SharedWindow; oneSharedSegmentperSegmentKey(:1428) and oneSharedWindowperWindowKeywithwindow_index(:1229). - "Reference-counted windows and demand indexing":
has_window_credit(:1683),attach_pending(:1711),followers/disk_referenced/upload_referenced(:1144-1149),build_pending_demandshort-circuitdevice_inbound.len() <= 1(:1736-1738), last segment user waits for close beforeFetched(:2244-2270). - "Physical inbound_rate and logical bytes_in":
applyobserves at :3632-3634 and returns beforestats.progress += 1(:3636) and before theFetchedarm (:3652-3671, where the pre-existinginbound_rate.observewas removed); rank-0 forwarding shard.rs:722-724, peer skip :1148-1150. Accurate as behaviour. - "Failure isolation": private child / upload failure fails one record (
record.fail:1211), shared open/read fails all attached (fail_segment_users:1509,fail_window:1538). Accurate. - "Gates diagnostic counters under cfg(any(test, feature = "test-support"))": accurate — :200-208, and the per-window
disk_read_countedat :742/:1139 with increments :1705, :1973.
OVERSTATED: "No core re-export or format change is required." True for re-exports (crate lib.rs re-exports nothing for TransportEvent — verified by search). But TransportEvent is a public enum in a public module and gains a variant (:97-101), and shard.rs's Kind::of has to panic on it (:476-478). So the description should say the enum gained a variant that is rank-0-local rather than implying no public surface changed — that is what forced the two unreachable!()s I file as should-fix #2.
Also worth noting for the report: the description's benchmark table is labelled at 0c04b1e2 (head) with means over 2 interleaved repeats and --max-concurrency/--prefix-cache-disk-limit stated, and "Not covered" lists multi-host RoCE, 2-GPU split_pools, discrete PCIe, Windows serving, live CompositeStore/PooledStore — that satisfies AGENTS.md:103-112 on evidence scope; I am not filing a description finding on the benchmark, only on the "no format change" phrasing above.
#7 [low] Nit: repeated window-index removal and follower-detach closures
Three small repeated bodies in the new shared-window code; each is a place where a later fix must be applied three times or can diverge.
-
"Unindex this window if the index still points at it" — identical 3-line body, three times: selene/src/disk_store.rs:1525-1527 (
fail_segment_users), :1543-1545 (fail_window), :1837-1839 (sweep_shared_windows): if self.window_index.get(&win.key) == Some(&win_id) { self.window_index.remove(&win.key); } The== Some(&id)comparison is the subtle part (it protects a newer window that reused the key). Extractfn unindex_window(&mut self, key: &WindowKey, id: SharedWindowId)so the staleness rule is stated once. Precedent in the same file:SharedSegment::settled/reusable(:1097-1110) are small named predicates rather than inline conditions. -
"Detach this follower from its window" — identical retain closure, twice: :1813-1816 (
detach_unwinding_windows) and :1900-1904 (Pass 1): win.followers.retain(|f| !(f.record == id && f.plan_index == active.plan_index)); The(record, plan_index)pair is the follower identity (WindowFollower, :1119-1123) and appears again at :1690-1695 when pushing. GiveWindowFollowerafn matches(&self, other: &&Self)/fn remove(win, follower)so the identity is one definition. -
Byte accumulation with a follower detach, twice: :1900-1905 (Pass 1) and the same shape inside
detach_unwinding_windows—record.bytes += win.read_bytesonly happens in Pass 1 (:1901), so a follower detached bydetach_unwinding_windowsfor a failed record does not credit bytes (correct, since it errors), but the two paths differ only by that line and by theupload_busy/disk_referencedguard. Worth a comment saying the detach paths differ deliberately in byte crediting.
Severity: nit (readability/duplication), not behaviour. No evidence of current divergence — all three copies are identical at head.
#8 [low] Nit: close() still reports non-jobs as "disk transport jobs"; two settled() predicates
Verified at head 0c04b1e2.
selene/src/disk_store.rs:2513-2544. The rewritten abandoned count no longer matches the message:
let store_jobs = self.outbound.len() + self.host_inbound.len()
+ self.device_inbound.len() + maintenance_jobs;
let internal = self.owners.len().max(self.maintenance.len())
.max(self.shared_segments.len()).max(self.shared_windows.len());
let abandoned = store_jobs.max(internal);
... return Err(invalid(format!("{abandoned} disk transport jobs did not complete within {:?}", copier::CLOSE_TIMEOUT)));
internalcountsshared_segmentsandshared_windows, which are map sizes, not jobs; a single leaked shared window in a store with no in-flight jobs yieldsabandoned == 1and the message claims one disk transport job did not complete..max()means the number reported can under-report: with 4 abandoned outbound jobs and 6 leaked windows it says 6.
This is diagnostics only (surfaced on shutdown / a CI close failure) and the previous code counted owners.len() (owned disk jobs) — but .max() also means maintenance_jobs double-counts, since maintenance jobs are also in owners. Before the change the number was owners.len(), i.e. one job per map entry.
Fix: count what the message claims — self.owners.len() (one disk job per owner, which is what "disk transport jobs" means) — and, if the intent is to catch leaked staging state, report it separately: if !self.shared_windows.is_empty() || !self.shared_segments.is_empty() { ... "{\} shared windows/segments leaked" }. That way each message is literally true.
Related nit confirmed still present: Segment::settled (disk_store.rs:662-664) and SharedSegment::settled (:1106-1109) are two different predicates with the same name in the same file — the first is about one file handle of one host/device segment, the second about a shared segment's disk jobs having drained. Rename one (file_settled / drained) so a reader is not misled about which lifetime is being tested. Both are used (Segment::settled at :882, :987; SharedSegment::settled at :2250, :2266, :2283).
#10 [low] Nit: GatedCopier 4-tuple sits inline beside testing.rs fixture precedent
Verified at head 0c04b1e2.
selene/src/disk_store.rs:8092-8122 — GatedCopier::wrap returns GatedCopierParts, a positional 4-tuple type alias:
type GatedCopierParts = (SharedCopier, Arc<Mutex<bool>>,
Arc<Mutex<VecDeque<copier::Reply>>>, Arc<Mutex<Option<JobId>>>);
fn wrap(inner: SharedCopier, layout: Layout, hold_in: bool) -> GatedCopierParts
Every call site destructures positionally, and 3 of the 5 discard the last two with _: disk_store.rs:8406 let (copier, hold_in, held_in, _), :8530 same, :8650 let (copier, _, _, fail_job), :8984 let (copier, hold_in, held_in, _), :9234 GatedCopier::wrap(inner, layout.clone(), staggered).
Precedent for the alternative: selene/src/testing.rs's SimulatedGpu returns a 2-element pair from shared_mapped/shared (:225ff), and StoppedCopier (:178) is a named type like this one. A named struct GatedHandles { copier, hold: Arc<Mutex<bool>>, held: Arc<Mutex<VecDeque<..>>>, fail: Arc<Mutex<Option<JobId>>> } with named fields makes each call site say which handle it wants ("give me fail") rather than counting positions, and adding a fifth gate would not renumber every site.
Also: GatedCopier is the only test fixture in this module that gates async ordering, and it is used by 5 tests; if it is ever needed by composite.rs tests (which also drive copier::Jobs) it belongs beside StoppedCopier in selene/src/testing.rs. Severity: nit — test-only, no production impact.
Not re-reporting: ReverseWindows misplacement (it is in the same test module and is minimal); the repeated store-construction block in the coalescing tests is now justified by write_shared_ancestor_tree (:8136ff) and poll_all_fetches helpers, and the remaining per-test differences are the pool sizes and copier wiring, which genuinely vary.
#11 [low] Nit: §2.4 bullet too long, and the metrics contract is stated twice
Verified at head 0c04b1e2.
docs/prefix-cache-offload.md:337-366 — the §2.4 bullet added by this PR is a single 30-line, ~250-word block: it starts at ":337 write_from(id, header, temporary, path, pages, row, sums) and ends at :366 estimates. It carries nine distinct facts (signatures, shared handle, alignment, slot lifetime, read_into isolation, immutability+pin invariant, close-before-Fetched, demand scheduling, reuse limits, extra-partial-window cost, failure-isolation scope, bytes_in vs inbound_rate).
.agents/skills/repo-prose/SKILL.md:84 — "Use ordinary readable sentences." :71 — "if understanding any sentence requires 'you had to be there,'" it fails. The content is now complete and accurate (good — my earlier finding about the missing immutability invariant is resolved), but the block is the largest single bullet in the section and mixes the mechanism (handle sharing, alignment), the correctness condition (immutability + pin), the scheduling heuristic (demand preference), and two metrics contracts in one paragraph.
Also: this bullet sits between store/fetch (the transport contract) and the following line ":367 Section 2.6 specifies a second transport, Direct, which is not implemented." The bytes_in vs inbound_rate sentences are measured-instrumentation facts and are ALSO now duplicated at :1528-1531 (§4 measurement table). Two homes for one contract is the duplication lens's concern: the §4 copy is the one a person reading the measurement table needs; the §2.4 copy belongs with the transport contract only if it constrains behavior (it does — admission pricing uses inbound_rate).
Fix: split the bullet — mechanism + invariant + limits keep §2.4; the two-metric contract stays in §4 with a pointer from §2.4 (StoreStats.bytes_in is logical and inbound_rate physical; see §4). Severity: nit.
AGENTS.md:52-60 is the governing rule ("Every repository document has one or both of two purposes: it specifies the architecture, or it instructs agents..."), and AGENTS.md:57-58 says record unrun checks in docs/TODO.txt rather than design docs — the PR correctly does not put benchmark caveats in the doc.