Verdict: worth merging — one documentation clause, no code changes required
Head bca7358 (+202/−34, 8 files) is the strongest version of this PR: the round-one blocker is fixed, retirement releases the request pin before the slot empties, the duplicated pin-flavour branches are folded behind pin_prefix/unpin_prefix, the two copied page tests are merged one-per-layer, and the API paragraph now states the awkward truths. Nothing in the diff changes an allocation, eviction, or scheduling decision.
Fit against the charter
A reported defect, not a wish. #537 is version-cited and reproducible (v0.3.2 c0c4f79): with the shipped gauges an operator can only bound KV use — ≈16 % upper, ≈0 % lower, against ≈9 % on vLLM — because a request's pinned prefix pages stay inside flare_cached_kv_pages and its reserved growth pages appear in no gauge. That is squarely the charter's merge list ("a reproducible bug … or bad docs"), and it is the missing half of the monitoring story #541 is shipping.
Right layer, no new switches. The counter lives where the quantity lives: helios/src/cache.rs maintains request_pinned_pages as pins change (cache.rs:519–589), helios/src/scheduler.rs adds its live slots' private and reserved pages in the same pass that already counted active requests (scheduler.rs:1199–1221), helios/src/server/metrics.rs renders two gauges (metrics.rs:1309–1318). No flag, env variable, per-model branch, or backend abstraction — nothing near a non-goal or the "no configuration switches" rule.
It respects the invariant it could have broken. The cache already keeps ready_checkpoints/unready_checkpoints/tail_pages precisely so stats never scans nodes (cache.rs:257–275, 825–861). The new counter follows that established pattern instead of adding the per-scrape graph walk the existing comment forbids. No simpler route to the same end exists: #537's own alternative (splitting cached_kv_pages into pinned/idle) needs identical bookkeeping and yields a less directly usable number; a ready-made ratio gauge would hide the reserved term and freeze the arithmetic.
Correctness, re-verified at this head
- Pins: creation starts both counts at 0 (cache.rs:461–462); a request pin increments
request_pinson the same chain walk the plain pin performs, adding tail pages only on the 0→1 crossing (539) and subtracting on 1→0 (565).unpin_requestrefuses when the checkpoint holds no request pin (547–549), turning a mispair into an error rather than an underflow. - Compaction: ancestor and heir must agree on request pins (
debug_assert_eq!cache.rs:636), and the ancestor's tail pages move into the already-counted heir, so the union stays counted exactly once — asserted at cache/tests.rs:346–360 (2 before and after the merge, 0 on the last release). - Eviction safety:
request_pins > 0impliespins > 0, and both eviction predicates requirepins == 0ordirect_pins == 0 && child_count == 1(cache.rs:667–673, with the compactiondebug_assert_eq!(node.direct_pins, 0)at 632), so counted pages cannot be stranded outsidenodes. - Retirement: the pin is released at scheduler.rs:3144–3149 before
request.take()at 3150, so a failed release leaves the request inspectable instead of leaking a pin behind a half-destroyed slot. - Copy-out retry key (was the blocker):
CopyoutResourcesembedsSchedulerStatswhole and derivesPartialEq(runtime.rs:1053–1059), so page counts would have re-offered deferred host copy-outs at every decode page boundary. Zeroing the two fields when building the key (runtime.rs:2443–2450) restores "no scheduling decision changes", with a comment saying why. The shape is slightly awkward — a stats struct partially nulled for a cache-resource comparison — but it is three documented lines; a dedicated cache-resource key struct would be nicer and is not worth demanding here. - Checked on every read: the test-only drift assertion compares
request_pinned_pageswith a full scan of the nodes holding request pins on everystats()call (cache.rs:827–846), so the whole cache and scheduler suite exercises it, not just the new tests.
Cost and beneficiaries
Two u64 per Checkpoint, one usize on the cache, one add/sub per pin on a chain already walked, and per stats one loop over at most slot-count live requests. No GPU work, no allocation, no scheduling decision; the description states the cost was read from code and not measured, which is correct for a visibility-only change.
Beneficiaries are operators migrating vLLM/Grafana dashboards and #541's KV panel, which otherwise shows only bounds. reserved_kv_pages is the cheap half — the measured value was 2–3 pages under two streaming chats — but it accounts for pages that leave free_pages at admission and appear in no other gauge, and it makes the documented (request + reserved) / total the vLLM-comparable figure that #548's mapping table will point at. The request gauge is the valuable half.
Evidence
Four-part description with a Discord: line and an explicit not-run list (Windows build, full helios suite, exported core → CI). The live scrape is the right shape and honestly scoped: idle 0/0 with 2019 cached of 21504; two concurrent streams 399/402 request pages, 3/2 reserved, ratio 0.0186/0.0187; the implied bound request + reserved ≤ total − free holds; no cross-runtime comparison claimed; the author discloses that the instance also served the agent's own traffic. The description correctly notes the scrape ran on 9cca87a and that bca7358 changed only docs, tests, and pin-bookkeeping structure — which the cache and scheduler tests assert directly.
What remains
One clause, no longer a gate. Snapshot (metrics.rs:70–129) is the documented format=json body and these two gauges are Prometheus-only. Earlier I treated that as blocking; at this head it is not, because docs/api.md:292–296 already frames that table as the JSON subset ("Beyond the JSON fields below, the text includes …"). One added sentence to the paragraph at docs/api.md:298–310 — "these two are Prometheus-only; the snapshot does not carry them" — closes it. Adding the two fields to Snapshot would also let the terminal dashboard plot them; that is a follow-up, not a merge condition.
Worth knowing, not worth blocking: SchedulerStats now doubles as the deferred-copy-out key, so every future field must be judged for key-worthiness (the manual two-field exception is commented — the cheap mitigation); a Debug-only cross-check that every live request with prefix: Some(_) carries a request pin would make a future mispair fail loudly, and the release-ordering fix already removes the silent-leak failure mode; pages of self.retired and of an in-flight restore ticket stay outside both gauges, which the docs now state.
Bottom line: worth merging. Focused, correctly layered, honestly evidenced, at a complexity cost the cache was designed to absorb, answering a defect a user reported with reproduction detail. Ask for the one-clause JSON sentence in docs/api.md and let CI cover the Windows build and full helios suite the description already flags; #549 and #548 touch disjoint regions of metrics.rs, so merge order does not matter.