Final review report · NVIDIA/hyperflare-inference #665

Raw Markdown for agents: https://autobot.eidonix.com/p/343106ba-9276-480e-9b3a-1e394c5d0217.md

Recommendation: Changes Requested

PR #665 proposes a clean, zero-knob, model-agnostic scan-resistant eviction policy (~68 net production LOC, no flags, floats, unsafe, or wire/core-format changes) in the right Helios cache/scheduler layer. However, two blocking issues prevent merge on head a7568c2: is_protected compares monotonic turnover against live growing cache counts so already-demoted checkpoints silently regain protection when new entries publish, and the PR omits the mandatory check.py --mutations verification gate while inaccurately claiming unit tests and TLA+ verify host-restore touch_hit. Several concrete should-fix items (snapshot-compaction turnover omission, preemption asymmetry in finish_inbound, stale design docs, and a BFS key() collision in lifecycle_tests.rs) and two clean subtractions also need resolution before merge.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

  1. Non-monotonic is_protected aging re-protects stale demoted checkpoints without a new hit (helios/src/cache.rs:346-361, :257-274, :604-609).
    • is_protected checks !(page_turnover >= self.tail_pages.max(1) as u64 && node_turnover >= self.ready_checkpoints.max(1) as u64) against live self.tail_pages and self.ready_checkpoints, both of which grow on every publication (count() at :257-264). Once a stale checkpoint demotes (is_protected == false), any subsequent publication that raises tail_pages or ready_checkpoints above the node's turnover flips is_protected back to true without a second reuse hit.
    • Concrete proof in the PR's own test geometry (helios/src/cache/tests.rs:1447-1467): after the 3rd leaf eviction (evicted_pages = 6, evicted_checkpoints = 3, tail_pages = 2, ready_checkpoints = 2), stale is demoted. If two fresh 1-page checkpoints publish before the next eviction instead of one (tail_pages = 4, ready_checkpoints = 4), node_turnover = 3 < 4 silently re-promotes stale to protected so evict drops fresh work instead. The same dynamic inflates the aging horizon during a workload shift from a few large sessions to many small checkpoints. (Secondary asymmetry: self.tail_pages counts both ready and unready checkpoints at :263, whereas evicted_pages counts only node.ready leaves at :604-609.)
    • Fix: Make demotion sticky once reached — e.g., clear node.reused = false on any expired nodes when turnover advances in retire_leaf (or evaluate against a monotonic bound that cannot re-enable already-demoted nodes, taking care not to freeze a near-empty warmup count at mark_reused time). Add a regression test in helios/src/cache/tests.rs that publishes multiple fresh checkpoints after demotion and asserts the demoted entry stays probationary.
  2. Missing blocking check.py --mutations run and inaccurate verification claim for host restore (docs/design-review.md:226-228, 247-251, helios/src/scheduler.rs:1884-1887, verification/helios-lifecycle/check.py:515-520).
    • docs/design-review.md:226-228 and :247-251 require running python3 verification/helios-lifecycle/check.py --mutations (or cargo-mutants) whenever adding or changing safety/eviction guards, and explicitly state that leaving an applicable CPU check unrun blocks PR acceptance. check.py:515-520 directly guards eviction_candidate_within_budget, whose victim ordering this PR modifies, yet only check.py --jobs 4 is reported.
    • Additionally, the PR description claims "Selene restore touch_hit is verified by unit tests and TLA+, not live offload", which is unsupported: none of the four added tests (helios/src/cache/tests.rs:1315-1504) invokes finish_inbound, none of the existing finish_inbound tests (helios/src/scheduler/tests.rs:2914-3208) asserts reuse protection or eviction ordering after restore, and CacheOwnership.tla (verification/helios-lifecycle/README.md:240-241) models neither host restore nor retention/eviction ranking.
    • Fix: Run python3 verification/helios-lifecycle/check.py --mutations and report its result; add a unit test in helios/src/scheduler/tests.rs exercising finish_inbound and asserting protection/eviction order against an un-reused scan; and update the PR description so its evidence claims accurately reflect what was tested.

