Architecture & scope review — PR #540, head 982a9ce3 (base main 353551e9)
10 files, +647/−47 (docs/scheduling-runtime-design.md, docs/scheduling-theory.md, helios/src/scheduler.rs, helios/src/scheduler/cost.rs, helios/src/scheduler/policy_tests.rs, helios/src/scheduler/refresh.rs, scripts/scheduling_sim/learning.py, scripts/scheduling_sim/learning_policy.py, tests/test_scheduling_learning_experiments.py, tests/test_scheduling_learning_policy.py).
Judged against the charter (Autobot charter lines 12, 14, 35, 42), AGENTS.md (scope/rejection L188-199, task→doc map L227, compatibility L431-444) and docs/design-review.md ("Testing hierarchy" L171-203; principles 1, 3, 12, 13, 15).
Key findings
Verdict: should-fix issues only. No blocking correctness or architecture defects; the approach belongs in this repository and is the right place for the fix.
- Scope is now correct. The earlier 33-file version I reviewed (SAM copy drafting, wide copy-verify graphs, batch-padding pruning) is gone. One coherent outcome remains — retain bounded timing-refresh/acceptance credit across idle and exclude embedding-readiness wait from refresh credit and charges — with no production flag, no manifest/Protobuf/ABI change, and no new graph family. This closes my earlier
AGENTS.md:198("Keep each PR focused on one coherent outcome") scope finding. - Two should-fix items, both documentation/qualification rather than code:
helios/README.md:437still documents the deleted rule, and the simulator's newretain_idle_creditdefaults to the pre-PR policy Helios no longer implements. - Two nits: the "compute duration" naming overstates parity with
ActionCosts::observe, andtiming_refresh_duration_ns's last fallback is unreachable behindvalidate_completionwhileidle()is now assertion-only. - Verified positives:
refresh_orderback toobserved_at_ns.max(last_attempt_ns)(starvation fix),abortkeeps debt/drops positive credit, and zero-charge refresh loops are closed.
Should fix
S1. helios/README.md:437 (unchanged file) still states the rule this PR deletes, and omits the readiness-wait exclusion.
The paragraph at helios/README.md:432-439 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."
That is exactly the behaviour removed here: RefreshState::idle is gone from helios/src/scheduler/refresh.rs (only complete :71-93 and abort :95-99 remain, and abort does credit_ns.min(0.0)), and RequestScheduler::idle (helios/src/scheduler.rs:1158-1168) now only asserts submissions.is_empty() and keeps bounded credit (<= CREDIT_CAP_NS, refresh.rs:9) and debt. The same paragraph also says nothing about the new readiness-wait exclusion.
Why it matters: AGENTS.md:227 names helios/README.md as required reading for "Change Helios runtime, scheduling, caches, transport, or frontend"; the runtime's own description of the funded-refresh policy now states the opposite of the code, and AGENTS.md:165-166 admits inaccurate documentation as a contribution category — inaccurate documentation of the very behaviour being changed is not shippable. docs/scheduling-runtime-design.md:434-474 and docs/scheduling-theory.md:727-738 were updated; helios/README.md was missed.
Fix: rewrite helios/README.md:432-439 to state that ordinary valid execution earns 0.002/0.998 of measured compute duration excluding readiness wait (cap 5 ms), that idle retains bounded earned credit and negative debt while abort discards positive credit, and that a refresh episode pays its compute duration excluding readiness wait (falling back to unexcluded physical/wall duration when the GPU sample does not exceed readiness wait).
S2. scripts/scheduling_sim/learning_policy.py:47 — retain_idle_credit: bool = False leaves the simulator's default modelling the policy Helios no longer has.
LearningScheduler::idle (scripts/scheduling_sim/learning_policy.py:671-677) only skips credit_ms = min(0.0, credit_ms) when the flag is set; Helios has no such switch — after this PR RequestScheduler::idle (helios/src/scheduler.rs:1158-1168) retains unconditionally. So after merge, a default retained-refresh simulator run models a rule the runtime does not implement, and the flag is only reachable as an explicit CLI option (learning.py:109) or an explicit --configs field (learning.py:48-56 configuration_id produces …:retain_idle_credit=True) — for --preset validate, the flag form is rejected outright (learning.py:479-484: "validation policy parameters come exclusively from --configs"), so the mandated catalog cannot express it on the command line at all.
Why it matters: docs/design-review.md:200-201 — "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". The PR's own prose concedes the divergence: docs/scheduling-theory.md:730-733 ("Without --retain-idle-credit, idle discards positive credit … with --retain-idle-credit (as in Helios)"). Helios is now the definition of correct, so the default should follow it.
Fix: default retain_idle_credit=True for retained-refresh (keep a documented opt-out for reproducing main), or make the value mandatory in PolicyConfig.__post_init__ (learning_policy.py:85-88 already uses that mechanism for funded/estimator). Add one sentence to docs/scheduling-theory.md:730-733 that the 64-seed --preset validate run encodes the setting in the --configs JSON, so operators do not try the flag against the preset.
Nits
N1. helios/src/scheduler/cost.rs:31-45 — "compute duration" and "Mirrors ActionCosts::observe" overstate the formula.
observed_compute_duration_ns returns max(gpu_ns, wall_ns) - wait_ns for isolated executions (:43-44), whereas ActionCosts::observe (cost.rs:330-353) records the GPU interval less wait and never uses wall_ns. The docstring at :33 claims parity, and the new prose at docs/scheduling-runtime-design.md:436-441 / docs/scheduling-theory.md:734-737 calls the quantity "compute execution duration". The max-with-wall term is inherited from observed_duration_ns (:21-29) and is not new, but the naming and the parity claim are. Fix: narrow the docstring/prose to "device interval (or isolated wall time) less readiness wait", or credit income on gpu_ns - wait_ns and keep the wall-inclusive form only as the strictly-positive charge fallback the design actually needs.
N2. helios/src/scheduler/cost.rs:53-57 dead fallback, and helios/src/scheduler.rs:1158-1168 now an assertion-only API.
timing_refresh_duration_ns's third term unwrap_or(timing.wall_ns) is unreachable for validated completions: RefreshState::validate_completion (refresh.rs:63-68) rejects a probe whose observed_duration_ns is None and wall_ns == 0, so the second fallback always fires first. Reduce to observed_compute_duration_ns(..).or_else(|| observed_duration_ns(..)).unwrap_or_default() with a comment naming the reachable callers. Separately, RequestScheduler::idle is now purely a precondition check (submissions.is_empty()), called once per idle-loop iteration from helios/src/server/runtime.rs:1184; either fold the assertion into the doc sentence and drop the method, or state in the doc comment that the retention rule is the only remaining semantics.
Verified positives (no action)
refresh_orderisobserved_at_ns.max(last_attempt_ns)again (cost.rs:303-305), matchingdocs/scheduling-runtime-design.md:446-449; expensive stale shapes cannot starve smaller ones — regression-tested atpolicy_tests.rs:5958-6045withD = 145 ms > ttl_ns / 499.- Income/charge split is correct and layer-appropriate:
RefreshState::completecredits timing refresh fromobserved_compute_duration_ns(refresh.rs:74-76) but keeps acceptance learning on raw physicalobserved_duration_ns(:77-79,:83-85), matchingdocs/scheduling-runtime-design.md:496-499. abort(refresh.rs:95-99) drops positive credit and preserves debt exactly asdocs/scheduling-runtime-design.md:492-493states.- Zero-charge refresh loops are impossible:
validate_completion(refresh.rs:63-68) still requires an isolated measured interval, andtiming_refresh_duration_nsis strictly positive on every reachable completion (covered forwait < gpu,wait == gpu,wall == 0andwall > 0atcost.rs:443-501andpolicy_tests.rs:6142-6175). - The retention bound is preserved argumentatively and in code: idle adds neither credit nor ordinary duration, so
P <= (0.002/0.998)*O + DandP <= (0.01/0.99)*O + Dstill hold (docs/scheduling-runtime-design.md:463-474). - Idle-separated short-request recovery is regression-tested at
policy_tests.rs:5881-5955; the funding loop now retains credit acrossidle()(:2548-2616), and the acceptance probe test switched fromidle()toabort()(:3545). - The simulator flag is fully plumbed and validated: pass-through
learning.py:105-109, sweep rejection:132-133, boolean checklearning_policy.py:83-84,retained-refreshconstraint:85-88, CLI/experiment tests attests/test_scheduling_learning_experiments.py:744-790andtests/test_scheduling_learning_policy.py:1530-1571.
Open questions for maintainers
docs/design-review.md:190-201requires that timing-estimation/funded-refresh changes be qualified against the simulator catalog. Should the qualifiedretained-refreshpolicy simply become the idle-retaining one (S2), making the flag temporary? That would remove the divergence permanently instead of documenting it.- Is the wall-inclusive term in timing-refresh income intentional (N1)? Charging refresh debt on
max(gpu, wall) - waitwhile the funded estimate uses the device interval alone means a refresh can be charged more than the cost it updates. No test or doc justifies that asymmetry. - Is
idle()still needed as an API (N2), or is a documented invariant onRequestSchedulerenough?
What I could not verify
- No CI checks on head
982a9ce3; the description's counts (804 pytest passes, 1,705 helios tests with one pre-existingmainfailure, 503/208/236/221/414 crate results, 9 TLA+ models / 590,327 transitions, the 64-seed--preset validaterun with 62 scenarios, 35/35 core, geomean 1.009886, 0/2,240 resets) were not re-executed here. - No GPU hardware run: live disk-readiness stalls, power-cap recovery and
tests/server/test_scheduler.py(not opened) are unrun. This head touches no GPU path, so the gap is smaller than at the previous head, but the readiness-wait exclusion itself is only exercised by syntheticExecutionTimingvalues (cost.rs:443-501). - Nothing in the diff changes Protobuf metadata, exported cores or the manifest, so
AGENTS.md:431-444core-compatibility re-export checks do not apply; I confirmed that by reading the changed files, not by loading an existing core. docs/TODO.txt:110-114still lists live Helios qualification of retained costs and funded remeasurement as open, which is consistent with the unrun-GPU limitation and does not block this PR.