#1 [high] Should fix: pin_request/unpin_request duplicate pin's chain walk and skip its refcount-overflow guard
PR 549, helios/src/cache.rs.
Precedent: Cache::pin (cache.rs:519-534) and unpin (cache.rs:536-546) compute self.chain(id)? once, check self.nodes[&id].direct_pins == u64::MAX || chain.iter().any(|id| self.nodes[id].pins == u64::MAX) and return Err("checkpoint reference count exhausted") before mutating.
New pin_request (cache.rs:551-563) does self.pin(id)? (which walks the chain) and then let chain = self.chain(id)?; again — two Vec allocations and two root-walks per pin, and the exact pattern is repeated in unpin_request (cache.rs:565-580, self.unpin(id)? then self.chain(id)?). Departure from the one-walk-per-operation shape of the siblings it wraps.
Second departure: the new counters direct_request_pins/request_pins are incremented with += 1 and decremented with -= 1 with no u64::MAX guard, whereas the existing cumulative pins/direct_pins are guarded by an explicit checked check in pin. The subtraction side relies only on the direct_request_pins == 0 early-out plus debug_assert_eq! in compact_ancestor (cache.rs:627) and the test-only scan in stats (cache.rs:819-837), so a mismatched release in a release build silently underflows request_pinned_pages (usize) instead of erroring the way unpin does.
Fix: fold the request accounting into pin/unpin behind a parameter (or a private pin_with(id, request: bool)), computing chain once and running the overflow guard over both pin sets; keep the tests' error messages by branching only in the error text. If the two-walk shape is kept, at minimum add the same u64::MAX check for request_pins.
Verified by reading cache.rs:519-580 and cache.rs:613-646.
#2 [high] Should fix: three copies of the pin/pin_request branch in admit_planned break the single-binding pattern
PR 549, helios/src/scheduler.rs:1643-1649, 1657-1669, 1683-1692.
Before the change the admission path took one let pinned = ... (scheduler.rs:1638-1642) and paired it with a single self.cache.pin(id) / self.cache.unpin(id) shape at each rollback site. Now the same two-branch conditional
if inbound.is_none() { self.cache.pin_request(id)? } else { self.cache.pin(id)? }
appears at 1643-1649 and the mirrored unpin_request/unpin rollback appears twice more (1657-1669, 1683-1692). Three copies of the pairing must stay in sync: a single missed mirror pin/unpins the wrong counter, which then trips only the test-only drift assert in Cache::stats (cache.rs:819-837) and nothing in a release build. The file's established convention is to encode such pairs once (cf. pinned/pin above, and pin_checkpoint/unpin_checkpoint wrappers at scheduler.rs:2038-2044 which exist precisely so callers cannot mismatch).
Fix: carry the pin kind in the existing binding, e.g. enum PinKind { Request, Admission } chosen next to let pinned = ..., and use one self.cache.pin_as(kind, id) / unpin_as(kind, id) at all three sites.
Also worth confirming with the author (documentation convention, docs/api.md:298-305): an Inbound request contributes neither to request_pages (its prefix is None until finish_inbound) nor to reserved_pages, while its ticket's ticket.pages are held out of free_pages — so those pages are in no gauge, although SchedulerStats::inbound_waiting (scheduler.rs:137-138) documents Inbound requests as active. docs/api.md says the gauges count "the distinct KV pages that active requests reference". Either count ticket pages in reserved_pages-like accounting or state the exclusion in docs/api.md.
#3 [low] Nit: new gauges get no runtime-core-design.md entry (api.md table row correctly omitted)
PR 549, docs/api.md:298-305 and helios/src/server/metrics.rs:1310-1318. Severity: nit.
Precedents for how a new scheduler page gauge is documented:
- docs/api.md:325-355 is the field table mapping every JSON field to its Prometheus name (cached_pages -> flare_cached_kv_pages at 345, free_pages at 346, total_pages at 347). The two new gauges deliberately have no JSON field (stated in the PR description), so absent table rows are consistent with the existing "beyond the JSON fields" sentence at docs/api.md:292-296 — not a finding.
- flare_snapshot_backing_pages has a design-document description at docs/runtime-core-design.md:873. The two new gauges have only the new api.md paragraph and the HELP strings at metrics.rs:1310-1318, so they have no runtime-core-design.md home.
Recommendation: add one sentence to docs/runtime-core-design.md near the snapshot_backing_pages text so the metric keeps the design-doc home the existing gauge has. Only worth doing if the semantics need a durable specification beyond the exposition help.
Prose facts verified against code: SchedulerStats::request_pages = live slots' private_pages.len() + cache.request_pinned_pages (scheduler.rs:1216-1222); request_pinned_pages adds a checkpoint's own tail_pages once when its request_pins rises from zero (cache.rs:551-563) and is checked against a full scan in stats (cache.rs:819-837). So "each page counted once even when several requests reference it" matches the implementation, and the api.md wording "idle cached prefixes ... are outside that share" is accurate — pinned shared pages are counted in both flare_request_kv_pages and flare_cached_kv_pages, which the text does not claim otherwise.