Should Fix

  1. compact_ancestor never advances turnover counters, preventing aging under snapshot-only compaction pressure (helios/src/cache.rs:626-657 vs :601-609, :749-753).
    • Under snapshot-row pressure (when KV pages are not exhausted), evict_checkpoint retires single-child interior ancestors via compact_ancestor (freeing 1 snapshot and 0 pages) without incrementing either evicted_checkpoints or evicted_pages. Stale protected entries therefore never age out when eviction pressure is absorbed by ancestor compaction, and even alongside leaf evictions compacted checkpoints never advance node_turnover.
    • Fix: Count compacted ready snapshots in turnover (and ensure snapshot-pressure turnover can age out stale protected entries rather than stalling indefinitely on page_turnover == 0), and add a compaction-aging test in helios/src/cache/tests.rs (plus a regime-shift check with reused Phase-1 documents in helios/src/scheduler/policy_tests.rs).
  2. Preemption and cancelled-waiter asymmetry on host restore (helios/src/scheduler.rs:1884-1887 vs :1727-1739).
    • For GPU hits, admit_planned_with_checkpoint_accounting gates touch_hit on fresh_admission = accounting.is_none() (scheduler.rs:1727, 1735) so preempted re-admissions refresh recency only. In finish_inbound (scheduler.rs:1884-1887), PublishResult::Created unconditionally calls self.cache.touch_hit(id, ticket.demand_epoch)? even when the ticket's only waiter was a preempted re-admission (helios/src/server/runtime.rs:3158 passes accounting.clone()) or all waiters were cancelled before transfer completion (ticket.waiters.is_empty(), as in scheduler/tests.rs:2976, 3152).
    • Fix: Record fresh_admission: bool on Ticket (set/ORed at scheduler.rs:1686-1709) and call touch_hit in finish_inbound only when ticket.fresh_admission && !ticket.waiters.is_empty() (otherwise plain touch), covered by a test in helios/src/scheduler/tests.rs.
  3. Design documents contradict the new victim ordering (docs/core-design.md:1536-1567, docs/scheduling-runtime-design.md:643-645, docs/prefix-cache-offload.md:298, AGENTS.md:52-60).
    • helios/src/cache.rs:363-365, :732 places is_protected ahead of RetentionRank, displacing #568's documented invariant ("Optional Anchor and Message captures reclaim lower-rank victims strictly by demand-recency order", docs/core-design.md:1565-1566) and changing #298/#416's completion refresh (scheduler.rs:3107-3118) so it refreshes recency only within the unprotected tier. All three design docs still state strict demand-recency/role ordering, violating AGENTS.md:52-60.
    • Fix: Update docs/core-design.md:1536-1567, docs/scheduling-runtime-design.md:643-645, and docs/prefix-cache-offload.md:298 to specify the two-tier protection ordering, inheritance rule, and dual-turnover aging, and cite #568 and #298/#416 in the PR description.
  4. BFS deduplication key in helios/src/cache/lifecycle_tests.rs:498-505 collides distinct reused states.
    • Fixture::key() appends the eviction_key-sorted semantic node IDs to self.projection(), which intentionally omits reused and turnover counters so it stays aligned with CacheOwnership.tla's 29-integer state tuple (verification/helios-lifecycle/README.md:230-234). Because Action 8 (duplicate publication, lifecycle_tests.rs:293-296) now mutates node.reused = true via touch_hit, two states with identical projection() — e.g., reused = [false, false, false] vs reused = [false, false, true] — both sort to [1, 2, 3] and produce identical key() values, causing visited.insert(next.key()) (:617) to prune downstream branches where subsequent duplicate publications yield distinct eviction orders.
    • Fix: Append each live node's protection/reuse state (and relevant turnover state) to Fixture::key() — leaving Fixture::projection() unchanged so CacheOwnership.tla stays valid — and re-run check.py.

Subtract / Simplify

  1. Delete dead duplicate write of existing.accessed (helios/src/cache.rs:468).
    • In publish_with_retention's Existing branch (cache.rs:466-471), line 468 writes existing.accessed = existing.accessed.max(use_epoch);, and line 471 immediately calls self.touch_hit(id, use_epoch)?, whose self.touch(id, use_epoch)? (:377-382) performs the exact same assignment. Delete line 468 (−1 LOC, eliminates duplicate field writer).
  2. Delete inert 33-line duplicate test (helios/src/cache/tests.rs:1472-1504).
    • reclaimable_if_pinned_matches_evict_with_mixed_protected_and_probationary_nodes calls evicted_after_pin (tests.rs:1026-1038), which evicts with pages: usize::MAX, snapshots: usize::MAX and compares sorted(...) sets; victim order cannot alter the drained fixpoint, and reclaimable() (cache.rs:785-843) reads none of the new fields. The same parity invariant is already tested on strictly richer topologies by projection_matches_eviction_for_chains_branches_and_compaction (tests.rs:1041-1080) and reclaimable_projection_matches_eviction_with_pins (lifecycle_tests.rs:641-703). Delete :1472-1504 (−33 LOC).

Nits

Dropped on verification