#1 [high] Lens findings (correctness/contracts/systems) — PR #496 @ ba1c73fd
F1 (Major, metric span / claim accuracy): CompositeStore's disk_inbound_rate is disk-read-only and physical-byte denominated, but the PR's new doc sentence claims it is end-to-end.
- docs/prefix-cache-offload.md:1626-1627 (added by this PR): "
CompositeStoremaintains an end-to-enddisk_inbound_rateoverread_intoandread_into_packedcompletions." - selene/src/composite.rs:1059-1068: observes
inbound.disk_bytesoverstarted.elapsed()wherestarted=inbound.disk_startedset at firststart_read(composite.rs:954) and cleared wheninbound.reads == 0→ span = disk reads only, excludes codec decode + GPU upload. - Units: COMPOSITE
hit()pricesdisk_bytes=node.tail_pages * layout.page_record_bytes + row(physical/compressed, composite.rs:357-358) over that rate (composite.rs:374); the upload is priced separately asbytes / memory_rate(logical). DiskStore's newinbound_rateinstead sampleslogical_bytes = layout.record_bytes(chain.pages)end-to-end (disk_store.rs:3450, 3242-3251). Two different quantities share one doc section. - Also selene/src/composite.rs:340-342 copies the disk store's end-to-end logical
inbound_rateintoCompositeStore.stats().inbound_rate, so the reportedStoreStats.inbound_ratefor a composite is not the rate used to price its Nvme component. Fix: either narrow the doc sentence to "disk-read-timedisk_inbound_rateover physical payload bytes" for CompositeStore, or make the composite observe end-to-end like DiskStore.
F2 (Minor, tests): the anti-regression latency test guards ~250x looser than achieved and never asserts the credit-regained demand pass.
- selene/src/disk_store/coalesce/tests.rs:583-586:
assert!(mean_us < 200.0, ...)while the PR table claims 0.25-0.75 us means. - selene/src/disk_store/coalesce/tests.rs:593-602:
credit_uscomputed andeprintln!-ed, never asserted; onlydemand_builds() > builds_beforeis checked. So per-probeHeaderIdentity/WindowKeyhashing cost (the exact regression yatesdr measured) can return without a failing test. Fix: assertcredit_us < 200.0too.
Verified sound (do not report as issues):
- Aligned planning:
plan_windows(..., true)keepsWindowPlan.offset(ticket-order cumulative page index,dst_offset) separate fromcursor(file-relativefirst), sorecord.pages[plan.offset..plan.offset+plan.count]inbuild_upload_job(coalesce.rs:1186-1191, 1200-1204) stays correct across multi-segment chains and thepages == 0row-only plan (coalesce.rs / disk_store.rs:2440-2460 region in diff). ReadRowhas no window id;SharedSegment.pending_row_readsis a FIFO VecDeque keyed per segment (coalesce.rs:116, 500, 1090) matching the disk thread's per-reader FIFO reply order (disk.rs:478-485 single-threaded run loop) — correct.- Reply routing cannot leak
upload_referenced:complete_finished_fetchesonly removes a record whenactive.is_empty()(coalesce.rs:1333-1337), anddetach_unwinding_windowsrefuses to detachupload_submitted && !upload_donewindows (coalesce.rs:782-786). remove_shared_segmentcannot drop a segment with outstanding replies: gated ondisk_settled()=Closed && disk_outstanding == 0(coalesce.rs:130-133, 1360-1369).- Failure blast radius: private/transient upload errors fail only that record (coalesce.rs:557-565), shared open/read content errors fail every attached record via
fail_segment_users/fail_window(coalesce.rs:436-476, 531-536); corrupt shared ancestor test asserts all 4 followers getrecord_readerrors,disk_opens == 1, pool fully free, no pins (tests.rs:1093-1179). - Public contract unchanged:
TransportEventstill 5 variants (disk_store.rs:89-109),FetchSegmentunchanged (disk_store.rs:171-177),plan_windowsprivate. - Close/leak accounting separates abandoned jobs from leaked shared entries and only forgets packed buffers still upload-referenced (disk_store.rs:1983-2021, coalesce.rs:313-319).
#2 [high] Research summary
Reviewed PR #496 at head ba1c73fd through the correctness/contracts/systems lens: read all six changed files (selene/src/disk_store/coalesce.rs in full, the disk_store.rs diff plus its fetch/apply/Staged/HostInbound/close paths at head, shared/record.rs Hash, shared/packed.rs Hash, the docs diff) and the direct callers/contracts they touch (selene/src/disk.rs job/Reply semantics and the single-threaded FIFO run loop, selene/src/levels.rs Rate, selene/src/composite.rs disk_inbound_rate/hit()/disk_read, selene/src/store.rs (not opened) worth_fetching), plus the relevant coalesce tests.
Two verified findings, both in my scratchpad (entry 1). F1 (Major, metric-span/claim accuracy): the doc sentence this PR adds ("CompositeStore maintains an end-to-end disk_inbound_rate over read_into and read_into_packed completions", docs/prefix-cache-offload.md:1626-1627) is contradicted by the code it describes — composite.rs:1059-1068 observes disk_bytes over inbound.disk_started, which is set at first start_read (composite.rs:954) and cleared when inbound.reads == 0, i.e. a disk-read-only span excluding codec decode and GPU upload, denominated in physical/compressed payload bytes (composite.rs:357-358) whereas DiskStore's new rate samples layout.record_bytes(chain.pages) end-to-end. Compounding it, composite.rs:340-342 copies the disk store's end-to-end logical rate into the composite's stats.inbound_rate, so the reported stat and the pricing rate differ. F2 (Minor, tests): the anti-regression poll-latency test asserts only mean_us < 200.0 (coalesce/tests.rs:583-586) against a claimed 0.25–0.75 µs, and the credit-regained demand pass is printed but never asserted (tests.rs:593-602) — exactly the per-probe hashing cost the reviewer measured can regress test-silently.
Beyond those I found the mechanics sound and say so rather than padding: aligned plan_windows correctly separates ticket-order offset from file-relative first; ReadRow's id-less FIFO reply handling matches the disk thread's per-reader ordering; upload references cannot leak because records only complete with empty active and unwinding refuses in-flight uploads; shared segments are removed only when Closed && disk_outstanding == 0; failure blast radius matches the documented private-vs-shared split and is covered by a corrupt-ancestor test asserting all followers fail with disk_opens == 1 and a fully freed pool; and no public contract (TransportEvent, FetchSegment, record format, wire protocol) changed. The inbound_rate change widens the measured span rather than shrinking it, and the downward-only guard for rode_preexisting is correctly ordered.
#3 [high] Downstream consumers of inbound_rate / estimated_seconds (for F1 impact)
Downstream chain for F1 (composite doc/rate mismatch), verified this pass:
- Pricing/entry:
CompositeStore::hitbuildsHostHit.estimated_seconds = disk_bytes as f64 / self.disk_inbound_rate.get().max(1.0) + bytes as f64 / memory_rate(selene/src/composite.rs:361-377).disk_bytesis physical record bytes (node.tail_pages as u64 * layout.page_record_bytes + row) at composite.rs:350-360, i.e. compressed for v4 packed, whilebytesislayout.record_bytes(chain.pages)logical and priced against the memory rate. So a composite hit is priced in two different byte units against two different rates — and this PR's doc sentence describes only the DiskStore one. - Admission:
worth_fetching(&hit, prefill_rate)=hit.estimated_seconds < 0.5 * gained_tokens / prefill(selene/src/store.rs:424-438); called from helios/src/server/runtime.rs:2782 and the restore-wait defer path at runtime.rs:2806 (restore_wait.defer(gained, hit.estimated_seconds, prefill_rate)). So the span/unit of the rate directly sets whether a restore is admitted and how long the request defers. - Observability: helios/src/server/metrics.rs:639 reports
stats.bytes_inashost_cache_bytes_in_total, and metrics.rs:656 reportsstats.inbound_rateashost_inbound_rate; for a composite both come from the copies at composite.rs:336 and 340-342 — i.e. the exportedhost_inbound_rateis the disk store's end-to-end logical rate, not thedisk_inbound_ratethat produced the estimate. Operators therefore see a rate that cannot be reconciled with the latency they observe through admission. - Related contract check requested by the lens (metric/rate span): DiskStore's span widened (disk-thread-only → end-to-end including open, slot queueing, decode, upload, all
Shardedranks: disk_store.rs:3422-3453 recordsstarted = Instant::now()beforetransport.fetchandlogical_bytes = layout.record_bytes(chain.pages); disk_store.rs:3242-3251 observes it inapply). This is the opposite of a hidden shrink and matches docs/prefix-cache-offload.md:1613-1625. Therode_preexistingguard is downward-only and correctly skipsinbound_rate.started()(disk_store.rs:3441-3443), so a coalesced follower cannot inflate the rate — the ordering is right. StoreStats.bytes_instays per-fetch payload bytes (self.stats.bytes_in += bytes, disk_store.rs:3240, wherebytesis the transport'sFetchedbyte count) and docs say "credited once per completed fetch including coalesced followers" (docs/prefix-cache-offload.md:1613-1615) — consistent withrecord.bytes += win.read_bytesper follower inreap_completed_uploads(coalesce.rs:757-763). No double count found.
Not verified / out of scope this pass: whether the composite's disk_started-scoped sample was already documented differently before this PR (only the current sentence was read), and no live or release-mode test run was performed; all conclusions are from source reading.