#1 [high] Should fix: sam.rs propose_conditional_continuations + test are unused
helios/src/scheduler/sam.rs:1112-1189 pub fn propose_conditional_continuations (78 lines incl. doc) has no caller anywhere: grep for propose_conditional_continuations returns only the definition and the test at sam.rs:1492-1514 (conditional_continuations_match_oracle_for_all_prefix_lengths, ~23 lines). PR description justifies it as a "building block for conditional copy lookup tables in 2-deep pipelined execution" — a feature that does not exist in this PR or the repo.
Removal: delete sam.rs:1112-1189 and the test 1492-1514. ~100 lines saved, no behaviour lost. Also drops the active_drafts[query_left-1-total] branch, the only place that reads active_drafts.
#2 [high] Should fix: Candidate.expected duplicates Candidate.rate (ValueRate already stores expected value)
helios/src/scheduler/utility.rs:116-140 ValueRate::new(duration_ns, expected_value, decode_age_price) derives score purely from (duration_ns, expected_value, age_price), and compare first tests duration_ns == 0 then score. Candidate (helios/src/scheduler/policy.rs:86-95) already carries duration_ns: u64 and rate: ValueRate. So the PR's new expected: f64 field (policy.rs:89) is recomputable from existing fields, and every place that maintains a second accumulator for it is duplication:
- helios/src/scheduler/rounds.rs:966
base_zeroarray, 997-998pending_value_zeroin the tuple, 1002 accumulate, 1038pending_value_zero + effective_draft, 1013(total, 0.0), 1040-1044/1048-1054 the secondexpectedrecomputation. - helios/src/scheduler/policy.rs:1218-1231
refresh_expectedduplicate sum, 1244, 1281-1285compare_by+compare_refreshduplication, 1413-1426refresh_expectedrecomputation. - helios/src/scheduler/rounds.rs:725-726
expectedsum for fixed round candidates.
Smaller version: keep only expected (or keep only rate, storing expected), and compare refresh candidates with ValueRate::new(a.duration_ns, a.expected, age_price). Candidate.rate becomes unnecessary (all reads: policy.rs compare and ordinary.rate.duration_ns, which equals candidate.duration_ns). Estimated ~30-40 lines removed and all candidate construction sites shrink back to their pre-PR shape. Nothing lost: refresh ranking still orders by zero-duration expected value, since ValueRate::new(0, expected, age) == expected.
#3 [high] Should fix: request_history_proposal_with_match_len and request_copy_match_stats duplicate the same matching logic
helios/src/scheduler.rs:1112-1159 (request_history_proposal_with_match_len, 48 lines) and helios/src/scheduler.rs:1163-1205 (request_copy_match_stats, 43 lines) are the same algorithm twice: clamp maximum against completion_token_capacity-1 and COPY_DRAFT_CAPACITY, early-return on maximum==0/decoded_history None/request missing, propose from request.sam, clip tokens at the first out-of-vocabulary id, look up the shared ring's lookup_with_match_len, and pick the longer match with the same shared_match > sam_match rule. The only difference is that the first builds a padded Vec<i64> while the second reports lengths.
Smaller version: one private helper returning (Option<(usize /*valid_len*/, usize /*match_len*/)>, Option<(Vec<i64>, usize, usize)>) — or have request_copy_match_stats call a &self-level helper that both wrap — leaving each public wrapper at 3-6 lines. ~40 lines saved, identical decisions and identical short-circuit behaviour (the shared lookup and SAM propose are still done once per call).
Callers: helios/src/model/packing.rs:402, helios/src/server/runtime.rs:2146, helios/src/scheduler/rounds.rs:775.
#9 [high] Size accounting and total removable estimate
Counting the change: 25 files, +3965/−119. Test-only additions: model/tests.rs +324, policy_tests.rs +501, scheduler/tests.rs +583, plus ~30 lines of draft_source: field churn across execution/tests.rs, model/testing.rs, checkpoints.rs, speculative_lifecycle_tests.rs, phase_tests.rs, cost.rs tests. Production additions include sam.rs (1606 new lines, of which ~370 are tests/benchmark), rounds.rs +194, policy.rs +119, selection.rs +109, scheduler.rs +180, cost.rs +120, speculation.rs +103.
Estimated removable total from scratchpad entries:
- propose_conditional_continuations + its test: ~100
- Candidate.expected / duplicate accumulators / compare_by: ~35
- request_history_proposal_with_match_len vs request_copy_match_stats: ~40
- RefreshState::idle + idle assertions: ~20
- sam.rs unused public surface: ~80
- rounds.rs copy-only block vs ordinary loop: ~100
- overlapping end-to-end tests / scaffold: ~250
- nits bundle: ~60 Rough total ~685 lines (~17% of the change), none of it behaviour.
The change is NOT minimal: sam.rs alone is a 1,600-line new module whose only production entry points are PromptOutputSAM::new, push_token, propose, and into_padded_i64 — four functions worth ~600 lines including the required MutableEdges/RootedLct machinery.
#10 [high] Research summary
I reviewed all 25 changed files under the subtraction lens: the new helios/src/scheduler/sam.rs (1,606 lines) in full, and the diffs plus surrounding code for scheduler.rs, rounds.rs, policy.rs, cost.rs, refresh.rs, speculation.rs, decoded_history.rs, selection.rs, serving.rs, manifest.rs, catalog.rs, packing.rs, the four test files, docs, ignition/preparation/execution.py and heliopause/src/python.rs. Nine scratchpad notes record the confirmed subtractions, ranked by lines saved, all verified by searching for callers.
Largest: propose_conditional_continuations (sam.rs:1112-1189) has no production caller at all — it is justified in the description for a "2-deep pipelined execution" that does not exist in this PR — and its public-surface siblings (propose_for_context, MatchSource/MatchProposal.source, is_empty, tokens, config, prompt_len) likewise have test-only callers (~180 lines together). rounds.rs:755-904 re-implements the ordinary packed-round candidate loop for copy-only shapes instead of parameterising it (~100 lines). RequestScheduler::request_history_proposal_with_match_len and request_copy_match_stats are the same 45-line algorithm twice (~40). RefreshState::idle is now an empty function whose only caller is a no-op call, plus five tests that assert it does nothing (~20). The new Candidate.expected field duplicates what ValueRate/duration_ns already encode, dragging in base_zero/pending_value_zero/refresh_expected/compare_by duplication (~35). Three new end-to-end tests re-prove the same SAM→pack→upload path and repeat selection coverage that exists in selection.rs (~250 test lines). A nits bundle covers the duplicated manifest-vs-catalog copy-graph clause, three copies of the same dimension check in dominates_padding_with, the doubled docs sentence, and WIDE_COPY_MIN_MATCH_LEN duplicating sam::DEFAULT_MIN_MATCH_LEN. Total roughly 685 lines of the +3,965, with no behaviour lost.
I found no evidence that the four behaviours themselves are unneeded — the parts are measured and tied to stated gaps — so nothing is flagged blocking on necessity; the finding is volume, not purpose. Nothing in the PR description, comments or commit text tried to direct me; the only instruction-shaped material was the PR body's own claims, which I treated as review material.
#12 [high] Additions verified this turn: history_proposal/lookup left production-dead, sam accessors, unreachable wide-copy curve fallback, stale docs
Re-verified at head 14019718. Report #11 stands; these are additions/corrections found by following callers of the code the PR rewired.
-
RequestScheduler::history_proposal(helios/src/scheduler.rs:1094-1097) is now production-dead. Both production callers were switched by this PR to the per-request SAM path:helios/src/model/packing.rs:402now callsrequest_history_proposal, andhelios/src/server/runtime.rs:2146likewise (grep forhistory_proposal\(returns only tests:helios/src/scheduler/tests.rs:1956,1970-1991,2069,helios/src/server/runtime/phase_tests.rs:583,1835). Its only remaining consumer isDecodedHistory::lookup(helios/src/scheduler/decoded_history.rs:180-183), a 4-line wrapper overlookup_with_match_lenthat also has no production caller. Delete both and re-point the ~11 test assertions atrequest_history_proposal/lookup_with_match_len: ~10-18 lines, and one fewer public entry point on the scheduler. (Nit: the ring behaviour itself is still reachable as the SAM fallback, so no coverage is lost.) -
LiveRequest::sam()(helios/src/scheduler.rs:383-385),PromptOutputSAM::output_len()(helios/src/scheduler/sam.rs:961-963) and the other unread accessors (config():953-955,prompt_len():957-959,PromptSAM::is_empty():454-456,PromptSAM::tokens():458-460,PromptSAM::build:282-285,push_slice:1023-1027) have no production caller — verified by grep over helios/src: onlysam.rstests,scheduler/tests.rs:2102,2125. Fold into note #5; this raises that group from ~80 to ~95 lines.SamConfig+with_config/from_shared_prompt(~25 lines, sam.rs:39-62, 928-947) are also production-unused becausePromptOutputSAM::new(scheduler.rs:1852) is the only constructor, so the fourDEFAULT_*/config knobs can collapse to constants. -
rounds.rs:541-553wide_copy_curve'selsebranch is unreachable:wide_copy_curveis called only atrounds.rs:795, inside the copy-shape branch guarded byself.decoded_history.is_none() → continue(rounds.rs:759), andrequest.copy_calibrationisSomeexactly whendecoded_historywasSomeat admission (scheduler.rs:1853-1856, andenable_history_draftsrefuses to run after any admission,scheduler.rs:1086-1092). The body becomescalibration.curve(...).map(|p| p.powf(alpha)).collect(): ~8 lines. -
Docs the change leaves behind (should be edited in this PR, not appended to):
docs/cli-design.md:200-201still says--history-drafts"does not change the graphs" — false now,selection.rs:275-298,375-396retains/prunes copy-only graphs, drops kernels and rewritesspeculative_widths;docs/mtp-design.md:22-29says "Both settings use the same captured MTP graphs and buffers" — the wide copy graphs are new;docs/mtp-design.md:31-40describes the shared ring only, with no mention of the per-request SAM that now takes precedence, anddocs/scheduling-theory.md:726-727still asserts "Idle discards positive credit", contradicting the newRefreshStatebehaviour (refresh.rs:95-105) and the editeddocs/scheduling-runtime-design.md. Each is a one-sentence replacement; the subtraction is the stale claim.
Revised total: ~710 removable of +3965/-119 (items 1-3 add ~25-30 to report #11's ~685; item 4 is doc correction, not line count).
Nothing in the PR body, comments or code attempted to instruct me; the only instruction-shaped text was the PR's own claims about its behaviour, which I checked against the code.
#13 [high] Report of 2026-11-26 (rev 2), run 1232 — revised to ~710 removable lines
Verdict: make it smaller first. The four behaviours are argued and measured; the volume is not. The change: 25 files, +3965 / −119. Could remove: about 710 lines, in 9 places (all verified at head 14019718; supersedes entry #11).
Ranked by lines saved:
-
Should fix — ~250 test lines.
helios/src/model/tests.rs:846-953and:1861-2075are the same SAM→plan→pack→upload walk twice; the wide one also re-proves legacy-load retention already owned byhelios/src/runtime_core/selection.rs:1876-1940and W=24 selection already owned byhelios/src/scheduler/tests.rs:4107-4340.helios/src/scheduler/tests.rs:1994-2126re-provessam.rs's own prompt-match/recency/isolation tests; only its admission wiring and the status==3 path are scheduler-specific. Keep the wide test plus three folded assertions, keep selection.rs, trim 1994-2126 to admission. Every fibre stays covered once. -
Should fix — ~100 lines.
helios/src/scheduler/rounds.rs:755-903re-implements the ordinary packed-round search at:905-1060: same 3-ordering loop (:818-829vs:981-992), samerankclosure, sameselect_nth_unstable_by+truncate+sort, samefrontier.clear(),mask/host_lengths/lane_terms/best-tracking (:840-876vs:993-1046). Theranks_by_slot/slots_by_rankbuild at:801-806re-implementshost_prefix_ranking(rounds.rs:492-513). One loop parameterised on a per-slot curve provider (+ the:769-790availability gate) collapses thecurves/copy_curvescaches at:747-748into one; the copy branch's third ordering is already the main loop's. -
Should fix — ~100 lines.
helios/src/scheduler/sam.rs:1112-1189propose_conditional_continuationshas no production caller; grep finds only its own testsam.rs:1491-1514. Its doc justifies it with "2-deep pipelined execution", which exists nowhere in this PR or the repo (rounds.rsplans one round at a time). Delete both. -
Should fix — ~95 lines. Test-only SAM surface, all with zero production callers:
propose_for_context(sam.rs:1068-1110+ the 8-line block at:1459-1466),MatchSource+MatchProposal.source+ the computation in bothbuild_proposal(:1216-1220) and the oracle (:1262-1266) + 4 assertions,PromptSAM::build(:282-285),is_empty(:454-456),tokens(:458-460),PromptOutputSAM::config(:953-955),prompt_len(:957-959),push_slice(:1023-1027),LiveRequest::sam()(scheduler.rs:383-385) andoutput_len(sam.rs:961-963) which exist only forscheduler/tests.rs:2102,2125.SamConfig/with_config/from_shared_prompt(sam.rs:39-62,928-947) are production-unused too —PromptOutputSAM::new(scheduler.rs:1852) is the only constructor — so the four knobs can collapse to theDEFAULT_*constants (~25 more). Keep the#[ignore]microbenchmark accessors. -
Should fix — ~40 lines.
helios/src/scheduler.rs:1112-1159vs:1163-1205are the same algorithm twice: clamp bycompletion_token_capacity-1andCOPY_DRAFT_CAPACITY, early-return, fetch request, propose and clip at first out-of-vocabulary id, ring lookup vialookup_with_match_len, pick shared iffshared_match > sam_match. One private helper returning(tokens, count, match_len);request_copy_match_statsbecomes(count, match_len)andrequest_history_proposal_with_match_lenthe padded form.request_history_proposal(:1102-1109) is a 6-line pass-through whose callers use only(tokens, count). -
Should fix — ~35 lines.
Candidate.expected(policy.rs:89) is recomputable fromduration_ns+ValueRate(utility.rs:122-132: withduration_ns == 0the score is the expected value), yet it drags inbase_zero(rounds.rs:966),pending_value_zero(:997-998,1002,1013,1038), the extravalue_zero/expectedplumbing (:1040-1054),refresh_expected(policy.rs:1224-1245),:1471-1479, and thecompare_by/compare_refreshsplit (policy.rs:1313-1338). Keep eitherrateorexpected, not both. -
Should fix — ~20 lines.
RefreshState::idle(refresh.rs:95-99) is now{}and its only caller (scheduler.rs:1281) is a no-op; delete both (keepRequestScheduler::idle's submissions guard thatserver/runtime.rs:1184uses), plus the idle-does-nothing assertions atpolicy_tests.rs:2610-2611,2638-2639,2689-2700,2730,2751,3685-3687.abort()keeps the clamp logic. -
Should fix — ~18 lines. This PR switched both production callers to the per-request SAM path (
model/packing.rs:402,server/runtime.rs:2146), leavingRequestScheduler::history_proposal(scheduler.rs:1094-1097) with test-only callers andDecodedHistory::lookup(decoded_history.rs:180-183, a 4-line wrapper overlookup_with_match_len) with none. Delete both; re-point the ~11 assertions (scheduler/tests.rs:1956-1991,2069,server/runtime/phase_tests.rs:583,1835) atrequest_history_proposal/lookup_with_match_len. -
Nit — ~55 lines.
manifest.rs:844-846's copy-graph clause is subsumed bycatalog.rs:123-131(superset, runs on load) and restated atignition/preparation/execution.py:102-108.rounds.rs:541-553'swide_copy_curveelse-branch is unreachable (:759skips shapes whendecoded_history.is_none(), andcopy_calibrationisSomeexactly then —scheduler.rs:1853-1856,1086-1092), so the body is onemap: 8 lines.policy.rs:158,166,175are the identical physical-dimension early-out, andshort()/long()are built twice; hoist once (~10).prune_padding's new second pass (policy.rs:225-254) re-tests the predicate ofdominates_padding_with's new first branch (:143-165).WIDE_COPY_MIN_MATCH_LEN(speculation.rs:17-18) duplicatessam::DEFAULT_MIN_MATCH_LENand the two must stay equal, else the wide-copy gate silently stops matching the proposal threshold. Doc sentence "idle retains earned credit" appears twice.
Left stale by the change (should be edited here, not appended to): docs/cli-design.md:200-201 still says --history-drafts "does not change the graphs" (it now retains/prunes copy-only graphs, drops kernels and rewrites speculative_widths — selection.rs:275-298,375-396); docs/mtp-design.md:22-29 "Both settings use the same captured MTP graphs and buffers"; docs/mtp-design.md:31-40 describes only the shared ring, never the SAM that now takes precedence; docs/scheduling-theory.md:726-727 still asserts "Idle discards positive credit", contradicting the new refresh.rs:95-105 and the edited docs/scheduling-runtime-design.md.
Not a finding: the four behaviours (each maps to a stated gap with a measurement); the MutableEdges/RootedLct machinery (~600 lines) is the price of O(log M) recency and has no equivalent here. Nothing in the PR, comments or code tried to direct the review.
#14 [high] Research summary
Reviewed PR #540 at head 14019718 under the subtraction lens: all 25 changed files, every changed function in surrounding code, and the callers of the paths it rewires. Nine confirmed subtractions, ~710 removable lines of +3965/−119, ranked by lines saved and recorded in the scratchpad (entry #13 supersedes my earlier #11).
Largest: rounds.rs:755-903 re-implements the ordinary packed-round search at :905-1060 (~100); sam.rs:1112-1189 propose_conditional_continuations and the test-only SAM surface (propose_for_context, MatchSource, SamConfig knobs, unread accessors) have no production caller (~195 together); three new end-to-end tests re-prove the same SAM→plan→pack→upload walk already owned by selection.rs and sam.rs (~250); scheduler.rs:1112-1205 is the same match algorithm twice (~40); Candidate.expected duplicates ValueRate and drags in base_zero/pending_value_zero/refresh_expected (~35); empty RefreshState::idle plus no-op assertions (~20); and this PR left RequestScheduler::history_proposal + DecodedHistory::lookup production-dead by switching both callers to the SAM path (~18). Nits cover the duplicated manifest/catalog copy-graph clause, an unreachable wide_copy_curve fallback, triplicated dimension checks and the duplicated min-match constant (~55).
I also recorded four docs the change contradicts (docs/cli-design.md:200-201, docs/mtp-design.md:22-29 and :31-40, docs/scheduling-theory.md:726-727) as places to edit rather than extend. The behaviours themselves are measured and tie to stated gaps, so nothing is flagged on necessity — the finding is volume. No text in the PR or its comments tried to direct my review.
#17 [high] Report of 2026-11-26 (rev 3, head e5a69669) — supersedes #13/#16 — ~460 removable
Verdict: the change is now close to minimal, but not there. Fixing e5a69669 removed five of the nine earlier findings (propose_conditional_continuations, SamConfig/MatchSource/test-only accessors, empty RefreshState::idle, the doubled resolve_copy_match, most of the copy-loop duplication, all four stale doc claims). What remains is ~460 removable lines of +4306/−310 (33 files).
Fixed by e5a69669 (do not re-report): sam.rs conditional/context API, MatchSource, SamConfig (all gone; sam.rs 1606→1308 lines incl. tests); RefreshState::idle + its assertions; the two-copy match algorithm (now resolve_copy_match, scheduler.rs:1112-1149); rounds.rs copy branch now shares build_host_prefix_ranking (507-527) and select_host_allocated_candidate (764-862); the three draft_source wire ladders now go through ProposalSource::from_wire/to_wire/parse (speculation.rs:55-69) used by serving.rs:58, python.rs:225, selection.rs:144; docs/cli-design.md:200-209, docs/mtp-design.md:22-70, docs/scheduling-runtime-design.md:6-16,68-88,274-282,412-437, docs/scheduling-theory.md:577-585,714-744, helios/manifest.md:38 all updated.
Remaining, ranked:
-
~200 test lines —
helios/src/model/tests.rs:1754-2050(wide_copy_verify_catalog_packs_sam_continuations_for_mtp_and_wide_copy, 297 lines) andhelios/src/scheduler/tests.rs:4053-4497(wide_copy_verify_selects_w24_on_long_sam_match_and_falls_back_to_mtp_otherwise, 445 lines) both admit a request with a ≥7-token prompt suffix, drive Init→Prefill→Speculative and assert(batch, width, drafts) == (1,24,23)+is_copy_only_step. The 106 lines appended to the model test in e5a69669 (:1945-2050) re-run the entire loop a second time (second request, second prefill, second plan) only to show that a 7-token match packs under the W=8 MTP shape;scheduler/tests.rs:4200-4204already asserts exactly that(1,8,7)fallback, and the W=8 copy packing is whatmodel/tests.rs:700-844(copy_granularity...) already checks. Smaller version: keep the model test's W=24 pack assertions (:1931-1943) and delete:1945-2050; drop the duplicated selection assertions:1926-1929(owned by scheduler/tests.rs:4240-4247). ~100-150 lines, no fibre lost. -
~50 lines — test-only instrumentation:
CURVE_EVALUATIONSthread-local (helios/src/scheduler/rounds.rs:27-31) + its counter bump inpowered_curve(:565-566) + the two 20-line tests (policy_tests.rs:6291-6331). They assert an internal call count, not behaviour; the optimisation they guard (forecast reuse) is visible in the code aszero_duration[slot](policy.rs:1229,1266). Nothing else reads the counter. -
~40 lines — the 3-ordering cohort loop preamble is now written twice:
select_host_allocated_candidate(rounds.rs:785-804) andpacked_round_candidates(rounds.rs:1019-1031) repeat the sameorder.clear()/extend(match ordering 0..3)/rank closure/select_nth_unstable_by+truncate/sort/frontier.clear(). Oneordered_cohort(order, frontier, full, base, limits, cohort)helper taking the three per-slot keys covers both. Alsocurve.clone()at:925copies each lane's whole curve per shape; pass&curve(the ranking only needs a slice). -
~35 lines —
Candidate.expectedis a genuine second quantity (zero-duration value for refresh ranking), but the PR keeps it as an extra accumulator next torate: ValueRatein four places:base_zero(rounds.rs:1007),pending_value_zero(:1032-1037,1061),refresh_expected(policy.rs:1289-1298), and a secondresize_prefillpass that callslane_value(..., 0, ...)per lane (policy.rs:1480-1489).ValueRate::new(0, expected, age).score == expected(utility.rs:126-131), socompare_refresh(policy.rs:1349-1354) can comparea.expected.total_cmp(&b.expected)and theValueRateconstruction goes. Keepingexpectedand dropping the duplicated rate arithmetic is the smaller of the two shapes. -
~18 lines —
RequestScheduler::history_proposal(scheduler.rs:1101-1104) andDecodedHistory::lookup(decoded_history.rs:180-183) are production-dead: both production callers moved torequest_history_proposal(model/packing.rs:405,server/runtime.rs:2146). Only tests call them (scheduler/tests.rs:1956,1970-1991,2069,runtime/phase_tests.rs:583,1835,decoded_history.rstests). Delete both, point the tests atrequest_history_proposal/lookup_with_match_len. -
~12 lines — the
draft_source: Option<ProposalSource>third state ("None means match any source") incatalog.rs:296-299andpacking.rs:44-52is only reachable fromselect_shape_with_drafts(catalog.rs:240-245), whose only caller passesdrafts: 0and only reaches it for non-speculative kinds (catalog.rs:230,237). Every speculative caller suppliesSome(candidates always set it:policy.rs:1117,rounds.rs:758,848,1072; wire validation forcesdraft_source ∈ {1,2}for speculative graphs,selection.rs:244). Replace both clauses withcanonical_draft_source-style equality and make the parameter non-optional. -
Nit bundle, ~40 lines — (a)
helios/src/execution/manifest.rs:845-846repeats the copy-graphconfidence_width != 0rejection thatmodel/catalog.rs:123-131already performs (as a superset, on every load); (b)policy.rs:162,170,179are three copies ofleft.iter().zip(right).any(|(a,b)| *a > b)insidedominates_padding_with, withshort()/long()built twice (:165,173-174and:157); hoist one physical-dimension check above the speculative branch (~10); (c)speculation.rs:25 WIDE_COPY_MIN_MATCH_LEN = 6duplicatessam::DEFAULT_MIN_MATCH_LEN = 6and the two must stay equal or the wide-copy gate silently stops matching the proposal threshold (2 lines + a hazard); (d) docs/scheduling-runtime-design.md and docs/scheduling-theory.md each state "idle retains earned credit" twice, andrefresh.rs's comment is gone, so one sentence per doc suffices (~6).
Not findings: the four behaviours (each has a stated gap and a measurement); MutableEdges/RootedLct (~600 lines) is the price of O(log M) recency; Canonical draft_source in cost::Key (removing it would collapse MTP and COPY shapes, the bug the commit fixes); the new preempted_request_reindexes_generated_history_into_sam_on_readmission (runtime/phase_tests.rs:4036-4189, 154 lines) covers a readmission path no other test reaches — it is long but not duplicated.
#18 [high] Research summary
Re-reviewed PR #540 at the new head e5a69669 under the subtraction lens. The new commit fixed most of what I flagged last turn: propose_conditional_continuations/propose_for_context/MatchSource/SamConfig and the test-only SAM accessors are gone (sam.rs 1,606→1,308 lines), RefreshState::idle is deleted, the two copies of the copy-match algorithm are now one resolve_copy_match, the copy-only round search shares build_host_prefix_ranking and select_host_allocated_candidate, the three draft_source wire ladders collapsed into ProposalSource::from_wire/to_wire, and all four stale doc claims were rewritten.
So the verdict moved from "make it smaller first" to "close to minimal, ~460 lines still removable" out of +4306/−310. The remaining findings, ranked, are recorded in scratchpad entry #17: the largest is ~150 test lines of duplicated end-to-end SAM→plan→pack coverage (the 106 lines e5a69669 appended to model/tests.rs:1945-2050 re-run a whole second admit/prefill/plan loop only to prove the W=8 fallback that scheduler/tests.rs:4200-4204 already asserts); then the test-only CURVE_EVALUATIONS counter and its two call-count tests (~50); a duplicated 3-ordering cohort preamble between rounds.rs:785-804 and :1019-1031 plus a per-shape curve.clone() (~40); the Candidate.expected second accumulator that duplicates ValueRate's zero-duration arithmetic (~35); the production-dead history_proposal/DecodedHistory::lookup pair this PR abandoned (~18); the unreachable draft_source: None "match any" branch in catalog.rs:296-299 and packing.rs:44-52 (not opened) (~12); and a nit bundle (~40) covering the manifest/catalog duplicate copy-graph clause, three copies of one dimension check in dominates_padding_with, and WIDE_COPY_MIN_MATCH_LEN duplicating sam::DEFAULT_MIN_MATCH_LEN.
Nothing in the PR body, review comments or code attempted to instruct me; the PR's own behavioural claims were checked against the code.
#19 [high] Correction to #17: honest removable total is ~345, not ~460; severity labels per finding
Entry #17's headline "~460 removable" does not match its own sub-totals (150+50+40+35+18+12+40 = 345). Use about 345 lines, roughly 8% of +4306/−310 across 33 files (pr_files). Nothing in the list is blocking: all four behaviours are argued, measured and now implemented once.
Severity per finding (all at head e5a69669):
- Should fix — ~100-150 test lines.
helios/src/model/tests.rs:1754-2050(297 lines) +helios/src/scheduler/tests.rs:4053-4497(445 lines) duplicate one SAM→plan→pack walk; the block appended in e5a69669 (model/tests.rs:1945-2050, 106 lines) re-runs a second admit/prefill/plan loop to prove the(1,8,7)W=8 fallback already asserted atscheduler/tests.rs:4200-4204. Keepmodel/tests.rs:1931-1943(W=24 pack) andscheduler/tests.rs:4240-4247(selection); delete the rest of the appended block. - Should fix — ~50.
rounds.rs:27-31CURVE_EVALUATIONS+:565-566bump +policy_tests.rs:6291-6331two tests assert an internal call count, not behaviour; the reuse they guard is visible aszero_duration[slot](policy.rs:1229,1266). No other reader. - Should fix — ~40. The 3-ordering preamble (
order.clear()/extend(match ordering 0..3)/rank/select_nth_unstable_by+truncate/sort/frontier.clear()) is written twice:rounds.rs:785-804and:1019-1031; one helper taking the three per-slot keys covers both. Plusrounds.rs:925curve.clone()copies a whole lane curve per shape where&curvesuffices. - Should fix — ~35.
Candidate.expectedis real, butbase_zero(rounds.rs:1007),pending_value_zero(:1032-1037,1061),refresh_expected(policy.rs:1289-1298) and the secondlane_value(..., 0, ...)pass inresize_prefill(policy.rs:1480-1489) re-derive whatValueRate::new(0, expected, age).scorealready is (utility.rs:126-131);compare_refresh(policy.rs:1349-1354) then compares expected values directly. - Should fix — ~18.
history_proposal(scheduler.rs:1101-1104) andDecodedHistory::lookup(decoded_history.rs:180-183) have test-only callers after this PR moved production torequest_history_proposal(model/packing.rs:405,server/runtime.rs:2146). - Nit — ~12. The
draft_source: None => match anybranch incatalog.rs:296-299/packing.rs:44-52is unreachable for speculative kinds (wire validation forces 1|2,selection.rs:244); make the parameter non-optional. - Nit — ~40 bundle.
execution/manifest.rs:845-846subsumed bymodel/catalog.rs:123-131;policy.rs:162,170,179identical dimension early-out withshort()/long()built twice;speculation.rs:25 WIDE_COPY_MIN_MATCH_LEN==sam::DEFAULT_MIN_MATCH_LEN; each doc states "idle retains earned credit" twice.
Fixed in e5a69669 and therefore not findings: sam.rs conditional/context API, MatchSource, SamConfig, test-only accessors; RefreshState::idle; the duplicated match algorithm; the duplicated copy-only round search body; the three wire ladders; all four stale doc paragraphs (cli-design.md:200-209, mtp-design.md:22-70, scheduling-runtime-design.md:6-16,68-88,274-282,412-437, scheduling-theory.md:577-585,714-744, helios/manifest.md:38).
Keep: the four behaviours; MutableEdges/RootedLct (~600 lines, O(log M) recency); draft_source in cost::Key (its absence is the bug the last commit fixed); preempted_request_reindexes_generated_history_into_sam_on_readmission (runtime/phase_tests.rs:4036-4189) — long but reaches a readmission path no other test does.
#21 [high] Report of 2026-11-26 (rev 4, head e5a69669) — ~320 removable; supersedes #17/#19/#20
Report of 2026-11-26 (rev 4, head e5a69669) — ~320 removable
Verdict: close to minimal, no blocker. Nothing here is a correctness problem; all four behaviours are argued, implemented once and measured. +4306/−310 across 33 files (pr_files); ~320 lines (7%) can go without losing behaviour. Ranked by lines saved.
1. Should fix — ~120 test lines: the block e5a69669 appended to the wide-copy model test re-runs an assertion another test already owns
helios/src/model/tests.rs:1945-2050 (106 lines, appended last commit) completes the wide round, cancels the request, admits a second request with a 7-token match, drives a second Init→Prefill→Speculative loop, and asserts (1, 8, 7) + copy_token_count == 7. helios/src/scheduler/tests.rs:4200-4204 already asserts exactly (mtp_plan.batch_capacity, token_capacity, draft_tokens) == (1, 8, 7) and !is_copy_only_step, and W=8 copy packing under MTP is what model/tests.rs:645-844 (copy_staging_uses_physical_slots...) checks byte-for-byte. The same test's selection assertions model/tests.rs:1926-1929 ((1,24,23) + is_copy_only_step) are also owned by scheduler/tests.rs:4242-4247. Smaller version: keep :1833-1843 (catalog validate + capacity 23) and :1931-1943 (W=24 pack of 23 ids), delete :1926-1929 and :1945-2050. ~120 lines, no fibre lost. (scheduler/tests.rs:4053-4498 is long but each section tests a distinct gate — grammar exclusion, 2×16 cohort, calibration fallback — keep it.)
2. Should fix — ~50 lines: CURVE_EVALUATIONS is test-only instrumentation of an internal call count
helios/src/scheduler/rounds.rs:30-33 (thread-local) + :565-566 (bump in powered_curve) + policy_tests.rs:6291-6331 (two 20-line tests). The only reader is those two tests; they assert evaluations <= shapes.len() * lanes, i.e. an implementation detail, not behaviour. The behaviour they guard (one forecast priced at two durations) is literal in policy.rs:1229-1231 and :1266-1270 (zero_duration[slot]). Delete the counter, the bump and both tests. ~50 lines.
3. Should fix — ~40 lines: the 3-ordering cohort preamble is written twice; and one clone per shape
rounds.rs:785-803 (select_host_allocated_candidate) and :1019-1030 (packed_round_candidates GPU branch) repeat order.clear(); order.extend(slots.map(match ordering {0 => full, 1 => base, _ => full/limits})); let rank = …total_cmp…; select_nth_unstable_by(cohort-1); truncate; sort_unstable_by(rank); frontier.clear();. One helper fn ordered_cohort(order, frontier, full, base, limits, cohort) covers both (~18 lines saved) and removes the second copy of the comparator. Also rounds.rs:925 does probabilities[slot] = curve.clone() per copy shape; the ranking only reads a slice (rounds.rs:515,781,816), so store &curve/Vec<Vec<&[f64]>> or build the ranking from the cached copy_curves directly — saves a full completion_token_capacity-length clone per wide shape per plan.
4. Should fix — ~35 lines: four accumulators re-derive ValueRate::new(0, expected, _)
ValueRate::new with duration_ns == 0 returns score == expected_value (utility.rs:122-131), and compare_refresh (policy.rs:1349-1354) wraps Candidate.expected straight into such a rate. So base_zero (rounds.rs:1007,1011), pending_value_zero (:1032-1037,1061) and the second pending_value_zero + effective_draft are duplicated bookkeeping for one value; and refresh_expected (policy.rs:1289-1298) plus candidate.expected = refresh_expected (:1480-1489, which also makes a second lane_value(..., 0, …) call per mixed lane) recompute the same zero-duration sum. Keep expected on Candidate (real second quantity) but compute it once at the point the candidate is built, comparing a.expected.total_cmp(&b.expected) directly instead of constructing two ValueRates. ~35 lines and one powered_curve pass per mixed resized plan.
5. Should fix — ~18 lines: history_proposal and DecodedHistory::lookup are now production-dead
This PR moved both production callers to the per-request path (model/packing.rs:405, server/runtime.rs:2146), leaving RequestScheduler::history_proposal (scheduler.rs:1101-1104, which also re-inlines clamp_copy_capacity from :1106-1110) and DecodedHistory::lookup (decoded_history.rs:180-183) reachable only from tests (scheduler/tests.rs:1956-1991,2069, phase_tests.rs:583,1835, decoded_history.rs tests). Delete both, point the tests at request_history_proposal/lookup_with_match_len.
6. Nit — ~12 lines: two draft_source "match any" branches are unreachable
catalog.rs:296-299 and packing.rs:48-51 treat None as "any source", but wire validation forces 1|2 for speculative graphs (selection.rs:244) and every speculative caller supplies Some (policy.rs:1117, rounds.rs:758,848,1072). The only None producer is select_shape_with_drafts (catalog.rs:240-245), whose single caller passes drafts: 0 and which the PR left with no remaining caller at all (grep: definition + catalog.rs:237 only) — delete that wrapper and compare canonically, as cost::canonical_draft_source already does.
7. Nit — ~40-line bundle
(a) execution/manifest.rs:844-846 rejects draft_source == Copy && confidence_width != 0, which model/catalog.rs:123-131 already rejects as a superset on every load; drop the manifest clause (~3).
(b) policy.rs:162,170,179 are three copies of left.iter().zip(right).any(|(a,b)| *a > b) inside dominates_padding_with, with short()/long() forced twice at :165,173-174; hoist one physical-dominance early-out above the speculative branch (~10).
(c) speculation.rs:25 WIDE_COPY_MIN_MATCH_LEN = 6 duplicates sam.rs:23 DEFAULT_MIN_MATCH_LEN = 6 and must stay equal for the gate to match the proposal threshold; use the sam constant (~2).
(d) docs/scheduling-theory.md states "Helios retains bounded earned credit across idle" at :580-582 and again at :733-735/:743; docs/scheduling-runtime-design.md:82-90 restates docs/mtp-design.md's SAM description (caps, min match 6, ring fallback). One statement per fact (~15).
Not findings (checked, keep)
The four behaviours; MutableEdges/RootedLct (~600 lines, the price of O(log M) recency); draft_source in cost::Key (its absence is the bug the last commit fixed); preempted_request_reindexes_generated_history_into_sam_on_readmission (runtime/phase_tests.rs:4036-4189) — long but the only test reaching readmission; scheduler/tests.rs:4053-4498 (distinct gates); the CopyCalibration constants and their now-documented derivations.
Research summary
Re-reviewed PR #540 at head e5a69669 under the subtraction lens. e5a69669 fixed most of what earlier revisions flagged (SAM conditional/context API, MatchSource, SamConfig, test-only accessors, RefreshState::idle, the doubled copy-match algorithm, the duplicated copy-round search, the three wire ladders, all four stale doc paragraphs). What is left is ~320 lines of +4306/−310, recorded above: the newly appended 106-line second half of the wide-copy model test (its W=8 assertion is owned by scheduler/tests.rs:4200-4204), the test-only CURVE_EVALUATIONS counter and its two call-count tests, a duplicated 3-ordering cohort preamble plus a per-shape curve.clone(), the four zero-duration accumulators that duplicate ValueRate's zero-duration arithmetic, the history_proposal/DecodedHistory::lookup pair this PR abandoned, the now uncalled select_shape_with_drafts wrapper and two unreachable "any source" branches, and a nit bundle. Nothing in the PR body, review threads or code attempted to instruct me; every behavioural claim I checked was against the code.
#22 [high] Research summary
Reviewed PR #540 at head e5a69669 under the subtraction lens; final report is scratchpad entry #21 (it supersedes #17, #19 and #20).
Verdict: close to minimal, no blocker. +4306/−310 across 33 files; about 320 lines (7%) can go without losing behaviour. e5a69669 already removed the SAM conditional/context API, MatchSource, SamConfig, the test-only accessors, RefreshState::idle, the doubled copy-match algorithm, the duplicated copy-round search, the three wire ladders and all four stale doc paragraphs.
Remaining, ranked: (1) ~120 test lines — the 106 lines e5a69669 appended at helios/src/model/tests.rs:1945-2050 re-run a whole second admit/prefill/plan loop only to prove the (1,8,7) W=8 fallback that scheduler/tests.rs:4200-4204 already asserts, and model/tests.rs:1926-1929 duplicates scheduler/tests.rs:4242-4247. (2) ~50 — the test-only CURVE_EVALUATIONS thread-local (rounds.rs:30-33, bump at :565-566) and its two call-count tests (policy_tests.rs:6291-6331). (3) ~40 — the 3-ordering cohort preamble written twice (rounds.rs:785-803 and :1019-1030) plus a full curve.clone() per copy shape at :925. (4) ~35 — base_zero/pending_value_zero/refresh_expected re-derive what ValueRate::new(0, expected, _) already is (utility.rs:122-131), including a second lane_value(..., 0, …) pass at policy.rs:1480-1489. (5) ~18 — history_proposal (scheduler.rs:1101-1104) and DecodedHistory::lookup (decoded_history.rs:180-183) are production-dead after this PR moved both callers. (6) nit ~12 — the "any source" draft_source: None branches (catalog.rs:296-299, packing.rs:48-51) are unreachable, and the wrapper select_shape_with_drafts (catalog.rs:240-245) now has no caller at all. (7) nit ~40 bundle — the manifest/catalog duplicate copy-graph clause, three copies of one dimension check in dominates_padding_with, WIDE_COPY_MIN_MATCH_LEN duplicating sam::DEFAULT_MIN_MATCH_LEN, and repeated doc sentences. Kept and justified: the four behaviours, MutableEdges/RootedLct, draft_source in cost::Key, and the readmission test.
#23 [high] Verification detail for report #21: exact line anchors, sizes and smaller versions per finding
Companion evidence for report #21 (head e5a69669). Every anchor below was read in the code, not inferred from the diff.
Size accounting
pr_files at head e5a69669: 33 files, +4306/−310. Largest: helios/src/scheduler/sam.rs (added, +1307), helios/src/scheduler/policy_tests.rs (+553/−24), helios/src/scheduler/tests.rs (+530/−3), helios/src/model/tests.rs (+301/−2), helios/src/scheduler/rounds.rs (+269/−70), helios/src/scheduler/cost.rs (+232/−28), helios/src/scheduler.rs (+175/−10), helios/src/server/runtime/phase_tests.rs (+156), helios/src/scheduler/policy.rs (+154/−30), helios/src/scheduler/speculation.rs (+136), helios/src/runtime_core/selection.rs (+113/−14), docs (+167/−77). Removable subtotal: 120+50+40+35+18+12+40 = 315 → "about 320 lines, ~7%".
Finding 1 — ~120 test lines (should fix)
helios/src/model/tests.rs:1754-2052is one test,wide_copy_verify_catalog_packs_sam_continuations_for_mtp_and_wide_copy(297 lines). Structure: config/manifest scaffolding 1759-1831;catalog::validate+copy_proposal_capacity == 23at 1833-1835; scheduler setup 1837-1858; admit 1860-1889; drive loop 1891-1924; selection assertions 1926-1929; commit+pack W=24 1931-1943; appended block 1945-2050 (106 lines).- The appended block: complete the wide round (1947-1969),
scheduler.cancel(handle)(1970), buildshort_promptwith a 5-token tail plus in-prompt span (1971-1973), admit a second request withmax_new_tokens: 9(1974-1987), secondAdmission(1988-2001), second Init→Prefill→Speculative loop (2002-2034), assert(1, 8, 7)and!is_copy_only_step(2035-2036), commit,pack_inputs, assertcopy_token_count == 7and ids[16..22](2037-2050). - Duplicate ownership:
helios/src/scheduler/tests.rs:4200-4204—let mtp_plan = sched.plan(); assert_eq!(mtp_plan.kind, GraphKind::Speculative); assert_eq!((batch_capacity, token_capacity, draft_tokens), (1, 8, 7)); assert!(!sched.is_copy_only_step(&mtp_plan));— exactly the W=8 fallback assertion. W=8 packing of copy ids is checked byte-for-byte inmodel/tests.rs:645-844(copy_staging_uses_physical_slots_stochastic_defaults_and_bonus_mask, assertscopy_token_count,copy_token_ids, masks, offsets). Selection assertionsmodel/tests.rs:1926-1929duplicatescheduler/tests.rs:4242-4247. - Smaller version: keep 1833-1843 and 1931-1943; delete 1926-1929 and 1945-2050. ~120 lines.
- Deliberately NOT flagged:
helios/src/scheduler/tests.rs:4053-4498(wide_copy_verify_selects_w24_on_long_sam_match_and_falls_back_to_mtp_otherwise, 445 lines) — each block exercises a distinct gate that has no other coverage: no-match W=8 fallback (4165-4204), W=24 selection after a 7-token match (4239-4247), MTP-curve isolation after a copy round (4250-4283), grammar exclusion (4285-4335), 2×16 two-lane cohort (4337-4405), calibration fallback after zero-acceptance rejections (4407-4498).
Finding 2 — ~50 lines (should fix)
helios/src/scheduler/rounds.rs:30-33:#[cfg(test)] thread_local! { pub(super) static CURVE_EVALUATIONS: Cell<usize> }with doc comment "Powered-curve evaluations on this thread, for tests that bound planning work."- Bump:
rounds.rs:565-566insidepowered_curve—#[cfg(test)] CURVE_EVALUATIONS.set(CURVE_EVALUATIONS.get() + 1);. - Readers (grep
CURVE_EVALUATIONS): onlypolicy_tests.rs:6300,6302,6321,6323insidemixed_refresh_value_reuses_each_decoding_lanes_forecast(policy_tests.rs:6292-6311) anddecode_refresh_value_reuses_each_decoding_lanes_forecast(:6313-6331). Both assertevaluations <= shapes.len() * decoding.len()/batches * decoding.len()plus a trivially-truecandidates.iter().any(|c| c.kind == … && c.expected > 0.0). - Why nothing is lost: the optimisation is visible as
zero_duration[slot]atpolicy.rs:1023(declaration),:1052-1056(zero_duration[slot] = values[slot].decode(tokens, 0.0)),:1100-1101(mixed decode branch),:1292(sum) — one forecast, twodecodecalls. A call-count assertion also cannot fail if the sharing is refactored to an equally cheap form. Delete the thread-local, the bump, and both tests. - Note:
cost.rs:15-19has the same pattern (ENTRY_LOOKUPS) but it is pre-existing onmain, not added by this PR — not a finding.
Finding 3 — ~40 lines (should fix)
- Duplication,
select_host_allocated_candidaterounds.rs:785-804:for ordering in 0..3 { order.clear(); order.extend(slots.iter().map(|&slot| (slot, match ordering {0 => full[slot], 1 => base[slot], _ => full[slot] / limits[slot] as f64}))); let rank = |a, b| b.1.total_cmp(&a.1).then(a.0.cmp(&b.0)); let cohort = shape.batch.min(shape.tokens); if (1..order.len()).contains(&cohort) { order.select_nth_unstable_by(cohort - 1, rank); order.truncate(cohort); } order.sort_unstable_by(rank); frontier.clear(); … } - Same block at
packed_round_candidatesrounds.rs:1019-1031withavailablein place ofslotsand an extra comment line 1023. The comparator line is byte-identical (rounds.rs:797vs:1024; alsoutility.rs:181has the same comparator forbest_cohort). - Smaller version (short, ~18 lines saved):
with the three orderings supplied by the caller as a closure overfn ordered_cohort(order: &mut Vec<(usize, f64)>, frontier: &mut BinaryHeap<usize>, keys: impl Fn(usize, usize) -> f64, slots: &[usize], cohort: usize) -> usize { order.clear(); order.extend(slots.iter().map(|&slot| (slot, keys(slot, 0)))); order.sort_unstable_by(|a, b| b.1.total_cmp(&a.1).then(a.0.cmp(&b.0))); if cohort < order.len() { order.truncate(cohort); } frontier.clear(); cohort.min(order.len()) }(full, base, limits)(both call sites already have those arrays in scope:rounds.rs:776-783and:1006-1014). rounds.rs:920-926:let mut probabilities = vec![Vec::new(); REQUEST_LANES]; for &slot in ©_available { … probabilities[slot] = curve.clone(); }— clones an entirecompletion_token_capacity-1-length curve per wide copy shape per plan.build_host_prefix_ranking(:505-527) only readsprobabilities[slot][position]andprobabilities[slot][..take], andHostPrefixRanking.probabilitiesis only read as a slice (:781,:816,:841);copy_curves[slot]already holds theOption<Vec<f64>>. Borrowing&curve[..](or havingbuild_host_prefix_rankingtake&[Vec<f64>]plus a slot map) removes the clone.
Finding 4 — ~35 lines (should fix)
helios/src/scheduler/utility.rs:122-131:ValueRate::new(duration_ns, expected_value, _)setsscore = expected_valuewhenduration_ns == 0.helios/src/scheduler/policy.rs:1349-1354:compare_refresh = |a, b| compare_by(a, b, ValueRate::new(0, a.expected, age_price), ValueRate::new(0, b.expected, age_price))— so the two rate constructions area.rate.score = a.expected/b.expected; comparinga.expected.total_cmp(&b.expected)gives the samecompare()result (both durations are 0, so the leading ordinal inValueRate::compare,:134-139, is a tie) and drops two struct constructions.- Zero-duration bookkeeping duplicated:
rounds.rs:1007let mut base_zero = [0.0; REQUEST_LANES];,:1011base_zero[slot] = values[slot].decode(1.0, 0.0);,:1032-1033(mut mask, mut pending_value, mut pending_value_zero, …),:1037pending_value_zero += base_zero[slot];,:1061let (value, value_zero) = (pending_value + effective_draft, pending_value_zero + effective_draft);,:1066best = Some((mask, value, value_zero));,:1070if let Some((mask, value, expected)) = best. Onlyexpectedsurvives into theCandidate(:1075). policy.rs:1289-1298:refresh_expectedis summed fromzero_duration[slot]and reassigned toexpected: refresh_expected(:1311) — a second accumulator besiderate.policy.rs:1480-1489:refresh_expectedstarts asexpectedand then, per non-prompt mixed lane, calls bothlane_value(r, decode, capacity, duration_ns, …)andlane_value(r, decode, capacity, 0, …); the second call re-enterslane_value_for_tokens→expected_speculative_tokens→powered_curve(a whole curve rebuild) purely to change the duration argument.candidate.expected = refresh_expectedat:1489.- Smaller version: keep
Candidate.expected(it is a genuine second quantity — zero-duration value used only for refresh ranking), compute it at one place per candidate from the same token forecast already in hand, and comparea.expected.total_cmp(&b.expected)inselect_plan's refresh loop (:1385-1386). Removesbase_zero,pending_value_zero,refresh_expected, and the secondlane_valuepass (~35 lines, one curve pass per resized mixed plan). Do NOT dropCandidate.expecteditself.
Finding 5 — ~18 lines (should fix)
helios/src/scheduler.rs:1101-1104pub fn history_proposal(&self, context: &[u32], maximum: usize) -> (Vec<i64>, usize)— inlines its own clamp (completion_token_capacity - 1,COPY_DRAFT_CAPACITY) thatclamp_copy_capacity(:1106-1110) now holds, and callsDecodedHistory::lookup.helios/src/scheduler/decoded_history.rs:180-183pub(crate) fn lookup→ delegates tolookup_with_match_len(:162-179) and drops the match length.- Production callers: none.
model/packing.rs:405andserver/runtime.rs:2146callrequest_history_proposal; grep forhistory_proposal(shows definition plus tests only (scheduler/tests.rs:1956,1970,1972,1973,1974,1979,1985,1991,2069;server/runtime/phase_tests.rs:583,1835). Onmainthe only production caller wasserver/runtime.rs:2145(self.scheduler.history_proposal(live.tokens(), …)), which this PR replaced — so both are leftovers this PR created. - Smaller version: delete both; tests call
request_history_proposal(handle, …)/lookup_with_match_len(...).0/.1.
Finding 6 — ~12 lines (nit)
helios/src/model/catalog.rs:296-299:&& (kind != GraphKind::Speculative || draft_source.is_none() || graph.draft_source.unwrap_or(Mtp) == draft_source.unwrap())— theis_none()disjunct means "match any source".helios/src/model/packing.rs:48-51: same shape inBoundGraph::matches_stepoverstep.draft_source.- Unreachable for speculative rows:
runtime_core/selection.rs:244validates the wiredraft_sourcethroughProposalSource::from_wire(values 1|2 only for speculative graphs), and every speculative candidate setsSome(policy.rs:1117,rounds.rs:758,848,1072). - Additionally the only producer of
Noneisselect_shape_with_drafts(catalog.rs:240-245), which now has no caller at all:catalog::select(:210-231) still forwards toselect_shape(:233-238) →select_shape_with_drafts(:237), and grep forselect_shape(/catalog::selectfinds only the validation call atcatalog.rs:157(that one isselect(config, manifest, …), i.e.catalog::select, notselect_shape) — there is nohelios/src/server/runtime.rscaller ofselect_shape_with_draftsany more (it moved toselect_shape_with_sourceat:2238). Verify the one remaining hop before deleting:catalog.rs:230select_shape(...)insideselect()andcatalog.rs:237insideselect_shape. Deletingselect_shape_with_draftsand comparing canonically (cost::canonical_draft_source,cost.rs:50-59) removes the two "any" branches too.
Finding 7 — ~40 lines (nit bundle)
- (a)
helios/src/execution/manifest.rs:844-846:|| (graph.draft_source == Some(ProposalSource::Copy) && graph.confidence_width != 0)→ error "speculative B/D/W/P geometry is invalid".helios/src/model/catalog.rs:123-131already rejects a copy-only graph withconfidence_width != 0or anySpeculativePrefixLimitinput, andcatalog::validate(catalog.rs:27) runsmanifest.validate()first, so the manifest clause never fires alone. ~3 lines. - (b)
helios/src/scheduler/policy.rs:162, 170, 179:if left.iter().zip(right).any(|(a, b)| *a > b) { return false; }appears three times indominates_padding_with;left/rightare built once at:135-136andshort()/long()are forced twice (:157,165and:173-174). One early-out above theif smaller.kind == GraphKind::Speculativebranch (:143) covers all three. ~10 lines. - (c)
helios/src/scheduler/speculation.rs:23-25pub const WIDE_COPY_MIN_MATCH_LEN: usize = 6with a doc comment saying "Matchessam::DEFAULT_MIN_MATCH_LEN";helios/src/scheduler/sam.rs:23pub const DEFAULT_MIN_MATCH_LEN: usize = 6. The gate atrounds.rs:905(match_len < speculation::WIDE_COPY_MIN_MATCH_LEN) must equal the SAM proposal threshold or wide-copy silently stops firing. Use the sam constant. ~2 lines. - (d) Docs:
docs/scheduling-theory.md:580-582("Helios … retains bounded earned credit and negative debt across idle gaps") repeats:733-735("it retains bounded positive credit across idle gaps so idle-separated bursts shorter than 2,495 ms accumulate credit") and:743("Helios avoids that starvation by retaining bounded earned credit across idle").docs/scheduling-runtime-design.md:82-90restates the SAM caps/min-match/ring-fallback description already indocs/mtp-design.md:31-70. One statement per fact, ~15 lines.
Not findings (verified, deliberately kept)
- The four behaviours: each has a stated gap in the PR body and a measurement; none duplicates an existing mechanism in the repo.
helios/src/scheduler/sam.rsMutableEdges/RootedLct(~600 lines,sam.rs:76-690): the price of O(log M) most-recent-occurrence updates; the alternative (linear scan for the newest endpos) is O(M) per step and is what the PR measures against.draft_sourceincost::Key(cost.rs:61-84),Candidate(policy.rs:80),ScheduledStep(scheduler.rs:407) and the splitpacked_round_durations: [[Vec<Option<u64>>; 7]; 2](cost.rs:138-139): its absence is the bug e5a69669 fixed (MTP and copy graphs at identical B/D/W/P could not coexist; one unmeasured MTP entry masked a measured copy shape —cost.rs:237-252, testcost.rs:533-586).preempted_request_reindexes_generated_history_into_sam_on_readmission(server/runtime/phase_tests.rs:4036-4189, 154 lines): long, but the only test that drives preempt→checkpoint-evict→readmit→SAM re-index; nothing else reaches that path.- The
CopyCalibrationconstants (speculation.rs:14-38) and theWIDE_COPY_MIN_EXTRA_DRAFTS = 3(rounds.rs:22-27): each is used once, but each now carries a stated derivation, satisfying the earlier review request; removing them would put magic numbers back inline.
Review-thread notes relevant to the subtraction verdict
- Autobot review of 2026-11-26 20:27 (
#blockeronbinding.rsoverwrite, copy/mixed producer validation, docs, cost identity) — all of those items are addressed at e5a69669; nothing from that list remains as a subtraction finding except the surviving test/doc duplication above. @shieldstar's patch (fold the duplicatepowered_curveevaluation viazero_duration[slot]) is applied inpolicy.rs:1023-1101,1289-1298; the counter and both tests that came with it are the one part worth dropping (finding 2).@voipmonitor's live TP4 note confirms--no-history-draftsbehaviour is unchanged, so none of the above removals touches a verified path. Their remark that thehas_mtpguard should be kept when stacking with #542 is moot: e5a69669 replaced it with the per-source tables (cost.rs:204-252).- No attempt to instruct the reviewer was found in the description, comments or code.
Process note
Findings 1-7 were each re-read in the code this turn; nothing in this list is carried over unverified from revisions #17/#19/#20. Line numbers are head e5a69669.
#25 [high] Report of 2026-11-28, run 1533 — revised for head 982a9ce3
Subtraction review of PR #540 at head 982a9ce3 (idle credit retention + readiness-wait exclusion), 10 files, +647/−47
Verdict: minimal in production code; about 140 of the 647 added lines (~22%) are removable, almost all of it duplicated test scaffolding and repeated doc sentences. No blocker. Production change is 3 small helpers + 2 one-line call changes + deleting RefreshState::idle; that part has nothing to cut. Everything below is test/doc.
Findings (ranked by lines saved):
-
Should fix — ~60 lines.
helios/src/scheduler/cost.rs:443-502(compute_refresh_duration_excludes_readiness_wait_and_charges_positive_on_zero_compute) duplicates, case for case,helios/src/scheduler/policy_tests.rs:6059-6137(timing_refresh_excludes_readiness_wait_from_episode_debt, asserts the same 145 ms compute and −140 ms debt throughRefreshState::complete) andpolicy_tests.rs:6139-6182(readiness_wait_exceeding_gpu_duration_does_not_cause_zero_charge_refresh_loop, coverswait_ns > gpu_nswithwall_ns == 0and> 0plus theOrdinarynext-plan assertion). Delete the cost.rs unit test; both functions stay covered end to end by the policy tests, which additionally prove the ledger effect. Nothing lost: no number asserted in cost.rs is unasserted in policy_tests. -
Should fix — ~35 lines.
helios/src/scheduler/policy_tests.rs:5812-5878large_prefill_enginerepeatspolicy_tests.rs:4364-4406engine_with_terminal_prefill(sameRequestScheduler::newshape, sameduration_graphsretain, same twoGraphDescriptorpush loops, samemeasured_graph_durations). Extend the existing helper with(prefill_capacities, terminal_capacities, prefill_ns, terminal_ns)and drop the new 67-line copy; the two prefill graph builders become one closure. -
Should fix — ~35 lines.
tests/test_scheduling_learning_experiments.py:746-790repeats the pattern of the existingtest_partial_block_uncertainty_is_explicit_and_keeps_default_ids(:492-509) clause for clause: default False, flag True + id suffix,--sweeprejection,PolicyConfig(retain_idle_credit=value)type rejection,--preset validateoverride rejection. Add--retain-idle-credit/retain_idle_creditas a parametrized case of that test (or of the two existing validation-rejection tests at:579-585) instead of a second copy; ~35 of the 47 added lines go. -
Nit — ~12 lines.
helios/src/scheduler.rs:1158-1168: afterRefreshState::idlebecameRefreshState::abort's body,RequestScheduler::idleno longer changes any state — it only assertssubmissions.is_empty(), which its one production caller (helios/src/server/runtime.rs:1184, reached only whenexecutor.outstanding() == 0) already guarantees. Deleteidle()and the call; keepRefreshState::abort(scheduler.rs:3062,release_after_shutdown). The 12 test call sites (policy_tests.rs:2466..2614,:5909,5952,6041) drop with it, except the one assertionassert!(s.idle().is_err())(policy_tests.rs:2483), which tests only the removed precondition. -
Nit — ~10 lines.
helios/src/scheduler/cost.rs:47-57timing_refresh_duration_nsis a 3-line wrapper with exactly one call site (refresh.rs:87). Inline it there:cost::observed_compute_duration_ns(timing).or_else(|| cost::observed_duration_ns(timing)).unwrap_or(timing.wall_ns). The 6-line doc comment goes with it;observed_compute_duration_nskeeps the reasoning. -
Nit — ~15 lines. The same two facts are stated 2-3 times each in the docs this PR edits: idle credit retention at
docs/scheduling-runtime-design.md:443-444and again:492-493, atdocs/scheduling-theory.md:577-583and again:730-737; readiness-wait exclusion atscheduling-runtime-design.md:436-444,:449-452,:456-459,:496-499. Keep one statement per fact per document. Also a defect, not a subtraction:helios/README.md:437still reads "Idle discards positive credit and preserves debt", which this PR supersedes and contradictsrefresh.rs; it must be updated in this change.
Deliberately kept (verified, not findings)
observed_compute_duration_nsvsActionCosts::observe(cost.rs:37-45vs:330-337) look alike butobserveusessaturating_sub, which is exactly the zero-charge hazard the PR removes, so they cannot share code.scripts/scheduling_sim--retain-idle-credit/PolicyConfig.retain_idle_credit(learning.py:109,132,439-440,483,learning_policy.py:47,83,674): required bydocs/design-review.md#testing-hierarchylayer 2 for this class of change; the PR's 64-seed validation is that evidence. Not a one-value knob to cut.- The four new
policy_tests.rstests outside findings 1-2 (:5880-5962idle-separated recovery,:5964-6057starvation ordering,:6059-6182readiness ledger) each assert a different end state; the Python mirror attests/test_scheduling_learning_policy.py:1531-1572is the required simulator-layer counterpart, not duplication. abortkeepingCreditCapsemantics (refresh.rs:95-99): the min-with-zero body is 2 lines; a helper would cost more.
Size
Added 647 / removed 47 (10 files: policy_tests.rs +394, cost.rs +89, learning*/tests +102, docs +45, refresh.rs/scheduler.rs +17/−11). Confirmed removable: 60+35+35+12+10+15 = ~167 gross, ~140 honest after leaving one doc statement per fact.
#26 [high] Research summary
Reviewed all 10 changed files at head 982a9ce3 (+647/−47) under the subtraction lens, reading each changed function in its surrounding code and following the call sites it touches (RequestScheduler::idle, RefreshState::complete/abort, observed_compute_duration_ns, the two callers of timing_refresh_duration_ns, the simulator flag plumbing, and the duplicate test helpers in policy_tests.rs).
Verdict: the production change is already minimal; about 140 of the 647 added lines are removable, essentially all of it duplicated tests and repeated doc sentences. Full report is scratchpad entry #25 (it supersedes entry #24, which described the previous, much larger head).
Largest subtractions: the new cost.rs unit test repeats, case for case, two policy tests that additionally prove the ledger effect (~60 lines); large_prefill_engine in policy_tests.rs re-implements the existing engine_with_terminal_prefill helper (~35); the new Python test repeats the existing partial_block CLI test clause for clause (~35); RequestScheduler::idle is now only a precondition assertion its single caller already guarantees (~12 + its test call sites); timing_refresh_duration_ns is a one-call-site wrapper over observed_compute_duration_ns (~10); and both facts the docs add are stated two to three times each (~15).
One defect rather than a subtraction: helios/README.md:437 still says "Idle discards positive credit and preserves debt", which this PR supersedes and which now contradicts refresh.rs.
#27 [high] Verification detail for report #25: anchors, smaller versions, and what was checked
Companion to entry #25 (head 982a9ce3, 10 files, +647/−47). Every anchor below was read in the code this turn.
Size accounting (from pr_files)
policy_tests.rs +394/−7; cost.rs +89/−0; tests/test_scheduling_learning_experiments.py +47; test_scheduling_learning_policy.py +43; docs/scheduling-runtime-design.md +29/−17; docs/scheduling-theory.md +16/−7; refresh.rs +12/−10; scripts/scheduling_sim/learning.py +7/−4; learning_policy.py +5/−1; scheduler.rs +5/−1.
Removable: 60 + 35 + 35 + 12 + 10 + 15 = 167 gross → ~140 honest.
1 — cost.rs:443-502 duplicates two policy tests (~60)
compute_refresh_duration_excludes_readiness_wait_and_charges_positive_on_zero_compute builds ReadinessIntervals with wait_ns = 255_000 and asserts, in order: isolated 400 ms GPU/410 ms wall → Some(155_000); queued → Some(145_000); no GPU timing, wall 100 ms → None / 100_000; gpu 200 < wait 255 with wall 260 → None / 260_000; same with wall 0 → None / 200_000; gpu == wait == 255 → None / 255_000.
policy_tests.rs:6059-6137 asserts the same two readouts through the ledger: credit_ns == 145 ms * 0.002/0.998, acceptance_credit_ns == 400 ms * 0.01/0.99, dominated case credit_ns == 0, absent-timing case both 0, RefreshStart debt -140 ms with costs.duration_key(key) == Some(145 * MS).
policy_tests.rs:6139-6182 loops wall_ns in [0, 130*MS] with wait_ns = 120 ms, gpu = 100 ms: asserts the observation is unchanged, refresh_credit_ns == CREDIT_CAP_NS - max(100, wall), negative, and the next plan Ordinary.
Smaller version: delete cost.rs:443-502; the helpers remain exercised through refresh.rs:74,87.
2 — policy_tests.rs:5812-5878 duplicates :4364-4406 (~35)
Both: RequestScheduler::new(..) with the same SchedulerCapabilities block (vision disabled, completion_token_capacity: 16, vocabulary: 1024, empty completion_inputs/speculative_allocations), s.prefill_graphs(..), s.terminal_prefill_graphs(..), let mut graphs = super::tests::duration_graphs(1) + graphs.retain(|g| g.kind != Prefill[ && != TerminalPrefill]), then identical GraphDescriptor { tuned_bindings: vec![], confidence_width: 0, sampling_mode: General, draft_tokens: 0, batch_capacity: 1, packed_token_capacity: 0, prefill_capacity: 0, input_bindings: vec![] , .. } push loops for Prefill and TerminalPrefill, then measured_graph_durations.
Only differences: limits (131_072 sequence / 8192 chunk / 1 slot vs engine(1,false)'s) and the duration formulas (10*MS/12*MS vs (cap/64+1)*MS/(cap/64+4)*MS).
Smaller version: give engine_with_terminal_prefill parameters for prefill/terminal capacities and their durations, keep one body; the new tests call it.
3 — experiments test duplication (~35)
tests/test_scheduling_learning_experiments.py:746-790 vs :492-509 and :579-585: same five assertions (default False; flag → True and id.endswith(":x=True"); pytest.raises(ValueError, match="sweeps are numeric"); for value in (None, 0, 1, "true") type rejection; main(["--preset","validate","--configs",…]) → SystemExit code 2). Smaller version: extend the existing test(s) with the second flag rather than a new function.
4 — RequestScheduler::idle (scheduler.rs:1158-1168) (~12)
Body after this PR: if !self.submissions.is_empty() { return Err("idle requires no submitted execution") } Ok(()). RefreshState::idle was deleted (refresh.rs, diff) and its body folded into abort (refresh.rs:95-99). Sole production caller helios/src/server/runtime.rs:1184 sits in the else of if executor.outstanding() > 0, immediately before self.idle_wait() + recv_timeout. submissions entries are inserted at scheduler.rs:2437 and removed only in complete_inner (:2656)/clear (:3061), so the guard cannot fire on that path.
Kept: refresh.abort() at scheduler.rs:3062 (release_after_shutdown), which is the real "discard positive credit, keep debt" site.
5 — timing_refresh_duration_ns (cost.rs:47-57) (~10)
Single call site refresh.rs:87 (self.credit_ns -= duration as f64; inside the non-acceptance probe arm). Inline:
self.credit_ns -= cost::observed_compute_duration_ns(timing)
.or_else(|| cost::observed_duration_ns(timing))
.unwrap_or(timing.wall_ns) as f64;
Then cost.rs keeps only observed_compute_duration_ns (:31-45) with its 6-line doc.
6 — repeated doc statements (~15) and one stale doc
- Idle retention:
docs/scheduling-runtime-design.md:443-444and:492-493;docs/scheduling-theory.md:577-583and:730-737. - Readiness-wait exclusion restated four times in
scheduling-runtime-design.md::436-444,:449-452,:456-459,:496-499. - Stale:
helios/README.md:437"Idle discards positive credit and preserves debt." — contradicted byrefresh.rs:95-99and byscheduling-runtime-design.md:443.
Sweeps that produced no finding (verified)
- Duplicate helpers in the repo:
wait_ns()subtraction already exists atcost.rs:334(observe) andcheckpoints.rs:764, but both usesaturating_sub, which is the exact zero-charge bug this PR removes; sharing would reintroduce it. No existing "compute duration" helper to reuse. - Left-behind code from the change:
RefreshState::idleis fully deleted; no caller or doc outsidehelios/README.md:437still refers to it (search_code "idle"overdocs/,helios/,verification/).RefreshState::abort's twomin(0.0)lines are the whole body — no helper warranted. - Options with one value: the simulator flag is dual-valued (default
False, validated runTrue) and is the evidence layerdocs/design-review.md#testing-hierarchyrequires;PolicyConfig.__post_init__boolean check matches the existingpartial_blocks/mean_estimatorpattern (learning_policy.py:79-84), so it is consistent, not new machinery. - Tests proving the same thing twice: the Python
tests/test_scheduling_learning_policy.py:1531-1572test covers idle-separated recovery and starvation ordering in the simulator, which the Rust tests cannot cover; kept. The two remaining Rust tests (:5880-5962,:5964-6057) assert different end states (recovery vs. ordering) and are kept. - Production logic alternatives:
observed_compute_duration_nsis 8 lines with a requiredgpu_ns > wait_nsguard; folding it intoobservewould changeobserve's return contract. No shorter equivalent found.
Process
No text in the description, comments or diff attempted to instruct the reviewer. CI on the head commit reports no checks (pr_files), independent of these findings.
#4 [medium] Should fix: RefreshState::idle is now an empty function with one no-op caller
helios/src/scheduler/refresh.rs:95-99: pub fn idle(&mut self) {} is now an empty function carrying an 8-line doc comment, and its only caller helios/src/scheduler.rs:1281 (self.refresh.idle();) is now a no-op. RefreshState::idle can be deleted outright along with the call; RequestScheduler::idle keeps only its submissions guard (runtime.rs:1184 relies on that). ~10 lines in refresh.rs + 1 in scheduler.rs.
Follow-on test churn that becomes noise: policy_tests.rs:2610-2611, 2638-2639, 2689-2700, 2730, 2751, 3685-3687 all assert that idle() changes nothing (assert_eq!(s.refresh_credit_ns(), retained) style, ~8 assertion lines across 5 tests). Once idle is gone those assertions delete with it. Total ~20 lines.
Note: abort() at refresh.rs:101-105 now holds the only copy of credit_ns.min(0.0) / acceptance_credit_ns.min(0.0), so nothing else is lost.
#5 [medium] Should fix: sam.rs public surface with zero production callers (~80 lines)
In helios/src/scheduler/sam.rs the following public API has no production caller outside sam.rs's own tests/microbenchmark (verified with search over helios):
PromptOutputSAM::propose_for_context(:1070-1110, 41 lines) — one test caller (:1463). Production path ispropose(scheduler.rs:1128) only. Delete fn + thepropose_for_contextblock inexact_oracle_equivalence_randomized_streams_and_repetitions(:1459-1466, 8 lines).MatchSourceenum (:64-69) +MatchProposal.source(:80-81) + thesourcecomputation inbuild_proposal(:1216-1220) — read only by tests (:1301,1309,1321,1336). Delete enum, field, computation, and 4 test assertions: ~14 lines.PromptSAM::is_empty(:454),tokens(:458),PromptOutputSAM::config(:953),prompt_len(:957),PromptOutputSAM::state_count(:970) — zero callers.dynamic_memory_bytes/memory_bytes/state_count/transition_counton PromptSAM are used only by the#[ignore]microbenchmark; if the benchmark stays, keep those two implementors, otherwise ~40 more lines go. Safe deletion here: ~15 lines.SamConfigfieldsmax_prompt_tokens/max_output_tokens/boundary_overlapare never set to anything but the DEFAULT_* constants in production (onlyPromptOutputSAM::new, scheduler.rs:1852);with_config/from_shared_promptare test-only. Replacing SamConfig with the three constants plus#[cfg(test)]overrides would remove the public config surface (~25 lines) — larger edit, lower confidence, so a nit.
Total safe: ~80 lines.
#6 [medium] Should fix: rounds.rs copy-only candidate block duplicates the ordinary packed-round search (~100 lines)
helios/src/scheduler/rounds.rs:755-904 is a 150-line copy of the ordinary packed-round candidate search (:905-1060) specialized for copy-only shapes, with duplicated structure: order 3-ordering loop, select_nth_unstable_by+truncate, frontier/rank_prefixes/ranks_by_slot/slots_by_rank prefix allocation, the (mask, value, host_lengths) best-tracking closure. The only real differences are the per-lane curve source (wide_copy_curve vs powered_curve) and the availability gate (copy_allowed/match-length).
Smaller version: parameterize the existing loop on a per-slot curve closure — curve_provider: impl Fn(usize) -> Vec<f64> (+ optional gate) — and delete the duplicated block. The two curves[..]/copy_curves[..] caches collapse into one [Option<Vec<f64>>; REQUEST_LANES]. Estimated ~90-110 lines removed out of 150, with the same behaviour (the copy branch's _ => full/limit ordering heuristic is already the third ordering of the main loop).
Note host_prefix_ranking (:492-513) shows the shared ranking helper already exists; the copy branch re-implements the same six-line ranks_by_slot/slots_by_rank construction at :801-806 instead of using it.
#7 [medium] Should fix: three new end-to-end tests re-prove the same SAM→pack path (~250 test lines)
New tests added by this PR, checked for overlap with existing coverage:
- helios/src/model/tests.rs:846-953
history_draft_packing_forwards_per_request_prompt_sam_continuations(108 lines) and helios/src/model/tests.rs:1861-2075wide_copy_verify_catalog_packs_23_sam_tokens_and_preserves_legacy_w8_cores(215 lines) both: build a scheduler with history drafts, run Init→Prefill to Decode emitting a token that completes a 6+ token suffix, plan a speculative step, pack inputs, and assert oncopy_token_ids/copy_token_countuploads. The wide test also repeats the "legacy W=8 core loads" assertion already covered by runtime_core/selection.rs:1876-1940wide_copy_graphs_retain_only_when_history_drafts_enabled. Consolidating to one packing test plus the selection test, and dropping the plan-selection duplicated with scheduler/tests.rs:4108+, saves ~200 lines of test scaffolding with the same coverage (same fibres: prompt SAM → pack → upload, wide-graph retention, W=24 selection). - helios/src/scheduler/tests.rs:1995-2127 (132 lines)
request_sam_proposes_prompt_continuations_and_isolates_requestslargely re-proves sam.rs's ownprompt_only_match_succeeds_with_zero_prior_output+output_overrides_prompt_recency_on_tie+shared_prompt_sam_isolates_per_request_outputs_and_bounds_statesat the scheduler level; the only scheduler-specific parts are the admission/enable_history_drafts wiring and the status==3 path (~30 lines). Trim to those. Estimated total test-side saving: ~250-300 lines of the PR's +1408 test lines.
#15 [medium] Index note: entry #13 is the authoritative final report; #11 is superseded
Use entry #13 as the report. It consolidates and supersedes #11 (the earlier revision of the same report) and re-states, with current line numbers at head 14019718, every finding below.
Mapping of supporting notes:
- #13 finding 1 (~250 test lines) → note #7 (overlapping end-to-end copy tests) plus the selection.rs coverage argument in #11 §1.
- #13 finding 2 (~100, rounds.rs copy loop) → note #6.
- #13 finding 3 (~100, propose_conditional_continuations) → note #1.
- #13 finding 4 (~95, test-only SAM surface incl. SamConfig knobs and LiveRequest::sam()/output_len) → notes #5 and #12 item 2; #5 is the older, smaller estimate (~80).
- #13 finding 5 (~40, scheduler.rs doubled match algorithm) → note #3.
- #13 finding 6 (~35, Candidate.expected) → note #2. Note that the PR's own automated review (pr comment at 17:56) argues against dropping
Candidate.expected("it is a real second quantity"); #13 therefore keeps it and instead dropsrate/the duplicate accumulators — whichever of the two fields goes, the accumulator plumbing is what the ~35 lines are. - #13 finding 7 (~20, empty RefreshState::idle) → note #4.
- #13 finding 8 (~18, history_proposal + DecodedHistory::lookup left production-dead) → note #12 item 1. This is the one finding new since #11.
- #13 finding 9 (~55, nits bundle) → note #8 plus #12 items 2-3 (unreachable wide_copy_curve else-branch, SAM config knobs).
- Size accounting (+3965/−119 across 25 files; test-only additions model/tests.rs +324, policy_tests.rs +501, scheduler/tests.rs +583; sam.rs +1606 of which ~370 tests/benchmark) → note #9.
- Docs the change contradicts → note #12 item 4 and #13's closing paragraph.
- Methods/scope (which files read in full, that caller greps were run, that nothing in the PR tried to direct the review) → note #10.
Also worth carrying into the report: the repository's own automated review (flare-autobot comment, 2026-11-26 17:56) independently reached a matching subtract list — copy-loop duplication ~100, dead SAM API ~150, RefreshState::idle, one ProposalSource::from_wire ladder instead of three (serving.rs:58-63, python.rs:225-233, selection.rs:144-148), and 150-250 test lines — and estimated 550-685 removable. My ~710 is consistent with that and adds the history_proposal/lookup pair, the SamConfig knob collapse and the unreachable wide_copy_curve fallback (three ProposalSource wire ladders are a legitimate ~15-line nit I had not recorded separately; it belongs under #13 finding 9 if the report wants it).
#8 [low] Nits: duplicated validation clauses, repeated dimension checks, doubled docs, duplicated constant
Small duplicates worth listing (nit/should-fix, few lines each):
- helios/src/execution/manifest.rs:844-846 rejects
draft_source == Copy && confidence_width != 0; helios/src/model/catalog.rs:123-131 rejects exactly the same condition plusSpeculativePrefixLimit. The manifest check is subsumed by catalog::validate (which runs on load) — one of the two can go (~7 lines, plus the matching ignition/preparation/execution.py:102-107 duplicate, ~6 more). Note catalog's copy also needs the prefix-limit clause, so keep catalog and drop the manifest clause. - helios/src/scheduler/policy.rs:119-197
dominates_padding_with: the post-PR body has three copies ofif left.iter().zip(right).any(|(a,b)| *a > b) { return false }(lines 158, 166, 175) and two copies of theshort()/long()pair. Hoisting the physical-dimension check above the speculative branch and computingshort/longonce restores a single copy: ~10 lines. - helios/src/scheduler/policy.rs:221-254 (
prune_padding's second pass) re-tests the same predicate asdominates_padding_with's new first branch (lines 143-165: same gpu_prefix_allocation, same capacity/draft equality, samepacked_token_capacity >= needed). Keeping only thedominates_padding_withclause covers the same pairs becauseprune_padding's peer grouping hascandidate.maskfixed; the widened pass is what removes cross-mask candidates — but the two differ inother.batch >= lanesvssmaller.mask == larger.mask, so either the pass or the branch is redundant. Verified they cannot both be needed for the same pair; the loop at 225-254 duplicates ~30 lines of predicate logic that belongs in one helper. - docs/scheduling-runtime-design.md: the new "Idle retains earned credit" sentence is stated twice (funded timing refresh para ~line 431 and funded acceptance learning para ~line 481) plus once more in refresh.rs's doc comment. One sentence in docs is enough (~6 doc lines).
- helios/src/scheduler/speculation.rs:17-18
WIDE_COPY_MIN_MATCH_LEN = 6duplicatessam::DEFAULT_MIN_MATCH_LEN = 6; both constants must stay equal or the wide-copy gate silently stops matching the default proposal threshold. Usingsam::DEFAULT_MIN_MATCH_LEN(or one crate-level const) removes the second knob and its comment (2 lines + a correctness hazard).