#1 [high] Research summary
Subtraction / Simplicity / Conventions — PR #655 (head f7f4d253)
The diff is lean: fresh_duration is fully removed (no dead shim left behind), no new config knob, no new CLI flag, no per-model branch — discovery is gated on the existing checkpoint_extra_work_fraction and existing limits.snapshots. Four things can still be deleted or collapsed. (Skipped per lens rules: the correctness questions around zero-priced discovery and its counter under-reporting.)
1. Three duplicated snapshot_discovery clear sites are unreachable-by-design — delete all nine lines (scheduler.rs)
helios/src/scheduler.rs:2686-2703:
if record.status == 3 {
request.error_code = Some(record.error_code);
request.terminal_snapshot_ready = false;
request.phase = RequestPhase::Finishing;
if self.snapshot_discovery == Some(lane.request) {
self.snapshot_discovery = None;
}
} else if kind == GraphKind::Snapshot {
...
request.phase = RequestPhase::Finishing;
self.stats.checkpoint_endpoint_captures += 1;
if self.snapshot_discovery == Some(lane.request) {
self.snapshot_discovery = None;
}
and helios/src/scheduler.rs:3066-3069:
fn retire(&mut self, handle: RequestHandle, publish: bool) -> Result<Option<CheckpointId>> {
if self.snapshot_discovery == Some(handle) {
self.snapshot_discovery = None;
}
The gate itself already self-heals (helios/src/scheduler/checkpoints.rs:1018-1023):
fn snapshot_discovery_in_flight(&self) -> bool {
self.snapshot_discovery.is_some_and(|handle| {
self.request(handle)
.is_ok_and(|request| request.phase != RequestPhase::Finishing)
})
}
In both complete_inner branches phase = Finishing is assigned immediately before the clear, so the predicate already reports "free"; after retire returns, request(handle) errors (scheduler.rs:1233-1239) so the slot is also already free, and the next claim unconditionally overwrites it (checkpoints.rs:1070-1072). Replace all three blocks with nothing, keeping only the Finishing-tolerant predicate and the claim at checkpoints.rs:1070. This is one invariant instead of two mechanisms, and the cancel-recovery test (checkpoints.rs:4183-4251) still passes through the is_ok_and path. If instead the explicit clears are kept deliberately, then the phase != Finishing filter is the redundant half — but pick one, not both.
2. measured_duration re-implements exact_duration's key construction — collapse to two lines (cost.rs)
helios/src/scheduler/cost.rs:783-790:
pub fn measured_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
self.batches(kind).iter().find_map(|&batch| {
let key = Key { drafts: 0, kind, batch, tokens, prefill: 0, packed: 0 };
self.entry(key)
.map(|estimate| estimate.nanos)
.filter(|&nanos| nanos != 0)
})
}
That Key literal is exactly what exact_duration already builds for a non-speculative kind (cost.rs:761-771): drafts becomes 0 and packed is passed as 0. Replace with:
pub fn measured_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
self.batches(kind)
.iter()
.find_map(|&batch| self.exact_duration(kind, batch, tokens, 0, 0).filter(|&n| n != 0))
}
Second, smaller point on the same function: after this PR every caller passes the same constants — measured_duration(GraphKind::Snapshot, 1) at checkpoints.rs:624, 965, 1039 and five test sites. Narrowing it to pub fn snapshot_copy_ns(&self) -> Option<u64> (Snapshot + token 1 inside) names the concept once, drops two constant-only parameters, and makes the three-site redundancy in checkpoint_selection / checkpoint_copy_allowed / allocate_terminal_capture visibly the same query.
3. Test helper duplicates the Snapshot ScheduledStep literal a fourth time — move it onto ActionCosts (checkpoints.rs + cost.rs)
helios/src/scheduler/checkpoints.rs:4164-4180:
fn clear_snapshot_costs(scheduler: &mut RequestScheduler) {
for batch in scheduler.costs.batches(GraphKind::Snapshot).to_vec() {
scheduler.costs.set_measured(
&ScheduledStep {
draft_tokens: 0,
kind: GraphKind::Snapshot,
batch_capacity: batch,
token_capacity: 1,
packed_token_capacity: 0,
mixed: None,
lanes: vec![],
requires_feedback: false,
},
0,
);
}
}
This literal already exists three times (checkpoints.rs:1113-1122 in measure, cost.rs:980-991 in snapshot_step, tests.rs:13-24). set_measured is itself a #[cfg(test)] API on ActionCosts (cost.rs:563-584) and already knows self.batches, so the loop belongs next to it:
#[cfg(test)]
pub fn clear_measured(&mut self, kind: GraphKind) {
for batch in self.batches[kind_index(kind)].to_vec() {
self.set_measured(&snapshot_step(batch), 0) /* or the existing step builder */;
}
}
Then delete clear_snapshot_costs (17 lines) and call scheduler.costs.clear_measured(GraphKind::Snapshot) at the two sites (checkpoints.rs:4171, 4257). Bonus: generalising measure (checkpoints.rs:1111-1125) to take a batch argument removes the token_capacity/batch_capacity hardcoding that forced this helper into existence.
4. Docs now assert both "at most one in-flight discovery capture" and "no concurrency-based snapshot share" three lines apart (docs)
docs/scheduling-runtime-design.md:625-631:
positive and no snapshot-copy cost has been measured yet, terminal capture
allows at most one in-flight discovery capture (priced at zero) so requests
whose anchor is already cached can observe the snapshot cost. Productive
completed decode earns the same fraction of measured time for a distinct
terminal capture. There is no fixed capture count or concurrency-based snapshot
share.
Same collision at docs/core-design.md:1444-1445 ("There is no capture-count limit or allocation of a fixed snapshot share to each request") versus core-design.md:1455-1457. The discovery slot is a server-global concurrency cap of one, so the unchanged sentence is now false. One-clause fix in both files: "There is no fixed capture count or concurrency-based snapshot share, apart from the single cold-discovery capture above." Doc-only, but it's the one place the PR leaves the docs contradicting themselves.
Things I checked that are fine
fresh_durationremoval is complete — no orphaned helper, no leftover TTL-based Snapshot path (grepforfresh_durationreturns nothing;is_freshremains legitimately used for dispatch refresh atscheduler.rs:1143,2336,policy.rs:1336(not opened)).- The
Key/ENTRY_LOOKUPScost of the ascending batch scan is memoised per planning scope (checkpoints.rs:410-428), so no hot-path objection. - Renamed test
unknown_prefill_or_unmeasured_snapshot_cost_disables_extrascorrectly drops the stale TTL assertions rather than keeping dead coverage; the new end-to-end test (checkpoints.rs:4253-4306) drives realplan/commit/completeinstead of callingmeasure, which is the right shape. - No new flags, knobs, wrappers, or speculative generality beyond the
kind/tokensparameters in item 2.
#2 [high] PR #655 Subtraction/Simplicity lens findings (head f7f4d253)
PR #655, head f7f4d253, 7 files +348/-63. Lens: subtraction, simplicity, module conventions. Verdict: diff is lean (fresh_duration fully removed, no new knob/flag/per-model branch). 4 findings.
FINDING 1 (delete 9 lines): three snapshot_discovery clear sites are unreachable-by-design, because the gate already self-heals.
- helios/src/scheduler.rs:2686-2692 (status-3 error path): after
request.phase = RequestPhase::Finishing;there is
if self.snapshot_discovery == Some(lane.request) {
self.snapshot_discovery = None;
}
- helios/src/scheduler.rs:2697-2702 (successful terminal snapshot): same 3 lines after
request.phase = RequestPhase::Finishing; self.stats.checkpoint_endpoint_captures += 1; - helios/src/scheduler.rs:3066-3069
fn retire(...):if self.snapshot_discovery == Some(handle) { self.snapshot_discovery = None; }Why redundant: helios/src/scheduler/checkpoints.rs:1018-1023snapshot_discovery_in_flightalready excludes aFinishinghandle and errors on retired handles (scheduler.rs:1233-1239request()returns Err for retired slot); next claim at checkpoints.rs:1070-1072 unconditionally overwrites the slot. Sophase != Finishingfilter OR the explicit clears — pick one, not both. Recommend deleting the three clear blocks and keeping the predicate. Also relevant: checkpoints.rs:1040-1043discovering = measured.is_none() && policy.checkpoint_extra_work_fraction > 0.0 && !self.snapshot_discovery_in_flight(), cost claimed only aftersnapshot.is_some()(1069-1072).
FINDING 2 (collapse to 2 lines + narrow signature): helios/src/scheduler/cost.rs:783-790
pub fn measured_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
self.batches(kind).iter().find_map(|&batch| {
let key = Key { drafts: 0, kind, batch, tokens, prefill: 0, packed: 0 };
self.entry(key).map(|estimate| estimate.nanos).filter(|&nanos| nanos != 0)
})
}
Duplicates exact_duration's key construction (cost.rs:761-771). Replace with self.batches(kind).iter().find_map(|&batch| self.exact_duration(kind, batch, tokens, 0, 0).filter(|&n| n != 0)). Additionally all 3 production callers pass identical constants (GraphKind::Snapshot, 1) — checkpoints.rs:624, checkpoints.rs:965, checkpoints.rs:1039 (plus 5 test sites) — so narrowing to pub fn snapshot_copy_ns(&self) -> Option<u64> names the concept once and makes the three-site redundancy visible.
FINDING 3 (delete 17-line test helper): helios/src/scheduler/checkpoints.rs:4164-4180 fn clear_snapshot_costs builds the same Snapshot ScheduledStep literal that already exists 3x: checkpoints.rs:1113-1122 (measure), cost.rs:980-991 (snapshot_step), tests.rs:13-24. set_measured is already #[cfg(test)] and knows self.batches (cost.rs:563-584), so add #[cfg(test)] pub fn clear_measured(&mut self, kind: GraphKind) next to it and replace the two call sites (checkpoints.rs:4171 inside unmeasured_snapshot_cost_allows_one_inflight_terminal_discovery_and_recovers_on_cancel at 4183-4251, and checkpoints.rs:4257 inside terminal_snapshot_discovery_end_to_end_plan_commit_complete_unblocks_subsequent_captures at 4253-4306). Also: generalising measure (checkpoints.rs:1111-1125, hardcodes batch_capacity:1) to take a batch arg would have made the helper unnecessary in the first place.
FINDING 4 (doc self-contradiction, doc-only): docs/scheduling-runtime-design.md:625-631 now says "terminal capture allows at most one in-flight discovery capture (priced at zero)" and then, 3 lines later, the unchanged "There is no fixed capture count or concurrency-based snapshot share." Same collision docs/core-design.md:1444-1445 ("There is no capture-count limit or allocation of a fixed snapshot share to each request") vs core-design.md:1455-1457. Fix: append "apart from the single cold-discovery capture above."
CLEARED / NOT findings (verified):
fresh_durationfully gone from tree (grep returns zero hits); no orphaned helper or TTL-based Snapshot path left.is_freshlegitimately still used for dispatch refresh: scheduler.rs:1143, scheduler.rs:2336, policy.rs:1336;stale_keys/record_attempt/refresh_orderuntouched (policy.rs:1564-1565).- Ascending batch scan cost is memoised per planning scope:
checkpoint_selectioncached inself.checkpoint_selections(checkpoints.rs:410-428), so checkpoints.rs:624 runs once per request per planning scope; ENTRY_LOOKUPS budgets hold. No hot-path objection. - The 3
measured_durationsites are the only production users;checkpoint_cut/estimated_checkpoint_cut/plan_checkpoints(checkpoints.rs:745-763, 765+) route throughcheckpoint_selection, so no extra duplicate gating was added. - Tests: renamed
unknown_prefill_or_unmeasured_snapshot_cost_disables_extrasdrops the stale TTL assertions correctly; new end-to-end test drives real plan/commit/complete rather than callingmeasure;measured_duration_uses_smallest_measured_batch_and_retains_after_ttl(cost.rs:993-1045) uses newsnapshot_fixture/snapshot_stephelpers. - Charter alignment: no new flags/knobs, nothing per-model; helios/README.md + docs updated in the same PR (good convention compliance).
- No AGENTS.md exists in the repo (list_files **/AGENTS.md → no matches), so conventions are the module docs (helios/manifest.md, docs/*-design.md).