Subtractive/Simplicity & Conventions review — PR #655, head f7f4d253
Verdict: the diff is already lean. The subtraction was done properly: fresh_duration is gone from the tree with no orphaned shim or TTL-based Snapshot path left behind (grep returns zero hits), the earlier probe apparatus (probe_duration, record_probe, last_probe_ns, smallest_batch_key) is fully deleted, and the new behaviour adds no config knob, no CLI flag, no per-model or per-feature branch, and no new persistence. Discovery reuses the existing checkpoint_extra_work_fraction gate and the existing limits.snapshots storage quote. The is_fresh uses that remain (scheduler.rs:1143, 2336, policy.rs:1336 (not opened)) are legitimate dispatch-refresh callers, not leftovers. There is no AGENTS.md (not opened) in the repo (**/AGENTS.md (not opened) → no matches), so conventions are the module docs; the PR updates helios/README.md and four design docs in the same change, which is the intended convention here.
What follows are four things that can still be deleted or collapsed, high importance first.
1. (high) Delete all three explicit snapshot_discovery clears — they are unreachable-by-design, 9 lines
The PR adds the same three-line clear in three places. helios/src/scheduler.rs:2686-2692 (status-3 error path):
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;
}
}
helios/src/scheduler.rs:2697-2702 (successful terminal snapshot):
request.terminal_snapshot_ready = true;
request.phase = RequestPhase::Finishing;
self.stats.checkpoint_endpoint_captures += 1;
if self.snapshot_discovery == Some(lane.request) {
self.snapshot_discovery = None;
}
helios/src/scheduler.rs:3066-3069 (retire, i.e. cancel/finish):
fn retire(&mut self, handle: RequestHandle, publish: bool) -> Result<Option<CheckpointId>> {
if self.snapshot_discovery == Some(handle) {
self.snapshot_discovery = None;
}
Why each is redundant. The gate the PR itself adds 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_innerbranches,request.phase = RequestPhase::Finishing;is assigned immediately before the clear, so thephase != Finishingfilter already reports "free" for exactly the state the clear creates. - After
retire,self.request(handle)returnsErr(scheduler.rs:1233-1239,ok_or_else(|| "stale or retired request handle")), sois_ok_andisfalseand the slot is already free. - The next claim overwrites the slot unconditionally when a row is obtained (
checkpoints.rs:1069-1072), so a staleSome(handle)is harmless by construction.
Concrete simplification: delete scheduler.rs:2690-2692, scheduler.rs:2700-2702, and scheduler.rs:3066-3069 entirely (9 lines, plus the retire body then starts with the unchanged if self.request(handle)?.phase == RequestPhase::Inbound). Keep the Finishing-tolerant predicate and the claim site. The cancel-recovery test (checkpoints.rs:4183-4251) still exercises recovery through the is_ok_and/retired-handle path, so coverage does not regress. Net effect: one mechanism replacing two, which is strictly safer — right now a future edit that changes the phase assignment order can make the two mechanisms disagree.
If instead the explicit clears are intentional (e.g. to free the slot before a slow retire body runs), then the request.phase != RequestPhase::Finishing filter is the redundant half. Either way, pick one; shipping both is the simplicity defect.
2. (medium-high) measured_duration re-implements exact_duration's key construction; collapse to two lines and narrow the signature
helios/src/scheduler/cost.rs:781-790:
/// Returns the smallest declared batch with a positive measured duration,
/// retaining measured estimates after `ttl_ns` expiry just like prefill costs.
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 precisely what the existing private helper builds for a non-speculative kind (helios/src/scheduler/cost.rs:761-771), where drafts becomes 0 and packed is the caller's argument:
fn exact_duration(&self, kind: GraphKind, batch: usize, tokens: usize, prefill: usize, packed: usize) -> Option<u64> {
self.entry(Key {
drafts: if kind == GraphKind::Speculative { tokens - 1 } else { 0 },
kind,
batch,
tokens,
prefill,
packed: if kind == GraphKind::Speculative { batch * tokens } else { packed },
})
.map(|estimate| estimate.nanos)
}
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(|&nanos| nanos != 0))
}
Second, smaller half of the same finding: every one of the 12 call sites passes the same constants. Production: checkpoints.rs:624, 965, 1039 — all measured_duration(GraphKind::Snapshot, 1). Tests: checkpoints.rs:4134, 4189, 4258, 4287 and cost.rs:1000, 1003, 1013, 1019, 1025, 1031, 1042 — same arguments. Since nothing can ever pass a different kind or tokens (Snapshot batch shapes are always token_capacity: 1, cf. cost.rs:980-991), the signature is speculative generality. Narrow it to pub fn snapshot_copy_ns(&self) -> Option<u64> with Snapshot/1 baked in; that also makes it visible that checkpoint_selection (checkpoints.rs:624), checkpoint_copy_allowed (965) and allocate_terminal_capture (1039) are asking the same question, which is exactly the invariant this PR is trying to establish.
3. (medium) The new test helper writes the Snapshot ScheduledStep literal for the fourth time — move it onto ActionCosts and delete 17 lines
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,
);
}
}
That literal already exists three times: checkpoints.rs:1111-1125 (measure, which hardcodes batch_capacity: 1 and is why this helper had to be written at all), cost.rs:980-991 (snapshot_step), and tests.rs:13-24. set_measured is already a #[cfg(test)]-only method sitting on ActionCosts and already has self.batches in scope (helios/src/scheduler/cost.rs:563-584), so the loop belongs beside it rather than in checkpoints::tests:
#[cfg(test)]
pub fn clear_measured(&mut self, kind: GraphKind) {
for batch in self.batches(kind).to_vec() {
// build the kind's step for `batch` and set_measured(step, 0)
}
}
Then delete clear_snapshot_costs (17 lines) and replace its two call sites — checkpoints.rs:4188 (clear_snapshot_costs(&mut scheduler) in unmeasured_snapshot_cost_allows_one_inflight_terminal_discovery_and_recovers_on_cancel, 4183-4251) and checkpoints.rs:4257 (in terminal_snapshot_discovery_end_to_end_plan_commit_complete_unblocks_subsequent_captures, 4253-4306) — with scheduler.costs.clear_measured(GraphKind::Snapshot). Adding a batch parameter to measure (checkpoints.rs:1111-1125) instead of hardcoding batch_capacity: 1 would have made the whole helper unnecessary, and is the cheaper fix if you prefer to touch only tests.
4. (medium; doc-only, but it is a self-contradiction the PR introduces) "at most one in-flight discovery capture" versus "no concurrency-based snapshot share"
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.
The same collision appears in docs/core-design.md:1444-1445 ("There is no capture-count limit or allocation of a fixed snapshot share to each request") against core-design.md:1455-1457 ("allows at most one in-flight discovery copy (priced at zero) to observe it."). The new discovery slot is a server-global concurrency cap of exactly one (scheduler.rs:661, checkpoints.rs:1040-1042), so the untouched sentence is now false in the same paragraph. This matters more than ordinary doc drift because docs/scheduling-runtime-design.md and core-design.md are the normative descriptions maintainers read instead of the code. Fix: append one clause in both files — "There is no fixed capture count or concurrency-based snapshot share, apart from the single cold-discovery capture above." The same one-line disclosure pattern was applied to docs/cli-design.md:707 already, so this is just completing the sweep.
Checked and deliberately not raised as simplification findings
- No hot-path objection to the ascending batch scan.
checkpoint_selectionis memoised per(handle, quote_storage)inself.checkpoint_selections(checkpoints.rs:410-428) and opened once per planning pass, socheckpoints.rs:624runs once per request per planning scope; theENTRY_LOOKUPSbudgets hold. The scan is bounded by the declared Snapshot batch count. - No duplicated gating was added.
checkpoint_cut/estimated_checkpoint_cut/plan_checkpointsall route throughcheckpoint_selection, and there are exactly three productionmeasured_durationcall sites — the PR did not copy-paste a fourth gate. min_measured_duration(cost.rs:33-39) is not the same helper. It aggregates across shapes preferring the shortest positive value;measured_durationselects the smallest declared batch and retains. They are genuinely different queries and should stay separate — this is worth stating explicitly because the two are easy to confuse in review.- Test shape is right. The renamed
unknown_prefill_or_unmeasured_snapshot_cost_disables_extrasdrops the now-dead TTL assertions instead of keeping stale coverage, and the new end-to-end test (checkpoints.rs:4253-4306) drives realplan()/commit()/complete()rather than callingmeasure()directly — that is the pattern the rest of the suite should follow. - Charter/convention alignment: nothing added is per-model, per-hardware, or a new tunable;
helios/README.mdand the design docs move together with the code. - Skipped by lens rules (Correctness & Contracts covers them): the zero-priced discovery copy under-reporting
flare_checkpoint_extra_work_nanoseconds_total(checkpoints.rs:1043→1075→1089-1094versusdocs/api.md:355-356(not opened)), and the fact that the work-budget test atcheckpoints.rs:1048-1056can never refuse a cost-0 discovery copy.
Open questions
- Are the three explicit
snapshot_discoveryclears intentional defence-in-depth, or scaffolding from before thephase != Finishingpredicate existed? The dossier timeline suggests the predicate came with the same revision, in which case the clears are simply the older of two overlapping mechanisms. A maintainer answer decides finding 1. - Should the new discovery guard be modelled in
verification/helios-lifecycle/CheckpointReservation.tla— as #568 did forTerminalDestination— or explicitly declared out of the model's domain?docs/design-review.md:226-228(not opened) asks forcheck.py (not opened) --mutationswhen "adding or changing safety guards", and this PR edits theRequestSchedulerstruct and three lifecycle release paths. The PR body's checklist notes are accurate aboutscripts/scheduling_sim(no checkpoint modelling exists there) but silent about the formal layer. - Will a human maintainer review this at all? Only one automated "Changes Requested" review exists, and it is against the superseded head
2d9454f; the author's 16:39 reply asks for re-review off7f4d253. No maintainer has taken a position on #534 or on the upstream-vs-fork framing ("Related to #534", not "Fixes"), and neither #534's fork diagnosis (mark-yong, 2026-11-28) nor flare-autobot's 2026-11-30 non-reproduction comment is cited in the body. - Should
docs/api.md:355-356(not opened) disclose the zero-priced discovery copy (it says the counter "sums charged predicted extra prefill and copy work" with no exception)? Owned by the Correctness lens, but it is the same one-sweep doc fix as finding 4.
What I could not find
No maintainer stance on #534 or #655 in either thread; no re-review of f7f4d253; no reproduction of a pure cold boot (nanos == 0) on upstream main without PrefillTailMerge; no TP>1, multi-host, SM103/SM121 or explicit core-load run; no logs or metric dumps behind the four live SM120 scenarios; and no checkpoint/unknown_cost/discovery model in scripts/scheduling_sim/, so the simulator layer cannot be run for this change even in principle. No AGENTS.md (not opened) exists in the repository, so there is no written per-file convention set to violate beyond the design docs cited above.