Prose review — PR #540 (helios: cost-refresh recovery, prompt+output SAM copy-drafts, calibrated wide copy-verify)
Reviewed at head 14019718 against AGENTS.md:43-65 (required prose review), AGENTS.md:72-112 (required PR description sections), AGENTS.md:188-199 (focused outcome, validation, limitations), .agents/skills/repo-prose/SKILL.md:13-37 (not opened) (present-state specification, no false definite references, disclose missing measurements) and the project charter. Every finding below was re-read in the code at this head.
Key findings
- Two blocking cases where a design document asserts something the code contradicts.
docs/cli-design.mdanddocs/mtp-design.mdboth promise--history-draftsdoes not change the loaded graph set;helios/src/runtime_core/selection.rs:277-298now keeps or prunes a whole graph family by that flag.docs/mtp-design.md:359promisesdraft_sourcecarries the proposal source;heliopause/src/export/binding.rs:201overwrites it with"MTP". - Seven should-fix cases where this PR changes scheduler behaviour but no document that specifies it was updated — the scheduling specification (
docs/scheduling-runtime-design.md) never mentions the SAM, the copy-only graph family, the copy calibration, or the wide-copy gate; two of its paragraphs (padding dominance, packed-duration aggregation) describe the pre-PR algorithm;docs/scheduling-theory.mdstill argues the retired idle-discard and last-attempt refresh order;helios/manifest.mdomitsdraft_source, a field the loader now reads. - One should-fix on the PR description itself: it reports a 13.05 ms / 4.52 MiB
PromptSAM::buildas a microbenchmark number without stating that the build runs synchronously at admission for every request on the serving path. - Three nits: the title omits the fourth commit's headline results, the four commits are bundled without stating their dependency, and one new doc comment references a mechanism that does not exist.
- Confirmed clean: the rewritten funded-refresh and acceptance-learning prose in
docs/scheduling-runtime-design.md:425-496matches the new code exactly, the description follows the four-question order and calibrates its measurements, and the required Discord line is present.
Blocking
1. docs/cli-design.md:200-201, docs/cli-design.md:741, docs/mtp-design.md:22-28 — the docs deny the one thing commit 9caba2c7 makes the flag do
docs/cli-design.md:200-201 reads:
--history-draftsenables host history tracking and feeds continuations into the captured graphs' history inputs; it does not change the graphs.
The flag table repeats the narrower claim at :741 ("requires enabled speculation and captured history inputs, as Qwen Flash provides"), and docs/mtp-design.md:22-28 says "Both settings use the same captured MTP graphs and buffers."
At this head the flag is a load-time graph selector. helios/src/runtime_core/selection.rs:277-298 computes copy_wide = retain_wide_copy && graph.kind == "speculative" && graph.draft_source == 2 && graph.token_capacity > 1 && graph.confidence_width == 0 && graph.draft_tokens > drafts, keeps those graphs only when retain_wide_copy is set, and then requires copy_wide for them to survive the width, fixed-width and mtp_verification_token_budget filters. Graphs that do not pass are removed from execution.graphs and their kernels are not loaded. The behaviour is pinned by wide_copy_graphs_retain_only_when_history_drafts_enabled in the same file.
Why it matters: AGENTS.md:52-56 makes every repository document a present-state specification, and repo-prose/SKILL.md:26-29 says to replace stale claims rather than layer new ones on top. cli-design.md and mtp-design.md are where an operator learns what a launch flag costs in GPU memory and what core it needs; both now understate what --history-drafts does (it selects a different graph set, and therefore a different GPU memory footprint and a different core requirement).
Fix: state that --history-drafts selects copy-only wide speculative graphs when the core provides them, that those graphs are pruned when the flag is off, that it remains a no-op on cores without them, and amend the :741 row and mtp-design.md:22-28 to match.
2. docs/mtp-design.md:359-360 — draft_source is documented as the proposal source, and the exporter overwrites it
docs/mtp-design.md:359-360 lists the manifest field as:
draft_tokens, verify_tokens, draft_source: draft depth D, verification width, and proposal source, on graphs that declare a draft depth
The producer side supports that reading: ignition/preparation/execution.py:102-108 validates draft_source in (1, 2) with 2 meaning COPY_DRAFT and rejects copy-only graphs that declare confidence_width != 0 or speculative_prefix_limits; heliopause/src/python.rs:225-233 decodes 0 to None, 1 to Mtp, 2 to Copy, defaulting by graph kind.
The export path destroys it. heliopause/src/export/binding.rs:201 does graph.insert("draft_source".into(), "MTP".into()); unconditionally for every speculative (and speculative-mixed) graph, on the only route into a core (called from heliopause/src/export/capture.rs:3158). A copy-only graph produced by ignition therefore reaches the wire as MTP, copy_wide is false at selection.rs:278-283, and the MTP branch at :291-293 rejects it because its draft_tokens exceeds the learned depth. Wide copy-verify is dead on exported cores.
This is primarily a behaviour bug, but it is squarely a prose finding too: mtp-design.md:359 asserts a field contract that no exporter honours, and no document mentions the coercion. Fixing the exporter to derive "COPY_DRAFT" from 2 (and reject unknown values instead of silently labelling them MTP) makes the documented sentence true; if the coercion is intended, mtp-design.md:359 must state it and cli-design.md must say the wide copy graphs do not survive export.
Should fix
3. docs/scheduling-runtime-design.md:6-12 and the document as a whole — the scheduling specification does not describe the new scheduling mechanism
The document's own inventory at :6-12 names policy.rs, utility.rs (not opened), service.rs (not opened), cost.rs, refresh.rs, learning.rs (not opened), rounds.rs, speculation.rs — and not sam.rs. Its opening paragraph claims the document specifies Helios selection; after this PR none of the following is specified anywhere in docs/:
- the per-request prompt/output suffix automaton (
helios/src/scheduler/sam.rs), its defaults (DEFAULT_MIN_MATCH_LEN = 6atsam.rs:22,DEFAULT_MAX_PROMPT_TOKENS = 131_072at:25,DEFAULT_BOUNDARY_OVERLAP = 512at:32), or that a per-request SAM is preferred over the shared history on equal-or-longer matches; - the copy-only speculative graph family and its contract (
confidence_width == 0, nospeculative_prefix_limits, four copy input buffers) enforced athelios/src/model/catalog.rs:93-131andhelios/src/execution/manifest.rs:840-851; - per-request
CopyCalibration(helios/src/scheduler/speculation.rs:14-21,98-190) withWIDE_COPY_PRIOR_RATE = 0.88,COPY_STEP_PRIOR_WEIGHT = 4.0,COPY_DEPTH_SHRINK_WEIGHT = 2.0, and the rule that copy-only completions are isolated from MTP acceptance profiles; - the wide-copy eligibility gate at
helios/src/scheduler/rounds.rs:751-790(WIDE_COPY_MIN_MATCH_LEN = 6atspeculation.rs:18,min_copy_len = base_mtp_drafts + 3,limit > base_mtp_drafts + 1), which is a scheduling rule a reader of this document cannot discover.
Why it matters: AGENTS.md:52-60 requires documents to specify the architecture, and scheduling-runtime-design.md is the file AGENTS.md:231 points scheduling-policy changes at. The description's own summary calls copy-only wide cohorts a change to how candidates "compete directly with full-batch MTP cohorts" — precisely the subject matter of this document — yet nothing there mentions it.
Fix: add sam.rs to the module list and add a section covering the copy-draft sources, the copy-only graph contract, the calibration, and the narrow/wide eligibility gates, with the numeric constants named.
4. docs/scheduling-runtime-design.md:249-254 — padding dominance is described only as the first pass
The document says candidates are discarded when "any physical shape whose capacities are all at least as large as an alternative, with at least one strictly larger capacity" exists.
helios/src/scheduler/policy.rs:221-254 adds a second rejection pass: for a GPU-allocated ragged speculative candidate it discards the candidate when another speculative shape exists with other.batch >= lanes, other.batch < candidate.batch, equal capacity and draft_tokens, and other.packed_token_capacity >= needed where needed = min(sum(lane lengths), candidate.packed_token_capacity). That is not the "all capacities at least as large" relation — the survivor may have a strictly smaller packed_token_capacity — so the surviving candidate's P can differ from the paragraph's description. This is the rule that produces the PR's headline max_b == C result.
Fix: extend :249-254 to state the second pass, including the min(lane_ceilings_sum, larger.packed_token_capacity) threshold.
5. docs/scheduling-runtime-design.md:396-399 — "minimum positive measured duration across matching shapes" no longer holds
The document states that when multiple packed speculative shapes cover a (batch, width) lookup, Helios "takes the minimum positive measured duration across matching shapes and returns zero only when every matching shape is unmeasured."
helios/src/scheduler/cost.rs:190-208 now computes has_mtp and skips every copy-source shape whenever any MTP packed shape exists, regardless of measured duration. So a copy-only shape with a valid measurement is excluded from the aggregate, not minimised into it. The sentence is now wrong in exactly the case the PR adds.
Fix: state the MTP-preferred aggregation and that copy-source measurements are excluded when an MTP shape exists.
6. docs/mtp-design.md:31-40 — history drafting is still specified as the shared ring alone
The document specifies the mechanism as a 65,536-token shared ring with eight- and four-token indexes returning up to seven continuation tokens, populated only by validated completions and shared across requests.
At this head the primary source is the per-request PromptOutputSAM built from the request's own prompt; helios/src/scheduler.rs:1139-1158 queries the per-request SAM first and falls back to DecodedHistory only when the SAM match is absent or shorter. The thresholds and capacities differ too (sam.rs:22, :25, :32), and prompt tokens are indexed (up to 128 Ki), which the ring paragraph explicitly denies.
Fix: describe the per-request prompt+output automaton as the first source and the shared ring as the fallback, with the match-length threshold and prompt cap stated.
7. docs/scheduling-theory.md:577-579, :714-721, :725-729 — the theory doc still argues the two rules this PR reverses
(a) :577-579: "Idle earns no credit and discards positive credit while retaining debt. Consequently, separate busy bursts shorter than 245 ms cannot fund a probe at the default settings." helios/src/scheduler/refresh.rs:95-99 is now pub fn idle(&mut self) {} with a doc comment stating it retains earned credit (capped at CREDIT_CAP_NS) and debt precisely so idle-separated requests can fund a refresh. docs/scheduling-runtime-design.md:437-438, 465-469 was updated to say so; the theory doc was not, so the two documents now contradict each other.
(b) :714-721: "It orders alternatives by the later of their last valid completion and last attempted dispatch, then by ordinary useful-value ranking." helios/src/scheduler/cost.rs:287-296 replaces that with the two-tier (bool, u64) refresh_order key — unattempted stale shapes first — and the ranking by expected useful value then applies via policy.rs:1333-1338, 1369-1372. The same paragraph was rewritten in scheduling-runtime-design.md:441-450 and left untouched here.
(c) The same passage at :704-712 calls retained-refresh the simulator policy that "models the retained-cost rule that Helios implements", but scripts/scheduling_sim/learning_policy.py:671 still does self.credit_ms = min(0.0, self.credit_ms) in idle(). The claimed correspondence is now false, and the 2,495 ms funding bound the PR's Result section cites is argued from the superseded rule.
Why it matters: AGENTS.md:231 lists this doc as required reading for scheduling-policy changes; a reviewer following it will conclude the PR is wrong.
Fix: update :577-579 and :714-729 to the retained-credit rule and the two-tier order, and either align learning_policy.py:671 or state that the simulator deliberately models the pre-PR policy.
8. helios/manifest.md:29-53 — the Python graph dictionary spec omits draft_source
The graph dictionary documented at helios/manifest.md:29-53 lists name, kind, sampling_mode, handle, batch_capacity, token_capacity, draft_tokens, packed_token_capacity, prefill_capacity, confidence_width, estimated_duration_ns, input_bindings, tuned_bindings — no draft_source. heliopause/src/python.rs:225-233 now reads that key (0/1/2, absent defaults by graph kind), and ignition/preparation/execution.py:102-108 validates it. A manifest writer following this spec cannot declare a copy-only graph.
Fix: add draft_source with its encoding and defaulting rule and its copy-only constraints.
9. PR description, "Result" — the SAM build cost is reported without its serving-path consequence
The description reports "PromptSAM::build takes 0.80 ms (0.37 MiB), 2.72 ms (1.27 MiB), and 13.05 ms (4.52 MiB)" as a CPU release microbenchmark. That number is not a benchmark curiosity: helios/src/scheduler.rs:1849-1852 builds PromptOutputSAM::new(&spec.prompt) synchronously inside admission whenever decoded_history is enabled, before the request is registered, i.e. on the serving thread for every --history-drafts request. The description later reports only +0.25 ms/rd scheduler overhead for non-repetitive decode, which measures steady state, not admission.
AGENTS.md:96-102 requires limitations attached to a claimed result, and repo-prose/SKILL.md:35-37 requires disclosing missing measurements. Neither the admission-time placement nor the per-live-request memory (up to 4.52 MiB each) is disclosed.
Fix: state that the build runs synchronously at admission, that the quoted milliseconds are per admitted request at that prompt length, and that no admission-latency measurement exists.
Nits
-
docs/mtp-design.md/ title: the title names three outcomes ("cost-refresh recovery, prompt+output SAM copy-drafts, calibrated wide copy-verify") and omits the fourth commit,14019718, which produced the headlinemax_b == Cand+12.9%results. Consider naming it. -
Bundling is asserted, not argued: the description says the bundle "preserves four atomic commits rebased cleanly", but never states which commits depend on which.
AGENTS.md:194-199asks for "one coherent outcome" and a stated problem/behaviour/validation/limitations per PR; if this must stay one PR, say why the four cannot land separately. -
helios/src/scheduler/sam.rs:1112-1117, false definite reference: the new doc comment sayspropose_conditional_continuationsprovides "a building block for conditional copy lookup tables in 2-deep pipelined execution". No such mechanism exists in the repository — the only call site is the function's own test atsam.rs:1505.repo-prose/SKILL.md:17-19forbids definite references without an introduced referent. Either name the caller or drop the clause.
Checked and confirmed correct
- The rewritten refresh and acceptance prose matches the code.
docs/scheduling-runtime-design.md:425-470and:477-496describe idle as a no-op that retains credit,abortas truncating positive credit (refresh.rs:101-105), timing refresh charged on compute time excluding readiness wait (refresh.rs:85-89), and the two-tier unattempted-first refresh order (cost.rs:287-296). All accurate. - The description satisfies
AGENTS.md:72-112. Why / what changed / result / evidence appear in the required order; combined-stack results are labelled as such and not attributed to this PR alone ("end-to-end throughput reflects the combined runtime, recipe, and kernel stack"); component measurements (cargo test counts, SAM microbenchmark, pytest counts) are separated from service results; untested hardware, models, and the copy-only wide graph GPU export are named as limitations. - Discord contact line present with a username, as the repository's PR convention asks.
Open questions and what could not be found
- Should
mtp-design.mdorscheduling-runtime-design.mdown the copy-only wide graph description? Not resolvable from the docs alone, but one must, becausecli-design.md:200-201currently states the opposite. - Is the admission-time SAM build a visible serving stall? Only a live
--history-draftsrun with a ~128K-token prompt would settle it; the description contains no admission-latency measurement, and CPU microbenchmark magnitudes alone cannot answer it. - Was the
learning_policy.pydivergence intended?scripts/scheduling_sim/learning_policy.py:671retains the pre-PR idle rule whiledocs/scheduling-theory.md:704-712claims it models Helios; only the author can say whether the simulator should change or the doc should record the divergence. - No tests were run in this review, and the head commit
14019718reports no CI checks; all behaviour findings above are from reading the code at that commit.