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