#1 [high] Should fix: request_copy_match_stats duplicates request_history_proposal_with_match_len
File: helios/src/scheduler.rs:1099-1205.
request_history_proposal_with_match_len (1112-1159) and request_copy_match_stats (1163-1205) repeat the same chain: same clamp (maximum.min(completion_token_capacity-1).min(COPY_DRAFT_CAPACITY)), same early exit on maximum == 0 || decoded_history.is_none(), same self.request(handle) lookup, same sam.propose(maximum), same out-of-vocabulary truncation (position(|&t| (t as usize) >= vocabulary)), same shared-ring query via DecodedHistory::lookup_with_match_len(request.tokens(), maximum), and the same "shared ring wins only on strictly longer match" rule. The second function differs only in returning (valid_len, match_len) instead of a padded vector.
Precedent: the same PR follows the opposite (correct) pattern in helios/src/scheduler/decoded_history.rs:162-183, where lookup is a two-line wrapper over lookup_with_match_len, and the sole difference is the returned tuple. helios/src/scheduler/rounds.rs powered_curve/expected_speculative_tokens (537-557) also factor a cheap view out of the expensive computation rather than copying it.
Risk beyond duplication: the two copies are already not identical. In request_history_proposal_with_match_len the shared-ring result is used unconditionally in the (None, Some(..)) arm (no count > 0 filter), whereas request_copy_match_stats filters .filter(|&(count, _)| count > 0) before the match; a zero-count shared result therefore yields (tokens, 0, 0) in one path and is skipped in the other. Any future fix to the vocabulary clip, the tie-break, or the count == 0 handling has to be made twice.
Fix: express one on the other, e.g. request_copy_match_stats calls a shared private helper returning (match_len, valid_len, provider) and drops the padded build (an Option<&MatchProposal>-style return), so the clip and tie-break exist once.
#2 [high] Should fix: wide_copy_curve fallback duplicates CopyCalibration's own prior and is unreachable
File: helios/src/scheduler/rounds.rs:541-553 (wide_copy_curve).
The else arm recomputes speculation::WIDE_COPY_PRIOR_RATE.powi(depth+1) over completion_token_capacity-1 depths, which is exactly what CopyCalibration::new(capacity).curve(generated, optimistic) returns when depths are all None (speculation.rs:121-151: prior = rate.powi(depth+1) for the None entry, with rate seeded at WIDE_COPY_PRIOR_RATE). The scoring structure the fix belongs to (wide_copy_curve/expected_copy_tokens wrapping powered_curve/expected_speculative_tokens) is the right precedent, but the fallback curve should live next to its owner.
The branch is also unreachable in practice: LiveRequest.sam and LiveRequest.copy_calibration are set together from the same predicate self.decoded_history.is_some() at admission (scheduler.rs:1849-1856), enable_history_drafts must run before admission (scheduler.rs:1086-1092: rejects when self.submitted != Fence(0) || self.admissions != 0), and every caller of wide_copy_curve is already gated on self.decoded_history.is_none() == false (rounds.rs:759). So copy_calibration cannot be None where this arm runs.
Fix: delete the else arm and use request.copy_calibration.as_ref().expect(...), or make CopyCalibration::curve the only source and give it a CopyCalibration::prior(capacity) constructor so no caller re-derives the geometric prior. This also removes the second hard-coded use of WIDE_COPY_PRIOR_RATE outside speculation.rs.
#3 [high] Remaining findings: doc staleness, cost.rs repetition, unwired public SAM API
Observations verified in the diff but not fully cross-checked against every convention precedent. Order by confidence. These were collected just before the time limit.
-
Deviation from convention (should fix) —
docs/scheduling-runtime-design.md:7-12lists the scheduler modules that specify the design (policy.rs,utility.rs,service.rs,cost.rs,refresh.rs,learning.rs,rounds.rs,speculation.rs). The newhelios/src/scheduler/sam.rsimplements a mechanism the same document specifies (copy proposals, lines 39-41 and 102) but is not added to that module index, so a reader of the design document cannot find the implementation. Fix: addsam.rs(per-request prompt and output suffix automata for copy proposals) to the list. -
Deviation from convention (should fix) —
docs/mtp-design.md:31-40describes copy proposals solely as the shared 65,536-token ring with eight- and four-token indexes, and lines 22-29 say history drafting uses "shared decoded history" only. After this PR a request's proposals come first from a per-request prompt+output suffix automaton (scheduler.rs:1099-1159) with a six-token minimum match (sam.rs:22, raised from three) and a 131,072-token prompt plus 131,072-token output cap per request (sam.rs:25-28).docs/cli-design.md:742likewise says only "shared decoded-history continuations". repo-prose SKILL.md:26-29 requires replacing stale present-state claims rather than layering; this is the file that owns copy-draft semantics. -
Nit —
helios/src/scheduler/cost.rs:195, 199, 229, 239plusrounds.rs:756spell outestimate.draft_source != Some(ProposalSource::Copy)five times. A single small accessor onEstimate(the file already carriesEstimate::fresh, cost.rs:111) would match local style and keep the meaning in one place;is_copy_only_stepandmax_mtp_draft_tokensread from it. -
Nit —
cost.rs:287-296:refresh_orderchanged return type to(bool, u64)and lost the doc comment explaining the ordering, which now lives only indocs/scheduling-runtime-design.md:437-441.(true, attempt_ns)meaning "attempted while stale, no valid observation" is not self-evident; neighbouring helpers in cost.rs (lines 21-48, 210-213) carry their invariants in one-line doc comments. -
Nit —
helios/src/scheduler/sam.rs:1236-1273: the test-onlybrute_force_oraclereturns the productionMatchProposaland re-implementsbuild_proposal's source selection and token slicing (sam.rs:1191-1227), so the oracle can drift with production code. Precedent: theoraclehelper inhelios/src/scheduler/decoded_history.rs:228-252returns the same plain(Vec<i64>, usize)the productionlookupreturns. The 120-trial randomized oracle (sam.rs:1402) is only as strong as its independence. -
Not a finding —
DEFAULT_MIN_MATCH_LEN = 6(sam.rs:22) andWIDE_COPY_MIN_MATCH_LEN = 6(speculation.rs:18) are two constants for the same threshold; rounds.rs:776 requires both to pass. Since the SAM default governs the plain--history-draftspacking path too (packing.rs:395-407 →request_history_proposal→SamConfig::default(), sam.rs:53-62), the wide-copy constant could reference the SAM default rather than repeat 6. Neither is wired to a flag, so both satisfy the "no magic defaults" rule only if the value is argued in prose; docs/mtp-design.md currently justifies neither. -
Not a finding —
helios/src/scheduler/sam.rsmodule doc (lines 7-17) and public API (PromptSAM::build,PromptOutputSAM::new,SamConfig,MatchProposal,MatchSource) do not use lifecycle labels, follow the SPDX header convention used acrosshelios/src/scheduler/, and add "Flare community contributors" as a second copyright line (matching speculation.rs:3).propose_conditional_continuationsandpropose_for_context(sam.rs:1070, 1118) are public but have no caller outside the test module;propose_for_contextis exercised only by sam.rs:1463. Consuming-only-in-tests public API is the kind of speculative surface AGENTS.md rejects ("Reject unsupported abstractions... Do not add frameworks, extension points... without a concrete requirement"), so this should be raised: either the 2-deep pipelined execution path that needs them lands in this PR, or the two functions and their tests should not ship aspub.