Review of PR #540 — simplicity lens (what can be deleted)
Head e5a69669, 33 files, +4306/−310. Rules applied: docs/design-review.md:16 (not opened) ("Keep Helios as simple as possible"), AGENTS.md (not opened)'s simplicity rule (the same principle; scheduling changes must also follow docs/scheduling-runtime-design.md (not opened), AGENTS.md:231 (not opened)), and the charter's runtime-size constraint (charter line 12: keep the runtime small and model-agnostic).
Key findings
- No blocking issues. Every path in the production diff that I followed has a live non-test caller; the only "second implementation" style problems left are two dead/vestigial entry points and three small nits.
helios/src/scheduler.rs:1101-1104—pub fn history_proposalis now test-only. This PR moved both production callers torequest_history_proposal, and the surviving method is precisely the prompt-blind bypass the PR exists to replace. Should fix (delete).helios/src/scheduler.rs:1267-1277—RequestScheduler::idleis a pure validator under a five-line doc comment describing refresh-credit retention it does not implement. Should fix (rename + cut doc).- Nits: a per-slot
Vec<f64>clone with two parallel memo arrays driving one ranking builder (rounds.rs:874-875, 920-926); a deadselect_shape_with_draftswrapper (catalog.rs:240-245); two independent6s for one copy-match threshold (speculation.rs:25vssam.rs:23).
What this PR already cleaned up (verified, so the report does not re-flag it)
I checked each by search at this head:
RefreshState::idledeleted —helios/src/scheduler/refresh.rsends at line 99 withabort(); nopub fn idle(&mut self) {}remains.sam.rstrimmed:SamConfig,with_config,from_shared_prompt,propose_for_context,propose_conditional_continuations,MatchSource/source,PromptSAM::build,push_sliceare gone; surviving accessors are#[cfg(test)](sam.rs:172, 420-430, 680, 818-823, 886). Module doc no longer claims cross-requestArcsharing despite production never doing it (sam.rs:7-17).ProposalSource::from_wire/to_wire(speculation.rs:55-60) replaced the three-way0/1/2ladder inruntime_core/serving.rs(not opened),heliopause/src/python.rs(not opened) andruntime_core/selection.rs(not opened).- The duplicated copy-cohort candidate loop is gone:
rounds.rshas onebuild_host_prefix_ranking(505-527) and oneselect_host_allocated_candidate(764-862), called from the copy branch (927-934) and the ordinary host-allocated branch (963-971), net ≈ −110 lines. - The two-arbitrations nit is resolved:
request_history_proposal_with_match_len(scheduler.rs:1164-1179) andrequest_copy_match_stats(1183-1194) now shareresolve_copy_match(1112-1149); they differ only in whether the padded vector is built. - Unreachable
wide_copy_curvefallback replaced byexpect("wide copy requires history drafts enabled before admission")(rounds.rs:570-579). BoundGraph::matches_step(packing.rs:40-53) replaced two inline closures — a dedup, not a new path.
Should fix
1. helios/src/scheduler.rs:1101-1104 — history_proposal became test-only in this PR, and it is the prompt-blind path the PR replaces
pub fn history_proposal(&self, context: &[u32], maximum: usize) -> (Vec<i64>, usize) {
let maximum = maximum.min(self.capabilities.completion_token_capacity - 1).min(speculation::COPY_DRAFT_CAPACITY);
self.decoded_history.as_ref().map_or((vec![-1; maximum], 0), |history| history.lookup(context, maximum))
}
Why it matters. Both production call sites were moved off it by this PR: helios/src/model/packing.rs:405 and helios/src/server/runtime.rs:2146 now call scheduler.request_history_proposal(...). The only remaining callers are tests: scheduler/tests.rs:1956 (not opened), 1970, 1972-1974, 1979, 1985, 1991, 2069 and server/runtime/phase_tests.rs:583 (not opened), 1835. Worse than dead code, it is exactly the prompt-blind behaviour the PR is fixing — it ignores LiveRequest.sam entirely and goes straight to DecodedHistory::lookup, so leaving it pub invites a future caller to silently reintroduce prompt-blind drafts. It also duplicates the capacity clamp that clamp_copy_capacity (scheduler.rs:1106-1110) already owns.
Fix. Delete the method. Move the shared-ring assertions in scheduler/tests.rs:1950-1991 (not opened) onto request_history_proposal — that test already admits live requests (a/b at 2064-2070 in the same file), so the handle-keyed path proves the same ring behaviour and additionally proves the SAM/ring arbitration the PR adds. Keep DecodedHistory::lookup visible to the ring's own oracle test in decoded_history.rs (make it pub(crate) if the deletion removes its last pub user). Net: −4 lines here, −1 duplicated clamp, −1 bypass route.
2. helios/src/scheduler.rs:1267-1277 — idle is a validator with a doc comment describing work it does not do
/// Validates that no execution is in flight across an idle gap.
///
/// Timing-refresh and acceptance-learning ledgers retain bounded earned credit
/// (`<= CREDIT_CAP_NS`) and negative debt across idle intervals because idle adds
/// neither credit nor ordinary duration.
pub fn idle(&mut self) -> Result<()> {
if !self.submissions.is_empty() { return Err("idle requires no submitted execution".into()); }
Ok(())
}
Why it matters. The body only validates the queue. Credit retention is now simply the absence of any mutation (refresh.rs:71-99; abort at 95-99 is the only discard path), so the doc comment and the name both point a reader at behaviour that lives elsewhere — the previous round's complaint about the empty RefreshState::idle survives here as a vestigial name plus a five-paragraph-argument comment on a three-line function. The single production caller is server/runtime.rs:1184.
Fix. Rename to assert_idle (or move the submissions.is_empty() check into the call site), cut the doc to one line ("no execution may be in flight while the worker waits"), and leave the retention argument to docs/scheduling-runtime-design.md (not opened) / docs/scheduling-theory.md (not opened), which the PR already updated. The nine s.idle().unwrap() credit-retention assertions in policy_tests.rs:2612 (not opened), 2640, 2691, 2701, 2732, 2753, 6102, 6108, 6153 keep working after the rename (a search-and-replace); the only semantically meaningful one is policy_tests.rs:2628 (not opened) (assert!(s.idle().is_err())).
Nits
3. helios/src/scheduler/rounds.rs:874-875, 920-926 — one clone per shape×lane and two parallel memo arrays for one purpose
The copy branch does let curve = copy_curves[slot].get_or_insert_with(...); probabilities[slot] = curve.clone(); — a full per-slot forecast vector clone for every shape×lane — then hands the owned Vec<Vec<f64>> to build_host_prefix_ranking, which only reads it and resizes it (rounds.rs:509, 515, 525). curves and copy_curves (874-875) are two arrays of the same type feeding the same builder, one for MTP and one for copy.
Smaller version. One [Option<Vec<f64>>; REQUEST_LANES] memo, parameterised by a curve source (the wide_copy_curve vs powered_curve choice), and take &[Vec<f64>] / &[&[f64]] in build_host_prefix_ranking instead of an owned, mutated vector — the resize at 525 exists only because the caller passes an array sized for REQUEST_LANES but partially filled.
4. helios/src/model/catalog.rs:240-245 — select_shape_with_drafts has no caller outside select_shape
select_shape_with_drafts (240-245) forwards to select_shape_with_source(..., None, mode). Its only caller is select_shape (237), which exists only to hard-code drafts = 0. catalog.rs:133 validates through select_shape_with_source directly and server/runtime.rs:2238 dispatches through select_shape_with_source, so the drafts-taking wrapper is a leftover of the pre-source plumbing. Fix: have select_shape call select_shape_with_source(..., 0, None, mode) directly and delete the 240-245 wrapper (the same drafts argument already reaches select_shape_with_source at 249).
5. helios/src/scheduler/speculation.rs:25 vs helios/src/scheduler/sam.rs:23 — two independent 6s for one threshold
WIDE_COPY_MIN_MATCH_LEN = 6 gates copy lanes at rounds.rs:905; DEFAULT_MIN_MATCH_LEN = 6 gates inside propose (sam.rs:853), and sam.rs:1055 even asserts DEFAULT_MIN_MATCH_LEN == 6. They are related only by prose (speculation.rs:22 says "Matches sam::DEFAULT_MIN_MATCH_LEN"). Two constants for one user-visible threshold is a drift hazard the PR's own docs then have to keep consistent (docs/mtp-design.md (not opened), docs/cli-design.md (not opened)). Fix: have rounds.rs:905 reference sam::DEFAULT_MIN_MATCH_LEN, or drop the rounds gate entirely since propose already refuses matches shorter than it — the copy lane's match_len < 6 check is then redundant with the proposal it just received.
Cleared (read in context, live production callers — so the "no blocking" claim is scoped)
cost.rscanonical_draft_source(50-59) is the single authority used byKey::from_step(81),prepared(170),exact_duration(292),fresh_duration(313),Candidate::cost_key(policy.rs ~97-104) andpolicy.rs:1074.packed_round_durations: [[Vec<Option<u64>>; 7]; 2]per source (cost.rs:139) withpacked_round_duration_for(223-235) called fromrounds.rs:588and viapacked_round_duration(237-251) atpolicy.rs:785; the(None, Some(0))arm guards the all-unmeasured case.is_copy_only_step(scheduler.rs:1196-1199) has production callersscheduler.rs:2502, 2790→server/runtime.rs:1722.- Copy-only graph gating:
selection.rs(not opened)copy_wide,catalog.rs:91-131(including theCopyConsumedTokens/CopyGeneration/CopyGrammar*contract check at 103-131),manifest.rs:840-851,serving.rs:55-64(not opened),heliopause/src/python.rs:223-233(not opened) — each the only gate on one boundary (wire load, catalog validate, scheduler retain); no redundant second gate found. binding.rs:201-216derivesdraft_source(0|1|"MTP" → MTP, 2|"COPY_DRAFT" → COPY_DRAFT, else invalid, rejects COPY_DRAFT on non-speculative) and matchesignition/preparation/execution.py:102-104(not opened) after thekind != "speculative"tightening.- Padding dominance rewrite (
policy.rs:133-262) replaced the exact-equality branch rather than adding a parallel one; exercised throughprune_padding/plan()bypolicy_tests.rs:58-200(not opened), i.e. real behaviour. LiveRequest.sam/copy_calibration(scheduler.rs:265-266) are pushed on both commit paths (scheduler.rs:1233, 3016) and read on both proposal paths (1127, 1178) and the rounds loop (rounds.rs:774).- New SAM tests worth keeping: the randomized brute-force oracle (
sam.rs:1400-1469) andrequest_sam_proposes_prompt_continuations_and_isolates_requests(scheduler/tests.rs:1995-2126(not opened)) prove real behaviour (per-request isolation, output-over-prompt recency,status==3leaving SAM untouched). - No
#[allow(dead_code)], no new feature flags or env-var fallbacks, no over-commented blocks beyond item 2, no behaviourless tests beyond thehistory_proposalcalls in item 1.
Open questions
- Is
history_proposalintended as a stable out-of-tree/embedding API? Nothing in the tree or the PR description says so, and it has no in-tree non-test caller; a one-line reply settles item 1 the other way. - Does anything plan to consume
speculation::WIDE_COPY_MIN_MATCH_LENseparately fromsam::DEFAULT_MIN_MATCH_LEN? If the gates are meant to diverge later, item 5 becomes a comment fix rather than a deletion.
Limits
- I did not run the Rust or GPU suites at this head; both should-fix items are deletions/renames that need no behavioural test.
- The two should-fix items and nits 3-5 are the only simplicity findings; areas outside
helios/src/{scheduler,cost,model,runtime_core},heliopause/src/binding.rs(not opened) and the docs diffs were not re-read this pass and carry no claim here.