Recommendation: Changes Requested
The state machine is sound: I traced every new progress edge, every parked/jobs/outbound mutation, and every can_retry_slabs() == false exit for a guaranteed future wake source, and found no correctness bug — no stall, no lost wakeup, no zombie waiter, no duplicate store() submission, no new panic path. What blocks it is the one thing the charter treats as non-negotiable for this PR class: a performance-titled "CPU storm" fix with no served-workload measurement on the patched build (Charter #210, docs/design-review.md:106-115), while issue #703 itself records that the storm was not reproduced on v0.5.3. Secondary: the mandated --locked --release (+--features test-support) Layer-1 runs were not performed (docs/design-review.md:180-184), docs/prefix-cache-offload.md still documents the pre-PR retry contract, and one accepted-publication path does its planning work twice.
Merge Risk
Level: Medium
- Touches the shared DRAM/NVMe retention state machine (
selene/src/composite.rs+519/−50) plus the single-threaded worker loop; a mistake here stalls prefix-cache stores or leaks waiters in production rather than failing loudly (mitigated by 9 focused tests and realdebug_assert!invariants). - Operator-visible metric semantics move (
progressunderENOSPC,held[0]cadence, deferredSlabsattempt counts) with no docs update, so dashboards/alerts built on #703's counters read differently. - Two large open PRs (#674, #694) rewrite the same
Retry(Slabs)branch, the sameservice_storeoutcome match and the sameHostStoretrait, with no merge order recorded; CI would run the release profile this PR did not.
Walkthrough
helios/src/server/runtime.rs:2791-2957— one per-CheckpointIdreconciliation oftake_publications(),deferred_stores,deferred_copyoutsintoVec<PendingStore>{publication, prior_retry, fresh}; duplicate IDs replace the earlier publication on theOccupiedpath (:2813-2817), deferred entries attachprior_retryto an existing entry instead of queueing twice (:2823-2826), and everywaiting.pushis gated byseen_waiting.insert(...)(:2835,:2884,:2936), so no waiter is dropped or duplicated across passes.helios/src/server/runtime.rs:2928-2954—progressis now edge-triggered:Queued(:2930), a changedStoreReason(prior_retry != Some(reason),:2933-2935),Present/Oversizevia_ =>(:2941-2943), copyout headroom change (:2891-2896) andErr(:2953). Repeated identicalRetry(Slabs)returnsOk(false), soWorker::runparks.host_retry_successnow keys onprior_retry.is_some()(:2947), which is correct for the fresh+deferred collision.helios/src/server/runtime.rs:2880-2888— the non-freshSlabsgate runs beforeexport_fits()/store(), so a skipped retry neither pins a checkpoint nor scoreshost_store_outcome;freshbypasses it, so ready publications are not starved.selene/src/composite.rs:1452-1456+:774-788,:752-771—can_retry_slabsreturnsfalseonly whenwriting < MAX_SPILLS && covered_slots < short && !backoff_active()fails; its negation is discharged by a future write completion (disk_stored→progress) or by the 50 msretry_afteredge (:1656-1660).has_spillable_slotsearly-exits, replacing the old fullsum()fold.selene/src/composite.rs:656-720,:1608-1624,:1656-1671—disk_storedreturnsfalseonly on theENOSPCpath (:687 return !pressure), soprogressno longer advances with zero durable slots; theretry_afterexpiry clears unconditionally and bumpsprogressexactly once, which also re-enters the maintenance block (:1662-1670) so spill maintenance still runs — one probe per 50 ms (~20 Hz), not a spin.selene/src/store.rs:324-329,pool/store.rs:615-616,pool/local.rs:45-49— new default-truetrait method forwarded throughPooledStore/Tiers(viais_none_or, the conservative direction), so out-of-tree and memory-only stores behave exactly as before.
Pre-merge Checks
- [PASS] Security / malicious screen: pure Rust refactor of the retention/retry path; no new dependency, flag, config key, wire, protobuf or on-disk format change, no network or shell surface, no instructions embedded in the diff.
- [WARN] Charter & value fit: right problem in the right layer (shared
selenestore +heliosworker, no per-model branch, knob defaults totrue) but the headline result is unmeasured — see Blocker 1. - [WARN] Related / duplicate / conflict check: not obsolete and not a duplicate of #674/#694, but both rewrite this same
Retry(Slabs)branch andservice_storeoutcome match (#694 addsStoreOutcome::Unprofitable, which this PR's_ =>wildcard would swallow) and no merge order is recorded — sequencing must be settled before either lands (informational, not a blocker). - [WARN] Tests & verification evidence: 9 new tests exist exactly where claimed and pin the real mechanisms (
composite.rs:6295-6634,phase_tests.rs:9022/9058/9119/9162), but everything ran in the debug profile; the mandatedcargo test --locked --release(and selene's--features test-support) was not run, and no check ran oneec5e95.
Blockers
- No served-workload measurement for a performance claim —
helios/src/server/runtime.rs+selene/src/composite.rs, PR title/summary.docs/design-review.md:106-115(principle 12: "Performance claims require equivalent baselines … and actual Helios service measurements") and Charter #210 ("Performance PRs need benchmarks showing an actual speedup overmainon a served workload") are hard requirements for this PR class. The only profile in evidence is issue #703's capture on the pre-fixflare 0.5.1binary, and #703 states the storm was not reproduced onv0.5.3; there is no post-fixperfsample, no CPU% before/after, no latency number. Fix: attach oneperf/CPU% before-after on #703's configuration (4× RTX PRO 6000 SM120, DeepSeek-V4.1-Flash TP4,--max-concurrency 64 --prefix-cache-memory 8G --prefix-cache-disk … --prefix-cache-disk-limit 100G) on the patched build, or retitle/downgrade the claim to the mechanism and state the mechanism-level evidence explicitly. This is an evidence-form gap, not a code defect — the code fixes the mechanism as described.
Should Fix
- Planning work is duplicated per accepted publication.
selene/src/composite.rs:1423-1428+:1452+:1455(can_retry_slabs) and:1328-1334(store) independently callself.disk.plan_record(checkpoint)— anO(tail_pages)Vec<PageId>clone (selene/src/disk_store.rs:2516-2531) — and independently callhas_spillable_slots. Whencan_retry_slabsreturnstruethe worker immediately re-entersstore()(helios/src/server/runtime.rs:2903) and repeats both, i.e. two clones and two scans per accepted publication. Fix: return the sizes rather than the vector (e.g.fn slab_need(&self, cp) -> Option<(Option<PrefixKey>, usize /*tail*/, usize /*needed*/, usize /*short*/)>) used by both callers, soplan_record's clone runs once per publication. - Mandated Layer-1 profile was not run.
docs/design-review.md:180-184requirescargo test --locked --releaseon every affected crate, matching.github/workflows/native-serving.yml:51 (not opened),55,63,68(selene also with--features test-support). The PR states "All checks ran in debug profile" and reports selene ascargo test --manifest-path selene/Cargo.toml(not opened) with no feature, so neither the release profile nor thetest-support-gated selene tests were exercised. Fix: attachcargo test --locked --releaseforselene(with and without--features test-support) andhelios --features runtime-core,server. docs/prefix-cache-offload.mdstill documents the pre-PR contract. TheHostStoreinterface listing at:272-284omits the newcan_retry_slabsoperation; the worker retry contract at:293-297("The worker retains only checkpoint IDs for retries after store progress…") no longer describes the retained per-ID reason plus theSlabsgate; the retention-metrics text at:1364-1372still describesheld_total{tier}per holding event andstore_skipped"including duplicates and retries" — precisely the cadence the PR's own "Narrow Metric and API Shifts" changes (held[0]now accounted on progress-gatedpoll()ticks; deferredSlabspublications skipped by the gate never reachstore()).AGENTS.md:52-58requires a design document to state the behavior the code implements. Fix: update those three passages in this PR or in an explicitly linked follow-up.
Subtract / Simplify
- Dead branch —
selene/src/composite.rs:903-905(else if self.backoff_active() { break; }). Unreachable: the enclosing loop is guarded by:892 if writing < MAX_SPILLS && !self.backoff_active(), andretry_afteris written in exactly two places (disk_stored,:668;poll,:1658), neither reachable fromspill()→thin_rows/reserve_capture/start_write; andbackoff_active()is monotone for a fixedretry_after. Delete the three lines. - Collapse the four dedup collections to one claim helper —
helios/src/server/runtime.rs:2791-2873.publication_index,seen_waiting,seen_copyoutsand thefresh/prior_retrypair answer one question ("has thisCheckpointIdalready been claimed this pass?"); theVacant/Occupiedblock at:2803-2819and the copyout block at:2857-2873are the same shape written twice. Astruct Pending { list: Vec<..>, at: HashMap<CheckpointId, usize> }withfn claim(..)plus anenum Prior { Fresh, Copyout, Retried(StoreReason) }removesseen_copyoutsentirely and makes the contradictoryfresh && prior_retry.is_some()state unrepresentable. - Nine fully-qualified collection paths shadow an existing import —
helios/src/server/runtime.rs:2801,2802,2805,2821,2854,2856writestd::collections::HashMap::<…>::new(),std::collections::hash_map::Entry::Vacant,std::collections::HashSet::new()although:8already hasuse std::collections::{HashMap, VecDeque};. Extending that import deletes all nine. - Duplicated preamble between
can_retry_slabsandstore—selene/src/composite.rs:1416-1422is character-for-character:1272-1275, and:1423-1431mirrors:1328-1333. Extract one helper (see Should Fix 1);checkpoint.tail_pages > checkpoint.chain_pages.len()(:1406-1408) is anErr(invalid(..))integrity check instorebut "go ahead and retry" here, so divergence converts a corrupt publication into a retry loop. - Unreachable guard —
selene/src/composite.rs:775-777(if need == 0 { return true; }): both production callers pass a value already proven> 0(:1334 if short > 0 && …,:1452after:1429 if short == 0 { return true; }). Either drop it or drop theshort > 0at:1334so the0case has one owner.
Nits
helios/src/server/runtime.rs:2941-2943—_ => { progress = true; }re-introduces the "anything I didn't enumerate counts as progress" assumption the PR is fixing;StoreOutcomecurrently has exactly four variants, soStoreOutcome::Present | StoreOutcome::Oversizeis one word longer and cannot silently swallow a future non-progress variant (open #694 addsStoreOutcome::Unprofitable).- PR claim "
Worker::run… enforces a 2 ms idle poll cap so theretry_afterexpiry edge fires reliably" is inaccurate:idle_wait()returns 50 µs with a store inbound transfer or scheduler inbound waiter, 100 µs when an incoming awaits the pool, and 2 ms only in the fallback (helios/src/server/runtime.rs:1269-1292), and that whole branch runs only whenexecutor.outstanding() == 0(:1248-1263). The expiry edge is still observed reliably; correct the justification. selene/src/composite.rs:765-769— the cross-checkdebug_assert_eq!(writing, self.parked.values().filter(..).count())turnswriting_spills()into two extraO(parked)passes in debug builds at three call sites (:1455,:888,:1378). Consider moving it to a#[cfg(debug_assertions)]consistency check inpoll()'s maintenance block.- Two undeclared-but-benign hunks should be named in "Changes": the relaxed pre-existing assertion at
selene/src/composite.rs:2733-2736(store.spill(child.key).unwrap()→ guarded by!store.parked[&child.key].writing, forced by the newspill()guard at:819-821) and the orphan-parkedcleanup at:661-664(closes a latentself.outbound[&key]panic at:823).
Dropped on verification
- "
can_retry_slabsperforms three to fourO(parked)scans to produce a single 'still saturated' bit / walks all 5,000 parked records in the saturated case" (upstream F1's counterexample) — false. In the saturated statehas_spillable_slots(short)(composite.rs:774-788) walksself.parked.keys()accumulatingrecord.slots()and early-exits as soon assum >= need(:782), andneedis one record's shortfall, not the pool size; with thousands of parked records it exits after a handful of keys. The function then reacheswriting_spills()(:1455), which isO(jobs)(≤ 8 writes). Nor is it "strictly worse than the code it replaced": the old path ranstore()→ the removedspillable_slots()fullsum()over every parked record (no early exit) →spill_parked()→waiting_spills()filter plussort_unstable_by_key(:869-881), all afterexport_fits(); the new path skipsexport_fits()(13.12% of #703's samples) and the sort entirely when it returnsfalse. What survives is the duplicate-work point, kept as Should Fix 1 at its real magnitude. - "
held[0]is no longer counted at all whileprogressis flat, under-counting a documented counter during ENOSPC" (upstream F3.1) — false. Theretry_afterexpiry atcomposite.rs:1656-1660unconditionally bumpsself.stats.progress += 1once per 50 ms, soprogressis not flat under sustainedENOSPC; the maintenance block at:1662-1671re-runs on that bump andspill_parkedstill chargesheld[0]at:908-910. The cadence change is real but bounded and deliberate (PR body item 2); it is covered by Should Fix 3 (docs), not by a metric defect. - "9 new tests are not deterministic / 'zero sleeps' is inaccurate because of a 10-second wall-clock loop" — dropped. The loop at
composite.rs:6489-6503usesstd::thread::yield_now()(not a sleep) with a fixed injected clock, and exits on the deterministicQueuedoutcome; the deadline is a hang guard, not the exit condition. - "Everything ran in debug profile, so the new
debug_assert!invariants are unverified in the shipped profile" as a code risk — dropped as a code finding. Choosing the debug profile is what executes those asserts; the release run is a separate evidence-form gap, carried as Should Fix 2. - "The new
spill()guard duplicates four existing!writingpre-checks, so the code has two sources of truth" (upstream subtraction #10) — dropped. The guard closes a real hole the pre-checks do not:drain_on_shutdowncallsself.spill(key)atcomposite.rs:1816and:1823with no!writingprecondition, so without it an already-writing record could be re-reserved and written twice concurrently. pr_diffshowingAGENTS.md,docs/*,flare-cli/*andpreserve_message_anchorhunks as PR content — dropped as base drift, verified.pr_fileslists exactly the 6 files the body claims (matching +820/−71), whilepreserve_message_anchorplumbing exists at PR head inhelios/src/scheduler.rs:160,231,1852,helios/src/scheduler/checkpoints.rs:470(not opened), andhelios/src/server/request.rs:427-452(not opened) — files not inpr_files— and those files have nopreserve_message_anchorin this mirror'smain. The mirror'smainis simply older than the branch point; the unrelated hunks (including the ~1,000 lines ofpreserve_message_anchor/HTTP-envelope tests inphase_tests.rs) are not this PR's content.- Cross-PR overlap with #674/#694, "no CI checks observable",
docs/TODO.txtbookkeeping, and PR-description phrasing (beyond the one factual "2 ms cap" correction) — not raised as blockers or should-fixes per calibration; recorded as Pre-merge/Info. - "
ENOSPCdisk-write failures no longer incrementStoreStats::progress" is a behavior regression / lost-wakeup risk — dropped. Verified safe: the suppressed path is exactly the one that re-parks the record withwriting = falseand re-armsretry_after(composite.rs:665-688), whose expiry edge (:1656-1660) restoresprogress, and everycan_retry_slabs() == falseexit (:1425-1427,:1429-1431,:1448-1450,:1452-1454,:1456) is discharged either by a write completion or by that 50 ms edge.