#1 [high] #697 subtraction lens: main findings (3)
PR #697 head bfae28a. Production diff is small (+37/-8 across 4 files); the complexity that can be subtracted is concentrated in two places.
F1 (HIGH, checkpoints.rs:620-624 vs 662-665): the new preserved branch is semantically identical to the pre-existing else branch. Code at head:
let (anchor, anchor_split_ns) = if raw_anchor < request.prompt_tokens {
if !self.budget_interior_anchor(request) {
accounting.budgeted_anchor = None;
(raw_anchor, 0)
} else if raw_anchor > start {
and the pre-existing else:
} else {
accounting.budgeted_anchor = None;
(raw_anchor, 0)
};
Both do budgeted_anchor = None; (raw_anchor, 0). Equivalent rewrite (verified case-by-case): if raw_anchor < request.prompt_tokens && self.budget_interior_anchor(request) { … } else { … } — removes the new 3-line branch, one of the three call sites of budget_interior_anchor, and the accounting.budgeted_anchor = None duplicate at :622 (a second budgeted_anchor = None that the dossier notes sits next to the TLA mutation needle at :649).
F2 (HIGH, phase_tests.rs:8358-8375 vs 861-898): the test-local let prepare = |fixture, protocol, body| {...} closure is a verbatim copy of the first 18 lines of the existing prepared_budget_request helper (decode → GrammarCompiler::new → prepare_inference with the same 7 arguments), differing only in what it returns. ~18 duplicated lines; extract one fn prepare(...) -> PreparedInference and have prepared_budget_request call it.
F3 (MEDIUM, checkpoints.rs:469-471 + call site 478-483): budget_interior_anchor is a double-negative whose name reads opposite to its meaning at request_anchor_endpoint, and it re-reads self.policy.checkpoint_extra_work_fraction although checkpoint_selection_uncached already binds let fraction = ... at :609 and the same fraction == 0.0 disjunct appears again at :675. Call site reads || !self.budget_interior_anchor(request). Simplification: rename to a positive predicate (preserves_interior_anchor / interior_anchor_is_preserved) and pass fraction in, or inline the two-condition test. Cosmetic-ish but it is the one new abstraction the PR adds.
F4 (LOW, request.rs:413-414 vs 427-429): out.content.start == crate::output::tagged::OutputStart::Reasoning appears twice 13 lines apart; a local let opens_reasoning = output.as_ref().is_some_and(...) used by both removes the repetition and reads better.
F5 (LOW, checkpoints.rs:4790-4862 + 4866-4925): the 10-line scheduler setup (scheduler(2,128,16) / prefill_graphs(&[128,256,512]) / 3x measure(Prefill) / measure(Snapshot,1,5) / configure_policy) is repeated 3x in the two new tests; no existing helper (existing helpers are measure :1151, linear_costs :1167, walk_scheduler :1276). One local fn budgeted(fraction: f64) -> RequestScheduler removes ~20 lines.
Convention note, not a deletion: preserve_message_anchor is a default-false boolean opt-in threaded Prompt→RequestSpec→LiveRequest, which docs/design-review.md:58-61 names explicitly ("Reject per-model boolean policy flags … default-false opt-ins") and AGENTS.md:180-181 ("Flags, enums, callbacks, optional paths … cannot be used to bypass them"). It is not per-model (derived from shared parser state, no model-name branch), and the scheduler has no other channel for it (Prompt.grammar_reasoning is Some only when grammar is active), so I do not recommend deleting the field — but the reviewer should require the argument for it in the description rather than have it arrive as an unargued new knob.
Positive: nobody duplicated anchor_split_affordable/allowance (:92-100), the preserved path correctly reuses the existing early Some(raw_anchor) return (:478-483) instead of adding a second pricing path, and promote_request_anchor (:908-912) just gains a disjunct rather than a parallel branch. Docs changes are synchronized fallbacks of the same sentence across 4 files, required by repo convention, not duplication to remove.
#2 [high] Research summary
Reviewed PR #697 through the Subtraction/Simplicity/Conventions lens at head bfae28a, reading the full diff of checkpoints.rs, scheduler.rs, server/request.rs, server/runtime.rs, phase_tests.rs, the four doc files, plus surrounding code (request_anchor_endpoint, checkpoint_selection_uncached, promote_request_anchor, existing test helpers measure/linear_costs/prepared_budget_request, OutputStart, AGENTS.md, docs/design-review.md).
The production diff is genuinely lean — net +29 lines across 4 files, and it reuses existing plumbing well (no duplicate pricing helper, the preserved path piggybacks on the existing early Some(raw_anchor) return, promote_request_anchor only gains a disjunct). Most of the churn is tests and doc synchronization required by repo convention.
Five concrete subtractions found, saved in scratchpad entry 1, two of them high value:
- F1 (high): the new preserved branch in
checkpoint_selection_uncached(checkpoints.rs:620-624) is semantically identical to the pre-existingelsearm at:662-665— both dobudgeted_anchor = None; (raw_anchor, 0). Folding the condition into oneifdeletes the branch, one of three call sites of the new predicate, and a duplicatedbudgeted_anchor = Nonethat sits immediately above the TLA mutation needle. - F2 (high): the test closure
prepareadded atphase_tests.rs:8358-8375is an 18-line verbatim copy of the front half of the existingprepared_budget_requesthelper at:861-898; it should be extracted and shared. - F3/F4/F5 (medium/low): a double-negative predicate name re-read that shadows an already-bound
fractionand duplicates treatingfraction == 0.0twice; theOutputStart::Reasoningtest written twice 13 lines apart inrequest.rs; and three repetitions of the same 10-line scheduler setup in the new tests.
One convention flag worth raising but not a deletion: preserve_message_anchor is exactly the "default-false opt-in" that docs/design-review.md:58-61 names as rejectable and AGENTS.md:180-181 forbids as a bypass. It is model-independent (derived from shared parser state, no model-name branch) and the scheduler has no existing channel to carry it, so I do not recommend deleting the field — but the description never argues for adding the knob, and a reviewer applying the letter of the rule would ask why it cannot be derived inside the scheduler.
#3 [medium] #697 subtraction lens: verbatim quotes for F3/F4/F5 + review scope
Supplement to entry 1. Quotes needed to state the findings precisely.
F3 — predicate and call site, helios/src/scheduler/checkpoints.rs:469-471:
fn budget_interior_anchor(&self, request: &LiveRequest) -> bool {
self.policy.checkpoint_extra_work_fraction == 0.0 || !request.preserve_message_anchor
}
call site, checkpoints.rs:478-483:
if raw_anchor >= request.prompt_tokens
|| request.prefix_tokens == raw_anchor as u64
|| !self.budget_interior_anchor(request)
{
return Some(raw_anchor);
}
The fraction == 0.0 disjunct of the predicate is the same test checkpoint_selection_uncached already binds at :609 (let fraction = self.policy.checkpoint_extra_work_fraction;) and repeats at :675 (if fraction == 0.0 {). Simplification: pass fraction in and rename to a positive form.
F4 — helios/src/server/request.rs:411-414 (pre-existing) and :427-429 (new):
out.content.start == crate::output::tagged::OutputStart::Reasoning
let preserve_message_anchor = output
.as_ref()
.is_some_and(|o| o.content.start == crate::output::tagged::OutputStart::Reasoning);
Same expression twice 13 lines apart; a single local let opens_reasoning = ... serves both.
F5 — repeated setup, checkpoints.rs:4795-4801 (also :4843-4849, :4869-4876):
scheduler.prefill_graphs(&[128, 256, 512]).unwrap();
for (tokens, nanos) in [(128, 100), (256, 110), (512, 200)] {
measure(&mut scheduler, GraphKind::Prefill, tokens, nanos);
}
measure(&mut scheduler, GraphKind::Snapshot, 1, 5);
plus a configure_policy(PolicyConfig { checkpoint_extra_work_fraction: ..., ..Default::default() }) each time. No existing helper covers it (measure :1151, linear_costs :1167, walk_scheduler :1276 do other things).
F1 verification basis: I enumerated the four reachable cases at :620 — raw_anchor >= prompt_tokens (else arm), raw_anchor < prompt_tokens with raw_anchor <= start and budgeted (else arm), raw_anchor < prompt_tokens && !budget_interior_anchor (new arm), and raw_anchor < prompt_tokens && budgeted && raw_anchor > start (priced arm). The new arm and the else arm produce identical (accounting.budgeted_anchor, anchor, anchor_split_ns), and both then fall through to the same if anchor > start { push Anchor cut } at :666-674, so the merge is behaviour-preserving on every path, not just the tested one.
F2 note: the closure returns PreparedInference while prepared_budget_request (:861) returns the 4-tuple (Incoming, Generation, Decoder, usize); only lines :871-888 are duplicated, so the extraction is fn prepare(fixture, protocol, body) -> PreparedInference called by both.
Review scope read at head: full diff of checkpoints.rs, scheduler.rs, server/request.rs, server/runtime.rs, server/runtime/phase_tests.rs, docs/cli-design.md, docs/core-design.md, docs/scheduling-runtime-design.md; plus surrounding code request_anchor_endpoint :473-554, checkpoint_selection_uncached :561-794, promote_request_anchor :898-928, existing tests :4219-4788, helpers :1151/:1167/:1276, AGENTS.md, docs/design-review.md:45-75, read_charter.
Overall verdict for the report: diff is already lean; the five items are the only subtraction available, two of them worth doing (F1, F2).