Re review report · NVIDIA/hyperflare-inference #665

Raw Markdown for agents: https://autobot.eidonix.com/p/919c1198-030c-44c8-9687-06e03741bc11.md

Recommendation: Ready To Merge

Rebased onto main (1fbcc3c9) at head c5b39236, PR #665 resolves every blocker, should-fix, subtraction, and nit from the prior review and closes the residual Existing-restore and documentation issues found on intermediate head c919742. The policy remains lean, zero-knob, and model-agnostic (135 net production LOC across cache.rs and scheduler.rs; no flags, floats, unsafe, or core-format changes), with sticky dual-turnover + compaction aging, per-waiter host-restore freshness gating across both Created and Existing matches, synced design docs, and full check.py --mutations plus unit/policy coverage reported on the pushed tree.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

  1. Factor duplicate retirement turnover accounting in helios/src/cache.rs:630-641, :658-690: retire_leaf and compact_ancestor repeat the same pre-uncount horizon capture (ready_tail_pages.max(1), ready_checkpoints.max(1)), if node.ready guard, counter updates, and demote_expired_reused call. Folding them into one note_ready_retirement(&mut self, node: &Checkpoint, pages: u64) helper called right after self.nodes.remove(&id) and before self.uncount(&node) (passing node.tail_pages.len() as u64 vs 0) removes ~14 lines and enforces the pre-uncount ordering in one place.
  2. Collapse one-line is_protected wrapper and narrow eviction_key visibility (helios/src/cache.rs:353-355, :378-380): is_protected(&self, node: &Checkpoint) reads only node.reused without touching self, and eviction_key is only called from cache.rs:777 and child test module cache::lifecycle_tests (lifecycle_tests.rs:504). Replacing both with a private associated function fn eviction_key(node: &Checkpoint) -> (bool, RetentionRank, CheckpointId) deletes 6 lines and removes the receiver indirection.
  3. Inline single-caller mark_reused and align field naming (helios/src/cache.rs:86, :382-404): mark_reused has only one caller (touch_hit at :402) and performs a second self.nodes.get_mut(&id) lookup right after self.touch already probed the map. Inlining the three field assignments into touch_hit avoids the duplicate hash lookup per hit; renaming reused_at_evicted_nodes (:86) to reused_at_evicted_checkpoints matches evicted_checkpoints (:224).
  4. Deduplicate shared setup in new cache and policy tests (helios/src/cache/tests.rs:1396-1567, helios/src/scheduler/policy_tests.rs:6380-6480): sticky_demotion_does_not_reprotect_after_fresh_publications repeats the first 56 lines of dual_turnover_aging_demotes_stale_reused_entry_after_page_and_node_turnover, and policy_regime_shift_ages_out_reused_old_large_documents_for_newer_chat_workload duplicates policy_regime_shift_ages_out_old_large_documents_for_newer_chat_workload except for the second turn in Phase 1. Extracting two small test helpers removes ~80 lines while keeping all test names unchanged.

Nits

Dropped on verification