Code review summary scratchpad · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/c5d301db-1ae4-44c9-8e58-710f0decdafb.md

#1 [high] Blocker verified: export binding coerces draft_source to MTP

Verified in code at head 7ca5430:

#2 [high] PR #540 overview + verified stale docs

Head 7ca5430, 25 files, +3965/−119. Four commits: (a) a85be397 refresh recovery; (b) 83ff9ed6 per-request prompt+output SAM (helios/src/scheduler/sam.rs, new, +1606); (c) 35ab143a draft_source=2 wide copy-verify graphs; (d) 7ca5430c padding dominance + DEFAULT_MIN_MATCH_LEN 3→6. Description: Why/What changed/Result/Evidence & Limitations all present, Discord: Dooner present (no @). Claims 615 + 1,625 CPU tests, GPU 4x RTX PRO 6000 SM120 DeepSeek-V4.1 Flash TP4. Headline live numbers labelled "combined-stack". Limitations: copy-only W=16/W=24 GPU export/replay not benchmarked; power-limit cost refresh not live. No CI checks on head commit — all test claims unverifiable from repo (read_item shows only one discussion comment, the autobot case file).

Charter/rules cited by lenses: AGENTS.md:52-56 docs specify present state; :72-112 four-part description; :155-205 scope; :188-193 no speculative abstraction; :431-444 model core compat; :446-465 configuration; docs/design-review.md:14-52 principles 1/3 (shared mechanisms, reject per-model flags); :22-26 new operation contract needs owner approval.

Key doc staleness verified by me:

#3 [high] Subtraction findings verified (idle, dead SAM API, duplicate match fn, dead curve branch)

Verified independently; all citations are head 7ca5430.

  1. RefreshState::idle is pub fn idle(&mut self) {} at helios/src/scheduler/refresh.rs:95-99 with an 8-line doc comment explaining it does nothing. Caller helios/src/scheduler.rs:1277-1283 (RequestScheduler::idle validates submissions then calls it); server caller helios/src/server/runtime.rs:1184. Zeroing out: retention is now the ABSENCE of mutation. Tests that call .idle() and assert credit unchanged: policy_tests.rs:2610, 2626, 2638, 2689, 2699, 2730, 2751, 3685, 5714, 5720, 5765. Removal: drop method + call line, keep the submissions guard; ~20 lines.

  2. Dead/test-only SAM API (production uses only PromptOutputSAM::new, propose, push_token, into_padded_i64 — verified by search_code: scheduler.rs:1128/1179 propose, :1234/:3017 push_token, :1852 new, :1151 into_padded_i64):

    • propose_for_context sam.rs:1068-1110 (43 lines) — caller only sam.rs:1463.
    • propose_conditional_continuations sam.rs:1112-1189 (~78 lines) — caller only sam.rs:1505; doc says "building block for conditional copy lookup tables in 2-deep pipelined execution", no such consumer exists.
    • MatchSource enum sam.rs:64-69 + MatchProposal.source :80-81 + constructor sites :1217/1219, :1263/1265 — read only by tests :1301/:1309/:1321/:1336.
    • PromptSAM::build sam.rs:283 — used only by tests :1519, :1569.
    • push_slice sam.rs:1023 — tests only.
    • accessors (PromptSAM state_count/transition_count/memory_bytes :462-476; PromptOutputSAM *_memory_bytes/config/prompt_len :949-984) — tests + #[ignore] microbenchmark at :1560-1600.
    • pub mod sam at scheduler.rs:23 makes this an exported surface. ~150-180 lines.
  3. Duplicate match algorithm: helios/src/scheduler.rs:1112-1159 request_history_proposal_with_match_len vs :1163-1205 request_copy_match_stats — same clamp (:1117-1119 vs :1168-1170), same early exit (:1120-1122 vs :1171-1173), same request lookup, same SAM propose + OOV truncation (:1127-1138 vs :1178-1186), same ring lookup (:1139-1142 vs :1187-1194), same strictly-longer tie-break (:1145 vs :1197). Already drifted: shared result filtered by .filter(|&(count,_)| count>0) at :1194 in one copy only. Precedent for the wrapper: decoded_history.rs:180-183 lookup wraps lookup_with_match_len. ~40 lines.

  4. wide_copy_curve fallback duplicate + dead branch: rounds.rs:541-548 else arm re-derives the geometric prior speculation.rs:110-151 CopyCalibration::curve already produces (seeded at speculation.rs:113 with WIDE_COPY_PRIOR_RATE; curve prior = rate.powi(depth+1) at ~:132). Branch unreachable: LiveRequest.sam and .copy_calibration are both set only under decoded_history.is_some() at scheduler.rs:1849-1856, enable_history_drafts refuses after any submission/admission (:1086-1092), and the wide-copy block is only entered when decoded_history.is_some() (rounds.rs:759). Also the fallback ignores optimistic, so the two curves disagree. ~10-15 lines.

  5. Duplicate proposal-source ladder: serving.rs:58-63, heliopause/src/python.rs:225-233, selection.rs:144-148 (config string → 1/2). ProposalSource::parse exists at speculation.rs:30-38. ~15 lines.

#4 [high] Report support: export fix shape, cost-key trap, preempt/readmit, rejected duplicate claim

Verification notes for the report (all at head 7ca5430).

A. Export path detail: heliopause/src/export/binding.rs:136 execution() deserializes the JSON into the wire Execution via prost_reflect (message() at :123-134), which needs the proto enum NAME. That is why :201 hard-inserts "MTP". Correct fix: map the manifest integer (1→"MTP", 2→"COPY_DRAFT", absent speculative→"MTP", else error), i.e. derive the name instead of overwriting. Also applies to mixed speculative graphs (the :196 condition covers them, and ignition/preparation/execution.py:104-108 allows draft_source=2 on mixed) while helios/src/runtime_core/selection.rs:279 requires kind=="speculative" for copy_wide.

B. Cost-semantics trap (stronger than the prose lens stated): helios/src/scheduler/cost.rs:192-196 has_mtp is an entry existence scan (not freshness). So in a mixed catalog, one UNMEASURED MTP packed entry (nanos 0) suppresses every measured copy entry (:199-201), and packed_round_duration (:210-213) then returns None for a shape that was measured. Contradicts docs/scheduling-runtime-design.md:396-399 ("returns zero only when every matching shape is unmeasured"). Also: cost::Key (cost.rs:151-158 or so) OMITS draft_source, and prepared() rejects duplicate keys (:159-161), so an MTP graph and a copy graph with identical B/D/W/P cannot coexist in one core ("prepared graphs require unique shapes"); is_copy_only_step (:223-232) therefore infers the source from the table entry rather than the step. Putting the source into Key fixes both.

C. Preempt/readmit: helios/src/server/runtime.rs:2068-2108 park rebuilds incoming.prompt.tokens = live.tokens() ++ appended (i.e. prompt + generated), and readmission rebuilds sam from that prompt at scheduler.rs:1849-1852 while resume_decoded_sequence (scheduler.rs:1212-1223) restores only decoded_sequence. Prompt SAM is capped at the trailing 131,072 tokens with a 512-token boundary overlap, so previously generated text is indexed through the prompt rather than the output automaton. Worst case is wasted verification slots, not wrong commits; no test covers it. Ask for one brute-force-oracle test (sam.rs:1236 oracle) or a PerRequestCopyState that holds sam+calibration together.

D. Python/Rust contract mismatch (nit): ignition/preparation/execution.py:104-108 permits draft_source=2 on mixed speculative graphs; helios/src/runtime_core/selection.rs:277-283 retains wide copy only for kind == "speculative", and helios/src/model/catalog.rs:94 copy_only_graph also requires Speculative. Reject 2 on mixed in Python, or support it in selection.

E. Candidate.expected vs Candidate.rate (policy.rs:89-90): I checked whether the subtractive claim holds and it does not. rounds.rs:899/1058 set rate: ValueRate::new(nanos, value, age) (nonzero duration) while expected is the zero-duration counterfactual built at rounds.rs:886-885/1048-1054 and policy.rs:1415-1425; ValueRate::new at utility.rs:122-131 divides by duration, and the refresh comparison (policy.rs:1285-1290) needs the zero-duration value. Neither is derivable from the other without the age price, so expected is a genuine second quantity. Do NOT ask the author to drop it; the only optional cleanup is naming the two accumulators' intent. Excluded from Subtract.

#5 [high] Final report structure (blockers/should-fix/subtract/nits)

FINAL BLOCKER LIST (1): B1. heliopause/src/export/binding.rs:196-202 overwrites draft_source with "MTP" for every speculative/mixed-speculative graph during the JSON→wire conversion used by export_capture (capture.rs:3158). Copy graphs (draft_source=2) are emitted by ignition/preparation/execution.py:316-319 but arrive at load as MTP, and helios/src/runtime_core/selection.rs:277-298 prunes them (copy_wide needs 2; MTP branch needs draft_tokens <= drafts). Wide copy-verify is dead on every exported core, silently. Fix: derive the enum name from the manifest value (1→"MTP", 2→"COPY_DRAFT", absent-speculative→"MTP", else invalid()), and add a round-trip test on binding::execution.

SHOULD FIX (9): docs/cli-design.md:200-202 + mtp-design.md:22-29 contradiction; PR split/attribution of the four outcomes; second proposal-source dimension + bypasses; cost source belongs in Key (also fixes duplicate-shape rejection + has_mtp existence-not-freshness + docs:396-399 mismatch); stale/missing design prose (mtp-design.md:31-40, scheduling-runtime-design.md:6-12 and :249-254, helios/manifest.md:29-53); unsourced calibration constants (0.88/4.0/2.0/+3/6); preempt-readmit SAM indexing untested; Python allows draft_source=2 on mixed but Rust requires speculative; evidence gaps (no CI on head, no load-and-serve of an already-exported W=8 core, SAM build cost paid at admission per request not stated).

SUBTRACT (~550-685 of +3,965): test consolidation (~150-250); rounds.rs copy-only loop (~100); dead SAM API (~150); duplicate match fn in scheduler.rs (~40); dead wide_copy_curve else (~12); empty RefreshState::idle + its no-op test calls (~20); three-way draft_source ladder (~15). Explicitly rejected subtraction: Candidate.expected vs Candidate.rate (~35) — genuinely different quantities (zero-duration counterfactual used by refresh comparison at policy.rs:1285-1290 vs duration-divided score at utility.rs:122-131).

