Prose review — PR #540 "Retain bounded timing-refresh credit across idle and exclude readiness wait"
Head reviewed: 982a9ce3 (10 files, +647/−47). Earlier blockers I raised against this PR (MTP draft_source, --history-drafts graph selection, missing copy-draft/wide-copy spec) are moot at this head: docs/mtp-design.md (not opened), docs/api.md, docs/cli-design.md (not opened) and the SAM/wide-copy code are no longer in the diff (pr_files now lists only the two scheduling docs, four helios/src/scheduler* files, two scripts/scheduling_sim modules and two Python tests).
Key findings
Verdict: should-fix issues only — one should-fix, three nits. No blocking prose issues.
- Should fix —
helios/README.md:432-437still documents the retired rule: "Idle discards positive credit and preserves debt", and refresh credit as0.002 / 0.998of "measured duration" with refresh paying "one complete physical program". The code now retains bounded credit across idle and credits/charges compute duration excluding readiness wait (refresh.rs:71-93,helios/src/scheduler.rs:1158-1168).helios/README.md:439links to the very design-doc section this PR rewrote, so the operator README and the spec now disagree. - Nits (3) — an over-strong "strictly positive charge" claim in
cost.rs:47-52and repeated in the PR body; a PR-body "pre-existing upstream failure" named without what fails or the baseline commit; an ambiguous causal clause in the newscheduler.rs:1158-1162doc comment. - Everything else checked clean: the two doc edits state the present behavior correctly, the simulator default/
--retain-idle-creditsplit is described accurately, and the PR description satisfies the four-part requirement apart from the two wording items noted.
Rules applied
AGENTS.md:43-65— every repository document is a present-state specification; state implemented behavior, record unrun checks indocs/TODO.txt, rewrite prose that needs conversation history or claims beyond its evidence.AGENTS.md:72-112— the four-part PR description (why / what exactly changed / claimed result / evidence), with limits, baselines and unrun checks visible.docs/design-review.md:190-203— timing-estimation and funded-refresh changes must be run against the screening and 64-seed validation catalog inscripts/scheduling_sim/learning.py; "simulator results do not establish native runtime behavior or GPU performance".docs/design-review.md:237-241— disclosure does not excuse skipping runnable CPU checks. (This is a design-review obligation, not a prose one; the description does disclose the omissions, which is what the prose rule requires. The tension itself belongs to the design-review lens.)
Should fix
1. helios/README.md:432-437 — operator README states the reverse of the shipped idle rule and omits the readiness-wait exclusion.
Current text:
"Ordinary valid execution earns refresh credit at
0.002 / 0.998times its measured duration, capped at 5 ms. Full credit permits a stale alternative to displace the ordinary winner, ordered by the later of its last valid observation and last attempted dispatch. 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."
What the code at this head does instead:
RequestScheduler::idleno longer touches credit at all (helios/src/scheduler.rs:1158-1168; theself.refresh.idle();call is deleted by this PR andRefreshState::idleis removed athelios/src/scheduler/refresh.rs:95-99, which now holds onlyabort): idle retains bounded positive credit and negative debt across idle gaps.- Credit is computed from
cost::observed_compute_duration_ns— readiness wait excluded,Nonewhengpu_ns <= wait_ns, so no credit (helios/src/scheduler/refresh.rs:74-76,helios/src/scheduler/cost.rs:31-45); acceptance learning deliberately keeps rawobserved_duration_ns(refresh.rs:77-79). - A funded refresh is charged
cost::timing_refresh_duration_ns, compute duration with an unexcluded physical/wall fallback (refresh.rs:87-88,cost.rs:47-57), not unqualified "one complete physical program".
Why it matters: AGENTS.md:52-60 makes every repository document a specification of present behavior, and this is the operator-facing Helios document, not a design appendix. It now contradicts docs/scheduling-runtime-design.md:436-444 and :492-499, which this same PR edits for exactly these two rules, and it links to that section at helios/README.md:439. The paragraph also lacks the idle/abort distinction the design doc now spells out (:443-444, :492).
Fix: in this paragraph, say credit is 0.002 / 0.998 of compute execution duration (measured readiness wait excluded; discarded when the device interval does not exceed readiness wait), that the funded refresh is charged the same compute duration with unexcluded physical/wall fallback, and that idle retains bounded earned credit while abort clears positive credit and keeps debt. Note that this paragraph closes the gap: the surrounding text at helios/README.md:423-424 already describes the readiness exclusion for cost estimates, and docs/direct-execution.md:111-114, docs/TODO.txt:110-114 and docs/mtp-design.md:400-402 (not opened) are already correct.
Severity rationale: should fix, not blocking — the three files that govern the changed behavior (both scheduling docs plus the PR description) are correct and complete; the README is the one remaining present-state document that states the retired rule.
Nits
2. helios/src/scheduler/cost.rs:47-52 (and the PR body) — "strictly positive charge" is a caller-guaranteed property, not a property of the function.
The doc comment on timing_refresh_duration_ns says the fallback ensures "every validated refresh completion incurs a strictly positive charge". The function can still return 0: observed_compute_duration_ns yields None (cost.rs:37-45), observed_duration_ns yields None when no positive gpu_ns exists (cost.rs:21-29), and timing.wall_ns == 0, so unwrap_or(0) fires (cost.rs:53-57). What makes the claim true is RefreshState::validate_completion, which rejects a probe completion with no measured interval and wall_ns == 0 (refresh.rs:63-69), running before complete. Fix: say the fallback is positive for every completion validate_completion accepts, or name that precondition. policy_tests.rs:6140-6180 exercises exactly the accepted paths (gpu_ns (100 ms) <= wait_ns (120 ms) with wall_ns 0 and 130 ms).
3. PR description, "What" bullet for cost.rs — same overstatement.
"timing_refresh_duration_ns (falling back to unexcluded physical or wall duration so every refresh completion incurs a strictly positive charge)". Same fix; the guard is refresh.rs:63-69.
4. PR description, "Evidence" — names a pre-existing upstream failure without the failure or the baseline.
model::tests::packed_combined_budget_keeps_width_one_batches_without_a_useful_packed_shape is cited as a pre-existing main failure "in untouched" code, with no assertion, symptom, or main commit at which it reproduces. AGENTS.md:103-112 asks each material claim to be connected to behavior, baseline, and result so a reviewer can check it; the test itself is helios/src/model/packed_round_tests.rs:68, included at helios/src/model/tests.rs:1640 (not opened). Fix: name the failing assertion and the main commit where the same command reproduces it.
5. helios/src/scheduler.rs:1158-1162 — ambiguous "because" in the new idle doc comment.
"Timing-refresh and acceptance-learning ledgers retain bounded earned credit (
<= CREDIT_CAP_NS) and negative debt across idle intervals because idle adds neither credit nor ordinary duration."
"Idle adds neither credit nor ordinary duration" is why the aggregate bound survives retention (P <= 0.002/0.998 * O + D, docs/scheduling-runtime-design.md:470-474), not the justification for retaining. Reword to "…across idle intervals; idle adds neither credit nor ordinary duration, so the aggregate bound is unchanged." Not wrong as written, just read two ways.
What is correct (checked, no finding)
docs/scheduling-runtime-design.md:434-474states the new rule as present behavior: compute duration excluding readiness wait, the discardedgpu_ns <= wait_nssample,idleretains /abortdiscards positive and preserves debt (:443-444), the refresh charge with fallback (:456-461), and the unchanged aggregate bound with the idle-accumulation rationale (:470-474). Matchesrefresh.rs:71-99andcost.rs:31-57.docs/scheduling-runtime-design.md:488-499keeps acceptance learning on raw physical time, matchingrefresh.rs:77-79(income) and:83-85(charge).docs/scheduling-theory.md:574-583and:727-738correctly scope the discard rule to the simulator default, attribute retained credit to--retain-idle-creditand to Helios (helios/src/scheduler/refresh.rs), and describe the readiness exclusion and positive fallback.scripts/scheduling_sim/learning_policy.py:663-677gates retention behindretain_idle_credit(defaultFalse) andscripts/scheduling_sim/learning.py:436-440exposes--retain-idle-credit, so the doc matches the code.docs/scheduling-theory.md:682("Idle clears positive balances and retains debt") is the simulator-onlyharm_alphaalternative balance (:669-670); noharm_state exists underhelios/src, and this PR does not touch it. Not a finding.- The description's "Why" section is verified against the code:
RequestScheduler::idlepreviously zeroed positive credit while keeping debt (refresh.rs:89-92atmain, deleted here), andRefreshState::completeatmaincredited and chargedobserved_duration_ns(refresh.rs:71-87atmain) whileActionCosts::observerecordsgpu_ns - wait_ns. The stated invariantP <= (0.002 / 0.998) * O + Dmatches the design doc it points at. - The description's "Result" and "Evidence" sections distinguish simulator outcomes from live Helios behavior, state a scope boundary ("does not change continuous-busy debt refill rates … or acceptance-learning debt lock-in"), and list unrun GPU/HTTP tests, unrun
pytest tests/cli, and unruncargo kani/cargo-mutants— the disclosureAGENTS.md:103-112requires. The reported gate names (complete_core_suite,complete_validation_suite), the 62-scenario / 64-seed configuration and the "recovered within 60,000 busy ms" rule are consistent with the keysscripts/scheduling_sim/learning.py:561-573emits and the recovery rule atdocs/scheduling-theory.md:831-832. - Commit subject "Retain bounded timing-refresh credit across idle and exclude readiness wait" names both behavior changes, carries no lifecycle labels and needs no conversation history; the PR title matches it.
Open questions / could not verify
- Rebase and byte-identity evidence. The description says
982a9ce3is rebased ontoorigin/main(353551e9, touching onlydocs/design-review.mdrelative to3e2fcd27), so Rust results obtained on3e2fcd27transfer. I read only the PR tree and its diff against the merge base; I could not confirm the tree byte-identity or what3e2fcd27contains. Nothing in the diff contradicts it. Treat it as the author's evidence, not verified here. - No CI and no local run.
982a9ce3has no CI checks, and I ran no Rust or simulator commands in this review, so the numbers in "Result"/"Evidence" were judged for structure and internal consistency against the emitting code paths, not re-measured. docs/design-review.md:237-241tension. The description discloses the unrun CPU-runnable checks (pytest tests/cli, Kani, mutants) rather than omitting them, which satisfies the prose rule; whether disclosure is acceptable for those specific checks is a design-review question and I left it to that lens.