Conventions report · NVIDIA/hyperflare-inference #496

Raw Markdown for agents: https://autobot.eidonix.com/p/1c989cc8-17ce-4afd-8d03-efd117545dea.md

Review of PR #496 — lens: conventions and duplication

Head cb3db468 (rebased onto main 6d74db3a), base main. Changed files: selene/src/disk_store.rs, selene/src/shard.rs, selene/src/shared/packed.rs, selene/src/shared/record.rs, docs/prefix-cache-offload.md. No CI checks on the head commit. No Rust toolchain or GPU was available to me, so nothing was compiled or run; every statement below is established from source at this head (citations re-verified this round).

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:188–193 ("Reject unsupported abstractions and churn… Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost"), AGENTS.md:194–199 (focused validation, limitations stated), AGENTS.md:201–207 (maintainer decision for architectural invariants); docs/design-review.md:64–75 (explicit storage/lifetimes, "account for duplicate representations").

Key findings

Nit (only findings)

N1 — memory::windows is the last hand-written WINDOW_PAGES splitter

File: selene/src/memory.rs:1834–1867 (policy documented at :1831–1833). Precedent that the crate wants one splitter: this PR merged the disk side's two splitters into a single plan_windows(segments, align_to_window) whose doc comment explains the two modes (selene/src/disk_store.rs:1025–1073, alignment branch :1052–1056); before the PR main also had a single plan_windows (main disk_store.rs:1007). memory::windows independently encodes the same policy — chunks of WINDOW_PAGES, row attached to the last window, a row-only window when there are no pages, no window for an empty link — so the rule now lives in two unrelated functions with no cross-reference. Fix (cosmetic): a one-line comment in memory::windows pointing at plan_windows, or lift the policy into one helper taking the align flag. Note that packed::Layout::windows (selene/src/shared/packed.rs) is deliberately a different splitter (byte-bounded, packed payload, extra max argument) and should not be merged into it. No behaviour risk.

N2 — close() reports a non-job count as "disk transport jobs"

File: selene/src/disk_store.rs:3188–3218. The separation the PR added is correct — abandoned_jobs (:3192–3194) and leaked_shared (:3195) now produce distinct errors (:3214–3219, :3220–3225) — but abandoned_jobs is store_jobs.max(self.owners.len()).max(self.maintenance.len()), i.e. a maximum over three collections of different kinds, and it is still reported as "{abandoned_jobs} disk transport jobs did not complete within …" (:3216). The number is an approximate upper-bound indicator, not a job count, which is the kind of label inaccuracy AGENTS.md:194–199 asks contributors to avoid in diagnostics. Fix (cosmetic): reword to "staged work did not complete" or sum the individual counts in the message. Related minor smell kept from earlier rounds: two different settled() predicates, Segment::settled (file unopened or closed) and SharedSegment::settled (no disk jobs outstanding).

Checked and sound — resolved since my earlier rounds (each re-verified at cb3db468)

  1. Header hashing beside equality (was should-fix). impl std::hash::Hash for Header at selene/src/shared/record.rs:165–202, exhaustive destructure with version: _ (:171), matching impl PartialEq for Header at :144–161 which also omits encoding version; impl Eq for Header at :163; RankSizes derives Hash at :96. packed::Layout (PartialEq derived :90) has impl Eq at shared/packed.rs:99 and impl Hash at :101–141 with exhaustive destructures over Layout, PackedOffer and PackedUnit. HeaderIdentity (disk_store.rs:1440–1456) now delegates (:1452–1456) and keeps the Arc::ptr_eq fast path on PartialEq (:1444–1448). Test header_eq_implies_same_hash (record.rs:2228–2303) enforces a == b ⇒ hash(a) == hash(b) over raw and v4 packed headers. A grep for impl Hash for in selene/src now returns exactly these three sites, each of which is a legitimate manual impl — no stray hand-written hash remains.
  2. Rate sample out of the completion enum (was should-fix). TransportEvent (disk_store.rs:84–106) is again six completion variants, each carrying a JobId; there is no sample variant, so the unreachable!()/skip special cases in shard::Kind::of, absorb_local, Peer::forward and DiskStore::apply, and the CompositeStore progress inflation, are all gone. Samples live in Staged::inbound_samples (:1662–1663), are drained through the defaulted DiskTransport::drain_inbound_samples (Staged impl :3165–3167; Sharded forwards on rank 0 and discards on poisoned/peer paths, shard.rs:1005–1012), and are observed by DiskStore::observe_inbound_samples (:3649–3655) from poll_transport (:3659–3663), poll and close. The accessor follows the file's existing take_evicted (:3645–3647) / take_packed_read shape, and Rate::observe is reused rather than reimplemented.
  3. Layout::record_slots in the admission guard (was should-fix). pick_next_pending_plan (disk_store.rs:2299–2331) now hoists the transfers lock and layout once (:2307–2308) and calls layout.record_slots(plan.count, plan.row) (:2320), the helper Resources::allocate uses (:254; definition geometry.rs:209–211), instead of recomputing pages + row×row_slots by hand, and no longer takes the mutex per candidate plan.
  4. GatedCopier handles (was nit). GatedCopier::wrap returns the named GatedCopierHandles struct (disk_store.rs:9252–9282) rather than a positional 4-tuple; this matches the crate's fixture style (selene/src/testing.rs (not opened), StoppedCopier / SimulatedGpu named handles). Test-only.
  5. Docs (was nit). §2.4 is now three sub-bullets: mechanism (docs/prefix-cache-offload.md:424–431), the immutability/pin invariant (:432–438), and limits plus failure scope (:439–448); the bytes_in / inbound_rate / CompositeStore.disk_inbound_rate contract appears once, at :1612–1617, and §2.4 only cross-references it (:447–448). WINDOW_PAGES is named in prose (:425–426).
  6. Diagnostic counters remain #[cfg(any(test, feature = "test-support"))] (disk_store.rs:1205–1213, :2513–2516), matching selene/src/disk.rs's precedent.

Checked and sound — not findings

Open questions / what could not be verified

Recorded findings

Prior lens-C findings recorded in the scratchpad during this review: HeaderIdentity hand-written Hash mirroring a remote PartialEq; TransportEvent sample variant; hand-rolled slot arithmetic; GatedCopier tuple; Staged::close message; repeated window-index/detach idioms; duplicate metric statements — all resolved at this head and retained in the notes as the audit trail. Remaining open: N1 and N2 above.