#1 [high] PR #674 Subtraction/Simplicity review — findings with citations
Lens: subtraction/simplicity/conventions. Diff is large but mostly load-bearing; 5 findings, ordered by value. All line numbers at PR head.
F1 (HIGH) — RowRestoreLatency is a second copy of selene::levels::Rate.
helios/src/server/runtime.rs:270-343:
#[derive(Default)]
struct RowRestoreBucket {
in_flight: usize,
samples: [f64; 3],
count: usize,
next: usize,
last_median: Option<(f64, std::time::Instant)>,
}
...
impl RowRestoreLatency {
const RECOVERY_SECONDS: f64 = 10.0;
selene/src/levels.rs:36-87 is the existing abstraction: struct Rate { samples: [f64; 3], count, next, last }, const RECOVERY: Duration = Duration::from_secs(10); (:34), observe() = 3-sample ring median (identical code to runtime.rs:322-330), started() = hold median while a transfer is in flight (:77-82), get() = time-based recovery. The new type differs only in decay direction (median * 0.5^(t/10) at runtime.rs:342 vs median * 2^(t/10) capped at seed at levels.rs:71-73) and per-RowRestoreSource bucketing. Two 3-sample medians with the same 10 s constant and the same hold-in-flight semantics is exactly the coupling that produced the review's blocker (start() bumping last_median unconditionally, runtime.rs:301-303). Replace RowRestoreBucket/RowRestoreLatency's estimator with Rate (+ a decay-direction/hold() accessor); keep only the in_flight: HashMap<PrefixKey,(source,Instant)> bookkeeping.
F2 (HIGH) — conditioned_window_ends duplicates the window partitioning in set_conditioned_inputs.
helios/src/scheduler.rs:2107-2116:
for input in inputs.iter().filter(|input| input.token_span.end > consumed) {
if !in_window || features + input.feature_range.len() > capacity {
if in_window {
ends.push(input.token_span.start);
}
in_window = true;
features = 0;
}
features += input.feature_range.len();
}
helios/src/scheduler.rs:2164-2183 is the authoritative same greedy pack (features + input.feature_range.len() > capacity → previous.prefill_end = input.token_span.start → push new ConditionedWindow). Two copies of one packing invariant; the copy omits the geometry validation set_conditioned_inputs applies (:2147-2158) and needs ends.sort_unstable(); ends.dedup() (:2120-2121) to repair ordering the real loop guarantees. Extract one fn partition_conditioned(inputs, capacity) -> Vec<WindowBounds> and have both call it.
F3 (MEDIUM) — worth_restore re-implements the shared policy, and worth_fetching/worth_transfer are left with no production caller.
helios/src/server/runtime.rs:223-229:
/// A host restore is worthwhile when its transfer (plus any accumulated wait)
/// takes less than half the GPU prefill time it replaces.
fn worth_restore(transfer_seconds: f64, prefill_saved_seconds: f64) -> bool {
transfer_seconds.is_finite()
&& prefill_saved_seconds.is_finite()
&& transfer_seconds < 0.5 * prefill_saved_seconds
}
vs selene/src/store.rs:459-468 worth_transfer = estimated_seconds < 0.5 * gained/rate.max(1.0), i.e. the same predicate with prefill_saved_seconds pre-divided. The PR deleted their only production caller (flare_selene::worth_fetching(&hit, prefill_rate)), so after this diff worth_fetching/worth_transfer (exported at selene/src/lib.rs:53) are called only from tests (selene/src/store.rs:498-504, selene/src/composite.rs:2920-2923, selene/src/disk_store/coalesce/tests.rs). Either delete the selene pair with its export, or keep one worth_restore(transfer, prefill_saved) in flare_selene and delete the helios copy — not both.
F4 (MEDIUM) — the buffered-write fallback is unreachable on Windows; delete it or the predicate. selene/src/disk.rs:1774-1784:
fn is_direct_unsupported(error: &io::Error) -> bool {
#[cfg(unix)]
{
error.raw_os_error() == Some(libc::EINVAL)
}
#[cfg(not(unix))]
{
let _ = error;
false
}
}
The predicate's only purpose is to gate the new fallback arms at selene/src/disk.rs:859-861 (Err(e) if is_direct_unsupported(&e) => self.write_record_buffered(...)) and :1423-1437 (buffered write_all loop). Returning false off-Unix makes both arms dead while eos/src/windows.rs:104-109 reports refusal as ErrorKind::Unsupported. So one of the two is surplus: either drop the ~20 fallback lines, or make the predicate Unsupported | InvalidInput and delete the #[cfg(not(unix))] stub. Pick one; do not keep both an unreachable fallback and a test-visible predicate.
F5 (MEDIUM) — write_record_direct's unaligned branch re-earns write_direct_slices.
selene/src/disk.rs:1277-1307 stages an aligned prefix + a scratch-rounded tail by hand:
let src = unsafe { raw_slice(span.address, span.length) };
if aligned(span.address as u64) && !src.is_empty() {
let block = BLOCK_BYTES as usize;
let aligned_prefix = src.len() - (src.len() % block);
let tail = src.len() - aligned_prefix;
...
} else {
self.write_direct_slices(file, &[src])?;
}
Its caller reaches this branch only when span.offset == 0 (whole_record, :848-852), which is the offset write_direct_slices (:1331-1376) already writes from, and that function already stages arbitrary slices through the same scratch with zero-padded tails. The hand-rolled path therefore buys one memcpy of the aligned prefix. Replace the whole if aligned(span.address …) block with self.write_direct_slices(file, &[src])? — or, if the copy is measurably hot, say so in a comment, since otherwise it is unverified duplication of the general path.
F6 (LOW, convention) — three parallel spellings of "pool level". selene/src/levels.rs:119-128 adds Ranking::rates() -> [f64; 4] (positional, with [NeighbourGpu, HostDram, HostNvme, RemoteNvme] asserted only by a doc comment), while helios/src/server/metrics.rs:1418-1423 hardcodes the matching label strings and relies on index order:
for (level, value) in [
("neighbour_gpu", &self.host_pool_inbound_rates[0]),
("host_dram", &self.host_pool_inbound_rates[1]),
One const POOL_LEVELS: [(Level, &str); 4] (or returning [(Level, f64); 4]) removes the silent index-drift risk and the duplicated ordering.
Non-findings to state plainly: Layout packing rework (helios/src/runtime_core/cache_memory.rs) and the middle/midpoint span change are irreducible given the measured handle recovery; PublishError/Reply::invalidated threading (selene/src/disk.rs:1657-1715) is the minimum needed to distinguish pre- from post-rename failure; the eval = closure + lo/hi doubling + binary refinement in plan_mapping_handles (:663-780) is more code than the old loop but replaces a rank-order-dependent 2× ramp; WindowReleaseSignal/writeback_wake_epoch machinery in selene-manager/src/store.rs is event-driven plumbing, not speculative generality. Test-only helpers union_aliases (helios/src/runtime_core/cache_memory.rs:103-114) and row_conflicts/verify_physical_invariants are #[cfg(test)] and acceptable, though handle_charge/plan_mapping_handles were widened to pub(super) solely for helios/src/runtime_core/memory/codec_layout_tests.rs.
AGENTS.md hooks worth citing: "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement" (AGENTS.md:188-193) — F3/F4 sit here; "Prefer proven b12x operators…" n/a. No env-var/config-switch violations found.
#3 [high] Research summary
Subtraction/Simplicity/Conventions review of PR #674 is complete; findings are on the scratchpad ("PR #674 Subtraction/Simplicity review" = entry 1, citations re-verified in entry 2).
Verdict: given a +10,106/−1,158 diff, the change is leaner than it looks. The Layout packing rework, PublishError/Reply::invalidated threading, and the WindowReleaseSignal/writeback_wake_epoch machinery are each the minimum needed for the behaviour they buy — I say so explicitly rather than padding the list. Six real simplifications remain, two of them high value:
- F1 (high)
RowRestoreLatency(helios/src/server/runtime.rs:283-343) re-implementsselene::levels::Rate(selene/src/levels.rs:36-87): samesamples: [f64;3]ring, same 10 s recovery constant, same hold-while-in-flight rule. This duplication is what produced the review's Blocker — the copy'sstart()refresheslast_median(:301-303) whereRate::started()is a no-op at seed. - F2 (high)
conditioned_window_ends(helios/src/scheduler.rs:2094-2123) is a second copy of the greedy window pack insideset_conditioned_inputs(:2162-2183), minus its validation and needing asort/dedupto repair ordering. One consumer (checkpoints.rs:462, :478); extract one partition helper. - F3 (medium)
worth_restore(runtime.rs:225-229) duplicatesflare_selene::worth_transfer(selene/src/store.rs:459-468), and this PR removed the last production caller ofworth_fetching/worth_transfer, leaving them test-only exports — delete one side. - F4 (medium) The new buffered-write fallback (selene/src/disk.rs:859-861, :1423-1437) is unreachable on Windows because
is_direct_unsupported(:1774-1784) is hard-falseoff-Unix; delete the fallback or the stub, not neither. - F5 (medium)
write_record_direct's hand-staged aligned-prefix path (:1278-1304) duplicateswrite_direct_slices(:1331-1376) for one memcpy; the caller reaches it only at offset 0. - F6 (low, convention) Three parallel spellings of the pool-level order: positional
Ranking::rates() -> [f64;4](levels.rs:119-128), hardcoded label strings (metrics.rs:1418-1423), and a doc comment; onePOOL_LEVELSconstant removes the index-drift risk.
AGENTS.md:188-193 ("no fallback layers … without a concrete requirement") is the convention hook for F3/F4. No env-var or config-switch violations found.
#4 [high] Final report skeleton + verdict wording + non-findings to state plainly
REPORT ORDER AND HEADLINES (full code quotes and citations live in entry 1; verified attributions in entry 2).
Opening verdict (state plainly): for a +10,106/-1,158 diff across 42 files this change is leaner than its size suggests. Most of the volume is load-bearing: the midpoint/half-width Layout packing rework (helios/src/runtime_core/cache_memory.rs) is irreducible against the measured handle recovery it buys; PublishError + Reply::invalidated (selene/src/disk.rs:1657-1715) is the minimum needed to tell pre- from post-rename failure; and the WindowReleaseSignal / writeback_wake_epoch machinery (selene-manager/src/store.rs) is event-driven plumbing replacing timer polling, not speculative generality. Six genuine simplifications remain, two high value.
The six, in report order:
- HIGH —
RowRestoreLatency(helios/src/server/runtime.rs:283-343) duplicatesselene::levels::Rate(selene/src/levels.rs:36-87): samesamples: [f64;3]ring median, same 10 s recovery constant (levels.rs:34 vs runtime.rs:290), same hold-median-while-in-flight rule. Framing point for the report: this duplication is the cause of round-2's sole Blocker — the copy'sstart()bumpslast_medianunconditionally (runtime.rs:301-303) whereRate::started()is deliberately a no-op at seed (levels.rs:77-82). So the fix is subtraction, not a new patch: keepin_flight: HashMap<PrefixKey,(source,Instant)>, delegate the estimator toRate(+ decay direction), deleteRowRestoreBucket. - HIGH —
conditioned_window_ends(helios/src/scheduler.rs:2094-2123) is a second copy of the greedy window pack insideset_conditioned_inputs(helios/src/scheduler.rs:2162-2183), minus that function's geometry validation (scheduler.rs:2147-2158) and needingends.sort_unstable(); ends.dedup()(:2120-2121) to repair an ordering the real loop already guarantees. Sole consumer isestimate_prefill_delta_ns(helios/src/scheduler/checkpoints.rs:462, :478). Extract onepartition_conditioned(inputs, capacity) -> Vec<WindowBounds>used by both. - MEDIUM —
worth_restore(helios/src/server/runtime.rs:225-229) re-implementsflare_selene::worth_transfer(selene/src/store.rs:459-468) withprefill_saved_secondspre-divided. This PR also deleted the last production caller ofworth_fetching/worth_transfer, so the pair exported at selene/src/lib.rs:53 is now test-only (selene/src/store.rs:498-504, selene/src/composite.rs:2920-2923, selene/src/disk_store/coalesce/tests.rs). Delete one side, not neither. - MEDIUM — new buffered-write fallback is unreachable on Windows:
is_direct_unsupported(selene/src/disk.rs:1774-1784) is hard-falseunder#[cfg(not(unix))], so the arms at selene/src/disk.rs:859-861 and :1423-1437 cannot fire while eos/src/windows.rs:104-109 reports refusal asErrorKind::Unsupported. Delete the fallback or the stub. - MEDIUM —
write_record_direct's hand-staged aligned-prefix branch (selene/src/disk.rs:1278-1304) re-earnswrite_direct_slices(:1331-1376) for one memcpy; it is reached only atspan.offset == 0(whole_record, :848-852), which is where the general helper writes anyway. - LOW (convention) — three parallel spellings of the pool-level order: positional
Ranking::rates() -> [f64;4](selene/src/levels.rs:119-128), hardcoded labels (helios/src/server/metrics.rs:1418-1423), doc-comment assertion. Oneconst POOL_LEVELS: [(Level, &str); 4]removes silent index drift.
Deliberately NOT flagged (say so, to show the lens was applied and rejected):
plan_mapping_handles'evaluateclosure + lo/hi doubling + binary refinement (helios/src/runtime_core/cache_memory.rs:663-780) is more lines than the old ramp, but it replaces rank-order-dependent 2x stepping with a symmetric search — the extra code is the fix.- Test-only helpers
union_aliases(cache_memory.rs:103-114),row_conflicts,verify_physical_invariantsare#[cfg(test)]; acceptable. Note only thathandle_charge/plan_mapping_handleswere widened topub(super)solely for helios/src/runtime_core/memory/codec_layout_tests.rs. PoolHandover+persisted_in_pool+refresh_ancestors/refresh_same_page_descendants(selene/src/memory.rs:997-1010, :975-990) plus theclean_slotsinvariant assertions are extra state, but they encode the retention contract the PR exists to add; not speculative.- Minor:
TierStore::pending_pool_draindefaultself.stats().memory_records(selene/src/store.rs:400-402) allocates a wholeStoreStatsper poll tick inMemoryStore— worth a one-line mention at most, it is a default-method convenience, not a defect.
Convention hook for items 3-4: AGENTS.md:188-193 — "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement."
Env-var / config-switch search (AGENTS.md:452-455): clean — no new toggle reads a variable.
#2 [medium] Verification of F1-F5 citations at PR head
Verification of F2 (double-checked at head):
- helios/src/scheduler.rs:2094-2123
conditioned_window_ends(new, added by this PR per pr_diff of scheduler.rs). - helios/src/scheduler.rs:2162-2183 the loop inside
set_conditioned_inputs— same greedyfeatures + input.feature_range.len() > capacityboundary rule, setsprevious.prefill_end = input.token_span.start, pushes the next window. - Callers of the new fn: helios/src/scheduler/checkpoints.rs:462 and :478 (inside
estimate_prefill_delta_ns), plus tests at checkpoints.rs:4402-4404. So it has exactly one consumer and that consumer only needs the boundary list.
Verification of F1: Rate lives at selene/src/levels.rs:36-87 and is used by Ranking (levels.rs:89-141, rates: [Rate; 5], RECOVERY: Duration = 10 s at :34). RowRestoreLatency (helios/src/server/runtime.rs:283-343) re-encodes the same fields and the same 3-sample median; the review's blocker (start() refreshing last_median, runtime.rs:301-303) exists only because that copy diverged from Rate::started() semantics (levels.rs:77-82, which is a no-op when the median is already at seed).
Verification of F3: selene/src/lib.rs:53 still exports worth_fetching, worth_transfer; both are now called only from tests (grep hits listed in the main note). worth_restore at helios/src/server/runtime.rs:225 duplicates the comparison.
Verification of F4: is_direct_unsupported (selene/src/disk.rs:1774-1784) returns false under #[cfg(not(unix))]; fallback arms at :859-861 and :1423-1437 are therefore unreachable on Windows, while eos/src/windows.rs:104-109 signals refusal as io::ErrorKind::Unsupported.
F5 spot-check: the whole_record gate is selene/src/disk.rs:848-852 (span.offset == 0 && publish size == span.length); write_direct_slices is :1331-1376. So the hand-staged branch at :1278-1304 only avoids one memcpy of the aligned prefix.
Repo-convention anchors: AGENTS.md:188-193 ("Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement") for F3/F4; AGENTS.md:194-199 for keeping each change's validation focused.