Key findings
The four behaviours are argued and measured; the volume is not. At head 14019718 the change is +3968/−119 across 25 files, of which helios/src/scheduler/sam.rs is a brand-new 1,606-line module and +1,408 lines are tests. I verified at head that roughly 710 lines (≈18%) can go without losing any behaviour: duplicated search loops, a SAM API with zero production callers, a now-empty function, a second copy of Candidate's expected value, two copies of the same match algorithm, three overlapping end-to-end tests, and a bundle of nits. Nothing in the PR body, comments or code tried to direct this review; the only instruction-shaped text was the PR's own claims about its behaviour, which I checked against the code.
Verdict: make it smaller first. The change is not minimal, but it is not mostly unnecessary either — each of the four commits maps to a stated gap with a measurement, and the MutableEdges/RootedLct machinery (~600 lines) is the price of O(log M) recency updates and has no equivalent in the repository.
Ranked by lines saved. All line numbers are at head 14019718.
1. Should fix — ~250 lines: three end-to-end tests re-prove the same SAM→pack path
helios/src/model/tests.rs:846-953 (not opened) (history_draft_packing_forwards_per_request_prompt_sam_continuations, 108 lines) and helios/src/model/tests.rs:1861-2075 (not opened) (wide_copy_verify_catalog_packs_23_sam_tokens_and_preserves_legacy_w8_cores, 215 lines) do the same walk twice: build a scheduler with history drafts, run Init→Prefill→Decode emitting a token that completes a ≥6-token suffix, plan a speculative step, pack inputs, assert on copy_token_ids/copy_token_count uploads. The wide test additionally re-asserts legacy W=8 retention already owned by helios/src/runtime_core/selection.rs:1876-1940 (wide_copy_graphs_retain_only_when_history_drafts_enabled) and W=24 selection already owned by helios/src/scheduler/tests.rs:4107-4340.
helios/src/scheduler/tests.rs:1994-2126 (request_sam_proposes_prompt_continuations_and_isolates_requests, 132 lines) mostly re-proves sam.rs's own prompt_only_match_succeeds_with_zero_prior_output, output_overrides_prompt_recency_on_tie and shared_prompt_sam_isolates_per_request_outputs_and_bounds_states; only the admission/enable_history_drafts wiring and the status == 3 path are scheduler-specific (~30 lines).
Smaller version: keep the wide test and selection.rs, keep one packing test, and trim scheduler/tests.rs:1994-2126 to admission + status-3. Every fibre stays covered exactly once. ~250 of the +1,408 test lines.
2. Should fix — ~100 lines: the copy-only round search duplicates the ordinary one
helios/src/scheduler/rounds.rs:755-903 is a 150-line copy of the ordinary packed-round candidate search at :905-1060, specialised for copy-only shapes: the same for ordering in 0..3 loop (:818-829 vs :981-992), the same rank closure, the same select_nth_unstable_by + truncate + sort, the same frontier.clear(), and the same (mask, host_lengths, lane_terms) best-tracking (:840-876 vs :993-1046). The only real differences are the curve source (wide_copy_curve vs powered_curve) and the :769-790 availability gate. The ranks_by_slot/slots_by_rank build at :801-806 also re-implements the existing host_prefix_ranking (rounds.rs:492-513) instead of calling it.
Smaller version: one loop parameterised on a per-slot curve provider (Fn(usize) -> Vec<f64>) plus the availability gate; the curves/copy_curves caches at :747-748 collapse to one array. The copy branch's third ordering (full / copy_limits[slot], :826) is already the main loop's third ordering, so nothing is lost.
3. Should fix — ~100 lines: propose_conditional_continuations has no caller
helios/src/scheduler/sam.rs:1112-1189: a 78-line public method (with doc) whose only reference in the whole repository is its own test sam.rs:1491-1514. Its doc justifies it as a "building block for conditional copy lookup tables in 2-deep pipelined execution" — no such execution model exists in this PR or in rounds.rs, which plans one round at a time. Deleting it also removes the only read of active_drafts.
Replacement: nothing. Delete sam.rs:1112-1189 and the test at :1491-1514.
4. Should fix — ~95 lines: test-only SAM surface and the SamConfig knob set
Verified by search over helios/src — these have no production caller, only sam.rs's own tests and scheduler/tests.rs:2102,2125:
PromptOutputSAM::propose_for_context(sam.rs:1068-1110, 41 lines) plus its 8-line block inexact_oracle_equivalence_randomized_streams_and_repetitions(:1459-1466); production goes throughpropose(scheduler.rs:1128).MatchSource(sam.rs:64-69) +MatchProposal.source(:80-81) + thesourcecomputation inbuild_proposal(:1216-1220) and in the oracle (:1262-1266) + 4 test assertions: ~14 lines.PromptSAM::build(:282-285),is_empty(:454-456),tokens(:458-460),PromptOutputSAM::config(:953-955),prompt_len(:957-959),output_len(:961-963),push_slice(:1023-1027),LiveRequest::sam()(scheduler.rs:383-385): ~20 lines.SamConfig+with_config/from_shared_prompt(sam.rs:39-62,928-947): the only production constructor isPromptOutputSAM::new(scheduler.rs:1852), so the four DEFAULT_* knobs can be constants: ~25 lines.
Keep the #[ignore] microbenchmark accessors (memory_bytes, dynamic_memory_bytes, state_count, transition_count) — the PR's result table cites that benchmark.
5. Should fix — ~40 lines: the match algorithm is written twice in scheduler.rs
helios/src/scheduler.rs:1112-1159 (request_history_proposal_with_match_len) and :1163-1205 (request_copy_match_stats) are the same algorithm twice: clamp maximum by completion_token_capacity - 1 and COPY_DRAFT_CAPACITY, early-return, fetch the request, propose from request.sam, clip at the first out-of-vocabulary id, ring lookup via lookup_with_match_len, then take the shared match iff shared_match > sam_match. The only difference is that the first returns a padded Vec<i64> and the second the lengths.
Smaller version: one private helper returning (Option<(Vec<i64>, usize /*count*/, usize /*match_len*/)>, Option<(usize, usize)>); the two public wrappers become 3-6 lines each. request_history_proposal (:1102-1109) is itself a 6-line pass-through whose callers (model/packing.rs:402 (not opened), server/runtime.rs:2146 (not opened)) use only (tokens, count) and can call the _with_match_len form directly.
6. Should fix — ~35 lines: Candidate.expected duplicates what ValueRate already holds
helios/src/scheduler/utility.rs:116-140: ValueRate::new(duration_ns, expected_value, age_price) derives everything from (duration_ns, expected_value, age_price), and compare tests duration_ns == 0 first, so with duration_ns == 0 the score is the expected value. Candidate (policy.rs:86-95) already carries both duration_ns and rate: ValueRate; the PR's new expected: f64 (policy.rs:89) is recomputable, and it drags in a second accumulator everywhere: base_zero (rounds.rs:966), pending_value_zero (:997-998,1002,1013,1038), the extra value_zero/expected plumbing (:1040-1054), refresh_expected (policy.rs:1224-1245, :1471-1479), and the compare_by/compare_refresh split (policy.rs:1313-1338).
Smaller version: keep one of the two quantities (either rate, or expected with ValueRate::new(0, expected, age) used at compare time) and let every construction site return to its pre-PR shape. Refresh ranking still orders by zero-duration expected value. (The PR's automated review argues expected is a "real second quantity"; whichever field survives, the duplicate accumulator plumbing is what the ~35 lines are.)
7. Should fix — ~20 lines: RefreshState::idle is now an empty function
helios/src/scheduler/refresh.rs:95-99 is pub fn idle(&mut self) {} under an 8-line doc comment, and its only caller helios/src/scheduler.rs:1281 is now a no-op call. Delete both; RequestScheduler::idle keeps just its submissions guard, which server/runtime.rs:1184 (not opened) uses. The "idle changes nothing" assertions go with it: policy_tests.rs:2610-2611,2638-2639,2689-2700,2730,2751,3685-3687. abort() (refresh.rs:101-105) still holds the only copy of the credit_ns.min(0.0) / acceptance_credit_ns.min(0.0) clamping, so nothing is lost.
8. Should fix — ~18 lines: history_proposal and DecodedHistory::lookup are left production-dead
This PR switched both production callers to the per-request SAM path (helios/src/model/packing.rs:402 (not opened), helios/src/server/runtime.rs:2146 (not opened)). RequestScheduler::history_proposal (helios/src/scheduler.rs:1094-1097) now has only test callers (scheduler/tests.rs:1956,1970-1991,2069, server/runtime/phase_tests.rs:583 (not opened),1835), and its only consumer DecodedHistory::lookup (helios/src/scheduler/decoded_history.rs:180-183, a 4-line wrapper over lookup_with_match_len) has none. Delete both, re-point the ~11 assertions at request_history_proposal/lookup_with_match_len. The ring behaviour stays reachable as the SAM fallback, so no coverage is lost.
9. Nit — ~55 lines, a bundle of small duplicates
helios/src/execution/manifest.rs:844-846rejectsdraft_source == Copy && confidence_width != 0;helios/src/model/catalog.rs:123-131rejects the same condition plusSpeculativePrefixLimitand runs on load, so the manifest clause is subsumed — drop it (~7 lines).ignition/preparation/execution.py:102-108restates the same rule a third time.helios/src/scheduler/policy.rs:158,166,175are three copies of the identicalleft.iter().zip(right).any(|(a, b)| *a > b)early-out indominates_padding_with, withshort()/long()built twice (:153,161and:169,170). Hoist the physical-dimension check above the speculative branch and build the two pairs once: ~10 lines.helios/src/scheduler/policy.rs:225-254(prune_padding's new second pass) re-tests the predicate ofdominates_padding_with's new first branch (:143-165): samegpu_prefix_allocation, same capacity/draft equality, samepacked_token_capacity >= needed. One of the two belongs in the other: ~30 lines of predicate logic.docs/scheduling-runtime-design.md(not opened) states "idle retains earned credit" twice (~lines 431 and 481) andrefresh.rs:95-98says it a third time; one sentence in docs suffices: ~6 doc lines.helios/src/scheduler/speculation.rs:17-18definesWIDE_COPY_MIN_MATCH_LEN = 6equal tosam::DEFAULT_MIN_MATCH_LEN = 6; if they ever diverge the wide-copy gate silently stops matching the proposal threshold. Use thesamconstant: 2 lines and a correctness hazard.- A visible nit not counted above: the
draft_sourcewire→enum ladder is written three times —runtime_core/serving.rs:58-63,heliopause/src/python.rs:225-233,runtime_core/selection.rs:144-148— where oneProposalSource::from_wire(~15 lines) would do.
Left behind by the change (should be edited here, not appended to)
docs/cli-design.md:200-201still says--history-drafts"does not change the graphs". It now retains/prunes copy-only graphs, drops kernels and rewritesspeculative_widths(runtime_core/selection.rs:275-298,375-396).docs/mtp-design.md:22-29— "Both settings use the same captured MTP graphs and buffers" is no longer true for the wide copy graphs.docs/mtp-design.md:31-40describes only the shared ring, never the per-requestPromptOutputSAMthat now takes precedence (scheduler.rs:1099-1101).docs/scheduling-theory.md:726-727still asserts "Idle discards positive credit", contradictingrefresh.rs:95-105and the editeddocs/scheduling-runtime-design.md(not opened).RequestScheduler::history_proposal/DecodedHistory::lookup(finding 8) andRefreshState::idle(finding 7) are dead entry points this PR leaves in place.
Size accounting
25 files, +3968 / −119 (summed from pr_files). Tests only: model/tests.rs (not opened) +324, policy_tests.rs +504, scheduler/tests.rs +583, plus ~30 lines of draft_source: churn. Production: sam.rs +1,606 (of which ~370 are its own tests/benchmark), rounds.rs +194, scheduler.rs +180, cost.rs +120, policy.rs +119, selection.rs +109, speculation.rs +103.
Estimated removable: 250 + 100 + 100 + 95 + 40 + 35 + 20 + 18 + 55 ≈ 713 lines, in 9 places (~18% of the change), none of it behaviour. That is consistent with the repository's own automated review of this PR (2026-11-26 17:56), which independently listed the copy-loop duplication (~100), dead SAM API (~150), RefreshState::idle, the three-way ProposalSource ladder, and 150-250 test lines, for 550-685.
Not findings (checked and kept)
- The four behaviours themselves: each maps to a stated gap (stale cost across idle, prompt-blind drafts, the MTP-width ceiling, over-padded ragged batches) with a measurement in the description.
- The
MutableEdges/RootedLctstructure insidesam.rs: ~600 lines, but it is the implementation of O(log M) recency updates; the repository has no existing structure that would replace it. - The
draft_sourcemetadata and its validation: no Protobuf wire change, andselection.rsneeds it to prune copy graphs when--history-draftsis off.
Open questions
- Whether the wide-copy
W=16/W=24path, which carries the largest new blocks (speculation.rs+103,selection.rs+109, half ofrounds.rs), has been exercised on GPU at all — the description lists copy-only wide graph GPU export/replay as a limitation, so part of finding 2's merged loop may be dead for now rather than merely duplicated. - Whether
Candidate.expectedwas kept deliberately overratefor readability; the PR's automated review defends it, so the recommendation is to drop the duplicate accumulators rather than to pick a field.