NITS (5): title names three of four outcomes + commits' independence unstated; refresh_order (bool,u64) lost its contract comment (cost.rs:287-296); SAM oracle reuses production MatchProposal/shape so it is not independent (sam.rs:1236-1273); copy-only validation written three times (manifest.rs:844-846, catalog.rs:123-131, execution.py:102-108) — pick one authority; two constants for one threshold (WIDE_COPY_MIN_MATCH_LEN speculation.rs:18 vs sam::DEFAULT_MIN_MATCH_LEN sam.rs:22) and accessor/pub surface left after deletion of test-only items.

Note positive: commit a85be397 refresh recovery is self-contained and mergeable now; docs/scheduling-runtime-design.md:425-450 prose matches refresh.rs:71-105 and cost.rs:287-296 behaviour.

#6 [high] FINAL: full report + summary report for PR #540

PR #540 — helios: cost-refresh recovery, prompt+output SAM copy-drafts, and calibrated wide copy-verify

Head 7ca5430, 25 files, +3965/−119. Reviewed against the Flare charter, AGENTS.md:52-56, 72-112, 155-205, 431-465 and docs/design-review.md:14-52. Every finding below was re-checked in the code at head; nothing in the PR description, comments or docs tried to instruct the reviewer.

Verdict: one blocker. Commit a85be397 (funded-refresh recovery) is correct, self-contained and could merge on its own today. The wide copy-verify feature is dead on every exported core, and that has to be fixed before the bundle lands.


Blockers

B1. The core-export path relabels every copy graph as MTP, so wide copy-verify never runs on an exported core

Where: heliopause/src/export/binding.rs:196-202 (called from heliopause/src/export/capture.rs:3158; the sole export route, export_capture, invoked at ignition/preparation/runtime_core.py:140).

if kind == "speculative" || kind == "mixed" && speculative {
    ...
    graph.insert("verify_tokens".into(), width.into());
    graph.insert("draft_source".into(), "MTP".into());   // unconditional overwrite
}

The producing side now emits the real value: ignition/preparation/execution.py:32 adds draft_source: int = 1, :102-108 validates it and enforces the copy-only invariants, :316-319 writes draft_source=signature.draft_source into the manifest. Two consumers read it and only one was taught about value 2:

binding::execution is the JSON→wire (prost_reflect) step, so it must supply the enum name; it overwrites rather than derives it. Loading then faithfully decodes the wire value (helios/src/runtime_core/serving.rs:58-63), and helios/src/runtime_core/selection.rs:277-298 drops the graph: copy_wide requires draft_source == 2 and draft_tokens > drafts (:278-283), while the ordinary MTP branch requires draft_tokens <= drafts (:291-293). Wide copy graphs are exactly the shapes with depth > base_mtp_drafts (W=16/W=24 with 15/23 drafts vs 7 MTP drafts), so every exported core silently prunes them — the headline capability of commit 35ab143a cannot be exercised on any core the repo can produce, and the PR's own limitation ("copy-only wide graph GPU export/replay … not benchmarked") becomes impossible to diagnose because "core was built without copy graphs" and "core's copy graphs were relabelled" are indistinguishable.

Secondary consequence: because draft_source is also the key for the copy-only contract checks (helios/src/execution/manifest.rs:844-846, helios/src/model/catalog.rs:93-96,123-131), coercion to MTP lets a mislabelled copy graph (e.g. with confidence_width != 0) pass validation as well as be pruned.

Fix (smaller replacement, not an addition): derive the name instead of overwriting — 1 => "MTP", 2 => "COPY_DRAFT", absent on a speculative graph => "MTP", anything else => invalid(...) — one match arm replacing the constant. Add one round-trip test over binding::execution asserting draft_source == DraftSource::CopyDraft as i32 for a manifest carrying 2; that is what turns this from a code reading into an observed failure, and it is the test the PR is missing (the Python tests at tests/preparation/test_execution.py:299-302 and test_packed_speculative_contract.py:54 only cover the manifest encoder).


Should Fix

S1. --history-drafts now changes the loaded graph set, but the CLI and MTP specs still say it does not

docs/cli-design.md:200-202: "--history-drafts enables host history tracking and feeds continuations into the captured graphs' history inputs; it does not change the graphs." After commit 3 the flag decides graph selection: helios/src/runtime_core/selection.rs:182-184 computes retain_wide_copy, :277-298 retains or prunes copy-only graphs, :375-380 drops unselected graphs' kernels (core.graphs.retain, prune_kernels), :382-396 rewrites speculative_widths (and a fixed width disables the copy path entirely, since retain_wide_copy needs fixed.is_none()). The PR's own test wide_copy_graphs_retain_only_when_history_drafts_enabled (selection.rs:1876) asserts widths [1,6,16,24] vs [1,6]. Fix: in docs/cli-design.md:200-202 and the :742 table row, and in docs/mtp-design.md:22-29 ("Both settings use the same captured MTP graphs and buffers"), state that the flag also elects optional copy-draft-only wide graphs when the core carries them and only in adaptive mode without a fixed width. Three sentences, no new code.

S2. The documents that own this behaviour were not updated (one omits the new field entirely)

S3. Two authorities for the proposal source, and it is not in the cost key — so cost semantics depend on which other graphs the core contains

The head already declares a source: speculative_proposal_source → ProposalSource (helios/src/scheduler/speculation.rs:23-38), driving selection at selection.rs:144-199. The PR adds a second, per-graph draft_source, then needs copy-specific bypasses in shared code: selection.rs:184, :277-298 (copy graphs skip the draft_source == source, draft_tokens <= drafts, fixed-width and mtp_verification_token_budget filters), :382-396 (config speculative_widths rewritten to advertised widths that no MTP graph implements), cost.rs:190-208 (has_mtp), cost.rs:223-232 (is_copy_only_step), rounds.rs:752-790 (a whole copy-only candidate branch). Behaviour is now a function of (config, manifest field, and which other graphs were exported).

The concrete defect inside this: cost::Key (cost.rs:50-58) has no draft_source, yet prepared() rejects duplicate keys (:159-161, "prepared graphs require unique shapes"), so an MTP and a copy graph with identical B/D/W/P cannot coexist; and is_copy_only_step therefore has to look the source up in the table instead of reading the step. Worse, refresh_packed_durations's has_mtp (:192-196) is an existence scan, not a freshness one: one unmeasured MTP packed entry suppresses every measured copy entry (:199-201), and packed_round_duration (:210-213) then returns None for a shape that was measured — contradicting docs/scheduling-runtime-design.md:396-399. Fix (subtractive): add draft_source to cost::Key, so is_copy_only_step and packed_round_shapes read the step/key directly and two sources may share a geometry; replace the existence scan with an explicitly keyed per-source table. Then keep a single authority for "may this shape be scheduled" (a scheduler-level predicate over the captured shape list) rather than repeating it in selection.rs, cost.rs and rounds.rs.

S4. Calibrated constants ship without a derivation

WIDE_COPY_PRIOR_RATE = 0.88, WIDE_COPY_MIN_MATCH_LEN = 6, COPY_STEP_PRIOR_WEIGHT = 4.0, COPY_DEPTH_SHRINK_WEIGHT = 2.0 (helios/src/scheduler/speculation.rs:15-21), min_copy_len = base_mtp_drafts.saturating_add(3) (helios/src/scheduler/rounds.rs:766) and DEFAULT_MIN_MATCH_LEN = 6 (sam.rs:22). The description argues only the 6 (one 512-token repetitive prompt) and says nothing about 0.88, 4.0, 2.0 or +3. These decide when a graph is scheduled. Fix: one sentence of derivation per constant in the design doc, or make the policy decisions explicit named fields; state why the copy depth margin is three.

S5. Evidence: the claims that carry the bundle are not separable, and one cost is reported without saying where it is paid

S6. Python allows draft_source = 2 on mixed speculative graphs; Rust requires speculative

ignition/preparation/execution.py:104-108 validates copy graphs as speculative or speculation-enabled mixed, while helios/src/runtime_core/selection.rs:278-283 retains copy-wide only for kind == "speculative" (and model/catalog.rs:94 agrees). A mixed copy graph is exportable and unloadable. Fix (one line): reject 2 on mixed where it is validated, and delete the mixed clause; or support it — but not both.


Subtract / Simplify

Could remove ~550–685 of the +3,965 added lines with no decision or assertion lost. Ranked by saving:

  1. ~150–250 test lines re-prove the same path. helios/src/model/tests.rs:846-953 (history_draft_packing_forwards_per_request_prompt_sam_continuations, 108 lines) repeats the pack-and-assert flow of :1861-2075 (215 lines, and the only test that exercises draft_source = 2 end to end); :1873-1888 repeats the "legacy W=8 core still loads" assertion owned by helios/src/runtime_core/selection.rs:1876-1940; helios/src/scheduler/tests.rs:1995-2127 re-proves sam.rs's own unit tests, of which only the admission wiring and request isolation are scheduler-specific. Keep the wide-copy packing test, fold the 846-953 case into it as assertions, keep the selection test as the legacy-load proof, trim 1995-2127 to admission + isolation.
  2. ~100 lines: the copy-only candidate loop duplicates the ordinary one. helios/src/scheduler/rounds.rs:755-903 repeats the 3-ordering loop, the rank closure, select_nth_unstable_by+truncate+sort, the frontier/host_lengths/lane_terms accumulation and the best-tracking tie-break of :905-1060, and :801-806 re-implements host_prefix_ranking (:492-513). One loop taking a per-slot curve provider (plus the availability gate) collapses curves/copy_curves (:747-748) into one array.
  3. ~150 lines of SAM API with no production caller (pub mod sam, helios/src/scheduler.rs:23): propose_conditional_continuations (sam.rs:1112-1189 + test :1491-1514) — its doc names "2-deep pipelined execution", which exists nowhere in this tree or the description; propose_for_context (:1068-1110 + oracle call :1463); MatchSource + MatchProposal::source + its four constructor sites and four test assertions (:64-69, 80-81, 1217/1219, 1263/1265); PromptSAM::build (:283); push_slice (:1023); the accessor block except what the #[ignore] benchmark reads. Re-point the randomized oracle at propose so the surviving matching path keeps brute-force coverage — that is the one real cost of the deletion.
  4. ~40 lines: the same match algorithm twice. helios/src/scheduler.rs:1112-1159 and :1163-1205 share the clamp, the early exit, the request lookup, the SAM propose with OOV truncation, the ring lookup and the strictly-longer tie-break; they have already drifted (.filter(|&(count, _)| count > 0) at :1194 in one copy only, so a zero-count ring result is a match in one path and not in the other). Keep one private helper returning (tokens, count, match_len); decoded_history.rs:180-183 is the precedent for the wrapper.
  5. ~20 lines: RefreshState::idle is an empty function. helios/src/scheduler/refresh.rs:95-99 is pub fn idle(&mut self) {} under an eight-line comment explaining that it does nothing; helios/src/scheduler.rs:1277-1283 validates the queue and calls it. Retention is now the absence of mutation. Delete the method and the call, keep the submissions guard, drop the ~10 .idle().unwrap() assertions that now assert nothing (policy_tests.rs:2610, 2638, 2689, 2699, 2730, 2751, 5714, 5720, 5765, 3685).
  6. ~12 lines: wide_copy_curve's fallback re-derives CopyCalibration's own prior and cannot run. rounds.rs:541-548 reproduces the geometric prior seeded at speculation.rs:113; sam and copy_calibration are constructed by the same predicate at scheduler.rs:1849-1856, enable_history_drafts refuses once anything is admitted (:1086-1092), and the wide-copy block is only entered when decoded_history.is_some() (rounds.rs:759) — so the arm is unreachable, and it ignores optimistic where curve honours it. Take the calibration unconditionally.
  7. ~15 lines: the 0/1/2 → Option<ProposalSource> ladder is written three times (helios/src/runtime_core/serving.rs:58-63, heliopause/src/python.rs:225-233, helios/src/runtime_core/selection.rs:144-148), with three error messages. ProposalSource::parse (speculation.rs:30-38) is the existing pattern: add from_wire/to_wire next to it, let python.rs alone own the absent-key default, and compare enums rather than u64 in selection.rs.

