#1 [high] Research summary
Reviewed the top commit at pr/694 by reading the changed files and their callers directly (PR-vs-base diff tooling is broken in the local copy: pr_diff fails with fatal: bad revision 'cc0a49d2…d74e810', so no diff hunks — findings are from full-file reads at head, with line citations). Focus was correctness/contracts/system-level consequences.
What is sound. The gate primitives are small and defensively written: worth_restore/standalone_spill_profitable/fork_dedup_profitable (selene/src/store.rs:496-550) reject NaN/inf, use saturating_mul, require strict byte savings, and are unit-tested (store.rs:593-638). PoolSpillPolicy::materially_differs_from hysteresis is correct and the push happens only from the single PooledStore::poll driver thread (selene/src/pool/store.rs:606-610), so no new cross-thread race: all Core/CompositeStore mutation stays on the store's driver thread. The new O(1) clean_slots (selene/src/memory.rs:1695-1701) is guarded by a full-index assert_clean_slots_invariant in debug/test (memory.rs:1613-1693), and Index::remove_nodes (selene/src/shared/index.rs:523-575) atomically validates the closed batch before mutating, so a bad batch cannot half-remove. boost-style metric plumbing stores cumulative StoreStats values, so the two new counters are monotonic like their neighbours (helios/src/server/metrics.rs:632-637, 872-885). Test coverage for the new paths is real and in-repo (composite.rs:7224-9063, memory.rs:8178-9011, pool/cascade.rs:1174-3785, pool/store/tests.rs:314 (not opened) new lines).
Findings (all verified, with citations in the scratchpad notes I wrote): (1) Major — the pool spill gate is inert for any record recovered from disk at startup, because DiskStore::new inserts scanned records through Index::insert, which initialises prefill_saved_ns: 0 (selene/src/shared/index.rs:468, disk_store.rs:2307-2320) and nothing backfills it during the scan, while disk_pool_standalone_profitable returns true when the price is zero (disk_store.rs:2196-2202) — so the pool gate silently fail-opens for the whole cold-restart population the PR's benchmark highlights. (2) Major — documents/contracts drift: the two new Prometheus series and the new unprofitable label value on flare_host_cache_store_reasons_total (helios/src/server/metrics.rs:872-885, 922-933) are absent from docs/api.md (no match for spill/profitab/unprofit; the host-cache family table is docs/api.md:341-398), and the new StoreOutcome::Unprofitable public variant is not listed in the documented publication outcomes (docs/prefix-cache-offload.md:1462-1465). (3) Minor/Major — the gate's restore-cost basis is decided from transient DRAM occupancy: composite.rs:546-551 passes composite_rates only when memory.fits(chain_slots), and disk_store.rs:3579-3584 then charges disk read or the single rate instead of disk read + DRAM→GPU upload, so the same checkpoint is priced ~2× cheaper exactly under memory pressure — contradicting the PR's "charging both disk read and DRAM-to-GPU upload" claim in that branch. (4) Minor — new full-index rescans on the publication hot path: reserve_disk_capture/store_excluding_reclaiming_dram_only loop (composite.rs:506-566) each call evict_blocking_dram_only_for_disk → reclaimable_uncharged_subtree, which iterates index.ordered() and walks whole subtrees per durable root (disk_store.rs:2626-2667), giving O(n) per retry and O(n²) worst case under sustained disk pressure. (5) Minor — reap_evicted_dram_only swallows batch-removal failure with unwrap_or_default() (composite.rs:455-463) after take_evicted already drained memory's eviction list, so a failed batch strands dram_only/dram_only_descendants entries with no resident copy and no retry, permanently suppressing later fork votes for that key. (6) Claim accuracy — the A/B table was measured on 09400ad8, not head d74e810, and per the PR body two of three models report zero skipped spills, so only the Qwen3.8 row exercises the gate; the fleet replay is offline against .ckpt headers, not a served workload (Charter #210).
#2 [high] Finding 1 (Major): pool spill gate inert for disk-recovered records — prefill_saved_ns starts 0
Correctness/contract finding, severity Major.
Index::insert initialises the new field to 0 for every record, and DiskStore::new inserts scan-recovered records through it (file: selene/src/shared/index.rs:457-476):
self.nodes.insert(
key,
Node {
key,
parent,
published_ancestors: Vec::new(),
chain_depth,
bucket,
tail_pages,
row,
ready,
prefill_saved_ns: 0,
selene/src/disk_store.rs:2306-2320 (startup scan insert, ready = true, no price):
for record in &scanned {
index.insert(
record.header.key,
record.header.parent,
record.header.bucket,
record.header.tail_pages as usize,
record.row,
true,
DiskRecord {
The gate treats 0 as "unpriced = profitable": selene/src/disk_store.rs:2191-2206
fn disk_pool_standalone_profitable(
layout: &Layout,
policy: Option<crate::store::PoolSpillPolicy>,
node: &Node<DiskRecord>,
) -> bool {
let Some(policy) = policy else {
return true;
};
let saved_ns = node.prefill_saved_ns;
if saved_ns == 0 {
return true;
}
and selene/src/store.rs:526-534
pub fn standalone_spill_profitable(transfer_seconds: f64, prefill_saved_ns: u64) -> bool {
if prefill_saved_ns == 0 {
return true;
}
worth_restore(transfer_seconds, prefill_saved_ns as f64 * 1e-9)
}
The only backfill is on republish of the same key (selene/src/composite.rs:810-825 backfill_prefill_saved_ns, called at composite.rs:1841, 1867, 1888).
Impact: after a restart, records loaded from NVMe (the exact population the PR's cold-restart table measures) carry no price, so disk_pool_eligible_node/memory_pool_standalone_profitable (selene/src/memory.rs:429-444, disk_store.rs:2208-2264) always take the true branch and cascade them to the pool anyway — the gate silently no-ops until each key happens to be republished, and never for keys that are never republished. Fix: derive prefill_saved_ns during the scan (or on first use) from geometry + the scheduler's prefill rate, or persist/publish it in the v4 header path and backfill in DiskStore::new before any retire decision; alternatively exclude zero-priced scanned records from pool spill until priced (fail-closed) with a counter.
#3 [high] Finding 2 (Major): new metric family + Unprofitable outcome undocumented in api.md/offload doc
Contract/docs finding, severity Major (charter: "PRs that address ... bad docs", and docs/api.md documents every other host-cache family).
New series, helios/src/server/metrics.rs:872-885:
text.push_str("# HELP flare_host_cache_spill_skipped_unprofitable_total Spills skipped because standalone restore latency exceeds the profitability threshold.\n# TYPE flare_host_cache_spill_skipped_unprofitable_total counter\n");
...
"flare_host_cache_spill_skipped_unprofitable_total{{tier=\"{tier}\"}} {}",
Also a new label value on an existing family, helios/src/server/metrics.rs:922-933:
"host_cache_store_reasons_total",
&[
"present",
"inflight",
"slabs",
"queue",
"budget",
"oversize",
"unprofitable",
][..],
and a new public enum variant, selene/src/store.rs:268-276 StoreOutcome::Unprofitable.
Verification of the doc gap: search_code in docs/api.md for pattern spill|profitab|unprofit returns no matches, while the host-cache family table and prose live at docs/api.md:341-398 (host_hits, flare_host_cache_held_total{tier}, flare_host_cache_dropped_total{tier,reason}, flare_host_cache_pool_inbound_bytes_per_second{level} etc.). The publication-outcome contract in docs/prefix-cache-offload.md:1462-1465 still lists only three outcomes:
- **Publication outcomes.** `Present` requires a committed local copy; a lookup
hint is not sufficient. `Oversize` includes required ancestor files that
cannot coexist within the disk limit even without unrelated records, and
`Retry` means that capacity or queue room is temporarily unavailable.
The only doc text added by the PR about the gate is docs/prefix-cache-offload.md:685-696 (dram_only/shadow behavior).
Impact: operators cannot interpret the new counters or the unprofitable reason in flare_host_cache_store_reasons_total, and embedders of selene reading the documented HostStore::store outcomes will not handle Unprofitable (helios treats it as terminal: unpin without deferral, helios/src/server/runtime.rs:2940-2941 and 2959-2961). Fix: add the two series (with the nvme/pool tier semantics and the "compressed vs uncompressed logical bytes" definition) plus unprofitable to docs/api.md:341-398, and add Unprofitable to docs/prefix-cache-offload.md:1462-1465 with its no-pin/no-event semantics.
#4 [high] Finding 3 (Major): NVMe gate drops the upload charge when DRAM cannot hold the chain
Correctness/pricing finding, severity Major (the PR explicitly claims it "charg[es] both disk read and DRAM-to-GPU upload on streamed temporary-pin writes to match cold CompositeStore::hit").
selene/src/composite.rs:540-551:
let layout = self.memory.layout();
let total_pages = (checkpoint.key.consumed_tokens / layout.page_tokens) as usize;
let row = self
.disk
.needs_row_excluding(checkpoint, Some(&self.dram_only));
let chain_slots = layout.record_slots(total_pages, row);
let composite_rates = self.memory.fits(chain_slots).then(|| {
(
self.disk_inbound_rate.get().max(1.0),
self.memory.stats().inbound_rate.max(1.0),
)
});
selene/src/disk_store.rs:3571-3589:
fn spill_eligible_nvme_with_rates(
&self,
checkpoint: &PublishedCheckpoint,
row: bool,
composite_rates: Option<(f64, f64)>,
) -> (bool, u64) {
let pages = checkpoint.key.consumed_tokens / self.layout.page_tokens;
let raw_bytes = self.layout.record_bytes_for(pages, row);
let transfer_seconds = match composite_rates {
Some((disk_rate, memory_rate)) => {
raw_bytes as f64 / disk_rate.max(1.0) + raw_bytes as f64 / memory_rate.max(1.0)
}
None => raw_bytes as f64 / self.inbound_rate.get().max(1.0),
};
Impact: memory.fits(chain_slots) is false exactly when DRAM pressure is high (the condition that makes spilling attractive). In that case the gate prices the restore at bytes / disk_rate only instead of bytes/disk_rate + bytes/dram_rate, i.e. roughly half the true cold-restore cost CompositeStore::hit charges (selene/src/composite.rs:406-423 charges disk_bytes/disk_inbound_rate + bytes/memory_rate). So under pressure the gate becomes ~2× more permissive than the restore-side admission price it is supposed to mirror, admitting exactly the writes it intends to skip — and the same checkpoint is priced differently depending on transient occupancy. Fix: always compute both rates for a composite (memory rate is known regardless of fit), or price the streamed case with disk_bytes/disk_rate + raw_bytes/memory_rate unconditionally; keep None only for the standalone (non-composite) DiskStore.
#7 [high] Finding 6 (claim accuracy): A/B measured on a different commit; two of three rows show the gate inactive
Claim accuracy, severity Minor-to-Major for a charter #210 ("performance PRs need benchmarks showing an actual speedup over main on a served workload").
PR body, verbatim: "Measured on combined development commit 09400ad8 vs base 19ce4a7b across three hybrid EXACT_ROW models (where only this write-side profitability gate is active; workload: 12 short single-turn prompts + 4 short-to-long growth conversations + 6-way fork over a 500-token system prompt + cold restart)" — while the PR head is d74e810.
Same table, GLM-5.3 TP2 row: "Skipped Unprofitable (Run 1 / Run 2) | 0 (TP2 prefill; see fleet replay)"; DeepSeek-V4.1 TP4 row: "0 (self-calibrating)". Only Qwen3.8 shows 25 / 4. So two of three served measurements do not exercise the gate at all, and the "NVMe bytes 62 → 62 (5.10 → 3.79 GB)" / "63 → 63 (834.8 → 832.2 MB)" deltas are attributed to the gate while reporting zero gated spills.
Fleet replay is explicitly offline: "Exact replay of standalone_spill_profitable + fork_dedup_profitable against .ckpt headers from production pools", with a "Shared Forks Promoted" column computed by the replay rather than observed.
Verified anchors that make this material: the gate only sees a price when helios publishes it (helios/src/server/runtime.rs:2917-2921):
publication.prefill_saved_ns = self
.scheduler
.estimate_prefill_delta_ns(c, 0, c, false, &[], &[])
.unwrap_or_else(|| ((c as f64 / self.prefill_rate.max(1.0)) * 1e9) as u64);
and estimate_prefill_delta_ns returns None until capacities are measured (helios/src/scheduler/checkpoints.rs:438-461, "Returns None when required prefill capacities are still unmeasured (cold)"), so the pre-exported-cores measurement window in the PR body is precisely the window where the fallback EMA price applies — a systematic difference from a warmed run. Fix: rerun the A/B at head d74e810 with a warmed prefill catalog, report per-config skip counts for every row, and state the measurement commit and that the fleet table is a replay next to the numbers.
#5 [medium] Finding 4 (Minor): O(n) index rescans per capture retry under disk pressure
System-level finding, severity Minor (bounded by pending writes, but hot under sustained pressure).
selene/src/composite.rs:506-532 (reserve_disk_capture retry loop):
loop {
let reserved = self
.disk
.reserve_capture(key, parent, bucket, tail_pages, row, true, role)?;
self.drop_evicted_copies();
if reserved.is_some() {
return Ok(reserved);
}
...
|| !self.evict_blocking_dram_only_for_disk(parent)
selene/src/composite.rs:552-566 (store_excluding_reclaiming_dram_only loop) does the same via evict_blocking_dram_only_for_disk(protected).
that helper (composite.rs:473-492) calls DiskStore::reclaimable_uncharged_subtree, selene/src/disk_store.rs:2612-2669:
pub(crate) fn reclaimable_uncharged_subtree(
&self,
protected: Option<PrefixKey>,
eligible: impl Fn(&PrefixKey) -> bool,
) -> Vec<PrefixKey> {
let mut protected_chain = HashSet::new();
...
for root in self.index.ordered() {
if !root.ready
index.ordered() (selene/src/shared/index.rs:401-403) walks the full LRU set, and the inner while head < subtree.len() walks each candidate root's whole descendant subtree (disk_store.rs:2642-2662).
Impact: each blocked capture attempt is a full-index scan plus subtree walks (plus a HashSet/Vec allocation), repeated until it succeeds or the loop bails — O(n) per retry, O(n·retries) per poll under sustained disk pressure, on the same single store thread that must also drain copies, lookups and restores. Fix: cache the ordered candidate roots between attempts (invalidate on successful reclaim), or stop the scan as soon as one eligible root is found instead of subtree.reverse(); return after building the full list; also hoist the protected_chain construction out of the per-attempt path.
#6 [medium] Finding 5 (Minor): reap_evicted_dram_only drops batch-removal errors after consuming the eviction list
Robustness finding, severity Minor.
selene/src/composite.rs:446-468:
fn reap_evicted_dram_only(&mut self) {
let evicted: Vec<PrefixKey> = self
.memory
.take_evicted()
.into_iter()
.filter(|key| self.dram_only.contains(key))
.collect();
if !evicted.is_empty() {
let removed = self
.disk
.remove_uncharged_batch(&evicted)
.unwrap_or_default();
for key in removed {
self.dram_only.remove(&key);
self.dram_only_descendants.remove(&key);
self.thinning.remove(&key);
}
}
memory.take_evicted() (selene/src/memory.rs:3708) drains the flat store's evicted list, so the eviction notice is consumed exactly once; if remove_uncharged_batch fails (see its validation at selene/src/disk_store.rs:3518-3536: a key with pins() > 1 or a surviving child is skipped/failed), the dram_only entry and its dram_only_descendants voters survive for a key that is no longer resident, and promote_dram_only will simply return on !self.resident(...) (composite.rs:627-629) while record_dram_only_descendant keeps adding voters for it (composite.rs:875-899).
Impact: the anchor can never be promoted or reclaimed, so a durable disk ancestor stays blocked (reclaimable_uncharged_subtree requires the whole subtree be removable, disk_store.rs:2649-2658) and the fork-dedup bookkeeping for that prefix is permanently poisoned until evictions_lost/policy reset. Fix: on Err, keep the keys on a retry set (or re-queue them) instead of unwrap_or_default(), and only remove bookkeeping for keys actually removed; debug_assert!/count the failure like the sibling remove_uncharged call sites do (composite.rs:1872-1879).
#8 [medium] Areas checked and found sound (avoid false positives)
Sound-on-inspection areas, with the code that proves it (so the report does not re-flag them):
-
Predicates are NaN/inf-safe and strict: selene/src/store.rs:496-550 (
worth_restore,standalone_spill_profitable,fork_dedup_profitablewithsaturating_mul, strict>), unit-tested at selene/src/store.rs:593-638 includingassert!(!standalone_spill_profitable(f64::NAN, 100_000_000));and the geometry-derived break-even cases (qwen38 18 children, deepseek41 4 children). -
Hysteresis has a single driver and cannot thrash: only
PooledStore::pollpushes it, selene/src/pool/store.rs:603-610:
let policy = self.pool_spill_policy();
if policy.materially_differs_from(&self.last_pool_spill_policy) {
self.last_pool_spill_policy = policy;
self.inner.set_pool_spill_policy(Some(policy));
}
and Core::set_pool_spill_policy short-circuits on equality and otherwise recomputes once (selene/src/memory.rs:1299-1305), so the 5% hysteresis prevents per-tick full rescans. All store state mutation stays on the store's own thread; no new lock is introduced (HostStore/TierStore take &mut self).
-
Level→rate index mapping is correct, not off-by-one:
Ranking::rates()returns POOL_LEVELS order [NeighbourGpu, HostDram, HostNvme, RemoteNvme] (selene/src/levels.rs:107-132) indexed byLevel::index()(ThisGpu=0 … RemoteNvme=4), and selene/src/pool/store.rs:242-258 mapsLevel::HostNvme => rates[2],Level::RemoteNvme => rates[3]— matching that order. -
O(1)clean_slots is defended: selene/src/memory.rs:1695-1701 withassert_clean_slots_invariantrecomputing from a full index scan in debug/test (memory.rs:1613-1693), plus a scanned-vs-cached assertion forpool_coverage(memory.rs:1632-1659). -
Index::remove_nodesvalidates the whole closed batch before any mutation, so a bad batch cannot half-remove: selene/src/shared/index.rs:523-544 (if node.pinned() || !node.children.iter().all(|child| removed.contains(child)) { return Err(...) }) followed by single pass overaffected_buckets/affected_parents(index.rs:545-574). -
Metrics stay monotonic because they store cumulative
StoreStatsrather than incrementing: helios/src/server/metrics.rs:632-637 inside the existingstore(...)gauge store loop; the render test asserts the new series (metrics.rs:2050-2052 usesStoreOutcome::Unprofitable) and the existing sum assertion at metrics.rs:1627-1634 still counts 6 outcomes becauseUnprofitableis only added in the new test. -
No protobuf/ignition/model-core/graph-contract/on-disk v4 files appear in the PR file list; the only wire-shaped change is the new
PublishedCheckpoint::prefill_saved_nsfield (selene/src/store.rs:42-45), which is Rust-API-visible to embedders (documented as0= unpriced) and forced fixture updates (selene-manager/tests/client.rsprefill_saved_ns: 0). -
Tooling limitation to restate in the report:
pr_difffails (fatal: bad revision 'cc0a49d2…d74e810') andsearch_historycannot resolve base objects, so no diff-hunk-level or commit-level evidence was available; all citations above are full-file reads atpr/694.