#1 [high] PR #660 subtraction/simplicity findings
PR #660, head 22cac91. Lens: subtraction/simplicity/conventions. Verified hunks only.
S1 (HIGH) Two independent anchor-affordability rules.
helios/src/scheduler/checkpoints.rs:500-516(request_anchor_endpoint):let fraction = ...; let keep_raw = match Self::anchor_split_ns(...) { Some((whole, split_ns)) => split_ns <= allowance(whole, fraction), None => fraction > 0.0, }; if keep_raw { Some(raw_anchor) } else { Some(request.prompt_tokens) }checkpoints.rs:588-598(planner):Some((whole, split_ns)) => { let budget_base = accounting.initial_prefill_ns.unwrap_or(whole); let available = allowance(budget_base, fraction); if split_ns == 0 || accounting.extra_spent_ns.saturating_add(split_ns) <= available { (raw_anchor, split_ns) } else { (request.prompt_tokens, 0) } }Same question answered twice; differs in base (wholevsinitial_prefill_ns.unwrap_or(whole)) and in counting spent work. Replace both with one helper:fn anchor_split_affordable(whole: u64, split_ns: u64, spent_ns: u64, fraction: f64) -> bool { split_ns == 0 || spent_ns.saturating_add(split_ns) <= allowance(whole, fraction) }endpoint:... => anchor_split_affordable(whole, split_ns, 0, fraction); planner:... => anchor_split_affordable(initial_prefill_ns.unwrap_or(whole), split_ns, extra_spent_ns, fraction). Removes ~8 duplicated lines and makes the one real difference explicit. (Dossier finding 6: divergence produced both blockers in #582 review; #582 landed thezero_budget_anchorlatch precisely to reconcile them.)
S2 (MED) Split-pricing formula duplicated.
checkpoints.rs:438-441(anchor_split_ns): threeinterval_prefill_nscalls +Some((whole, before.saturating_add(after).saturating_sub(whole))).checkpoints.rs:685-701(optional-candidate loop): identicalwhole/before/aftertriple and identicalSome(before.saturating_add(after).saturating_sub(whole)), only with memoizedwholefrombetween. Factor intofn split_overhead_ns(request, catalog, window, left, whole, endpoint, right) -> Option<u64>;anchor_split_nsbecomes a 2-line wrapper. ~6 lines and one formula removed; also guarantees anchor and extras are priced by the same expression.
S3 (MED) Shared fixtures re-parameterised with copy-pasted 8-line blocks.
helios/src/scheduler/tests.rs:3305-3318andhelios/src/scheduler/boundary_tests.rs:74-85are the same block:let mut graphs = duration_graphs(N); for g in &mut graphs { if g.kind == GraphKind::Prefill { g.estimated_duration_ns = 100_000 + g.token_capacity as u64; } } ... measured_graph_durations(&graphs); configure_policy(PolicyConfig { checkpoint_extra_work_fraction: 1.0, .. })plusscheduler.prefill_graphs(&[64, 128, 256, 512])in tests.rs:3305, boundary_tests.rs:438, boundary_tests.rs:569. Hoist onepub(crate)helper next toduration_graphs(tests.rs:157), e.g.zero_split_prefill_graphs(active)that still callsprefill_graphs(&[64,128,256,512]),linear_checkpoint_costs-style (boundary_tests.rs:175-182 is the pre-existing precedent). Net −20 lines, one definition of "fixture whose aligned splits are free". The 8 extraconfigure_policyblocks across checkpoint_lifecycle_tests.rs:155-161, policy_tests.rs:4833-4837, 5251-5255, vision_window_tests.rs:389-394, phase_tests.rs:3898-3906 are the repo idiom, fine as-is; the real cost is phase_tests.rs:1539-1595 rewriting a whole runtime publication scenario (prompt 13/boundary 10 -> chunk_aligned) rather than choosing a fraction, so the test no longer covers an unaligned prompt end.
S4 (MED-LOW) Same rule now stated three times in prose; README left contradicting it.
docs/core-design.md:1437-1452,docs/scheduling-runtime-design.md:614-625,docs/cli-design.md:699-707all state interior-anchor budgeting + "split charged / copy uncharged" (+41/−36 near-parallel prose). Keep the authoritative statement in core-design, reduce the other two to a sentence + cross-reference.helios/README.md:372-379still says "Checkpoint selection prioritizes the last eligible message boundary, using the prompt end when no message boundary is eligible ... Extra captures charge snapshot-copy cost" — now contradicts core-design's "its single anchor snapshot copy remains uncharged". This diff edited three docs and not the README.
Minor/naming leftovers (not worth a change request): test names zero_budget_multi_chunk_fallback_reservations_match_lifecycle_model (checkpoint_lifecycle_tests.rs:309) and zero_budget_interior_anchor_drift_and_mixed_shift_match_lifecycle_model (:445), and the mutation string "dropped multi-chunk zero-budget fallback" (verification/helios-lifecycle/check.py:673-675) now describe the renamed budgeted_anchor.
Clean: no new flag/config key/ABI/unsafe; zero_budget_anchor -> budgeted_anchor rename complete with no dead references outside those test names; split_ns == 0 || short-circuit at :591 is load-bearing (test :4596 retains a zero-cost anchor when extra_spent > available), not removable.
#2 [high] Research summary
Reviewed PR #660 under the subtraction/simplicity/conventions lens: read the full production hunks in helios/src/scheduler/checkpoints.rs (anchor pricing :430-442, request_anchor_endpoint :444-517, checkpoint_selection_uncached :524-753, promote_request_anchor :857-886) plus every changed test/doc/simulator file, and checked for existing helpers (allowance, interval_prefill_ns, linear_costs, linear_checkpoint_costs, duration_graphs, measure).
The diff is genuinely lean where it matters: no new flag, config key, ABI, unsafe, or fallback layer; the zero_budget_anchor→budgeted_anchor rename is complete; anchor_split_ns replacing anchor_split_is_zero_cost is a strict collapse (six else { return false } early returns become ?); and the split_ns == 0 || short-circuit is load-bearing, not speculative.
Four findings, saved to scratchpad with verbatim quotes and replacements:
- HIGH — the anchor-affordability rule is implemented twice with different bases and different spent-work accounting:
checkpoints.rs:500-516(split_ns <= allowance(whole, fraction)) vs:588-598(allowance(initial_prefill_ns.unwrap_or(whole), fraction)plusextra_spent_ns). Oneanchor_split_affordable(whole, split_ns, spent_ns, fraction)helper removes the duplication and makes the single real difference (the budget base) explicit — the same class of two-site divergence that produced both #582 blockers. - MED — the split-overhead formula
before.saturating_add(after).saturating_sub(whole)is written out in bothanchor_split_ns(:438-441) and the optional-candidate loop (:685-701); one helper shared by both. - MED — the two shared test fixtures (
tests.rs:3305-3318,boundary_tests.rs:74-85) paste the same new 8-line "make aligned prefill splits free + fraction 1.0" block, plus three copies ofprefill_graphs(&[64,128,256,512]); hoist one helper besideduration_graphs(the repo already haslinear_checkpoint_costsas precedent). Alsophase_tests.rs:1539-1595rewrote a whole scenario rather than setting a fraction. - MED-LOW — the new rule is now stated in three near-parallel doc passages (
core-design.md:1437-1452,scheduling-runtime-design.md:614-625,cli-design.md:699-707) whilehelios/README.md:372-379was left contradicting core-design ("Extra captures charge snapshot-copy cost" vs. the new uncharged anchor copy). Suggested: authoritative statement in core-design, cross-references elsewhere, and correct the README.
Minor: two lifecycle test names and one check.py mutation label still say "zero-budget".
#3 [high] Quote bank: verbatim lines for each #660 simplification finding
PR #660 head 22cac91. Quotes read from head source.
S1a — helios/src/scheduler/checkpoints.rs:500-516 (request_anchor_endpoint):
let fraction = self.policy.checkpoint_extra_work_fraction;
let keep_raw = match Self::anchor_split_ns(
request,
&catalog,
terminal_window,
price_start,
request.prompt_tokens,
raw_anchor,
) {
Some((whole, split_ns)) => split_ns <= allowance(whole, fraction),
None => fraction > 0.0,
};
if keep_raw {
Some(raw_anchor)
} else {
Some(request.prompt_tokens)
}
S1b — checkpoints.rs:588-601 (checkpoint_selection_uncached):
Some((whole, split_ns)) => {
let budget_base = accounting.initial_prefill_ns.unwrap_or(whole);
let available = allowance(budget_base, fraction);
if split_ns == 0
|| accounting.extra_spent_ns.saturating_add(split_ns) <= available
{
(raw_anchor, split_ns)
} else {
(request.prompt_tokens, 0)
}
}
None if fraction > 0.0 => (raw_anchor, 0),
None => (request.prompt_tokens, 0),
Replacement helper (drop both bodies' decisions into it):
fn anchor_split_affordable(whole: u64, split_ns: u64, spent_ns: u64, fraction: f64) -> bool {
split_ns == 0 || spent_ns.saturating_add(split_ns) <= allowance(whole, fraction)
}
endpoint site: Some((whole, split_ns)) => anchor_split_affordable(whole, split_ns, 0, fraction),
planner site: Some((whole, split_ns)) => if anchor_split_affordable(accounting.initial_prefill_ns.unwrap_or(whole), split_ns, accounting.extra_spent_ns, fraction) { (raw_anchor, split_ns) } else { (request.prompt_tokens, 0) },
S2a — checkpoints.rs:438-441:
let whole = Self::interval_prefill_ns(request, catalog, terminal_window, start, end)?;
let before = Self::interval_prefill_ns(request, catalog, terminal_window, start, anchor)?;
let after = Self::interval_prefill_ns(request, catalog, terminal_window, anchor, end)?;
Some((whole, before.saturating_add(after).saturating_sub(whole)))
S2b — checkpoints.rs:685-701:
whole.and_then(|whole| {
let before = Self::interval_prefill_ns(
request,
&catalog,
terminal_window,
left,
endpoint,
)?;
let after = Self::interval_prefill_ns(
request,
&catalog,
terminal_window,
endpoint,
right,
)?;
Some(before.saturating_add(after).saturating_sub(whole))
})
Replacement: fn split_overhead_ns(request, catalog, window, left, whole, endpoint, right) -> Option<u64>; S2a becomes Some((whole, Self::split_overhead_ns(request, catalog, terminal_window, start, whole, anchor, end)?)), S2b becomes whole.and_then(|whole| Self::split_overhead_ns(request, &catalog, terminal_window, left, whole, endpoint, right)).
S3a — helios/src/scheduler/tests.rs:3305-3318:
scheduler.prefill_graphs(&[64, 128, 256, 512]).unwrap();
let mut graphs = duration_graphs(1);
for g in &mut graphs {
if g.kind == GraphKind::Prefill {
g.estimated_duration_ns = 100_000 + g.token_capacity as u64;
}
}
scheduler.measured_graph_durations(&graphs).unwrap();
scheduler
.configure_policy(PolicyConfig {
checkpoint_extra_work_fraction: 1.0,
..Default::default()
})
.unwrap();
S3b — helios/src/scheduler/boundary_tests.rs:74-85: identical body with duration_graphs(4) and s in place of scheduler.
Also repeated prefill_graphs(&[64, 128, 256, 512]) at tests.rs:3305, boundary_tests.rs:438, boundary_tests.rs:569.
Replacement: one pub(crate) fn zero_split_prefill_graphs(active: usize) -> Vec<GraphDescriptor> next to duration_graphs (tests.rs:157) doing prefill_graphs + the window rewrite; call sites then scheduler.prefill_graphs(&[64,128,256,512]).unwrap(); → helper, measured_graph_durations(&zero_split_prefill_graphs(N)), plus the configure_policy line. Existing precedent for a combined fixture helper: linear_checkpoint_costs at boundary_tests.rs:175-182.
S4a — helios/README.md:372-379 (not touched by this PR):
tokens. Checkpoint selection prioritizes the last eligible message boundary,
using the prompt end when no message boundary is eligible. Earlier messages and
a distinct prompt end compete within a work allowance of
`scheduler_checkpoint_extra_work_fraction` times estimated uncached prefill work,
defaulting to 0.05. Extra captures charge snapshot-copy cost and additional prefill
caused by splitting chunks. Productive completed decode earns the same fraction
of measured time for a distinct terminal capture. Unknown costs exclude extras
while preserving best-effort anchor retention.
contradicts the PR's own docs/core-design.md:1443-1447: "When an interior anchor is retained, its predicted split overhead is charged against that same extra-work allowance while its single anchor snapshot copy remains uncharged."
S4b — three parallel restatements: docs/core-design.md:1437-1460, docs/scheduling-runtime-design.md:614-638, docs/cli-design.md:699-711.
S4c — helios/src/server/runtime/phase_tests.rs:1539-1546 rewrote the scenario instead of setting a fraction:
let fixture = Fixture::new();
let boundary = fixture.config.limits.prefill_chunk_size;
let prompt_len = boundary + 3;
let (sender, receiver) = mpsc::channel();
let (mut incoming, mut generation) = fixture.incoming(vec![0; prompt_len], 2);
incoming.prompt.message_boundaries = vec![boundary];
(was prompt 13 / boundary 10), so unaligned prompt-end coverage in that runtime test is gone.