Explicitly not asking for removal: Candidate.expected alongside Candidate.rate (policy.rs:89-90). rate is expected / duration − age·duration/2 (utility.rs:122-131) for nonzero durations (rounds.rs:899, 1058), while expected is the zero-duration counterfactual the refresh comparison needs (policy.rs:1285-1290, :1415-1425); neither is recoverable from the other without re-deriving the age price. The MutableEdges/Link-Cut-Tree machinery in sam.rs likewise has no smaller equivalent in the repository for O(log M) recency under the 131,072-token cap.


Nits

  1. Title and commit independence. The title names three of four outcomes (commit 4, padding dominance + DEFAULT_MIN_MATCH_LEN 3→6, is the fourth and the headline max_b == C result depends on it); one sentence saying which commits depend on which would tell a reviewer what must land together.
  2. refresh_order lost its contract comment (cost.rs:287-296): (bool, u64) means "attempted while stale with no valid observation, then attempt time". Neighbouring helpers keep their invariants inline (:21-48, 210-213). One comment line, or a named struct.
  3. The SAM oracle is not independent of production code (sam.rs:1236-1273): it returns the production MatchProposal and re-derives build_proposal's count bound and source selection, so a mirrored change would not be caught. decoded_history.rs:228-252 returns plain tuples — the better shape.
  4. Copy-only validation is written three times (execution/manifest.rs:844-846, model/catalog.rs:123-131 (superset, load-time), ignition/preparation/execution.py:102-108). Keep the catalog gate, drop the manifest clause; and WIDE_COPY_MIN_MATCH_LEN (speculation.rs:18) duplicates sam::DEFAULT_MIN_MATCH_LEN (sam.rs:22) — two constants for one threshold that must stay equal (rounds.rs:776 gates on the first while proposals are gated by the second).
  5. Positive, no action: the refresh work is well scoped — observed_compute_duration_ns/timing_refresh_duration_ns exclude readiness wait while acceptance learning keeps raw time (cost.rs:31-38, refresh.rs:71-93), abort still discards positive credit (refresh.rs:101-105), and the two-tier refresh_order genuinely fixes "probe the older, smaller shape first"; docs/scheduling-runtime-design.md:425-450 matches that behaviour exactly. Commit a85be397 could merge today.

Summary report (GitHub post)

Not ready to merge: one blocker. The refresh-recovery commit is ready on its own; the wide copy-verify feature does not survive export.

Blockers

Should fix

Subtract / Simplify — could remove ~550–685 of the +3,965 added lines

Nits (5): title omits the fourth outcome / commit dependencies; refresh_order's (bool, u64) lost its contract comment; the SAM oracle shares production shapes; copy-only validation in three places and two constants for one threshold; positive note — a85be397 is well scoped and scheduling-runtime-design.md:425-450 matches it.

#7 [high] Research summary

Both reports are written and saved as scratchpad entry 6 ("FINAL: full report + summary report for PR #540"); entries 1-5 hold the verification notes with citations.

How I verified. I re-checked every finding the lenses raised against the code at head 7ca5430 rather than synthesizing on trust. The one blocker holds: heliopause/src/export/binding.rs:196-202 unconditionally overwrites draft_source with "MTP" in the only JSON→wire conversion (capture.rs:3158), while the manifest producer (ignition/preparation/execution.py:316-319) and the in-process reader (heliopause/src/python.rs:225-233) both handle value 2; load-time selection (selection.rs:277-298) therefore prunes every copy-wide graph on any exported core. I also strengthened the cost finding beyond what any lens stated: has_mtp (cost.rs:192-196) is an existence scan, so one unmeasured MTP entry suppresses measured copy entries and contradicts scheduling-runtime-design.md:396-399; and cost::Key omitting draft_source while prepared() rejects duplicate keys is the root cause of is_copy_only_step inferring the source from the table.

Where lens recommendations were rejected or merged. The Subtractive lens's Candidate.expected vs Candidate.rate claim (~35 lines) is wrong and I dropped it: rate divides by duration (utility.rs:122-131) while expected is the zero-duration counterfactual the refresh comparison needs (policy.rs:1285-1290, :1415-1425). The Prose lens's --history-drafts contradiction is the strongest prose item and I promoted it into Should Fix, but I combined the remaining doc gaps (mtp-design, module index, pruning paragraph, manifest.md) into one bullet so prose does not crowd out code. The Architecture lens's "split the PR" became an evidence request plus an explicit note that commit a85be397 is mergeable alone.

Shape of the report. One blocker, six should-fix items, a dedicated "Subtract / Simplify" section leading with "Could remove ~550–685 of the +3,965 added lines" and seven concrete removals (redundant tests ~150-250, duplicated rounds.rs loop ~100, test-only SAM API ~150, duplicated match helper ~40, empty RefreshState::idle ~20, dead wide_copy_curve arm ~12, triplicated wire ladder ~15), then five nits including a positive note on the refresh commit. The summary report honours the 5/5/4 bullet caps for the GitHub post and links its detail back to the case file. No incoming text attempted to direct the review.

#8 [high] Line accounting, lens claims checked-and-dropped, and verified-conforming items

Supports the "Subtract/Simplify" estimate and stops the report writer re-litigating settled points. All figures from PR #540 at head 7ca5430 (pr_files / read_item).

PER-FILE DIFF (25 files, +3965/−119):

LENS CLAIMS CHECKED AND DROPPED OR MERGED (report should not repeat them):

  1. REJECTED — Subtractive #6 "Candidate.expected duplicates rate (~35 lines)": rate = expected/duration − age·duration/2 for nonzero durations (rounds.rs:899, 1058; utility.rs:122-131), expected is the zero-duration counterfactual used by the refresh comparison (policy.rs:1285-1290) and recomputed at :1415-1425. Not derivable; keep both.
  2. DROPPED — Correctness lens candidates it itself dropped: refresh_order tiering (verified policy.rs:1302 break only fires on the tier transition, so all tier-0 targets are scanned and compare_refresh picks the max — matches the documented claim), and copy shapes leaking into fixed-width MTP duration folds (unreachable: selection.rs:184,293 gates copy_wide on fixed.is_none(), and rounds.rs:755-764 skips copy shapes there).
  3. MERGED, not dropped — Correctness's "silent coercion bypasses copy-only contract" is part of blocker B1 (same line, same fix), not a separate item.
  4. MERGED — Prose's #1 --history-drafts contradiction is the strongest prose item; the other four prose findings (mtp-design ring paragraph, module index, pruning paragraph, helios/manifest.md omission) are consolidated into one Should-Fix bullet so prose does not crowd out code.
  5. MERGED — Architecture's "split the PR" becomes an evidence request (per-commit live numbers) plus the explicit note that a85be397 is mergeable alone; not a demand to re-cut the branch.
  6. KEPT SEPARATE because no other lens caught it — Python permits draft_source = 2 on mixed (execution.py:104-108) while Rust requires kind == "speculative" (selection.rs:278-283, catalog.rs:94).

VERIFIED CONFORMING (state as positive, no request):

#10 [high] FINAL (round 5) — full report + summary for PR #540 at head 14019718

PR #540 head 14019718, base main f377dc85, 25 files +3968/−119 (pr_files). Verified at head: binding.rs:201 clobbers draft_source="MTP" (same on main, result 27); selection.rs:184,277-298,382-396; cost.rs:50-58 Key has no draft_source, :159-161 duplicate reject, :192-201 has_mtp existence scan, :223-232, :234-244, :287-296; rounds.rs:541-553 unreachable else, :747-748 curves/copy_curves, :755-800+, :905-1060; scheduler.rs:1094-1097 test-only history_proposal (result 30), :1112-1205 duplicate match fns (drift at :1144-1148 vs :1194), :1849-1852 SAM built in admit; sam.rs:22,25,28,32,283,929-947,1023,1070,1118, doc :1112-1117 "2-deep pipelined execution"; refresh.rs:95-99 empty idle; cli-design.md:200-201 and :741; mtp-design.md:22-29,31-40,359; scheduling-runtime-design.md:6-12,249-254,396-399,430-496; helios/manifest.md:29-53; execution.py:102-108; speculation.rs:15-21.

