Subtraction, Simplicity & Conventions review — PR #660 (helios/scheduler: budget interior conversation-anchor splits against checkpoint_extra_work_fraction)
Key findings
The production diff is genuinely lean where it counts: no new flag, config key, ABI field, unsafe, or fallback layer; anchor_split_is_zero_cost() -> bool → anchor_split_ns() -> Option<(u64,u64)> is a strict collapse (six early-return arms become ?); the zero_budget_anchor → budgeted_anchor rename is complete with no dead references; and the split_ns == 0 || short-circuit at checkpoints.rs:591 is load-bearing (a zero-cost anchor must survive when extra_spent_ns already exceeds the allowance), not speculative generality. Nothing here should be reverted.
What is left to subtract is four things, none of them blockers except possibly the first:
- HIGH — the anchor-affordability rule is implemented twice, with different budget bases and different spent-work accounting (
checkpoints.rs:509vs:588-598). One three-argument helper collapses both and makes the single real difference (the budget base) explicit. This is the same two-site divergence that produced both blockers in #582's review. - MED — the split-overhead formula is written out twice (
checkpoints.rs:438-441and:685-701), one helper short of a single pricing expression. - MED — the two shared test fixtures paste the same new 8-line "free aligned splits + fraction 1.0" block (
tests.rs:3305-3318,boundary_tests.rs:74-85), while the repo already has the precedent helperlinear_checkpoint_costs(boundary_tests.rs:175-182). - MED-LOW — the new rule is now stated three times in near-parallel prose (
docs/core-design.md:1436-1461,docs/scheduling-runtime-design.md:614-638,docs/cli-design.md:696-710) whilehelios/README.md:372-382— the fileAGENTS.md:227names as the entry point for scheduling changes — was left contradicting it.
Minor (not worth a change request): two lifecycle test names and one check.py mutation label still say "zero budget" after the budgeted_anchor rename.
S1 (HIGH) — One affordability rule, two implementations with two budget bases
Site A, 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)
}
Site B, 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),
These answer the same question — "is this interior anchor worth its split?" — with three undisclosed differences: the allowance base (whole vs initial_prefill_ns.unwrap_or(whole)), whether already-spent work counts (:509 ignores extra_spent_ns; :592 charges it), and whether the zero-split case is exempt (:591 exempts it; :509 re-tests it against the allowance, which passes only because 0 <= allowance(...)).
Concrete replacement. Add one private helper next to anchor_split_ns (checkpoints.rs:430):
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)
}
Site A becomes one line:
Some((whole, split_ns)) => Self::anchor_split_affordable(whole, split_ns, 0, fraction),
Site B becomes:
Some((whole, split_ns)) => {
let base = accounting.initial_prefill_ns.unwrap_or(whole);
if Self::anchor_split_affordable(base, split_ns, accounting.extra_spent_ns, fraction) {
(raw_anchor, split_ns)
} else {
(request.prompt_tokens, 0)
}
}
Net: ~8 lines of duplicated decision logic removed, and — more importantly — the pass-through of spent_ns = 0 at site A makes the one remaining asymmetry a visible, reviewable argument instead of a silent second copy of the rule. The dossier's finding 6 records that exactly this class of two-site divergence produced both blockers in #582's review (duplicate RetentionRole::Anchor captures from EWMA drift), and that #582's budgeted_anchor latch exists purely to reconcile the two sites. A single predicate makes the latch a belt rather than the only braces.
If reviewers conclude the two sites genuinely must differ (site A prices a provisional endpoint, site B prices the plan), then the honest simplification is the opposite direction: delete the duplicated decision from site A and have request_anchor_endpoint read request.checkpoints.budgeted_anchor unconditionally, falling back to raw_anchor only when no plan exists. Either way, one rule, one place.
S2 (MED) — The split-overhead formula is spelled out twice
checkpoints.rs:438-441 (anchor_split_ns):
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)))
checkpoints.rs:685-701 (optional-candidate loop):
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))
})
Same three interval calls, same before + after - whole expression, same saturating semantics — the anchor and the optional extras are priced by two independently maintained copies of the formula that the PR's whole thesis depends on being the same price.
Concrete replacement. One helper:
fn split_overhead_ns(
request: &LiveRequest,
catalog: &[PrefillCatalogCost],
terminal_window: usize,
left: usize,
whole: u64,
endpoint: usize,
right: usize,
) -> Option<u64> {
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))
}
:438-441 collapses to Some((whole, Self::split_overhead_ns(request, catalog, terminal_window, start, whole, anchor, end)?)) and :685-701 to whole.and_then(|whole| Self::split_overhead_ns(request, &catalog, terminal_window, left, whole, endpoint, right)). ~10 lines removed, and the two paths can no longer drift.
S3 (MED) — The fixture re-parameterisation is copy-pasted, and the repo already has the pattern
helios/src/scheduler/tests.rs:3305-3318 (prefill_to_publication_boundary):
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();
helios/src/scheduler/boundary_tests.rs:74-85 (the boundary fixture) contains the identical loop and the identical configure_policy block (only duration_graphs(4) and the binding name s differ), and scheduler.prefill_graphs(&[64, 128, 256, 512]) is repeated verbatim at tests.rs:3305, boundary_tests.rs:438 and boundary_tests.rs:569. Three copies of a magic capacity list and two copies of "prefill cost = 100_000 + capacity, fraction 1.0" is the kind of fixture drift the repo already avoids elsewhere: linear_checkpoint_costs (boundary_tests.rs:175-182) is exactly this shape of combined helper, and duration_graphs (tests.rs:157) is the natural place to put its sibling.
Concrete replacement. One pub(crate) fn zero_split_prefill_graphs(active: usize) -> Vec<GraphDescriptor> beside duration_graphs (tests.rs:157) that returns duration_graphs(active) with the prefill rewrite applied, plus a constant const PREFILL_CAPACITIES: &[usize] = &[64, 128, 256, 512];. Both fixtures then read scheduler.prefill_graphs(PREFILL_CAPACITIES).unwrap(); scheduler.measured_graph_durations(&zero_split_prefill_graphs(N)).unwrap(); and keep their own configure_policy. Net ≈ −20 lines duplicated, one definition of "a fixture whose aligned splits are free."
Related, and worth separating: helios/src/scheduler/checkpoint_lifecycle_tests.rs:155-161, policy_tests.rs:4833-4837/:5251-5255, vision_window_tests.rs:389-394 and phase_tests.rs:3898-3906 each add a one-off checkpoint_extra_work_fraction: 1.0 override. Those are the ordinary repo idiom and should stay as they are. The one that is not idiomatic is helios/src/server/runtime/phase_tests.rs:1539-1546, which rewrote an entire publication 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];
Previously prompt 13 / boundary 10 (unaligned); now boundary + 3 with a chunk-aligned boundary. A checkpoint_extra_work_fraction: 1.0 on the fixture would have preserved the original scenario at one line — and, unlike the rewrite, would have kept this runtime test covering an unaligned prompt end. That lost coverage is a subtraction of test surface, not an addition of production risk, but it is the one place in the test diff where the change costs more than it needed to.
S4 (MED-LOW) — The rule is now prose in three files, and the fourth file contradicts it
Three near-parallel restatements of the same new rule were added:
helios/src/scheduler/../..→docs/core-design.md:1436-1448: "An interior message boundary before the prompt end is retained as the conversation anchor only when splitting prefill there adds predicted prefill work within the request's extra-work allowance … 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."docs/scheduling-runtime-design.md:614-624: "… falling back to the prompt end when no message is eligible or when splitting prefill at an interior message boundary would add predicted prefill work exceeding the request-local allowance ofscheduler_checkpoint_extra_work_fractiontimes estimated uncached prefill work (defaulting to 0.05, and reducing to exact zero split cost when the fraction is zero). A retained interior anchor charges its predicted split work against that allowance while keeping its anchor snapshot copy uncharged."docs/cli-design.md:699-707: "An interior message endpoint before the prompt end serves as the conversation anchor only when splitting prefill there adds predicted prefill work within the request's extra-work allowance (reducing to zero added prefill work when the fraction is zero), and otherwise the zero-split prompt end acts as the anchor. … Any retained interior anchor split, earlier messages, and a distinct prompt end share the fraction of estimated uncached prefill work."
Four sentences of the same rule, in three files, with three slightly different phrasings of the zero-fraction case ("reducing to exact zero split cost", "reducing to zero added prefill work", "reducing to zero added prefill work"). The docs/cli-design.md passage is the flag's contract, so it must stay; the docs/core-design.md passage is the authority; docs/scheduling-runtime-design.md:614-624 is the one to reduce to a sentence plus a link to docs/core-design.md#exact-endpoint-capture, matching the cross-reference style the same README paragraph already uses.
Meanwhile helios/README.md:372-382 was not touched, and it now directly contradicts docs/core-design.md:1444-1446:
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.
Three separate stalenesses in that paragraph: (a) it says the allowance bounds only "Earlier messages and a distinct prompt end" — the anchor is now inside it; (b) it says "Extra captures charge snapshot-copy cost", which readers will apply to the anchor, whereas core-design now says the anchor's "single anchor snapshot copy remains uncharged"; (c) "using the prompt end when no message boundary is eligible" omits the new second fallback condition (boundary eligible but split unaffordable). This matters beyond tidiness because AGENTS.md:227 names helios/README.md as the required reading for "Change Helios runtime, scheduling, caches, transport, or frontend" — the file a reviewer of scheduling changes is told to read first is the one file the PR left stale, while #655 (adjacent, open) did update it.
Concrete fix: one corrected paragraph in helios/README.md:372-382 stating that the anchor itself is gated by the allowance, that its split is charged while its copy is not, and that the prompt end is the fallback both when no boundary is eligible and when the eligible boundary's split does not fit; then compress docs/scheduling-runtime-design.md:614-624 to a sentence plus the existing core-design link.
Minor — stale names after the budgeted_anchor rename
Not worth a change request, but if the author is touching the file anyway: zero_budget_multi_chunk_fallback_reservations_match_lifecycle_model (helios/src/scheduler/checkpoint_lifecycle_tests.rs:309) and zero_budget_interior_anchor_drift_and_mixed_shift_match_lifecycle_model (:445), and the mutation label "dropped multi-chunk zero-budget fallback" (verification/helios-lifecycle/check.py:673-675). "Zero budget" now names only the fraction == 0.0 special case, so these read as if they test something the PR removed.
What is already lean (do not change)
- No new configuration surface.
git-level check of the diff and head source: no flag, noPolicyConfigfield, no Protobuf/ABI change, nounsafe.checkpoint_extra_work_fractionis reused as-is (helios/src/scheduler/policy.rs:40, validated finite and in[0,1]atpolicy.rs:210-211). - The
Optioncollapse is the right call.anchor_split_is_zero_cost(bool) →anchor_split_ns(Option<(u64,u64)>) atcheckpoints.rs:430-442removes the sixelse { return false }arms #582 needed while gaining the split magnitude this PR charges. It is strictly less code for strictly more information. - The
split_ns == 0 ||clause at:591is load-bearing, not defensive noise. Removing it would drop a genuinely free anchor whenever spent work already exceeds the allowance; the test atcheckpoints.rs:~4596pins that behaviour. Do not "simplify" it away. - The multi-chunk guard at
checkpoints.rs:533-546is not speculative. It preserves an already-charged, not-yet-reachedAnchorcut acrossrevoke_unused_anchor_guards(); two new tests (anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget,default_fraction_anchor_guard_revocation_preserves_charged_anchor_split) cover it. The condition is dense but each disjunct (request.anchor_guard.is_some(),extra_spent_ns > 0,cut.split_ns > 0) distinguishes a real state. - The optional-candidate filter change is a one-token fix, not added complexity:
end < raw_anchorat:645(wasend < anchor) andrequest.prompt_tokens != anchorat:648are the minimal correct predicates now thatanchorcan be the prompt end.
Open questions
- Do the two anchor-decision sites (
checkpoints.rs:509vs:588-598) need different budget bases on purpose? If yes, that intent is currently invisible — it should be a comment or an argument, not two copies of the predicate. If no, S1 removes ~8 duplicated lines and the #582-class divergence risk with them. - Was the
phase_tests.rs:1539-1595scenario rewrite (prompt 13/boundary 10 →boundary + 3, chunk-aligned) forced by the new rule, or was it faster than finding a fraction that keeps the unaligned case? Either way, that runtime test no longer covers an unaligned prompt end, and a fraction override would have cost one line. - Should
docs/scheduling-runtime-design.md:614-624be compressed to a cross-reference, givendocs/core-design.md:1436-1461is the authority? Three restatements of one rule is how the README drifted in the first place.
What could not be found or verified
- No builds, tests or benchmarks were run for this review; every behavioural statement above comes from reading the head source at
22cac91. The PR has no CI on the head commit and no reviews, so line-level behaviour is verified but runtime behaviour is author-reported only. checkpoints.rsis 4,657 lines and was not read in full; verified are the production hunks this PR touches (:430-442,:444-517,:524-753,:857-886) plus the test blocks cited, and the four documentation files.- Whether
scripts/scheduling_simshould model anchor splits is out of scope for this lens, but note the body says nothing about the simulator; the dossier records that it has no checkpoint/anchor modelling at all (which#655argues explicitly and this PR does not). - Commit trailers (
Design-Signed-Off-By: …; design-review=<hex>) for22cac916were not readable, sodocs/design-review.md:294-311(not opened) compliance is unknown. - No maintainer statement on record about this change; the only third-party signal is yatesdr's
#663citing#660as complementary.