Correctness, Contracts & System-Level Consequences review — PR #660 (head 22cac91)
Reviewed against main (5d53040e), the head source of helios/src/scheduler/checkpoints.rs, its callers in helios/src/scheduler.rs, the touched test fixtures, and the contracts in helios/README.md / docs/api.md. The change is well aimed and mostly sound (see "Sound" below); the problems are one real divergence introduced by the new pricing, one undocumented operator-visible metric shift, and a test re-baselining pattern that removes coverage of the shipped default.
Key findings
- Major — the PR introduces a second, inconsistent anchor-budget rule.
request_anchor_endpointprices the split fromprice_startagainstwholeand ignoresextra_spent_ns; the planner prices frominitial_prefill_nsand subtractsextra_spent_ns. Onmainboth sites returned the raw anchor unconditionally at nonzero fraction, so they agreed; #660 makes them disagree. Becauseis_request_anchor_endpointis what stampsRetentionRole::Anchoron inbound/restored tickets (helios/src/scheduler.rs:1797) andcheckpoint_copy_allowedreturnsOk(true)unconditionally for Anchor, an interior checkpoint the planner declined can still be promoted and copied uncharged — the same over-ranked-Anchorclass that produced both blockers on #582. - Major —
flare_checkpoint_extra_work_nanoseconds_totalsilently changes scope. The Anchor cut'ssplit_nswas hard-coded0onmain; now it is charged and aggregated (checkpoints.rs:902-907), so a documented operator counter (docs/api.md:356-357,helios/src/server/metrics.rs:852) takes a step change for every anchored request, andextra_spent_nsnow gates terminal captures differently, movingflare_checkpoint_skips_total{reason="work_budget"}. Neither body nor docs say so. - Major — the shipped default
0.05loses its pre-existing coverage. Six shared fixtures were re-parameterised to1.0/0.2/0.1(tests.rs:3313-3318,boundary_tests.rs:81-85,checkpoint_lifecycle_tests.rs:156-161,policy_tests.rs,vision_window_tests.rs,phase_tests.rs), and the TLA+ lifecycle conformance test now runs only at1.0. The body calls this "Updated … unit tests". - Minor —
helios/README.md:372-380still states the pre-PR anchor contract while all three design docs were rewritten. It is now the only place in-repo that describes anchoring without the allowance. - Minor —
verification/helios-lifecycle/check.py's only mutation was renamed, not extended: nothing kills a mutant of the new budget comparison (checkpoints.rs:591-597) or the new guard (:537-543), yet the body reportscheck.py10/10 TLC / 8/8 Observed / 12/12 aux as evidence. - Minor (conditional) — the anchor split can be charged twice across preemption, because
clear_reservations(checkpoints.rs:48-51) clearscuts/reserved_nsbut notextra_spent_ns, and the new early-return guard (:533-546) only fires while anAnchorcut still exists. - Tests/claims — the
None if fraction > 0.0 => (raw_anchor, 0)unknown-cost arm has no new test at the default fraction, and the A/B caveat "0checkpoints.rsedits in571a4471..5d53040e" does not isolate #656/#628.
1. Correctness, safety & contracts
F1 — Major: two anchor-budget decision sites disagree on both the price base and the spent work
helios/src/scheduler/checkpoints.rs:500-516 (site A, 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,
};
helios/src/scheduler/checkpoints.rs:588-597 (site B, 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)
}
}
Differences, all verified in head source:
- Price start. Site A prices the split from
price_start, which isbaseline_startwhen it is below the anchor, elsegpu_reused, else fallback0(checkpoints.rs:463-493, the0at:487). Site B prices fromstart = Self::prefill_cursor(request)(:532,:584). Site B's budget base isinitial_prefill_ns, computed frombaseline_interval(:553-571), yet another start. - Spent work. Site A ignores
accounting.extra_spent_nsentirely; site B adds it.
main agreed because both were unconditional above zero — main checkpoints.rs:459-464:
if self.policy.checkpoint_extra_work_fraction != 0.0
|| raw_anchor >= request.prompt_tokens
|| request.prefix_tokens == raw_anchor as u64
{
return Some(raw_anchor);
}
and main checkpoints.rs:577-579 budgeted only at fraction == 0.0.
Impact. is_request_anchor_endpoint (checkpoints.rs:519-522) is the predicate that classifies inbound/restored checkpoints:
pub(super) fn is_request_anchor_endpoint(&self, request: &LiveRequest, endpoint: u64) -> bool {
self.request_anchor_endpoint(request)
.is_some_and(|anchor| endpoint == anchor as u64)
}
used at helios/src/scheduler.rs:1797:
let role = if self.is_request_anchor_endpoint(request, inbound.consumed_tokens) {
RetentionRole::Anchor
and Anchor copies are never gated (checkpoints.rs:971-973):
if capture.role == RetentionRole::Anchor {
return Ok(true);
}
So when site A says "keep raw_anchor" but site B said "fall back to prompt_tokens", a return-visit request still stamps Anchor rank on the interior checkpoint the planner refused to fund, retaining it over Message/Endpoint checkpoints and copying it without budget — the duplicate/over-ranked Anchor failure mode that blocked #582 twice. Divergence also runs the other way (site A's price_start == 0 at :487 prices a larger whole, so A can keep a split B rejects on extra_spent_ns), and any request whose budgeted_anchor latch is absent (wrong raw_anchor/prompt_tokens pair after a re-admit, see F6) has no reconciliation at all.
Fix. One decision function, e.g. fn anchor_decision(&self, request: &LiveRequest) -> (usize, u64) computing budget_base = accounting.initial_prefill_ns.unwrap_or(whole) and extra_spent_ns + split_ns <= allowance(base, fraction), called by both request_anchor_endpoint and checkpoint_selection_uncached, so the predicate that assigns RetentionRole::Anchor cannot disagree with the planner. Add a test that asserts is_request_anchor_endpoint and checkpoint_selection return the same endpoint for a request where extra_spent_ns > 0.
F2 — Major: an existing operator metric changes meaning without being mentioned
helios/src/scheduler/checkpoints.rs:899-908 (commit_checkpoint_plans):
accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.split_ns);
accounting.extra_spent_ns = accounting.extra_spent_ns.saturating_add(cut.split_ns);
self.stats.checkpoint_extra_work_ns = self
.stats
.checkpoint_extra_work_ns
.saturating_add(cut.split_ns);
On main the Anchor cut was pushed as Cut { endpoint: anchor, role: RetentionRole::Anchor, split_ns: 0, copy_ns: 0 } (main checkpoints.rs:610-617), so this loop added nothing for anchors; the head pushes the real split (checkpoints.rs:619-627).
Contract text, untouched by the PR — docs/api.md:356-359:
`flare_checkpoint_extra_work_nanoseconds_total` sums charged predicted
extra prefill and copy work; it is not a GPU timing measurement.
`flare_checkpoint_anchor_reservations` reports unused anchor guards, excluding
armed destinations and in-flight copies.
Exported at helios/src/server/metrics.rs:852:
("checkpoint_extra_work_nanoseconds_total", "counter", &self.checkpoint_extra_work_ns),
Impact. Any dashboard, alert, or regression gate on flare_checkpoint_extra_work_nanoseconds_total steps up by the anchor split of every anchored request, with no doc change and no note in the body — a metric/scope shift of exactly the kind the review lens asks to trace. Second-order: extra_spent_ns is also read by checkpoint_copy_allowed (checkpoints.rs:981-984) and allocate_terminal_capture, so flare_checkpoint_skips_total{reason="work_budget"} (metrics.rs:844) moves too, in a change whose whole point is fewer extra prefill launches.
Fix. Amend docs/api.md:356-357 to say the counter now includes charged anchor split work (and that anchor snapshot copies remain uncharged), and state the movement in the PR body. If a stable series matters, consider leaving the anchor split out of checkpoint_extra_work_ns and exposing it separately — but either way the doc must say which.
F6 — Minor (conditional): anchor split can be double-charged across a real preemption
helios/src/scheduler/checkpoints.rs:48-51:
pub(super) fn clear_reservations(&mut self) {
self.cuts.clear();
self.reserved_ns = 0;
}
extra_spent_ns survives, and clear_reservations runs on every admit (helios/src/scheduler.rs:1731: checkpoints.clear_reservations();). The new guard that protects a charged anchor cut (checkpoints.rs:533-546) requires such a cut to still exist:
|| accounting.cuts.iter().any(|cut| {
cut.role == RetentionRole::Anchor
&& cut.endpoint > start
&& (request.anchor_guard.is_some()
|| accounting.extra_spent_ns > 0
|| cut.split_ns > 0)
})
After clear_reservations the cuts vector is empty, so re-planning proceeds; if raw_anchor > start again (:579), site B adds split_ns to reserved_ns (:620) and commit_checkpoint_plans adds it to extra_spent_ns a second time (:903). On main this path could not charge for an anchor (split_ns: 0), so the PR extends an existing extras-only accounting quirk to anchors.
Impact. A preempted-and-readmitted request with an interior anchor can lose budget twice for the same split, pushing the terminal capture and later Message extras out of the allowance for the rest of the request — cheap to avoid, hard to see, and only on the contended path where the budget is tight.
Fix. Either include the committed anchor split in baseline_interval-style carried state that clear_reservations preserves (a charged_anchor: Option<(usize, u64)>), or make the guard at :533 consult extra_spent_ns/budgeted_anchor independently of the still-present cuts entry. Add a test that preempts after an anchor cut commits and asserts extra_spent_ns does not grow by the same split twice. I flag this as conditional only because I did not trace every preemption path that resets prefill_cursor behind the anchor.
Verified sound in this area
- The new early-return guard (
checkpoints.rs:533-546) correctly leaves an unreached, already-charged Anchor cut in place instead of clearing it, and both new tests (anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget,default_fraction_anchor_guard_revocation_preserves_charged_anchor_split) cover it. - No new lock, channel, allocation-in-hot-loop, or blocking call: the scheduler is single-threaded
&mut selfplus a thread-local selection cache scoped perselect_plan(checkpoints.rs:134-137,:410-428), so there is no contention/head-of-line/failure-propagation surface added.anchor_split_ns(:430-442) priceswholeonce and reuses it, so the change does not multiply catalog work per plan. configure_policystill rejects out-of-range fractions (helios/src/scheduler/policy.rs:206-213); no new flag, config key, ABI, protobuf, captured-graph contract, orunsafeappears in the diff. Signed/exported cores serve unchanged.- The candidate filter change
end < anchor→end < raw_anchor(checkpoints.rs:645) genuinely closes a duplicate-capture path that existed onmainwhen the anchor fell back toprompt_tokens.
2. Architecture, contracts & charter compliance
F4 — Minor: helios/README.md now contradicts the code; all three design docs were updated
helios/README.md:372-380 (unchanged by this PR):
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.
The three docs that were rewritten say the opposite of "prioritizes the last eligible message boundary": docs/cli-design.md:696-711 ("serves as the conversation anchor only when splitting prefill there adds predicted prefill work within the request's extra-work allowance … otherwise the zero-split prompt end acts as the anchor"), docs/core-design.md:1434-1460 ("its predicted split overhead is charged against that same extra-work allowance"), docs/scheduling-runtime-design.md:613-630.
Impact. The crate README is the in-repo contract operators read for checkpoint behaviour; after this PR it is the only document describing anchoring without the allowance, and it omits the two operationally important facts (the anchor can fall back to the prompt end; the anchor split competes with Message/Endpoint extras).
Fix. Add one sentence to helios/README.md:372-380 in this PR stating that the interior anchor is retained only within the same allowance and that its split work is charged (copy uncharged).
Charter / process items worth adjudication
- Evidence (#210). The body's own limits say the
4× DGX Spark GB10run used pre-#656571a4471, defended by "0checkpoints.rsedits in571a4471..5d53040e" — that does not isolate merged changes in the range (#656 conditional speculative acceptance and acceptance-probe charging; #628 Copy-Engine gating), all of which move prefill/decode timing. The4× RTX PRO 6000table is on22cac916834fvs5d53040e, but no repeat counts or variance are given, and the same body disclosesmixed-c32per-user p5093.9 -> 71.0 tok/swith>250 msgaps215 -> 434. - Formal/simulator coverage. The body declares
kaniand gated templates unrun and says nothing aboutscripts/scheduling_sim. Per the discovery dossier,docs/design-review.md(not opened) treats an applicable unrun simulator/TLA+/Kani check as blocking;scheduling_simhas no checkpoint/anchor model (plausibly N/A) but the PR does not make that argument, unlike #655. - Sequencing. #655 rewrites the same
checkpoint_selection_uncached; this PR's version still callsself.costs.fresh_duration(GraphKind::Snapshot, 1)atcheckpoints.rs:634. A rebase collision plus re-A/B is near-certain.
3. Tests & claim accuracy
F3 — Major: fixtures were re-baselined away from the shipped default instead of covering it
helios/src/scheduler/tests.rs:3303-3318 (the widely shared prefill_to_publication_boundary):
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 does the identical duration rewrite plus checkpoint_extra_work_fraction: 1.0. helios/src/scheduler/checkpoint_lifecycle_tests.rs:152-161 (the TLA+/lifecycle conformance test checkpoint_reservations_match_lifecycle_model) also runs at 1.0:
for cancellation in 0..5 {
let mut scheduler = tests::scheduler(2, 64, 3);
scheduler
.configure_policy(PolicyConfig {
checkpoint_extra_work_fraction: 1.0,
..Default::default()
})
.unwrap();
Also re-parameterised: policy_tests.rs (0.2, 1.0), vision_window_tests.rs (0.1), phase_tests.rs:3898-3906 (1.0), and phase_tests.rs:1539-1600 (exact_system_and_prompt_checkpoints_publish_only_after_snapshot_completion) was rewritten from prompt 13 / boundary 10 to a chunk-aligned boundary plus 3 tokens so the anchor lands where the budget accepts it.
Impact. These tests encoded the behaviour the PR classifies as a bug, so re-baselining is legitimate — but the body presents it as "Updated … unit tests". The consequence is that the shipped default (0.05, helios/src/scheduler/policy.rs:40, validated policy.rs:206-213) is now exercised only by the new inline tests inside checkpoints.rs, and the TLA+ conformance model only ever runs at 1.0 — i.e. no reservation-accounting edge is emitted for the charged-anchor path at the fraction every deployment actually uses, which is precisely what verification/helios-lifecycle exists to police.
Fix. Keep one lifecycle-model run at the default fraction (or add a second edge-emitting run at 0.05 with an interior anchor that is charged), and say in the body that shared fixtures were re-baselined to 1.0 and why.
F5 — Minor: the lifecycle mutation was renamed only; the new decision is unmutated
verification/helios-lifecycle/check.py:672-677 — the only hunk in the PR:
check_mutations(cargo, ROOT / "helios/src/scheduler/checkpoints.rs", CHECKS[7][1], [
("dropped multi-chunk zero-budget fallback",
"accounting.budgeted_anchor = Some((raw_anchor, request.prompt_tokens, chosen));",
"accounting.budgeted_anchor = None;",
"multi-chunk prefill must retain zero-budget prompt-end anchor fallback"),
])
The rename keeps the mutation valid (the target line still exists at checkpoints.rs:602), but no mutation kills a mutant of what this PR adds — the budget comparison at checkpoints.rs:591-597 or the new guard conjunct cut.split_ns > 0 at :542. The body nonetheless lists check.py (10/10 TLC, 8/8 Observed / 594,065 edges, 12/12 aux) under evidence for the change.
Fix. Add mutations: (a) if split_ns == 0 || accounting.extra_spent_ns.saturating_add(split_ns) <= available → if true (interior anchor always retained), (b) drop || cut.split_ns > 0 from :542.
Untested new arm, and the trade the diff itself proves
checkpoints.rs:599—None if fraction > 0.0 => (raw_anchor, 0)keeps an interior anchor uncharged when prefill cost is unknown. It is deliberate and documented (docs/cli-design.md:702-705,docs/core-design.md:1455-1459) and mirrored at:510, but I found no new test for it; the unknown-cost tests that exist are the older zero-fraction ones.- The dropped-extras trade is explicit in the new assertion at
checkpoints.rs:1809-1820: "Anchor 896 adds 110 ns … leaving 90 ns … 640 (split 90 + copy 1) exceeds the remaining budget", withcuts == [256, 512, 768, 896, 1024]andreserved_ns == 134wheremainhad[256, 512, 640, 768, 896, 1024]/115. Intended, but it is a silent loss of one terminalEndpointon that shape and deserves a body sentence.
Claim accuracy in the description
- The body (as stored on the PR) states its
4× DGX Spark GB10run was pre-#656571a4471while the headline table is22cac916834fvs5d53040e; the "0checkpoints.rsedits" defence covers only this file, not the merged #656/#628 behaviour in the same range. - The premise measurement (
Prefill(128) = 18 msvsPrefill(512) = 29 ms, "splitting a 453-token prompt at 450 adds an 18 ms tail") is hard-coded as an input into the new test aroundcheckpoints.rs:4176-4218; the test checks the arithmetic consequence, not the measurement. That is fine as a unit test, but the measurement itself is author-reported only. - No repeat counts, no variance, no CI on
22cac916834f.
Open questions for adjudication
- Should F1's two sites share one budget basis (my recommendation), or is the "latch normally reconciles them" argument considered sufficient? The divergence matters exactly when the latch is missing.
- Is the
mixed-c32per-user regression (93.9 → 71.0 tok/s,>250 msgaps215 → 434) an accepted trade for+96.2%mean decode batch and+23.7%output throughput, or should it block until re-measured with repeats? - Is losing the late interior
Endpointcapture on multi-boundary prompts (the[256,512,640,768,896,1024]→[256,512,768,896,1024]assertion) intended, and should the README/docs state it? - Sequencing against #655 (same function, Ready-To-Merge): which lands first, and does #660 re-baseline and re-A/B before review?
- Does the maintainer want anchor split work in
checkpoint_extra_work_nanoseconds_total(meaning change, undocumented) or a separate series?
What could not be found or verified
- No builds, tests, or benchmarks were run here; every statement is from reading head source,
mainsource, the diff, and the in-repo docs. All suite counts and benchmark deltas are author-reported. - Commit trailers (
Design-Signed-Off-By: …; design-review=<hex>, DCO) for22cac916were not readable, sodocs/design-review.md(not opened)'s sign-off requirement could not be checked. helios/src/cache/*RetentionRoleranking internals,helios/src/server/metrics.rsbodies beyond:842-857, and the remaining ~3,000 lines of thecheckpoints.rstest module were not inspected.scripts/scheduling_simwas not opened; per the dossier it has no checkpoint/anchor model, so its absence from the evidence is plausibly N/A but unconfirmed by the author.- No CI results, reviews, or maintainer statements exist for this head commit (only an autobot case-file comment).