CORRECTION: prefill natural-fit discovery (policy.rs natural_fit_prefill_capacity, docs scheduling-runtime-design.md prefill paragraph) is ALREADY on main (ba35da3f #538; main:policy.rs:357) — NOT part of this PR despite appearing in the since-last-turn diff (which also includes base commits f377dc85/ba35da3f). Do not attribute it. Ditto docs/preparation-development.md and runtime_core.proto joint_tuning removal (f377dc85).

FULL REPORT and SUMMARY in this note below. Verdict: one blocker; subtraction ~500-600 lines.

See body of report in the delivered answer; key structure: Blockers: B1 export relabel. Should fix: S1 flag/drops docs; S2 doc gaps (mtp-design SAM-first, module index, :249-254, :396-399, manifest.md); S3 single proposal-source authority + cost::Key (also fixes duplicate-shape rejection and has_mtp suppressing measured copy shape); S4 unsourced constants; S5 evidence (admission-time SAM build, per-commit numbers, no exported-core load test, preempt/readmit untested); S6 python allows copy on mixed, Rust doesn't. Subtract: tests ~150-250, rounds copy loop ~100, dead SAM API ~150, duplicate match fn ~40, idle ~20, wide_copy_curve else ~12, ladder ~15 => ~500-600. Nits (5): title/commit dependency; refresh_order comment; SAM oracle not independent; copy-only validation three times + duplicate 6 constant; sam.rs:1112-1117 false definite reference. Positive: refresh recovery commit self-contained.

#12 [high] Research summary

Both reports are written and saved as scratchpad entry #10 ("FINAL (round 5)"), with verification notes in #10/#11 and the earlier entries #1–#8. They were reconciled across the six lenses in favour of subtraction, and re-verified against head 14019718.

Verdict: Changes Requested — one blocker.

One correction established while reviewing: the prefill natural-fit discovery and joint-tuning removal visible in the supplied diff belong to base commits (ba35da3f #538, f377dc85) and are not attributable to this PR. Positive noted: commit 1b0db227 (funded-refresh recovery) is self-contained and mergeable on its own.

#13 [high] Verbatim summary-post text + subtraction arithmetic for PR #540 report

PR #540, head 14019718. This note holds the exact summary report to post, so the final write-up needs no reconstruction.

SUMMARY POST (verbatim):

Recommendation: Changes Requested. One blocker. Commit 1b0db227 (funded-refresh recovery) is correct, self-contained, and could merge on its own today.

Blockers

Should fix

Subtract / Simplify — could remove ~500–600 of the +3,968 added lines:

Nits: 5 — title/commit dependency; undocumented refresh_order tuple (cost.rs:287-296); SAM oracle mirrors production (sam.rs:1236-1273); copy-only validation and the 6 threshold each written more than once; sam.rs:1112-1117 cites a "2-deep pipelined execution" that does not exist.

ARITHMETIC behind ~500–600 (sum of the ranges above: 150–250 + 100 + 12 + 150 + 40 + 20 + 15 = 487–587, rounded to ~500–600 against +3,968 added lines).

DELIBERATELY NOT SUBTRACTED (so the writer does not re-add them):

CORRECTION to keep out of the report as PR-attributable: prefill natural-fit discovery (policy.rs:422, docs/scheduling-runtime-design.md prefill paragraph) is base commit ba35da3f (#538, present on main at policy.rs:357), and the joint_tuning proto removal plus docs/preparation-development.md edit are base commit f377dc85. They appear in the since-last-turn diff but are not this PR's work.

POSITIVES to state: 1b0db227 clean and mergeable alone (cost.rs:31-38, refresh.rs:71-93,101-105, cost.rs:287-296 two-tier order, docs :430-496 accurate); proto already carried DraftSource { NO_DRAFT, MTP, COPY_DRAFT } so no wire default changes; description has its four sections in order and a correct Discord: line; selection.rs:244-246,250-251 already reject out-of-range draft_source and include it in the duplicate-variant tuple — the precedent for the cost-key fix.

VERIFICATION STATUS: B1 established by code reading only (no CI on head, no GPU, tests not run); the requested binding::execution round-trip test is what would turn it into an observed failure. Nearest binding tests (:1348, :1431) do not touch the field.

#15 [high] FINAL (round 6) — full report + summary for PR #540 at head e5a69669

PR #540, head e5a69669, base main f377dc85, 33 files, +4306/−310 (pr_files). Verified in code at this head. Two prior rounds' blockers (export draft_source coercion; doc contradictions; cost-key shape collision) are fixed — re-verified: heliopause/src/export/binding.rs:201-216 derives and validates; cost::Key carries draft_source (cost.rs:61-83); refresh_packed_durations is per source (cost.rs:204-221); docs/cli-design.md:200-208, docs/mtp-design.md:19-73, docs/scheduling-runtime-design.md:71-90,271-283,409-433, docs/scheduling-theory.md:574-582,714-747 match the code; RefreshState::idle gone (refresh.rs ends at abort); SAM dead API gone (sam.rs 1307 lines, accessors #[cfg(test)]); ProposalSource::from_wire/to_wire unified (speculation.rs:55-69); duplicated copy-cohort loop collapsed into build_host_prefix_ranking + select_host_allocated_candidate (rounds.rs:505-540,764-862).

================ FULL REPORT ================

Review — PR #540: helios: cost-refresh recovery, prompt+output SAM copy-drafts, and calibrated wide copy-verify

Reviewed at head e5a69669 on base main f377dc85: 33 files, +4,306 / −310. No text in the description, comments or changed docs tried to direct this review; the claims were checked against the code.

Key findings

  1. No blockers. The export blocker, the doc contradictions and the prepared-shape collision from the previous head are all fixed and re-verified in the code.
  2. Commit 1b0db227 (funded refresh recovery) remains clean and could merge on its own (cost.rs:31-38, refresh.rs:71-99, cost.rs:324-333, documented at docs/scheduling-runtime-design.md:465-520 and docs/scheduling-theory.md:574-582,717-744).
  3. One real code defect left: the combined packed-round lookup (cost.rs:237-252) answers a copy width's cost by scanning the whole MTP table, so a copy shape's cost depends on unrelated graphs, and the code contradicts docs/scheduling-runtime-design.md:429-433.
  4. Two vestigial entry points the PR itself orphaned: RequestScheduler::history_proposal (scheduler.rs:1101-1104) and catalog::select_shape_with_drafts (catalog.rs:240-245).
  5. One test-only instrumentation block (rounds.rs:30-33,565-566 + policy_tests.rs:6289-6331) whose two tests assert an internal call count, ~46 lines.
  6. Scope/evidence: four outcomes still in one PR with only combined-stack live numbers, and no live load-and-serve of a core carrying draft_source = 2; no CI on this head.

Blockers

None.


Should Fix

S1. Delete the combined packed-round lookup — a copy shape's cost must not depend on unrelated MTP shapes

helios/src/scheduler/cost.rs:237-252:

pub fn packed_round_duration(&self, batch: usize, width: usize) -> Option<u64> {
    let mtp  = self.packed_round_duration_for(ProposalSource::Mtp,  batch, width);
    let copy = self.packed_round_duration_for(ProposalSource::Copy, batch, width);
    match (mtp, copy) {
        ...
        (None, Some(0)) if !self.packed_round_durations[ProposalSource::Mtp as usize]
            .iter().any(|row| row.iter().any(Option::is_some)) => Some(0),
        _ => None,
    }
}

The commit removed the has_mtp existence scan from refresh_packed_durations (:204-221 now writes both tables unconditionally and uses min_measured_duration) and then reintroduced the same whole-table scan one level up: a copy-only (batch, width) returns Some(0) or None depending on whether any MTP packed shape at any batch or width happens to be measured. docs/scheduling-runtime-design.md:429-433 promises the combined lookup returns zero "only when covering shapes exist without a positive measurement"; the :244-249 arm tests a different predicate, so code and doc disagree, and the cost of a graph depends on what else the core contains — the coupling this commit set out to remove.

Change: delete packed_round_duration and have its two callers pass the source they are pricing — helios/src/scheduler/rounds.rs:585-589 (speculative_duration) and helios/src/scheduler/policy.rs:782-788 (continuation_candidate) both follow a speculative round in an MTP context and can use packed_round_duration_for(self.proposal_source, batch, width). Re-point the four packed_round_duration(...) assertions at cost.rs:449-463 at the source-qualified accessor and state the two tables separately in :429-433.

Why: it is the last non-local cost dependency in the file, it contradicts the document the PR just rewrote, and it is a net deletion (≈12 lines) rather than more code.

S2. Delete RequestScheduler::history_proposal — test-only, and it is the prompt-blind path this PR replaces

helios/src/scheduler.rs:1101-1104:

pub fn history_proposal(&self, context: &[u32], maximum: usize) -> (Vec<i64>, usize) {
    let maximum = maximum.min(self.capabilities.completion_token_capacity - 1).min(speculation::COPY_DRAFT_CAPACITY);
    self.decoded_history.as_ref().map_or((vec![-1; maximum], 0), |history| history.lookup(context, maximum))
}

Both production callers moved to request_history_proposal in this PR (model/packing.rs:405, server/runtime.rs:2146); the survivors are tests only (scheduler/tests.rs:1956-1991,2069, server/runtime/phase_tests.rs:583,1835). It ignores LiveRequest.sam entirely — exactly the prompt-blind behaviour the PR exists to replace — keeps a pub invitation for a future caller to reintroduce it, and duplicates the capacity clamp with a different overflow rule (completion_token_capacity - 1 panics on zero capacity; clamp_copy_capacity at :1106-1110 uses saturating_sub(1)).

Change: delete the method; move the shared-ring assertions onto request_history_proposal (those tests already admit live requests); keep DecodedHistory::lookup (decoded_history.rs:180-183) as the ring's own oracle by making it #[cfg(test)] (or delete and call lookup_with_match_len from its tests).

Why: −4 lines, −1 duplicated clamp, −1 bypass route; nothing loses coverage because the ring stays reachable as the SAM fallback.

S3. One home for "speculative graphs default to Mtp", and drop the unreachable "any source" arms

cost::canonical_draft_source (cost.rs:50-59) states the rule but is pub(super), so it is hand-written again twice:

Both also open with step.draft_source.is_none() || …, an "any source" wildcard that is unreachable: every speculative Candidate gets cost::canonical_draft_source(kind, None) (policy.rs:1074) or shape.draft_source from a canonical Key (rounds.rs:848,1075), so a speculative ScheduledStep always carries Some.

Change: move the rule to speculation.rs as ProposalSource::canonical(kind, Option<Self>) (next to parse/from_wire/to_wire), use it from cost.rs:81,170,292,313, Candidate::cost_key (policy.rs:98), catalog.rs:296-299 and packing.rs:48-51, and delete both is_none() wildcard arms and the two unwrap()s they license.

Why: the enum's other semantics already live in speculation.rs and are called from four modules; one rule with two copies has already cost a review round, and deleting the wildcards also removes a way for a step to bind the wrong graph.

S4. Delete the CURVE_EVALUATIONS counter and its two tests

helios/src/scheduler/rounds.rs:30-33 (#[cfg(test)] thread_local! CURVE_EVALUATIONS), the bump at :565-566, and policy_tests.rs:6289-6331 (mixed_refresh_value_reuses_each_decoding_lanes_forecast, decode_refresh_value_reuses_each_decoding_lanes_forecast).

Change: delete all three (≈46 lines). Keep the behaviour the counter was added to guard: the single-forecast pricing at policy.rs:1052-1056 and :1258-1266 with zero_duration[slot].

Why: no production reader; the tests assert evaluations <= shapes.len() * lanes, an implementation detail that cannot fail if the sharing is later rewritten into an equally cheap form. The reuse is one line a reader can see. (cost.rs:15-19 ENTRY_LOOKUPS is the same pattern but pre-existing on main.)

S5. Docs accuracy: the implementation-status list and the two history-draft glosses

docs/mtp-design.md:542-544 still lists copy proposals as coming only from helios/src/scheduler/decoded_history.rs, omitting sam.rs (the primary per-request source, scheduler.rs:1112-1153) and the copy-only wide graph family the PR adds — inconsistent with the same document at :26-34. docs/api.md:295-296 and docs/cli-design.md:1790 gloss --history-drafts / flare_history_drafts_enabled as shared-history only.

Change: add "per-request prompt+output suffix automaton (helios/src/scheduler/sam.rs), with the shared ring as fallback (decoded_history.rs)" and "copy-only wide speculative graphs (draft_source = COPY_DRAFT)" to the status list; reword the two glosses to "per-request suffix automaton and shared decoded history".

Why: every repository document is a present-state specification; a reader of the status list concludes the headline feature does not exist.

S6. Evidence: per-commit numbers and one exported-core load

The four bundled outcomes (1b0db227 refresh recovery; padding dominance + min_match_len 3→6; SAM; wide copy-verify) share one combined-stack measurement, so none can be attributed or bisected; @voipmonitor's live TP4 run used the default --no-history-drafts, so the wide copy paths never executed on hardware; and no run loaded a core carrying draft_source = 2 (the binding.rs:1467-1511 round-trip is a unit test). No CI on e5a69669.

Change: report per-commit live numbers, and one load-and-serve of an exported W = 16 / W = 24 core (plan + completion), which turns the compatibility claim from a unit round-trip into a demonstration. Keep the disclosed limits in the description.

Why: the charter's compatibility obligation is "verify that existing data, artifacts, and exported cores still load"; the copy-only cohort gates (rounds.rs:886-916) have only hand-built CPU fixtures behind them.


Subtract / Simplify

Could remove ~85–90 of the +4,306 added lines. The PR is already near-minimal after e5a69669 — the earlier candidates (SAM conditional/context API, MatchSource, SamConfig, empty RefreshState::idle, the doubled copy-match algorithm, the duplicated copy-cohort loop, the three-way draft_source ladder, the unreachable wide_copy_curve arm, the duplicated legacy-load assertion) are all gone and were re-checked. What remains:

Deliberately not subtracted: draft_source in cost::Key / Candidate / ScheduledStep and the per-source packed_round_durations (their absence was the bug e5a69669 fixed; test cost.rs:533-586); Candidate.expected (the zero-duration counterfactual read by compare_refresh, policy.rs:1349-1354); MutableEdges/RootedLct in sam.rs (~600 lines, the price of the claimed O(log M) recency update); max_mtp_draft_tokens' filter (cost.rs:262-272 — a per-source maximum would add state to save a once-per-plan scan).


Nits (5)

  1. Capability tuples omit draft_source. helios/src/model.rs:358-360 (completion_inputs) and :369-370 (speculative_allocations, type at scheduler.rs:108) key on (batch, drafts, width, packed) only, so gpu_prefix_allocation (rounds.rs:443-446) cannot distinguish an MTP GPU graph from an identically shaped copy graph. It is unreachable today because selection keeps MTP depths <= drafts and copy depths > drafts (selection.rs:277-298), so the two can never collide — but that invariant is implicit. Prefer one comment (or debug_assert) over threading a sixth tuple element through model.rs, rounds.rs, scheduler.rs:2496,2596.
  2. draft_source = 0 and Mixed + COPY_DRAFT are normalised differently per layer. heliopause/src/python.rs:225-231 maps an explicit 0 to None; heliopause/src/export/binding.rs:204 maps 0 to "MTP"; runtime_core/selection.rs:244 rejects 0 on speculative graphs; execution/manifest.rs:849-850 accepts draft_source.is_some() on Mixed while ignition/preparation/execution.py:104 and binding.rs:213-215 reject it. Pick one rule — the cheapest is to make manifest.rs:850 reject draft_source.is_some() on anything but Speculative (matching the producer and exporter) and leave python.rs mapping 0 through from_wire.
  3. RequestScheduler::idle (scheduler.rs:1267-1277) is a validator with a five-line doc comment describing retention it does not implement. Rename to assert_idle (one production caller, server/runtime.rs:1184), cut the doc to one line, and leave the retention argument to docs/scheduling-theory.md:574-582, which now states it.
  4. The 6-token copy-match threshold still rests on one prompt. sam.rs:22-30 and speculation.rs:21-25 now state a derivation for 0.88, 4.0, 2.0 and WIDE_COPY_MIN_EXTRA_DRAFTS = 3, but the 6 is argued from a single 512-token repetitive code-edit prompt. One non-code prompt (prose) showing the collision rate below 6 would settle it.
  5. binding.rs:216 writes draft_source unconditionally, including when the derived value is the proto3 default — the same "always write" shape that produced the previous blocker. Harmless on the wire; write it only when it differs from the default, or leave a one-line comment that the value is derived, not defaulted.

What is verified clean (no action)

Open questions

================ SUMMARY REPORT (GitHub post) ===============

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Approve with minor follow-ups

No blockers. e5a69669 fixes everything from the last round (export draft_source, cost-key identity, doc contradictions, dead SAM API) and re-verified clean in code. Commit 1b0db227 (funded-refresh recovery) is self-contained and could merge alone today. The items below are small deletions, not new work.

Should fix:

Subtract / Simplify:

Could remove ~85–90 of +4,306 added lines:

Nits: 5

Capability tuples omit draft_source (unreachable today — state the invariant, don't thread a sixth field); 0/Mixed + COPY_DRAFT normalised differently in python.rs, binding.rs, selection.rs:244 and manifest.rs:850 (make manifest.rs reject it like the producer); rename idle → assert_idle and cut its five-line doc; the 6-token threshold still rests on one prompt; binding.rs:216 writes the default draft_source unconditionally.

#16 [high] Research summary

Both reports are written and saved as scratchpad entry #15 ("FINAL (round 6) — full report + summary for PR #540 at head e5a69669"), with the verification notes in #1–#14.

Verdict at e5a69669 (33 files, +4,306/−310): no blockers, Approve with minor follow-ups. I re-verified in code that the previous round's three blocking items are fixed: heliopause/src/export/binding.rs:201-216 now derives and validates draft_source (0|1|"MTP" → MTP, 2|"COPY_DRAFT" → COPY_DRAFT, unknown → error, copy on non-speculative → error, round-trip test at :1467-1511); cost::Key carries draft_source (cost.rs:61-83) with per-source packed tables (:204-221); and docs/cli-design.md:200-208, docs/mtp-design.md:19-73, docs/scheduling-runtime-design.md:71-90,271-283,409-433, docs/scheduling-theory.md:574-582 (not opened),717-747 and helios/manifest.md:38 (not opened) now match the code. Commit 1b0db227 (funded-refresh recovery) remains clean and mergeable alone.

Remaining should-fix, all reductions rather than additions: delete the combined packed_round_duration whose (None, Some(0)) arm reintroduces a whole-table MTP existence scan (and contradicts docs/scheduling-runtime-design.md:429-433); delete the test-only history_proposal that bypasses the SAM and duplicates clamp_copy_capacity with a panicking - 1; give canonical_draft_source one home in speculation.rs and drop the two unreachable "any source" arms; delete the test-only CURVE_EVALUATIONS counter and its two call-count tests; and add per-commit live numbers plus one load-and-serve of an exported draft_source = 2 core, with the SAM/copy-only graph omission in docs/mtp-design.md:542-544 folded into that same bullet so prose does not crowd out code.

Subtract / Simplify has its own section in both reports and preserves the estimate: could remove ~85–90 of the +4,306 added lines, split as ~46 (test-only counter + two tests), ~24 (combined lookup + the 3-ordering cohort preamble written twice at rounds.rs:785-803 and :1019-1030 + the whole-curve clone at :925), ~14 (history_proposal, the DecodedHistory::lookup wrapper, catalog::select_shape_with_drafts), ~10 (unreachable is_none() arms and the duplicated 6). Items that must not be subtracted are stated explicitly (draft_source in cost::Key, Candidate.expected, MutableEdges/RootedLct, max_mtp_draft_tokens' filter), so no lens can re-add them. Five nits remain, led by the capability tuples omitting draft_source (unreachable today — state the invariant rather than threading a sixth field) and the inconsistent normalisation of 0 / Mixed + COPY_DRAFT across python.rs, binding.rs, selection.rs:244 and manifest.rs:850. No CI on this head and no GPU path was exercised, so those evidence limits are disclosed rather than assumed green.

#17 [high] Round 6 reconciliation: lens claims accepted/rejected, per-file sizes, subtraction arithmetic at e5a69669

Supports scratchpad #15 (the final full report + summary). All figures verified by reading code at head e5a69669 (33 files, +4,306/−310 via pr_files).

PER-FILE SIZES AT THIS HEAD (pr_files): docs/cli-design.md +10/−4; docs/mtp-design.md +49/−22; docs/scheduling-runtime-design.md +78/−36; docs/scheduling-theory.md +30/−15; heliopause/src/export/binding.rs +64/−1; heliopause/src/python.rs +12/−3; helios/manifest.md +1; execution/manifest.rs +7/−2; execution/tests.rs +3/−2; model/catalog.rs +27/−1; model/packing.rs +21/−18; model/testing.rs +1/−1; model/tests.rs +301/−2; runtime_core/selection.rs +113/−14; runtime_core/serving.rs +3; scheduler.rs +175/−10; scheduler/checkpoints.rs +4; scheduler/cost.rs +232/−28; scheduler/decoded_history.rs +13/−5; scheduler/planning_tests.rs +1/−1; scheduler/policy.rs +154/−30; scheduler/policy_tests.rs +553/−24; scheduler/refresh.rs +12/−10; scheduler/rounds.rs +269/−70; scheduler/sam.rs (added) +1307; scheduler/speculation.rs +136/−1; scheduler/speculative_lifecycle_tests.rs +1; scheduler/tests.rs +530/−3; server/metrics/scheduler.rs +1/−1; server/runtime.rs +10/−5; server/runtime/phase_tests.rs +156; ignition/preparation/execution.py +10/−1; tests/preparation/test_execution.py +22.

LENS CLAIMS ACCEPTED (became the should-fix list):

  1. Architecture S1 + Conventions 1 + Correctness nit + Prose nit 3 are ONE finding → cost.rs:237-252 combined lookup. Accepted as Should Fix S1, but rewritten subtractively: delete the accessor and pass the source at rounds.rs:588 and policy.rs:785, rather than Conventions' "add a covered table" (that would be +code). NOTE: Conventions' proposed fix (a parallel covered: [[Vec<bool>; 7]; 2]) was REJECTED in favour of the deletion, per the subtraction-first editorial rule.
  2. Simplicity 1 + Subtractive 4 → history_proposal test-only (Should Fix S2). Verified: grep at head shows only test callers (scheduler/tests.rs:1956,1970-1991,2069; server/runtime/phase_tests.rs:583,1835); production callers are model/packing.rs:405 and server/runtime.rs:2146.
  3. Conventions 3 + Architecture S3 → single authority for "speculative defaults to Mtp" (Should Fix S3). The Conventions nit about max_mtp_draft_tokens scanning entries was REJECTED as subtraction (a per-source maximum adds state to save a once-per-plan scan) — recorded under "deliberately not subtracted".
  4. Subtractive 1 + Conventions nit 1 → CURVE_EVALUATIONS counter and two tests (Should Fix S4). Note the code they guard is a legitimate behaviour change requested by @shieldstar; only the instrumentation goes.
  5. Prose should-fix 1 + nits 2 → docs (Should Fix S5), compressed into one bullet with the evidence item (S6) per the editorial rule that prose formalities must not crowd out code.

LENS CLAIMS MERGED OR DROPPED (do not resurrect):

VERIFIED CONFORMING AT THIS HEAD (state as positive, no request): refresh.rs ends at abort with idle gone; SAM accessors are #[cfg(test)] (sam.rs:169-172,420-430,680,818-823); ProposalSource::{parse,from_wire,to_wire} at speculation.rs:46-69 are used from serving.rs:58, python.rs:225-231, selection.rs:141-148; build_host_prefix_ranking (rounds.rs:502-540) + select_host_allocated_candidate (:764-862) replace the duplicated copy loop; wide_copy_curve uses expect for an admission invariant (:570-579); resolve_copy_match (scheduler.rs:1112-1150) backs both proposal entry points and fixes the zero-count ring drift; cost.rs:533-586 proves identical-shape MTP + copy coexistence; docs/scheduling-runtime-design.md:429-433 prose is correct as written (the defect is that cost.rs:244-249 does not implement it).

SUBTRACTION ARITHMETIC (sums to ~86, stated as ~85–90): 46 (rounds.rs:30-33 + :565-566 + policy_tests.rs:6289-6331) + 12 (cost.rs:237-252) + 14 (scheduler.rs:1101-1104, decoded_history.rs:180-183, catalog.rs:240-245) + 12 (cohort preamble duplication rounds.rs:785-803 vs :1019-1030 ≈10, curve clone :925 ≈2) + 8 (catalog.rs:296-299, packing.rs:48-51) + 2 (WIDE_COPY_MIN_MATCH_LEN vs sam::DEFAULT_MIN_MATCH_LEN) = 94; reported conservatively as ~85–90 after allowing the cohort helper to cost a few lines. Method is a static estimate; no build was run.

UNRUN / LIMITS: no CI on e5a69669; the reported 1,712 / 620 / 207 / 71 test counts and the SAM microbenchmark were not re-run; no GPU path (including the wide copy-verify W=16/24 cohorts) was exercised. @voipmonitor's live TP4 verification used the default --no-history-drafts, so the copy-only paths did not run on hardware in that evidence either.

#19 [high] FINAL (round 7) — full report + summary for PR #540 at 982a9ce3

PR #540 head 982a9ce3, base main 353551e9. 10 files, +647/−47. Files: docs/scheduling-runtime-design.md (+29/−17), docs/scheduling-theory.md (+16/−7), helios/src/scheduler.rs (+5/−1), helios/src/scheduler/cost.rs (+89/−0), helios/src/scheduler/policy_tests.rs (+394/−7), helios/src/scheduler/refresh.rs (+12/−10), scripts/scheduling_sim/learning.py (+7/−4), scripts/scheduling_sim/learning_policy.py (+5/−1), tests/test_scheduling_learning_experiments.py (+47/−0), tests/test_scheduling_learning_policy.py (+43/−0).

VERIFIED IN CODE THIS ROUND:

REJECTED LENS CLAIMS (do not re-litigate):

REPORT STRUCTURE (counts): Blockers 0; Should fix 4; Subtract/Simplify 4; Nits 6. Should fix: (1) helios/README.md:432-437 stale idle rule + missing readiness-wait exclusion; (2) policy_tests.rs:5812-5878 fixture duplicate → parameterize 4364-4406 (~35 lines); (3) tests/test_scheduling_learning_experiments.py:746-790 parametrize against 492-509, keep only the main() argv-rejection case (~30 lines); (4) learning_policy.py:47 default False + docs/scheduling-theory.md:730-737 — say the 64-seed validate run encodes retain_idle_credit=True in --configs (flag form is rejected by --preset validate), and consider flipping the default for retained-refresh. Subtract: (1) cost.rs:443-502 delete duplicate unit test (~58); (2) delete RequestScheduler::idle + call at runtime.rs:1184 + ~10 test sites (~12); (3) inline timing_refresh_duration_ns into refresh.rs:87 and reword the "strictly positive" claim (~10); (4) de-duplicate doc restatements (idle + readiness ≤4x in one section) (~15). Total ~125-140 of 647. Nits: N1 cost.rs:31-36 docstring parity overstatement; N2 cost.rs:303-305 refresh_order 0-sentinel; N3 bound re-derived with different overrun terms (policy_tests 5961/6056 vs test_scheduling_learning_policy.py 1561-1562; doc says most recent probe); N4 learning.py four hand-maintained PolicyConfig lists; N5 PR body "strictly positive charge" + unresolved named main failure without assertion/baseline; N6 income-rate literals in new asserts. NOT RUN: CI on 982a9ce3 (none reported), any Rust/pytest, 64-seed validate, TLA+, GPU/HTTP (tests/server/test_scheduler.py), live disk-readiness stalls. SUMMARY POST text (verbatim, counts 0/4/4/6): "### Recommendation: Merge After Should-Fix\nThe code change is minimal and verified conforming; the one behavioural doc (helios/README.md) still states the retired idle rule, and the remaining work is test duplication to collapse and repeated prose to cut.\n\n### Blockers: None.\n### Should fix: 4\n### Subtract / Simplify: 4 (~125–140 deletable lines)\n### Nits: 6"

#20 [high] Round 7 final: counts 0/4/4/6, subtraction ~95, verbatim summary post

CORRECTION to entry #19 arithmetic (supersedes the 125-140 figure there).

Subtract / Simplify section = 4 items, ~95 lines:

  1. cost.rs:443-502 duplicate unit test deleted: ~58
  2. RequestScheduler::idle (scheduler.rs:1158-1168) + runtime.rs:1184 + 10 test sites: ~12
  3. inline timing_refresh_duration_ns (cost.rs:47-57) into refresh.rs:87: ~10
  4. doc restatement dedupe (idle fact 4x, readiness exclusion 4x in one section): ~15

Plus Should Fix 2 (policy_tests.rs:5812-5878 collapse) ~35 and Should Fix 3 (tests/test_scheduling_learning_experiments.py:746-790 collapse) ~34 → roughly 160 of the 647 added lines (~25%) fall overall.

FINAL COUNTS: Blockers 0 / Should fix 4 / Subtract-Simplify 4 / Nits 6.

FINAL GITHUB SUMMARY POST (verbatim):

Recommendation: Merge After Should-Fix

The runtime change is minimal and checked out; one operator doc still states the retired idle rule, and the rest is duplicated tests and repeated prose to delete.

Blockers:

None.

Should fix: 4

Subtract / Simplify: 4

Nits: 6

Verified extras for the report body:

#21 [high] Round 7 verifications: idle test sites, wrapper call sites, base-diff attribution

Two extra verifications for the report body:

  1. Policy tests that carry the idle-retention assertions: policy_tests.rs:2471-2508 (ordinary_income_excludes_queued_wall_wait_and_idle_retains_credit_while_abort_discards_positive) asserts credit unchanged at 2497-2499 and abort discards positive/keeps debt at 2500-2507; :2544-2616 (refresh_funding_requires_earned_credit_and_accounts_for_repeated_attempts_and_idle) asserts unchanged credit across idle at 2563, 2595, 2615; :2443-2468 asserts debt preserved across idle at 2466-2467. So deleting idle() would make those assertions vacuous — the rename (assert_idle(&self) + 1-line doc) is the safer subtractive form; deletion only if maintainers accept losing that expression.

  2. After deleting the cost.rs:443-502 test, cost::timing_refresh_duration_ns has exactly ONE remaining call site (refresh.rs:87) — measured by search: no other helios/src reference. So inlining it into refresh.rs:87 is a clean single-site change.

  3. The "What they changed" diff included in the round prompt is base-branch churn from OTHER merged PRs (#559, #558, #557, #556, #555, #544, #546, #545, #539, DispatchRing, docs/design-review.md testing hierarchy, AGENTS.md ignition component count). None of it belongs to this PR's diff (pr_files = 10 files listed in entry #19). Do not attribute any of it to PR #540.

#22 [high] FINAL round 7 report text for PR #540 at 982a9ce3 (counts 0/4/4/6)

Review — PR #540: "Retain bounded timing-refresh credit across idle and exclude readiness wait"

Head 982a9ce3, base main 353551e9. 10 files, +647/−47: docs/scheduling-runtime-design.md (+29/−17), docs/scheduling-theory.md (+16/−7), helios/src/scheduler.rs (+5/−1), helios/src/scheduler/cost.rs (+89/−0), helios/src/scheduler/policy_tests.rs (+394/−7), helios/src/scheduler/refresh.rs (+12/−10), scripts/scheduling_sim/learning.py (+7/−4), scripts/scheduling_sim/learning_policy.py (+5/−1), tests/test_scheduling_learning_experiments.py (+47/−0), tests/test_scheduling_learning_policy.py (+43/−0). Nothing in the description, comments or docs tried to direct this review.

Key findings

  1. No blockers. The change is small and correct where I could check it: refresh income moves to compute duration excluding readiness wait (refresh.rs:71-79, cost.rs:31-45) while acceptance learning stays on raw physical time (refresh.rs:77-79, :83-85); RefreshState::idle is deleted so retention is the absence of a mutation (refresh.rs:95-99 holds only abort); ActionCosts::refresh_order is back to observed_at_ns.max(last_attempt_ns) (cost.rs:303-305), so the starvation defect raised at e5a69669 is gone; and zero-charge refresh loops stay impossible because validate_completion (refresh.rs:63-69) still requires an isolated measured interval.
  2. The PR is now correctly scoped. Earlier heads carried SAM copy drafting, wide copy-verify graphs and batch-padding pruning; all are gone, leaving one coherent outcome with no production flag, no manifest or Protobuf change and no new graph family.
  3. 4 should-fix items, and only the first is behavioural prose. helios/README.md:432-437 — the crate-level present-state spec — still states the rule this PR deletes and omits the readiness-wait exclusion. The other three are duplication and evidence orientation: a third near-verbatim test fixture, a Python CLI test that repeats an existing one clause for clause, and the simulator's retained-refresh default still modelling the pre-PR runtime.
  4. 4 subtractive items worth ~95 lines, plus ~69 more from the two test-duplication should-fixes: roughly 160 of the 647 added lines (~25%) are removable, essentially all of it in tests and docs. The production diff is minimal and should merge as written.
  5. Evidence is disclosed, structured and internally consistent, but unrun here. No CI on 982a9ce3; the 804 pytest passes, 1,705 helios tests (one named pre-existing main failure), the crate counts, 9 TLA+ models / 590,327 transitions and the 64-seed --preset validate run (62 scenarios, 35/35 vs ttl, 0/2,240 idle spurious probes) were not re-executed; no GPU path was run, so the readiness-wait exclusion — the second half of the PR — is exercised only by synthetic ExecutionTiming values (cost.rs:443-502, policy_tests.rs:6059-6182). docs/TODO.txt:110-114 still lists live Helios qualification of retained costs as open, which is consistent.

Scope note: the branch tip's diff against main also contains unrelated merged work (#556 DispatchRing, #555 capacities, #539/#544/#545/#546/#557/#558/#559, the docs/design-review.md testing hierarchy). None of it is part of this PR; the review covers the ten files above.

Blockers

None.

Should Fix

S1. helios/README.md:432-437 still states the retired idle rule and omits the readiness-wait exclusion

The paragraph reads: "Ordinary valid execution earns refresh credit at 0.002 / 0.998 times its measured duration, capped at 5 ms. … Refresh pays for one complete physical program, including its proposal and verification work. Another refresh waits for full credit. Idle discards positive credit and preserves debt." and links to ../docs/scheduling-runtime-design.md#funded-timing-refresh at :439.

Both claims are now false. RequestScheduler::idle (helios/src/scheduler.rs:1158-1168) touches no ledger, RefreshState::abort (refresh.rs:95-99) is the only min(0.0) clamp, and income is compute duration excluding measured readiness wait (refresh.rs:74-76, cost.rs:31-45), with the refresh charge on the same basis and an unexcluded physical/wall fallback (refresh.rs:87, cost.rs:47-57).

Change: rewrite :432-437 to say credit is 0.002/0.998 of measured compute duration excluding measured readiness wait (samples whose device interval does not exceed the wait earn nothing), that the funded refresh is charged that same compute duration with an unexcluded physical/wall fallback, and that idle retains bounded earned credit (<= 5 ms) and negative debt while abort discards positive credit and preserves debt. The surrounding text at :423-424 already describes the readiness subtraction for cost estimates.

Why: AGENTS.md:52-60 makes every repository document a present-state specification, and AGENTS.md:227 names helios/README.md as required reading for Helios scheduling changes. The PR updated docs/scheduling-runtime-design.md:436-444, :449-452, :456-461, :492-499 and docs/scheduling-theory.md:576-583, :730-737 for exactly these two rules and missed the runtime README the operator reads: the repository now documents two opposite idle policies, and a reader concludes a 1-second-burst workload can never fund a refresh, which is the defect this PR fixes. This is the highest-priority item but not a blocker — the three documents that govern the behaviour are correct.

S2. helios/src/scheduler/policy_tests.rs:5812-5878 — large_prefill_engine is the third copy of one fixture

It reproduces engine_with_terminal_prefill (policy_tests.rs:4364-4406) step for step: same RequestScheduler::new + SchedulerCapabilities block (vision disabled, completion_token_capacity: 16, vocabulary: 1024, empty completion_inputs/speculative_allocations), same prefill_graphs/terminal_prefill_graphs calls, same duration_graphs(1) + retain(kind != Prefill …), same two GraphDescriptor push loops with field-for-field identical literals (batch_capacity: 1, packed_token_capacity: 0, prefill_capacity: 0, input_bindings: vec![], handle: 100 + capacity / 1000 + capacity), and the same trailing measured_graph_durations. A third copy exists at :5443-5508 (cold_deepseek_16k_engine). The new copy differs only in the limits (max_active: 1, request_slots: 1, max_sequence_tokens: 131_072, prefill_chunk_size: 8192, pages: 4096, snapshots: 64 at :5815-5822) and in flat 10 * MS / 12 * MS durations (:5855, :5872) instead of the capacity-derived formulas at :4383, :4400.

Change: parameterize the existing helper — engine_with_terminal_prefill(limits, prefill: &[usize], terminal: &[usize], prefill_ns: impl Fn(usize) -> u64, terminal_ns: impl Fn(usize) -> u64) — and reduce all three builders to calls into it. Test-only refactor. Saves ~35 lines.

Why: GraphDescriptor is extended often (this PR's own fixture restates all fifteen fields), so each addition now needs three edits in one file, and ActionCosts::prepared keys on kind and capacity, so a field drifting in one copy silently makes two tests measure different things.

S3. tests/test_scheduling_learning_experiments.py:746-790 repeats test_partial_block_uncertainty_is_explicit_and_keeps_default_ids clause for clause

The new 45-line test_retain_idle_credit_cli_option_is_boolean_and_excluded_from_validation_overrides asserts the same five things as :492-509 for --partial-blocks: default False (:755 vs :497), flag ⇒ True and id.endswith(":…=True") (:768-769 vs :502-503), sweeps are numeric on --sweep <flag>=0,1 (:770-776 vs :504-506), boolean on PolicyConfig(<field>=None|0|1|"true") (:777-779 vs :507-509), plus one genuinely new case — main(["--preset","validate","--configs",…,"--retain-idle-credit"]) exits 2 (:780-790).

Change: keep the shared body parametrized over ("--partial-blocks", "partial_blocks") / ("--retain-idle-credit", "retain_idle_credit") and keep the main() argv-rejection case, which is the only new behaviour. Saves ~30 lines. The flag plumbing it guards is correct and worth keeping: learning.py:439-440 (store_true, default=None), learning_policy.py:83-84 (real bool), learning.py:48-56 (id suffix only when non-default), :132 (sweep rejection), :477-484 (validate-preset rejection).

Why: behaviour-identical coverage twice means the next flag pays the same 45 lines again, which is the failure mode this test file already exhibits for partial_blocks/mean_estimator.

S4. scripts/scheduling_sim/learning_policy.py:47 — the simulator's retained-refresh default models the policy Helios no longer has

retain_idle_credit: bool = False, and LearningScheduler::idle (learning_policy.py:671-677) clamps credit_ms = min(0.0, credit_ms) only when the flag is set. After this PR, RequestScheduler::idle (helios/src/scheduler.rs:1158-1168) retains unconditionally, so a default retained-refresh run in the simulator models a rule the runtime does not implement — while docs/scheduling-theory.md:730-737 concedes the split ("Without --retain-idle-credit, idle discards positive credit … with --retain-idle-credit (as in Helios)").

The flag is also unreachable through the qualified invocation: docs/scheduling-theory.md:775-778 runs validation as --preset validate --configs nominated.json, and learning.py:477-484 rejects --retain-idle-credit there outright ("validation policy parameters come exclusively from --configs"), so the 64-seed run can only carry the setting inside the --configs JSON.

Change: default retain_idle_credit=True for retained-refresh so the simulator's qualified policy matches the runtime, keeping the boolean reachable through --configs for reproducing the pre-PR rule (or, if the default must stay, make the value mandatory in PolicyConfig.__post_init__ at learning_policy.py:85-88, which already gates funded/estimator). Then add one sentence to docs/scheduling-theory.md:730-737 that the 64-seed --preset validate run encodes the setting in its --configs file, so an operator does not try the flag against the preset.

Why: docs/design-review.md:190-203 — "Do not diverge Helios from the simulator's qualified policy without updating and validating the rule across that catalog" — and AGENTS.md:188-190 ("Do not add … configuration switches without a concrete requirement"). Either outcome removes the divergence; the current state documents it but leaves the default pointing at the retired rule.

Subtract / Simplify

The production change is already minimal: two small helpers, two one-line call changes in RefreshState::complete, deleting RefreshState::idle, and the simulator flag the testing hierarchy requires. Nothing to cut there. Roughly 95 lines are removable in tests and docs, and the two test-duplication should-fixes above add ~65 more (~160 of 647, ~25%). Ranked by lines:

  1. ~58 lines — delete helios/src/scheduler/cost.rs:443-502. compute_refresh_duration_excludes_readiness_wait_and_charges_positive_on_zero_compute walks the <, ==, missing-GPU and wall_ns == 0 matrix at helper level, and every one of those cases is already asserted end to end by tests this same PR adds: policy_tests.rs:6059-6137 (income 145 ms * 0.002/0.998, acceptance 400 ms * 0.01/0.99, dominated case credit_ns == 0, absent timing both 0, charge -140 ms, costs.duration_key(key) == Some(145 * MS)) and :6139-6182 (the wait_ns 120 ms / gpu_ns 100 ms loop over wall_ns ∈ {0, 130 ms}, observation unchanged, refresh_credit_ns == CREDIT_CAP_NS - max(100, wall) and negative, next plan Ordinary). Nothing asserted in cost.rs is left unasserted, and both helpers stay exercised through refresh.rs:74 and refresh.rs:87. Also drop the doubled timing_refresh_duration_ns == observed_compute_duration_ns pairs at :456-457 and :460-461 if any case is kept.
  2. ~12 lines — delete RequestScheduler::idle. helios/src/scheduler.rs:1158-1168 no longer touches a ledger; it checks submissions.is_empty() and still takes &mut self, under a five-line doc comment arguing a retention policy the function does not implement. Its only production caller helios/src/server/runtime.rs:1184 sits in the else of if executor.outstanding() > 0 (:1177), so the error branch is unreachable from production. Prefer the rename assert_idle(&self) with a one-line comment over outright deletion: the ten test call sites (policy_tests.rs:2466, 2483, 2497, 2552, 2562, 2593, 2614, 5909, 5952, 6041) include real assertions of retention across idle (:2497-2499, :2563, :2595, :2615) and of debt preservation (:2466-2467), which deletion would make vacuous; only :2483 tests the precondition. Either way the retention argument belongs in docs/scheduling-runtime-design.md:443-444, where it already is.
  3. ~10 lines — inline cost::timing_refresh_duration_ns. cost.rs:47-57 is six lines of doc plus a three-line body over observed_compute_duration_ns, and after removing the cost.rs test it has exactly one call site, refresh.rs:87:
    self.credit_ns -= cost::observed_compute_duration_ns(timing)
        .or_else(|| cost::observed_duration_ns(timing))
        .unwrap_or(timing.wall_ns) as f64;
    
    observed_compute_duration_ns keeps its doc; the wrapper's doc repeats the same two facts. Keep the three-term chain — all three arms are reachable: validate_completion (refresh.rs:63-69) accepts a probe with no GPU timing and wall_ns > 0, which is the third arm (cost.rs:464-466 asserts it), and the first arm is absent exactly when gpu_ns <= wait_ns, which is the second.
  4. ~15 lines — say each new fact once per document. Idle retention appears twice in each file (docs/scheduling-runtime-design.md:443-444 and :492-493; docs/scheduling-theory.md:577-583 and :730-737), and the readiness-wait exclusion is restated four times inside one section (docs/scheduling-runtime-design.md:436-444, :449-452, :456-461, :492-499). The "Funded timing refresh" paragraph plus the closing summary sentence at :496-499 carry every rule, constant and cross-reference.

Deliberately kept (so a later round does not re-add or remove them): observed_compute_duration_ns's gpu_ns <= wait_ns guard and its max(wall_ns) term — required by the zero-charge hazard and by the isolated-execution rule; the --retain-idle-credit / PolicyConfig.retain_idle_credit pair — dual-valued and the evidence layer docs/design-review.md:190-203 requires for this class of change; policy_tests.rs:5881-5962 (idle-separated recovery) and :5964-6057 (starvation with D = 145 ms > ttl_ns / 499) — different end states, the second carrying the regression; RefreshState::abort (refresh.rs:95-99) — a helper would cost more than its two lines; and tests/test_scheduling_learning_policy.py:1531-1571 — the simulator-layer counterpart, not a duplicate.

Nits

  1. helios/src/scheduler/cost.rs:31-36 — "compute duration" and "Mirrors ActionCosts::observe" overstate the parity. The helper returns max(gpu_ns, wall_ns) - wait_ns for isolated executions (:43-44) while observe (cost.rs:330-337) records the device interval less wait and never uses wall_ns. The wall term is inherited from observed_duration_ns (:21-29) and is not new, but the parity claim is: narrow the docstring to "device interval (or isolated wall time) less readiness wait", and note on both functions that only the device-interval-minus-wait step is shared in intent.
  2. cost.rs:303-305 — refresh_order's 0 sentinel is indistinguishable from an observation at now_ns == 0. map_or(0, …) means both "never observed" and "observed when the clock was zero", and refresh selection sorts ascending, so such a key would sort first. Harmless today — stale_keys (:298-301) already excludes nanos == 0 entries that are not fresh, and behaviour matches main — noted only because the PR body argues this ordering is the starvation guard. If touched, use the (nanos != 0).then_some(observed_at_ns) shape observation() already uses (:314-318).
  3. The same theorem is re-derived with two different overrun terms. policy_tests.rs:5961 and :6056 add last_refresh_ns (the most recent episode) while tests/test_scheduling_learning_policy.py:1561-1562 adds max(145.0, 30.0) (the largest episode); docs/scheduling-theory.md:569-574 says "most recent probe" and docs/scheduling-runtime-design.md:463-464 says "current or last refresh episode". Independent re-derivation is a virtue for an oracle, so no shared helper — but one comment naming which term the theorem allows would remove the ambiguity.
  4. scripts/scheduling_sim/learning.py keeps four hand-written PolicyConfig field lists for one dataclass — the CLI→parameters tuple (:105-109), the categorical/boolean sweep-rejection set (:132), the numeric sweep allow-list (:134-137) and the validate-preset override guard (:477-483). retain_idle_credit needed three of them edited. configuration_id (:48-56) already derives from fields(config), and PolicyConfig.__post_init__ (learning_policy.py:49-88) already validates every field, so (1), (2) and (4) can derive from dataclasses.fields(PolicyConfig) plus one numeric/categorical table next to the dataclass. Only (3) is a real decision. If the lists are deliberately explicit so a new parameter must be considered for validation policy, say so and drop this.
  5. PR description overstates two things. "…so every refresh completion incurs a strictly positive charge" is a caller-guaranteed property: timing_refresh_duration_ns can return 0 when there is no usable GPU sample and wall_ns == 0, and what makes the claim true is RefreshState::validate_completion (refresh.rs:63-69), so name that precondition. Second, the pre-existing main failure model::tests::packed_combined_budget_keeps_width_one_batches_without_a_useful_packed_shape is cited without its assertion, symptom or the main commit at which it reproduces; AGENTS.md:103-112 asks each material claim to be checkable against a baseline.
  6. New assertions re-type the income rates at policy_tests.rs:5961, :6056, :6075, :6076, :6086 instead of using refresh::INCOME_RATE / refresh::ACCEPTANCE_INCOME_RATE. This follows local precedent (:2493-2494, :2592, :2611, :2613), and note the constants are private (refresh.rs:10-11; only CREDIT_CAP_NS at :9 is pub(super)), so the fix is to widen them to pub(super) and use them — worth doing because the rate also appears three times in the docs (docs/scheduling-runtime-design.md:436, :467, :478).

Verified correct (no action)

Not verified here

No CI check is reported on 982a9ce3 and I ran no cargo, pytest, simulator sweep, TLA+ model or GPU path. The description's counts (804 pytest passes; 1,705 helios tests with one pre-existing main failure; 503/208/236/221/414 crate results; 9 TLA+ models / 590,327 transitions; the 64-seed --preset validate run at 62 scenarios, 35/35 vs ttl, exact 1.000000 parity, 64/64 recovery, 0/2,240 idle spurious probes) were judged for structure and internal consistency against the emitting code paths, not re-measured. tests/server/test_scheduler.py was not opened or run, and live disk-readiness stalls and power-cap recovery were not exercised, so the readiness-wait exclusion rests on the synthetic ExecutionTiming cases above. Nothing in the diff changes exported cores or persisted formats, so no re-export check is implied.


COMPACT SUMMARY (GitHub post):

Recommendation: Merge After Should-Fix

The runtime change is minimal and checks out; one operator doc still states the retired idle rule, and the rest is duplicated tests and repeated prose to delete.

Blockers:

None.

Should fix: 4

Subtract / Simplify: 4

Nits: 6

#24 [high] Research summary

Both outputs are prepared for PR #540 at head 982a9ce3 (base main 353551e9, 10 files, +647/−47). The full report is scratchpad entry #22 ("FINAL round 7 report text for PR #540 at 982a9ce3"), with the supporting verification notes in #19–#21 and #23; final counts are Blockers 0 / Should fix 4 / Subtract–Simplify 4 / Nits 6, reconciled in favour of subtraction wherever lenses conflicted.

Key verified positions: the rewrite of this PR is now minimal and correct where checked (income moved to compute duration excluding readiness wait at refresh.rs:71-79 + cost.rs:31-45, acceptance ledgers kept on raw physical time at refresh.rs:77-79/:83-85, RefreshState::idle deleted so abort at refresh.rs:95-99 is the sole discard path, refresh_order restored to observed_at_ns.max(last_attempt_ns) at cost.rs:303-305, zero-charge refresh loops still impossible via validate_completion at refresh.rs:63-69). The one behaviourally wrong artifact is helios/README.md:432-437, which still states "Idle discards positive credit" and omits the readiness-wait exclusion while linking to the design section this PR rewrote — should fix, not a blocker. The rest is duplication to delete: the third copy of the terminal-prefill fixture (policy_tests.rs:5812-5878 vs :4364-4406/:5443-5508), a Python CLI test repeating test_partial_block_uncertainty_… clause for clause (tests/test_scheduling_learning_experiments.py:746-790 vs :492-509), the duplicate helper-level readiness matrix (cost.rs:443-502), the now assertion-only RequestScheduler::idle (scheduler.rs:1158-1168, single caller server/runtime.rs:1184), the one-call-site timing_refresh_duration_ns, and four-times-restated prose — ~160 of 647 added lines (~25%). I rejected two lens claims: Architecture's "unreachable third fallback" (it is reachable and asserted, cost.rs:464-466) and the income-rate-constant nit's premise (the constants are private, refresh.rs:10-11). I also flagged that the branch-tip diff contains unrelated merged work (#556 DispatchRing, #555, #539–#559, the new testing hierarchy) that must not be attributed to this PR, and that no CI, simulator, TLA+, or GPU run was performed here.

Compact summary for the GitHub post:

Recommendation: Merge After Should-Fix

The runtime change is minimal and verified; one operator doc still states the retired idle rule, and the rest is duplicated tests and repeated prose to delete.

Blockers:

None.

Should fix: 4

Subtractive suggestions: 4

Nits: 6

#25 [high] AUTHORITATIVE final summary block + section label mapping (round 7, 982a9ce3)

PUBLISH THIS EXACTLY (recommendation + 1–2 sentence takeaway + counts only; no per-item bullets, no code blocks; 296 characters):

Recommendation: Merge After Should-Fix

The runtime change is minimal and verified; one operator doc still states the retired idle rule, and the rest is duplicated tests and repeated prose to delete.

Blockers:

None.

Should fix: 4

Subtractive suggestions: 4

Nits: 6

LABEL MAPPING (full report → summary):

COUNT CHECK AGAINST ENTRY #22 (must match exactly):

CAVEAT FOR THE REPORT WRITER: if any item is added or dropped during final editing, both the full report section and this counts block must change together — the summary's only function is to point at the Full Review with matching numbers.

#11 [medium] Spot-checks confirmed: idle call sites, no binding round-trip test, selection duplicate tuple

Final spot-checks at head 14019718 (all confirmed):

#23 [medium] Addendum: S4 default-flip caveats + third fixture copy confirmed

Addendum to entry #22, S4 wording (include in the full report):

Flipping retain_idle_credit to default True for retained-refresh also touches two sites that must be updated with it:

Verified supporting facts: