Review of PR #582 — simplicity lens (D)
helios: avoid splitting prefill on zero-budget checkpoint anchors, head a3c6483, base main, 7 files, +931/−16.
Key findings
The change reaches its stated goal (no checkpoint cuts at zero snapshot capacity; interior anchors only when the split prices at zero extra prefill work; prompt-end fallback retained across multi-chunk progress, Restore, Speculative and reuse promotion). It does so with more machinery than the goal needs, and the excess is not cosmetic: three of the four blocking items below are the duplicated decision paths that produce the two duplicate-Anchor defects voipmonitor already reported (CHANGES_REQUESTED, 2026-11-28). Simplifying them removes both defects at the same time.
- Blocking (4):
known_wholeparameter (F1), the second pricing branch in selection (F2),clear_reservationswiping the latch (F3), andis_request_anchor_endpointas a second price model (F4). Roughly 60–70 lines of production code, plus both blockers. - Should fix (4): anchor reconstruction in
plan_checkpoints(F5), a third copy of the test completion helper (F6), a 13-line source-text mutation needle (F7), two now-false doc sentences (F12). - Nits (5): synthetic wall-clock assertion (F8), a duplicate test (F9), a bundled unchanged-behaviour scenario (F10), redundant lookup chains (F11), doc triplication (F13).
Rules applied: AGENTS.md:188-193 — "Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement"; AGENTS.md:194-197 — "source-text checks and mocks that bypass the behavior cannot establish runtime correctness"; docs/design-review.md:16 principle 1 "Keep Helios as simple as possible"; .agents/skills/repo-prose/SKILL.md:26-29 (not opened) — "Documentation is a present-state specification... Replace stale claims"; SKILL.md:38-39 — "Comments explain invariants, intent, and non-obvious constraints".
Blocking
F1 — known_whole parameter exists only to make the two callers differ, and causes the stale-EWMA duplicate Anchor
File: helios/src/scheduler/checkpoints.rs:364-388 (parameter at 371; plumbing at 471-473 and 498-500)
fn anchor_split_is_zero_cost(
request: &LiveRequest, catalog: &[PrefillCatalogCost], terminal_window: usize,
start: usize, end: usize, anchor: usize,
known_whole: Option<u64>, // <- 371
) -> bool {
let Some(whole) = known_whole
.or_else(|| Self::interval_prefill_ns(request, catalog, terminal_window, start, end))
else { return false; };
The only callers that pass Some are 474-482 and 491-501, and both pass accounting.initial_prefill_ns — a cached, EWMA-updated value — while before and after at 378-383 are always freshly priced. before + after - whole therefore does not cancel when the cached whole drifts upward, which is exactly voipmonitor's blocker #1 (duplicate Anchor capture from a stale known_whole). is_request_anchor_endpoint already passes None (411-419), so the parameter buys one cache hit on a value the scheduler already recomputes elsewhere.
Why it matters: it is an unnecessary parameter and the concrete mechanism of a reported correctness defect; AGENTS.md:188-193 rejects exactly this kind of speculative fast path.
Fix (smaller version): delete the parameter, price whole inside via Self::interval_prefill_ns(request, catalog, terminal_window, start, end), and drop the .then_some(accounting.initial_prefill_ns).flatten() blocks at 471-473 and 498-500. Ten lines disappear and the split test becomes self-consistent.
F2 — the second disjunct re-decides a question the first branch already answered
File: helios/src/scheduler/checkpoints.rs:489-507
} else if accounting.anchor_fallback_from == Some(raw_anchor)
|| (baseline_start < raw_anchor
&& !Self::anchor_split_is_zero_cost(
request, &catalog, terminal_window, baseline_start,
request.prompt_tokens, raw_anchor,
(baseline_end == request.prompt_tokens)
.then_some(accounting.initial_prefill_ns).flatten(),
))
{
Lines 470-488 already decided the same predicate for this request (start, which is consumed_tokens) and recorded it in anchor_fallback_from. The disjunct re-prices from baseline_start instead, so once start has advanced past the interior boundary (chunk 3 under Mixed alignment) the two evaluations can disagree and a second Anchor is captured — voipmonitor's blocker #2.
Fix (smaller version): keep only the latched decision,
} else if accounting.anchor_fallback_from == Some(raw_anchor) {
which deletes ~13 lines including the duplicated terminal_window/catalog pricing call, and makes the fallback sticky by construction instead of re-derived. Requires F3.
F3 — clear_reservations resets a decision field, so the F2 latch cannot be trusted
File: helios/src/scheduler/checkpoints.rs:48-52, called from helios/src/scheduler.rs:1726
pub(super) fn clear_reservations(&mut self) {
self.anchor_fallback_from = None; // 49 — new in this PR
self.cuts.clear();
self.reserved_ns = 0;
}
admit calls clear_reservations() on the carried-over accounting (scheduler.rs:1726) while deliberately preserving baseline_interval and initial_prefill_ns (both survive; see for_epoch at 35-41 and the is_none() guard at 451). Clearing anchor_fallback_from here discards the decision at readmission, which is why F2's disjunct looks necessary: without it the fallback would be lost.
Why it matters: a function named for reservations now mutates selection state; that is a hidden coupling, and it is the reason the redundant disjunct exists. AGENTS.md:188-193 (no fallback layers).
Fix (smaller version): remove line 49, or set the latch once at admission. Either way clear_reservations goes back to clearing reservations only.
F4 — is_request_anchor_endpoint is a second price model of one predicate
File: helios/src/scheduler/checkpoints.rs:390-420; callers helios/src/scheduler.rs:1794, checkpoints.rs:402, 763
if request.checkpoints.anchor_fallback_from == Some(raw_anchor) { return true; } // 402-404
let catalog = self.prefill_catalog_costs(request); // 405
...
!Self::anchor_split_is_zero_cost(request, &catalog, terminal_window, 0, request.prompt_tokens, raw_anchor, None)
This re-walks the catalog from token 0 to answer "is the prompt end the anchor for this request?", while checkpoint_selection_uncached answers the same question from baseline_start/start at 467-511. Two definitions of one predicate, in different coordinate systems, is precisely how blocking defect #2 (Mixed alignment) becomes possible; it is also voipmonitor's Major #3 (the start = 0 re-pricing) and, at zero fraction, the O(N) wasted pricing they flag as minor #5.
Fix (smaller version): checkpoint_selection_uncached already computes the answer at 467-511 — store it as an anchor: usize field on CheckpointAccounting, and let is_request_anchor_endpoint read it, keeping only the guards (endpoint == raw_anchor, snapshots == 0, fraction != 0.0, raw_anchor >= prompt_tokens). ~25 lines of pricing disappear, scheduler.rs:1794 and promote_request_anchor:763 keep working off the same value, and the two call sites cannot disagree.
Should fix
F5 — plan_checkpoints reconstructs the anchor instead of reading it
File: helios/src/scheduler/checkpoints.rs:671-685
let anchor = accounting.cuts.iter().find(|cut| cut.role == RetentionRole::Anchor)
.map_or_else(|| {
let raw_anchor = request.checkpoint_anchor();
if accounting.anchor_fallback_from == Some(raw_anchor) { request.prompt_tokens }
else { raw_anchor }
}, |cut| cut.endpoint);
This is a third encoding of "what is the anchor": a scan of cuts, plus a re-derivation of the fallback condition. With F4's anchor field it collapses to accounting.anchor; the same field also replaces the request.checkpoints.anchor_fallback_from test at 402.
Why it matters: three encodings of one value must be kept in sync by hand; the cuts scan is also the reason commit_checkpoint_plans has to thread accounting around. docs/design-review.md:16.
F6 — complete_test_step is a third copy of an existing helper
File: helios/src/scheduler/checkpoints.rs:1942-2016 (75 lines); duplicates helios/src/scheduler/boundary_tests.rs:93-145 (run_step) and helios/src/scheduler/policy_tests.rs:162-200 (completion_records/complete)
All three build CompletionRecords from a lane walk, with the same GraphKind match, the same consumed/generated arithmetic, the same status quorum, and the same TokenVector construction for Speculative. The single real difference is per-lane vs per-step kind (step.lane_kind(row) vs step.kind).
Why it matters: the new tests depend on this copy's slightly different semantics (per-lane kind, emitted capped by 3 and max_new_tokens), so the reviewer cannot tell which completion model the assertions are actually testing. AGENTS.md:194-199.
Fix (smaller version): move one parameterised helper into scheduler::tests (already pub(crate)) and have all three call sites use it; the new tests shrink by ~60 lines.
F7 — the new check.py mutation is a 13-line source-text literal
File: verification/helios-lifecycle/check.py:325-343
("dropped multi-chunk zero-budget fallback",
" } else if accounting.anchor_fallback_from == Some(raw_anchor)\n"
" || (baseline_start < raw_anchor\n"
... 10 more literal lines ...
" {",
" } else if false {",
It duplicates the } else if ... branch character for character, is whitespace-brittle, and asserts nothing the new lifecycle test does not already assert (helios/src/scheduler/checkpoint_lifecycle_tests.rs:334-340 asserts the fallback survives into the model). AGENTS.md:194-197 is explicit that source-text checks cannot establish runtime correctness.
Fix (smaller version): a one-line needle on the latch (accounting.anchor_fallback_from == Some(raw_anchor) → false) and, if the pricing branch needs its own guard, the same for it; or drop the mutation once F2/F3 make the model test cover the decision. This is also voipmonitor's minor #6.
F12 — two docs sentences are now false
Files: docs/core-design.md:1452-1453 and docs/scheduling-runtime-design.md:570-572
"Unknown prefill costs or unknown or stale snapshot-copy costs exclude extras without excluding the anchor." (core-design 1452-1453) "Unknown prefill costs and unknown or stale snapshot-copy costs disable extras while preserving anchor eligibility." (scheduling-runtime 570-572)
anchor_split_is_zero_cost returns false on an unknown price (373-386), which under a zero fraction means the anchor is lost to the prompt end — so at zero fraction unknown costs now do exclude the interior anchor. Both sentences were true before this PR and are contradicted by it.
Fix: add the zero-fraction exception to both, per SKILL.md:26-29 ("Replace stale claims instead of layering history on top").
Nits
F8 — a 110-line test whose extra assertion is an underived wall-clock bound
File: helios/src/scheduler/checkpoints.rs:2449-2559, assertion at 2554-2558
assert!(
all_prefills_done_ns <= 2_000_000_000,
"16 single-launch short prefills should complete without anchor-tail starvation (took {:.1} ms)",
all_prefills_done_ns as f64 / 1e6,
);
Synthetic durations are accumulated into all_prefills_done_ns (2503, 2537-2539) to compare against a magic 2 s bound with no stated derivation. The behavioural assertion is max_decode_batch == 16 (2548) plus prefill_launches == 16 (2544). AGENTS.md:187 requires numerical bounds to follow required arithmetic and measured repeatability; AGENTS.md:509-510 — keep raw benchmark measurements rather than manufacturing a threshold.
Fix: drop the timing assertion and the all_prefills_done_ns/now_ns accumulators (~12 lines), or state how 2 s is derived.
F9 — the new zero-capacity test duplicates an existing one
Files: helios/src/scheduler/checkpoints.rs:2326-2362 vs helios/src/scheduler/boundary_tests.rs:193-210
snapshot_capacity_does_not_disable_prompt_fallback_anchor already loops snapshots including 0 and asserts checkpoint_anchor_captures == 0 and prompt_checkpoints == 0 (205-206). The only new information in the new test is the launch count and lane token count.
Fix: extend the existing test with assert_eq!(prefill_launches, 1) over the zero-capacity iteration instead of adding a second test (AGENTS.md:188-193, no redundant coverage).
F10 — a bundled test, one part of which tests unchanged behaviour
File: helios/src/scheduler/checkpoints.rs:2726-2852, Part B at 2764-2781
zero_fraction_aligned_interior_anchor_and_mixed_prefill_preserve_exact_contracts runs three independently configured schedulers (A, B, C). Part B sets checkpoint_extra_work_fraction: 0.05 and asserts boundary 200 stays as the anchor — behaviour this PR does not change and which existing nonzero-fraction selection tests already cover.
Fix: split A and C into their own named tests and drop B.
F11 — two near-identical lookup chains in promote_request_anchor
File: helios/src/scheduler/checkpoints.rs:758-767
key_at(raw_anchor).and_then(ready_by_prefix).or_else(|| is_request_anchor_endpoint(prompt).then(|| key_at(prompt)).flatten().and_then(ready_by_prefix)) — since is_request_anchor_endpoint returns true when endpoint == raw_anchor (392-394), the whole thing is one anchor choice followed by one lookup:
let anchor = if self.is_request_anchor_endpoint(request, prompt_tokens as u64) {
prompt_tokens
} else {
raw_anchor
};
let id = request.history.key_at(anchor as u64).and_then(|key| self.cache.ready_by_prefix(&key));
Saves ~6 lines and removes the duplicated key_at/ready_by_prefix pair.
F13 — the new rule is paraphrased three times with no cross-reference
Files: docs/core-design.md:1436-1445, docs/scheduling-runtime-design.md:553-559, docs/cli-design.md:702-709
Each states the zero-fraction interior-anchor rule in different words ("only if splitting prefill there adds zero predicted prefill work, otherwise the prompt end serves as the anchor" / "falling back to the prompt end when ... would add predicted prefill work" / "used as the anchor only when splitting prefill there adds zero predicted prefill work, and otherwise the prompt end acts as the anchor"). Three copies will drift — F12 shows two paragraphs already drifting in the same PR.
Fix: state the rule once in core-design.md as the specification and have the runtime design and the CLI flag text reference it; fix F12 in the same pass.
Checked and not findings
anchor_split_is_zero_costreturningfalsefor an unknown price (373-386) is a deliberate conservative choice, not an extra path to delete (only its documentation is wrong — F12).scheduler.rs:1794usingis_request_anchor_endpointfor the inbound ticket role is a legitimate reuse of the new helper; the finding is F4's duplicate pricing, not this call.limits.snapshots == 0early return at 460-462 could move above theinitial_prefill_nscomputation at 451-459 to skip a catalog walk for a request that can never capture, but that is a micro-optimisation, folded into F4 rather than reported separately.- The added comment block at 463-466 explains an invariant ("retain that replacement after natural chunks pass the boundary"), which is what
SKILL.md:38-39asks for; no bloat finding.
Limits
No cargo or pytest in this environment, so nothing was executed; every code finding is from reading the head a3c6483 sources plus voipmonitor's reproducers in the PR thread (review of 2026-11-28, CHANGES_REQUESTED; head has no CI checks). F1/F2/F5 assert consequences on the anchor decision, so the fix is confirmed by running the PR's own zero-fraction tests after the simplification, plus the reviewer's upward-EWMA and Mixed-alignment reproducers. The outbound tests added here (checkpoints.rs:2326, 2364, 2449, 2562, 2726) are the ones that should keep passing unchanged under F1–F11.