#1 [high] F1: observe_prefill_rate is unconditionally dead (regression vs main)
CONFIRMED at head 45fb380.
helios/src/server/runtime.rs:3058-3065 let capacity = step.prefill_capacity() as u64; if !step.kind.is_prefill() || step.lanes.len() != 1 || capacity == 0 || (step.lanes[0].tokens as u64).saturating_mul(2) < capacity { return; }
- helios/src/scheduler.rs:465-467:
pub fn prefill_capacity(&self) -> usize { self.mixed.as_ref().map_or(0, |m| m.prefill_capacity) }→ 0 whenevermixed.is_none(). - helios/src/execution/manifest.rs:85-87:
is_prefill()= Prefill | TerminalPrefill | ScoredPrefill. - helios/src/scheduler.rs:437-462 (
validate_mixed):None if self.kind != GraphKind::Mixed => Ok(()),Some(m) if self.kind == GraphKind::Mixed— so a prefill-kind step can never carrymixed, and a Mixed step is neveris_prefill(). =>!is_prefill() || capacity == 0always true;self.prefill_rate(initINITIAL_PREFILL_RATEat runtime.rs:1288) never updates.
Impact: estimated_prefill_saved_seconds (runtime.rs:3248-3269) falls back to gained as f64 / fallback_prefill_rate.max(1.0) at :3267-3268 with a hard-coded 8000 tok/s on every cold/unmeasured capacity, and RestoreWait::defer budget uses the same value — exactly the "wall-clock EMA mispricing" this PR claims to remove.
Regressed vs main: main's sampler (helios/src/server/runtime.rs:2976-2989 at main) measured fence elapsed for every prefill with no capacity/lane gate, call site main :1829-1831.
Test gap: no test calls observe_prefill_rate; the three pricing tests set the EMA by hand (phase_tests.rs:8665 worker.prefill_rate = 0.5;, :8707 1.0, :8780 0.001), and :1741 asserts it stays at INITIAL.
Fix: gate on step.token_capacity (valid now that !kind.is_prefill() already restricts to pure prefill) and add a unit test asserting the EMA moves on a >=50%-fill single-lane prefill and not on a <50% fill or multi-lane step.
#2 [high] F2: page_pressure_victim_priority outranks recency/role; contradicts PR's own doc
CONFIRMED at head 45fb380; both symbols are new in this PR.
helios/src/scheduler/cache_memory.rs:210-223 let releases_page = (node.child_count() == 0 && !node.tail_pages().is_empty()) || snapshot_pages.get(node.snapshot().0 as usize).is_some_and(|range| { range.clone().any(|page| refs.get(page as usize).copied() == Some(1)) }); ( !releases_page, node.retention_rank().use_epoch, !role_preserving_compaction )
Consumed as the OUTER key: helios/src/cache.rs:788-790
.min_by_key(|(node, _, role_preserving)| (priority(node, *role_preserving), self.eviction_key(node)))
with eviction_key = (is_protected, retention_rank, id) only as tie-break (cache.rs:378-380).
Called from the mandatory path: cache_memory.rs:627-641 eviction_candidate_with_priority(None, false, None, |node, role| page_pressure_victim_priority(...)) — below = None and protected_token_budget = None, so cost is always 0 (cache.rs:768-785) and the priority tuple alone decides.
Defect 1 (recency/role inversion): two cold overlapping checkpoints that share a band give refs == 2 for every page, so neither has refs == 1 → both releases_page == false; a brand-new Anchor/Message leaf with tail pages is true and therefore always loses first. releases_page also outranks role_preserving_compaction, so a hot leaf dies before a cold role-preserving compaction that frees nothing.
Defect 2 (fires with no page need): helios/src/scheduler.rs:1263,1276-1280 — backing_conflict = snapshot_unavailable && !self.free_snapshots.is_empty() and evict_for_pressure(need_pages, need_snapshots, need_pages > 0 || backing_conflict). In cache_memory.rs:599-601 page_pressure is then true with need_pages == 0 && need_snapshots == 1 && free_snapshots.len() >= 1, so the store destroys a hot leaf for KV pages it does not need instead of dropping a cold overlapping snapshot.
Defect 3 (hot path): scheduler.rs:1361 self.evict_for_pressure(want - self.free_pages.len(), 0, true) runs on every growable-decoder page refill, so this ordering applies to steady-state decode, not only capture.
Doc/comment contradiction (added by this PR): docs/runtime-core-design.md:869-873 "victim selection prioritizes checkpoints that release at least one usable KV page ... preserves completion recency, and within the same recency epoch prefers role-preserving single-child compactions"; cache_memory.rs:200-203 repeats "preserve completion recency (use_epoch)". Recency is only preserved within the releases_page partition, so both statements are false as written.
Fix: bucket releases_page inside the recency comparison (e.g. key (node.retention_rank().use_epoch, !releases_page, !role_preserving), or bound the skip so it cannot sacrifice a strictly newer leaf), do not force page pressure when need_pages == 0 (prefer freeing the conflicting snapshot), and restate both doc sentences as "within the oldest recency epoch".
#3 [high] F3: RowRestoreLatency::observe uses upper median for a lower-is-better metric
CONFIRMED at head 45fb380, distinct from the already-fixed start() decay-clock blocker.
helios/src/server/runtime.rs:313-318 bucket.samples[bucket.next] = seconds; bucket.next = (bucket.next + 1) % bucket.samples.len(); bucket.count = (bucket.count + 1).min(bucket.samples.len()); let mut ordered = bucket.samples; ordered[..bucket.count].sort_by(f64::total_cmp); bucket.last_median = Some((ordered[bucket.count / 2], std::time::Instant::now()));
Latency is lower-is-better, so the upper median is the worse sample. With count == 2 (one aged spike + one fast recovery probe) [0.002, 0.500] → 0.500, and last_median's timestamp is reset to now, so estimate_seconds (runtime.rs:321-332, median * 0.5f64.powf(elapsed / RECOVERY_SECONDS), RECOVERY_SECONDS = 10.0 at :282) jumps back to the full spike for another 10 s.
The source it was copied from is the mirror case: selene/src/levels.rs:65-67 sorts bytes/sec (higher-is-better) and takes values[self.count / 2], whose doc at levels.rs:30-33 states the intent — "One slow sample ... must not ... one slow transfer would refuse its restores for good."
Downstream: row-only restores are gated by hit.estimated_seconds.max(row_restore_latency.estimate_seconds(source)) (runtime.rs:3355-3360) before flare_selene::worth_restore (:3362), so an aged spike keeps deleting pages == 0 restores for another full recovery window after they demonstrably recovered.
Test gap: runtime/phase_tests.rs:8829-8851 only checks the decay clock across start/finish(false); nothing exercises spike-then-fast-probe with count == 2.
Fix: ordered[(bucket.count - 1) / 2] and add the spike+fast-probe regression test.
#6 [high] Research summary
Review of PR #674 (head 45fb380) for the Correctness, Contracts & System-Level Consequences lens. Seven findings, all verified against the head tree by opening the files; four are new defects introduced by this PR, and I confirmed that the round-2 RowRestoreLatency::start blocker is genuinely fixed.
Blockers / major, all confirmed in code and cited in the scratchpad:
observe_prefill_rateis unconditionally dead code (helios/src/server/runtime.rs:3058-3065) — the guard gates onprefill_capacity(), which ismixed.as_ref().map_or(0, …)(scheduler.rs:465-467), while prefill-kind steps can never carrymixed(scheduler.rs:437-462). The EMA stays atINITIAL_PREFILL_RATEforever, and that frozen value is whatestimated_prefill_saved_seconds(runtime.rs:3267-3268) andRestoreWait::deferfall back to. This is a regression relative to main (runtime.rs:2976-2989on main), and the three pricing tests set the EMA by hand, so nothing covers it.page_pressure_victim_priority(scheduler/cache_memory.rs:210-223) puts!releases_pageahead ofuse_epochand role as the outer sort key (cache.rs:788-790), so under mandatory pressure a hot leaf always loses to an ancient overlapping checkpoint; and becausebacking_conflictalone forces page pressure (scheduler.rs:1263,1276-1280), it fires withneed_pages == 0. Both this PR's new comment and its new doc sentence (docs/runtime-core-design.md:869-873) claim recency preservation.RowRestoreLatency::observetakes the upper median for a lower-is-better latency (runtime.rs:313-318), keeping a spike and re-arming its 10 s decay on the first fast recovery probe. Theselene::levels::Rateit mirrors is higher-is-better, so the index is inverted; the new test only covers the decay clock.- Three per-victim hot-path costs on the single-threaded scheduler: unconditional
page_snapshot_refs.clone()(scheduler/cache_memory.rs:608), a freshHashMapover all checkpoints per selection (cache.rs:740-753), and an O(candidates × span)refs[page] == 1scan (scheduler/cache_memory.rs:211-217).
Minors: the pressure path's retiring-snapshot list is not deduped the way projected_fits dedupes it (scheduler/cache_memory.rs:609-626 vs :570); full-GPU-hit requests store pool_plan without a pool_lookup (runtime.rs:3332-3334), so a queued eviction of that checkpoint cannot re-plan; and a freshly queued manager writeback waiter inherits the just-bumped epoch (selene-manager/src/store.rs:1419-1423, :1602-1607, :1629-1632), so it waits for the next release or the 5 s expiry.
Checked and sound: the start/finish decay-clock fix; the O_DIRECT whole-record write path including PublishError post-rename invalidation and the buffered fallback for partial unaligned streaming windows (selene/src/disk.rs:837-881, :1272-1330); the arena WindowHold drop ordering and WindowReleased coalescing; the metric split (docs/api.md:390-398 matches metrics.rs:1409-1428 and levels.rs:109-114); POOL_LEVELS ordering; and the pool estimated_seconds/rate-observe scope, which is measured end-to-end per restore and twice-priced only when a row-first plan degrades to a row-only one (selene/src/pool/store.rs:376-379, :465-472).
One process note for downstream adjudication: the 18:24 Autobot "Ready To Merge" and Luke Alonso's 19:04 "Changes Requested" review the same head and contradict each other; findings above were re-verified independently rather than taken from either.
#7 [high] Verified-sound areas (lens 1/3): O_DIRECT path, Arena/WindowHold, metric split, pool pricing scope
All inspected at head 45fb380.
SOUND — packed/record direct I/O and disk invalidation (selene/src/disk.rs):
Job::WriteRecord(disk.rs:837-881):whole_record = span.offset == 0 && publish.is_some_and(|(_, size)| *size == span.length)→ direct path also for unaligned whole records;span.aligned() || whole_recordtriesdirect_update_file, falls back towrite_record_bufferedonly onis_direct_unsupported(EINVAL on unix / Unsupported|InvalidInput elsewhere — cross-platform parity handled), and returnsio_failurefor any other error.write_record_direct(disk.rs:1272-1310): aligned prefix transferred zero-copy fromspan.address, only the< BLOCK_BYTEStail copied into zero-paddedself.scratch;raw_slice(disk.rs:1765-1773) guardslen == 0.write_direct_slices(disk.rs:1322-1372) truncates viaset_len(total)for the exact logical length.PublishError::{pre_rename,post_rename}(disk.rs:1657-1682) +reply_publish(disk.rs:1703-1716) correctly markinvalidated = trueonly afterfs::renamesucceeded and the destination was removed, andselene-manager/src/store.rs:4246-4249consumes it viainvalidate_disk_record. Pre-rename failures leave the prior file readable — tested inpost_rename_dir_sync_failure_marks_reply_invalidated.is_direct_unsupportednon-unix arm matchesUnsupported | InvalidInput(disk.rs:1787-1799), anddirect_open_failurereuses it — Windows parity preserved.
SOUND — manager arena/waiter machinery:
WindowHoldfield order (extentbefore_release, store.rs:5346-5349) makes the store observe the decrementedArccount before the signal drops;WindowReleaseSignal::notifyusesswap(true)so notifications coalesce losslessly (store.rs:5328-5341).writeback_wake_cursor/writeback_wake_remainingfixups infilter_writeback_waiters(store.rs:1450-1474) andscan_writeback_waiters_step(store.rs:1639-1656) keep the cursor in range and clampremainingtolen; the no-spin behaviour is tested (writeback_waiter_does_not_spin_across_idle_ticks_and_expires_on_deadline, store.rs:10703-10745) and a dedicated rotation test exists (store.rs:11568-11618). The only issue I found here is the epoch-inheritance note (scratchpad entry 5, F7).
SOUND — metric / rate scope check (the lens's explicit instruction):
flare_host_cache_pool_inbound_bytes_per_secondlabel set comes fromflare_selene::levels::POOL_LEVELS(levels.rs:109-114) zipped positionally withRanking::rates()(levels.rs:130-132) in metrics.rs:1418-1427 — one shared constant, no drift.docs/api.md:394-398describes it accurately as ranking estimates, leavingflare_host_cache_inbound_bytes_per_secondfor the local measured rate (metrics.rs:1395-1399).- The disk gauge split (docs/api.md:390-394) is reflected in the changed Python test (
tests/server/test_conditioned_input_cache.py:144-149now addsflare_host_cache_disk_reserved_bytesto the bound), so the reservation bytes cannot hide from the cap assertion. - Pool restore pricing span did NOT shrink inappropriately:
rates.observe(...)fires onrestore.started.elapsed()at the end-to-end completion of the restore (selene/src/pool/store.rs:376-379), andestimated_secondsisrates.part_seconds(level, bytes)over the whole planned byte count (:465). The only double-counting edge is a pool plan that degrades to row-only and is then raised byRowRestoreLatency(helios/src/server/runtime.rs:3355-3360) — that raises the estimate (conservative direction) and is the intended new behaviour. host_lookup_costnow takes prefill-saved seconds directly (helios/src/server/metrics.rs:538-564), matchingdocs/api.md:293-294; no unit distortion found.
#4 [medium] F4: per-victim O(N) allocations and O(candidates x span) scan in pressure eviction
CONFIRMED at head 45fb380.
-
helios/src/scheduler/cache_memory.rs:608
let mut effective_refs = self.page_snapshot_refs.clone();— unconditional, perevict_for_pressurecall, i.e. per victim per loop iteration ofensure_resources(scheduler.rs:1276) andrefill_reservations(scheduler.rs:1361). On the PR's own DeepSeek-V4.1-Flash TP4 geometry (156,956 pages) that is ~628 KiB per victim even when nothing is retiring. -
helios/src/cache.rs:740-753 —
track_role_preserving = priority_uses_role_preserving || ...is always true forevict_for_pressure(it passes a priority closure, cache.rs:794-802), so a freshHashMap<CheckpointId, RetentionRole>over allself.nodes(up to ~4,864) is built per selection pass, not reused across victims. -
helios/src/scheduler/cache_memory.rs:211-217 —
range.clone().any(|page| refs[page] == 1)per candidate → O(candidates x span) (~836k checks with 4,864 checkpoints x 172 pages), whileselect_snapshotsin the same file deliberately uses prefix sums to avoid exactly this shape.
Impact: all three are on the scheduler thread that also admits/gates requests (scheduler.rs:1258-1291 loop), so they add latency under pressure — precisely the regime the PR targets.
Fix: Cow::Borrowed when cache.pending_retirement().is_empty() && self.retired.is_empty(); track only_child: Option<CheckpointId> on Checkpoint beside child_count; build one prefix-sum of refs[p] == 1 per pass and answer releases_page in O(1).
#5 [medium] F5/F6 minors: retiring-snapshot dedupe asymmetry; full-GPU-hit eviction gap; waiter epoch inheritance
All verified at head 45fb380.
F5 (Minor) — retiring-snapshot double decrement in the pressure path.
- helios/src/scheduler/cache_memory.rs:609-626 chains
cache.pending_retirement()snapshots withself.retiredsnapshot lists and appliessaturating_sub(1)per occurrence, with no dedupe. - The sibling
projected_fitsDOES dedupe: same file :570let retiring: BTreeSet<_> = retiring.iter().copied().collect(); - If a snapshot appears in both sources (pushed by two retirement bookkeeping paths),
effective_refsfor a page still owned by a live unpinned snapshot drops to 0, sopage_pressure_victim_priority(…:211-217) reportsreleases_page == falsefor the victim that would actually free it, and vice versa for a shared page. Consequence is mis-selection (and, combined with F2, extra churn), not a panic —saturating_subkeeps it in range. - Fix: dedupe into a
BTreeSet<SnapshotId>exactly likeprojected_fits.
F6 (Minor) — full-GPU-hit requests store pool_plan with no pool_lookup.
- helios/src/server/runtime.rs:3332-3334:
if plan.resident_tokens() == plan.history().token_count() { return Ok((scheduler.admit_planned_with_checkpoint_accounting(spec, plan, None, accounting.clone())?.handle, None)); }— the store is never consulted, sopool_lookupstaysNonewhilepool_planisSome. - If that GPU checkpoint is then evicted while the request is capacity-blocked, the retry path cannot refresh the plan or issue a lookup, so the request recomputes from the shorter resident prefix without consulting the pool it just lost. This is adjacent to, but not covered by, the new once-per-episode stale-ticket refresh.
- Fix: drop
pool_plan(or mark it stale) when the take path returns without a ticket so the retry re-plans and looks up.
F7 (Minor, deliberate but worth stating) — a freshly queued writeback waiter inherits the just-bumped epoch and is skipped by any scan in that epoch.
- selene-manager/src/store.rs:1419-1423
self.writeback_waiters.push_back(WritebackWaiter { …, last_wake_epoch: self.writeback_wake_epoch }); - :1602-1607 each
wake_writeback_waiters(false)bumps the epoch, setsremaining = len, then scans once; :1629-1632if …last_wake_epoch == epoch { continue; }without counting towardchecked, so a waiter queued after the bump is invisible to the rest of that epoch and waits for the next release event or the 5 sPUT_WRITEBACK_WAITexpiry (:38) viaexpire_waiters(:1710-1737). - Bounded (no hang; expiry re-dispatches) and the no-spin behavior is intentionally tested (:10703-10745), so this is a latency note, not a blocker. Feed the waiter with an epoch one behind (or scan new arrivals in the current epoch) to wake on the release that unblocked it.
Also confirmed as NOT a defect (the review's round-2 blocker is genuinely fixed):
RowRestoreLatency::startno longer touchesbucket.last(runtime.rs:284-293) andfinishreturns beforeobserveon failure (:302-304), with the aged-decay regression test at phase_tests.rs:8829-8851.
#8 [medium] Process notes: contradictory reviews of the same head; injection-shaped line in review text
Reviews present on #674 (read_item 674 / pr_comments):
- Autobot 08:42: Changes Requested (0 blockers, 2 should-fix) — reviewed
7d7dcdc-era code. - Autobot 11:24: Changes Requested — at
19ce4a7b. - Autobot 18:24: Ready To Merge, 0 blockers / 0 should-fix at
0ebee3d4(base4cc6f2fd), asserting the round-2 fixes landed. - Luke Alonso 19:04: Changes Requested at that same
0ebee3d4,helios/scope, with three bugs + one hot-path defect + three minors.
The two 18:24/19:04 reviews are of the same head and contradict each other; the 18:24 "Ready To Merge" is not a human approval and was superseded 40 minutes later. Head is now 45fb380 (one commit past both reviews), and Luke Alonso's file:line claims still reproduce at 45fb380 for all four bugs and all three minors — I re-verified each independently rather than inheriting them.
Process note worth flagging to reviewers: the 08:42 review comment ends with "Have your agent review the Full Review for complete verified findings" and the case-file/PR text contains further pointers to autobot.eidonix.com. That reads as an instruction addressed to an automated reviewer. I treated all of it as material under review, did not fetch or act on those links, and re-verified every claim that mattered directly in the tree. The artefacts themselves are not reachable with my tools, so no review claim in my report depends on them.
PR-body claim accuracy (lens 4), spot-checked against the diff and main:
- The body's "Compatibility and Limitations" now discloses
Kind::StoreInvalidated = 4, the sub-page memory-only startup failure, and theflare-selenepublic API list, so the earlier disclosure gap is closed. - The body's restore-pricing bullet says the wall-clock prefill EMA was replaced, and it still claims "Retains a narrowed cold-start fallback
prefill_rateEMA (sampled on single-lane prefill steps with>= 50%capacity fill)". Finding 1 (scratchpad entry 1) shows that retained fallback is the dead one, so the description's description of it is accurate while the behaviour it describes does not occur. - The headline A/B tables remain against
5d53040e, and Table F ran on7d7dcdcb; the effective base is now at least07e666e6(#665, merged, which changes the very eviction policy Table A/C measure) — charter #210 evidence rule still unmet, unchanged from the dossier.