Recommendation: Ready To Merge
Head f7f4d25 cleanly resolves all three items from the prior review (2d9454f) and replaces the 30 s probe timer with a simpler, strictly better design: ActionCosts::measured_duration brings Snapshot pricing into parity with Prefill cost retention (PR #285) while handling coalesced batch > 1 observations, and a single in-flight snapshot_discovery slot handles cold warm-restart discovery (nanos == 0) without risking storage-refusal or cancellation lockouts. No correctness, safety, concurrency, or regression blockers remain, and the new end-to-end plan -> commit -> complete test plus 4-scenario SM120 validation cover the claimed behavior.
Merge Risk
Level: Low
- Production changes are small and tightly scoped to
ActionCosts::measured_duration(helios/src/scheduler/cost.rs:783-790),RequestScheduler::allocate_terminal_capture/checkpoint_selection_uncached/checkpoint_copy_allowed(helios/src/scheduler/checkpoints.rs:624, 965, 1018-1079), andsnapshot_discoverylifecycle tracking (helios/src/scheduler.rs:661, 756, 2690-2692, 2700-2702, 3067-3069); no wire format, CLI default, metric schema, or row-ownership/fencing logic changes. RequestScheduleris single-threaded (&mut self),checkpoint_selectionis memoized per planning pass (helios/src/scheduler/checkpoints.rs:410-428),checkpoint_extra_work_fraction == 0.0anddeferred_prefillbehavior are preserved unchanged, andsnapshot_discoveryis claimed only after a snapshot row is obtained.- Worst-case failure mode of the cold-discovery gate is benign degradation to pre-PR
unknown_costskips;ActionCosts::observe(helios/src/scheduler/cost.rs:852-861,498-510) still resets the rolling window on the next execution after TTL expiry.
Walkthrough
helios/src/scheduler/cost.rs: ReplacedActionCosts::fresh_durationwithActionCosts::measured_duration(:783-790), which scansself.batches(kind)in ascending order and returns the smallest declared batch withnanos != 0regardless of TTL expiry (whileobserve()still resetsReplayTimeswhen stale). Updated unit test coverage inmeasured_duration_uses_smallest_measured_batch_and_retains_after_ttl(:994-1045).helios/src/scheduler/checkpoints.rs: Switched all three snapshot-cost gates (checkpoint_selection_uncached:624,checkpoint_copy_allowed:965,allocate_terminal_capture:1039) fromfresh_durationtomeasured_duration. Addedsnapshot_discovery_in_flight(:1018-1023) and single-in-flight zero-priced terminal discovery inallocate_terminal_capture(:1039-1079) whenmeasured.is_none(),checkpoint_extra_work_fraction > 0.0, and storage is actually obtained. Updated two existing tests (:1646-1687) and added three new tests covering post-TTL terminal retention, single-in-flight discovery with storage-refusal/cancel/zero-fraction invariants, and end-to-endplan -> commit -> completediscovery (:4125-4306).helios/src/scheduler.rs: Addedsnapshot_discovery: Option<RequestHandle>(:661, initializedNoneat:756) and cleared it incomplete_inner(status-3 fallback:2690-2692and terminal snapshot completion:2700-2702) andretire(:3067-3069).docs/scheduling-runtime-design.md,docs/core-design.md,docs/cli-design.md,helios/README.md: Synchronized the checkpoint extra-work specification across all four documents to describe retained snapshot-copy estimates after expiry and the single in-flight zero-priced terminal discovery copy.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure scheduler cost lookup and request-handle tracking; no I/O, parsing, FFI, privilege, or untrusted-input surface introduced.
- [PASS] Charter & value fit: Model- and core-agnostic (
self.batches(kind)uses declared core metadata; no new flags, magic defaults, or per-model branches), minimal footprint in Helios, directly supports persistent host/Selene prefix-cache retention. - [PASS] Related / duplicate / conflict check: PR body updated from
Fixes #534toRelated to #534(avoiding premature auto-close of #534); cleanly extends PR #285 and #568; complementary to open draft #301 (cost.rspersistence across restarts). - [PASS] Tests & verification evidence: All six new/updated CPU tests are isolated (no global state mutation) and exercise real production entry points—including end-to-end
plan -> commit -> complete;scripts/scheduling_simN/A rationale is disclosed;.github/workflows/helios-lifecycle.yml(not opened) runs TLA+ conformance (check.py) andcargo kanionhelios/**; 4-scenario live SM120 verification covers >30 s decode, >33 s idle pauses, and warm disk restart.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Drop the three redundant explicit
snapshot_discoveryclears (helios/src/scheduler.rs:2690-2692,:2700-2702,:3067-3069).snapshot_discovery_in_flight(helios/src/scheduler/checkpoints.rs:1018-1023) already treatsRequestPhase::Finishingand retired/stale handles (self.request(handle)checks slot occupancy and generation equality athelios/src/scheduler.rs:1233-1239) as free. Bothcomplete_innerbranches setrequest.phase = RequestPhase::Finishingimmediately above the clear (:2689,:2698), andretireremovesslot.requestat:3124. Removing all three clears deletes 9 lines acrossscheduler.rs, keeps a single source of truth, and avoids mutatingself.snapshot_discoveryat:3068before the fallible?operations inretire. - Reuse
exact_durationinActionCosts::measured_duration(helios/src/scheduler/cost.rs:783-790). The inlineKey { drafts: 0, kind, batch, tokens, prefill: 0, packed: 0 }lookup duplicatesexact_duration(kind, batch, tokens, 0, 0)(:761-771), which also handlesGraphKind::Speculativekeys if ever called with one:
(Optionally, since all call sites passpub 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)) }(GraphKind::Snapshot, 1), this could be narrowed further to a dedicated snapshot-copy helper.)
Nits
docs/api.md:355-356: Optionally note that the single cold-discovery terminal copy is priced at zero inflare_checkpoint_extra_work_nanoseconds_total(and that concurrent terminal captures skipped while discovery is in flight incrementunknown_cost), matching the disclosure added to the four design docs.docs/scheduling-runtime-design.md:625-631,docs/core-design.md:1444-1457,helios/README.md:381-383: Optionally qualify "There is no fixed capture count or concurrency-based snapshot share" / "no capture-count limit" with "in steady state" (or "beyond the single cold-discovery capture") so it does not visually sit beside "allows at most one in-flight discovery capture".
Dropped on verification
- TLA+ /
CheckpointReservation.tlamodeling &--mutationsblocker (Correctness F1): Dropped. Verified inverification/helios-lifecycle/CheckpointReservation.tla:1-140andverification/helios-lifecycle/README.md:1-120thatCheckpointReservation.tlamodels snapshot row ownership, GPU fences, guard revocation, andTerminalDestinationeviction safety—not cost-pricing gates (checkpoint_extra_work_fraction,allowance,unknown_cost).snapshot_discoveryonly toggles whether an optional capture is priced at0vs skipped; it cannot bypassdeferred_prefill(checkpoints.rs:1033-1035) or storage/eviction quoting (:1063-1068), and.github/workflows/helios-lifecycle.yml:3-48(not opened) already runscheck.pyandcargo kanionhelios/**. - Latent panic when
batches(GraphKind::Snapshot)is empty (Correctness F4): Dropped. Verified inhelios/src/model/catalog.rs:138-148that manifest validation requiresGraphKind::Snapshotfor every required batch, and even before this PR bothAnchorcaptures (checkpoints.rs:610-617,:962-964) andfinish_early(scheduler.rs:1449-1452) already enterRequestPhase::Snapshotwithout checkingbatches(GraphKind::Snapshot). - Undocumented work-allowance bypass in
docs/core-design.md:1455-1457(Correctness F5): Dropped as redundant; the updated text already explicitly states "(priced at zero)". - Move
clear_snapshot_costsontoActionCosts(Subtraction #3): Dropped as low-signal test-helper preference;clear_snapshot_costs(checkpoints.rs:4164-4180) is local to two tests incheckpoints::tests, and generalizing it ontoActionCostswould require per-GraphKindstep-construction branching.