#1 [high] Lens: simplification findings for PR #655 (helios snapshot probe)
PR #655 (yatesdr, head 2d9454f): +253/−9 in 3 files. Production code is ~20 net lines.
VERDICT: diff is already lean. No new config knob, no wire/metric change, gating reuses existing scheduler_checkpoint_extra_work_fraction (policy.rs:40). smallest_batch_key (cost.rs:783-786) is a genuine de-duplication: it replaces the inline key build previously inside fresh_duration and now serves 3 call sites, and it honours a core whose smallest declared Snapshot batch != 1. last_probe_ns: Option<u64> kept separate from last_attempt_ns is deliberate and correct: folding it into record_attempt would move refresh_order (cost.rs:820-822) and double-count funded timing-refresh credit (policy.rs:1563-1599, policy_tests.rs:2477-2481). Do NOT suggest reusing last_attempt_ns.
S1 (medium) checkpoints.rs:1032-1045 — 3-arm match duplicates self.stats.checkpoint_skip_unknown_cost += 1; return Ok(None); in two arms. Collapse to match on Option + single let-else. 13 -> 9 lines, one skip path.
S2 (low) cost.rs:797-799 — if estimate.fresh(...) { return None; } is unreachable from the sole production caller (checkpoints.rs:1032 only calls probe_duration after fresh_duration on the same key returned None). Only the unit test at cost.rs:1057-1058 pins it. Not load-bearing.
S3 (low-medium) cost.rs:983-997 + 999-1008 vs 1016-1030 + 1046-1055 — the new test re-types an identical 15-line GraphDescriptor literal + 10-line ScheduledStep literal already present verbatim in fresh_duration_uses_smallest_declared_batch_when_batch_one_is_absent. ~40 lines removable by folding the probe assertions into that existing test (it already asserts the None->measured transition) or extracting one fixture fn.
S4 (medium, convention) The rule now lives in 4 places; PR edited 1. scheduling-runtime-design.md:619-626 updated; core-design.md:1452-1454 still "Unknown prefill costs or unknown or stale snapshot-copy costs exclude extras without excluding the selected anchor"; helios/README.md:376-379 still "Unknown costs exclude extras while preserving best-effort anchor retention"; cli-design.md:696-709 unchanged. Both remaining texts now contradict the new documented behavior. AGENTS.md:52-60 requires documents to state designed behavior; merged precedent #285 updated the paragraph copies together. Minimal fix: one clause each.
Checked and rejected as suggestions: probing at tokens: 1 hardcoded (harmless, matches pre-existing fresh_duration convention); gating on fraction>0.0 (required, prevents behavior change at 0.0 — test checkpoints.rs:4243-4261); record_probe-after-snapshot ordering (correctness lens, not subtraction).
#3 [high] Research summary
Subtraction/Simplicity/Conventions review of PR #655 is complete; four suggestions, all cited, in the scratchpad (entry 1 = findings, entry 2 = verbatim doc quotes).
Verdict: the diff is already lean. ~20 net production lines in two shared scheduler files, no new config knob, flag, metric, env var or wire field, and the gating reuses the existing scheduler_checkpoint_extra_work_fraction (policy.rs:40). smallest_batch_key (cost.rs:783-786) is a real de-duplication — it lifts the inline key build out of fresh_duration and serves three call sites, and keeps the probe on the same smallest declared batch the core provides rather than hardcoding batch 1. The separate last_probe_ns field is deliberate and should not be collapsed into last_attempt_ns: doing so would move refresh_order (cost.rs:820-822) and double-count the funded timing-refresh credit (policy.rs:1563-1599; policy_tests.rs:2477-2481).
Suggestions:
- S1 (medium)
checkpoints.rs:1032-1045— the 3-armmatchrepeatsself.stats.checkpoint_skip_unknown_cost += 1; return Ok(None);in two arms; collapse to onelet Some(cost) = … else { skip; return }(13 → 9 lines, single skip path). - S2 (low)
cost.rs:797-799— theif estimate.fresh(...) { return None; }guard is unreachable from the only production caller (checkpoints.rs:1032callsprobe_durationonly afterfresh_durationon the same key returnedNone); only the unit test pins it, so it isn't load-bearing. - S3 (low-medium)
cost.rs:983-997/999-1008vs1016-1030/1046-1055— the new test re-types aGraphDescriptorandScheduledStepliteral that already exist verbatim infresh_duration_uses_smallest_declared_batch_when_batch_one_is_absent; ~40 lines removable by folding the probe assertions into that test or extracting one fixture. - S4 (medium, convention) The extra-work rule is stated in four places and the PR updated one:
docs/scheduling-runtime-design.md:619-626(updated) vsdocs/core-design.md:1452-1454andhelios/README.md:376-379(both now contradict the new terminal-capture behavior) anddocs/cli-design.md:696-709. AGENTS.md:52-60 requires documents to state designed behavior; one clause each fixes it.
I explicitly rejected three tempting "simplifications" as wrong: hardcoded tokens: 1 (pre-existing convention, harmless), removing the fraction > 0.0 gate (required for byte-identical behavior at zero, test at checkpoints.rs:4243-4261), and the record-probe ordering (correctness lens, and the ordering is intentional).
#4 [high] Verbatim code quotes + concrete replacements for S1-S3
Evidence quotes for the three code suggestions (S4 doc quotes are in note #2).
=== S1 (medium): duplicated skip path in the 3-arm match === helios/src/scheduler/checkpoints.rs:1032-1045, verbatim:
let (cost, probed) = match self.costs.fresh_duration(GraphKind::Snapshot, 1) {
Some(cost) => (cost, false),
None if self.policy.checkpoint_extra_work_fraction > 0.0 => {
let Some(cost) = self.costs.probe_duration(GraphKind::Snapshot, 1) else {
self.stats.checkpoint_skip_unknown_cost += 1;
return Ok(None);
};
(cost, true)
}
None => {
self.stats.checkpoint_skip_unknown_cost += 1;
return Ok(None);
}
};
The self.stats.checkpoint_skip_unknown_cost += 1; return Ok(None); pair appears twice (lines 1036-1037 and 1042-1043), and the follow-on let Some(prefill) = accounting.initial_prefill_ns else { self.stats.checkpoint_skip_unknown_cost += 1; return Ok(None); }; at 1046-1049 is the same skip a third time. Replace all three with one path:
let cost = self.costs.fresh_duration(GraphKind::Snapshot, 1).or_else(|| {
(self.policy.checkpoint_extra_work_fraction > 0.0)
.then(|| self.costs.probe_duration(GraphKind::Snapshot, 1))
.flatten()
});
let (Some(cost), Some(prefill)) = (cost, accounting.initial_prefill_ns) else {
self.stats.checkpoint_skip_unknown_cost += 1;
return Ok(None);
};
let probed = self.costs.fresh_duration(GraphKind::Snapshot, 1).is_none();
(with an extra boolean captured up-front if the second fresh_duration lookup is unwanted; it is one hashmap hit either way.) 22 lines of gates become ~9 with a single skip site, which also removes the risk of the three sites drifting (they already differ in nothing but position).
=== S2 (low): probe_duration re-checks freshness its only caller already checked ===
helios/src/scheduler/cost.rs:794-804, verbatim:
pub fn probe_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
let key = self.smallest_batch_key(kind, tokens)?;
let estimate = self.entry(key)?;
if estimate.fresh(self.now_ns, self.ttl_ns) {
return None;
}
let ready = estimate
.last_probe_ns
.is_none_or(|at| self.now_ns.saturating_sub(at) >= self.ttl_ns);
ready.then_some(estimate.nanos)
}
Callers: checkpoints.rs:1035 (the only production one, reached only after fresh_duration on the same key returned None) and the unit test cost.rs:1057-1058. The if estimate.fresh(...) arm is therefore unreachable in production; it is defensiveness that only the unit test exercises. Either drop it and rename to make the precondition explicit (e.g. document "call only when fresh_duration returned None"), or keep it and drop the corresponding test assertion — not both. Not a defect, just ~4 lines of guard with no production exerciser.
=== S3 (low-medium): the new unit test re-types an existing fixture ===
helios/src/scheduler/cost.rs:983-1008 (existing test fresh_duration_uses_smallest_declared_batch_when_batch_one_is_absent) and cost.rs:1016-1055 (new test probe_duration_uses_smallest_declared_batch_and_bounds_by_ttl) contain byte-identical 15-line GraphDescriptor literals (name "snapshot-b2", kind Snapshot, batch_capacity 2, token_capacity 1) and twice the same 10-line ScheduledStep { draft_tokens: 0, kind: GraphKind::Snapshot, batch_capacity: 2, token_capacity: 1, packed_token_capacity: 0, mixed: None, lanes: vec![], requires_feedback: false }. The existing test already asserts exactly the transition the new test needs (fresh_duration … None → set_measured → Some(750_000)). Cheapest fix: delete the new test's fixture block (cost.rs:1016-1030, 1046-1055) and either extend the existing test with the four probe_duration assertions or hoist one fn snapshot_b2_costs() -> (ActionCosts, ScheduledStep) used by both. Removes ~40 duplicated test lines.
=== Scope note ===
Nothing else in the diff is removable: no new flag, config key, metric, or fallback layer; the last_probe_ns field is load-bearing (kept off last_attempt_ns so refresh_order at cost.rs:820-822 and the funded refresh path at policy.rs:1563-1599 do not double-count), and the fraction > 0.0 gate is required to keep zero-fraction behavior identical (test checkpoints.rs:4243-4261). The production diff is about 20 net lines and is idiomatic for this module.
#2 [medium] Doc copies of the checkpoint extra-work rule (verbatim, for S4)
-
docs/scheduling-runtime-design.md:619-629 (UPDATED by PR, quote of new text): "Unknown prefill costs and / unknown or stale snapshot-copy costs disable prefill extras while preserving the / selected anchor; ... When the fraction is / positive and the snapshot-copy cost is unmeasured or stale, terminal capture / still allows at most one probe per
estimate_ttl_ns(priced against the / retained snapshot duration when stale) so requests whose anchor is already / cached or whose decode outlives the TTL can refresh the estimate." -
docs/core-design.md:1447-1455 (STALE): "Unknown prefill costs or unknown or stale snapshot-copy / costs exclude extras without excluding the selected anchor; when the fraction is / zero, unknown prefill costs fall back from an interior message boundary to the / prompt-end anchor."
-
helios/README.md:372-380 (STALE): "Earlier messages and / a distinct prompt end compete within a work allowance of /
scheduler_checkpoint_extra_work_fractiontimes estimated uncached prefill work, / defaulting to 0.05. ... Unknown costs exclude extras / while preserving best-effort anchor retention." -
docs/cli-design.md:696-709 (flag description, no unknown-cost sentence; arguably fine, but states "With a nonzero fraction, the scheduler considers the last eligible message endpoint as a best-effort conversation anchor even when timing estimates are unavailable" — the sentence a user sizing the flag reads).
AGENTS.md:52-60: "Every repository document has one or both of two purposes: it specifies the architecture, or it instructs agents how to work in the repository. State designed behavior that the code does not implement as a specification marked designed, not implemented."