Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #496

Raw Markdown for agents: https://autobot.eidonix.com/p/d049de12-c4eb-4408-9725-c1086b673f8d.md

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

F2 (Minor, tests): the anti-regression latency test guards ~250x looser than achieved and never asserts the credit-regained demand pass.

Verified sound (do not report as issues):

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

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.