#1 [high] Verified: request pin/unpin symmetry across scheduler
Files: helios/src/scheduler.rs, helios/src/cache.rs (PR #549 head 5ed7af8).
Request-owned pins (grep cache.(un)?pin(_request)?):
- admission helios/src/scheduler.rs:1643-1649:
pin_requestonly wheninbound.is_none(); when an inbound restore is being created the plainpinis taken onlookup.checkpoint(the future ticket parent) and released with plainunpininfinish_inbound(1881-1883) andfail_ticket(1917-1919). Symmetric. The two error paths (Context 1658-1664, ensure_resources 1684-1690) repeat the sameif inbound.is_none()choice, so a request pin is never taken and released with the plain API. finish_inbound1900:pin_request(id)per waiter, immediately beforerequest.prefix = Some(id)(1902). Waiters retired earlier (!readybranch 1884-1891,fail_ticket) still haveprefix == None(phase Inbound), soretirenever unpins a prefix they do not hold.publish_boundary2966-2979 (Created) and 2988-3000 (Existing):pin_request(new)strictly beforeunpin_request(parent)and beforerequest.prefix = Some(new); new != parent because the proposal must strictly extend the parent.retire3155-3159:unpin_request(prefix)for exactly the prefix the request pinned.pin_checkpoint/unpin_checkpoint(2038-2044) keep the plain API; used only for host-store copy-out (server/runtime.rs:2360,2364,2396,2473,2489) and export (2698,2703), never against a request's prefix.
Conclusion: LiveRequest::prefix == Some(id) implies exactly one direct_request_pins on id, on every path I read (admission with/without hit, host-restore creating/joining, boundary publication Created/Existing, cancel, cancel-before-inference, preemption, finish, release_after_shutdown). No path found that pins plain and unpins _request (which would now turn into a hard error and leak the slot, since retire takes the request out of the slot at 3143 before unpinning).
#2 [high] Verified: request_pinned_pages counter cannot drift or underflow
helios/src/cache.rs:
pin_request/unpin_request(551-580) increment/decrementrequest_pinsoverchain(id)and add/subtracttail_pages.len()only at the 0↔1 transitions, matching the#[cfg(test)]full-scan assertion instats(819-837).request_pinsis the subtree sum (incremented on every ancestor), socompact_ancestor's newdebug_assert_eq!(node.request_pins, child.request_pins)(627) holds whenever the removed ancestor hasdirect_pins == 0andchild_count == 1; andrequest_pinned_pagesis unchanged by compaction because the removed node's pages move into a heir that is either counted before and after, or uncounted before and after.retire_leaf(594) /compact_ancestoronly run throughevict_checkpoint(682, requires an eviction candidate:pins == 0for leaves),cancel_publication(648, requirespins == 0) —request_pins <= pins, so a node leavingnodesalways hasrequest_pins == 0and never contributes torequest_pinned_pages;retire_leaf/uncounttherefore need no adjustment.advance_completed(787) only flipsready, no pin or tail-page change.pinrejectsu64::MAXondirect_pinsand every chain node'spins(524-528);pin_requestcallspinfirst, sorequest_pinscannot overflow before the plain count does.unpin_requestrejects a release whendirect_request_pins == 0(566-568) before touchingrequest_pins, so the only way to underflowrequest_pinned_pageswould be an unpair error, and I found none.
SchedulerStats::request_pages (1216-1222) = sum of live slots' private_pages.len() + cache.request_pinned_pages. private_pages are drained into the checkpoint exactly when publish_boundary/retire publish them (2978, 3150-3152), and that checkpoint is pinned for the request at the same time, so the same page is not counted twice; reserved_pages are disjoint from private_pages (commit pops reserved into private, 2433-2438).
#3 [high] Should fix: new gauges leak into CopyoutResources equality and change copy-out retry cadence
helios/src/server/runtime.rs:1053-1059 defines CopyoutResources as { completed, scheduler: SchedulerStats, exports, next } deriving PartialEq, and 2441-2449 compares it every host-store pass:
let resources = CopyoutResources { completed: .., scheduler: self.scheduler.stats(), exports: .., next: .. };
let retry_copyouts = retry || progress || self.copyout_resources != Some(resources);
self.copyout_resources = Some(resources);
let deferred_copyouts = std::mem::take(&mut self.deferred_copyouts);
for id in &deferred_copyouts { ... if retry_copyouts { publications.push(publication) } else { self.deferred_copyouts.push(*id) } }
for publication in publications {
if !self.scheduler.export_fits(publication.id, next) {
if !deferred_copyouts.contains(&publication.id) {
self.metrics.copyout_headroom_deferrals.fetch_add(1, ..);
progress = true;
}
self.deferred_copyouts.push(publication.id); continue;
}
...pin_checkpoint + store.store(publication)...
}
Before this PR, SchedulerStats only carried values that change on admission, retirement, eviction, or fence progress, so copyout_resources != Some(resources) was a coarse "cache resources moved" signal. The two new gauges change on nearly every decode step: commit (helios/src/scheduler.rs:2433-2438) pops pages out of reserved_pages into private_pages for every scheduled lane, and refill_reservations (1383-1425) appends to reserved_pages again; retire/finish_early also move pages between them. So for any live request the struct now differs on essentially every step, retry_copyouts becomes true nearly always, and each deferred copy-out is re-offered to store.store on every step instead of only when cache resources actually moved. When it still does not fit, flare_host_cache_copyout_headroom_deferrals_total (metrics.rs ~?) is incremented again for each retry, and progress = true propagates.
Effect: an instrumentation-only change alters host-store copy-out retry cadence and inflates a documented counter (docs/prefix-cache-offload.md:1171 headroom). It also contradicts the PR's "No allocation, eviction, or scheduling decision changes" claim.
Fix: keep CopyoutResources sensitive only to cache-resource movement — either store the fields it needs explicitly (free/retiring/cached pages, snapshot backing, pending retirement) or exclude request_pages/reserved_pages from the comparison, e.g. a small ResourceKey struct built from SchedulerStats without the two new gauges.
Settled by: a runtime test that defers a copy-out for headroom, advances one decode step that changes only reserved_pages/private_pages, and asserts copyout_headroom_deferrals does not increase (would fail today, pass after the fix).
#4 [high] Research summary
I read all seven changed files in context (cache.rs, cache/lifecycle_tests.rs, cache/tests.rs, scheduler.rs, scheduler/tests.rs, server/metrics.rs, docs/api.md) plus the callers that matter (server/runtime.rs host-store loop and admission, scheduler/sharing.rs, scheduler/checkpoints.rs, scheduler/cache_memory.rs), and checked the change against AGENTS.md, docs/design-review.md and the charter.
The pin accounting itself holds up. Every request-owned pin now goes through pin_request/unpin_request, and LiveRequest::prefix == Some(id) implies exactly one direct_request_pins on id on every path I traced: admission with and without an inbound restore (including both early-error rollbacks), finish_inbound for created and joined tickets, publish_boundary for Created and Existing results, and retire for cancel, preemption and finish. The ticket-parent pin and the host-store copy-out/export pins correctly keep the plain API and are released with the plain API. The cache-side counter cannot drift or underflow: retire_leaf and compact_ancestor only run on nodes with pins == 0, advance_completed does not touch pins or pages, pin still guards overflow, and unpin_request rejects a release before decrementing.
One confirmed finding, recorded as "Should fix" in the scratchpad: the two new SchedulerStats fields silently widen CopyoutResources (helios/src/server/runtime.rs:1053-1059), whose PartialEq gates retry_copyouts at 2441-2449. request_pages/reserved_pages change on nearly every decode step (commit moves pages from reserved_pages to private_pages, refill_reservations grows them back), so deferred host-store copy-outs now re-offer to store.store every step rather than only when cache resources moved, and flare_host_cache_copyout_headroom_deferrals_total inflates. That contradicts the PR's "no allocation, eviction or scheduling decision changes" claim. Fix: keep the comparison key to cache-resource movement only.
I had also started checking the doc claim that dividing by flare_total_kv_pages "gives the KV share held by live requests" — request_pages sums private_pages per live slot plus deduplicated checkpoint tail pages, which is the intended pool measure, but pages held only by retired-but-unfenced slots (self.retired) are excluded, so a scrape taken while a cancelled request's pages are still draining under-reports; that is a documentation nit I did not finish verifying against the release path.
#8 [high] Research summary
Review — PR #549 (correctness lens), second pass on head 9cca87a
Verdict: no blocking or should-fix issues remain; only nits. The push since my last turn resolved both substantive findings, and I re-verified the pin accounting it touched.
Previous findings, now resolved (verified in the new code)
- The gauges no longer leak into the copy-out retry key.
helios/src/server/runtime.rs:2441-2454still embedsSchedulerStatswhole inCopyoutResources(declaredPartialEqat1053-1059, compared at2455), but the two new fields are now explicitly zeroed when the key is built (scheduler: SchedulerStats { request_pages: 0, reserved_pages: 0, ..self.scheduler.stats() }).SchedulerStatsis not compared anywhere else (runtime.rs:1056is the only use), so page-boundary movement incommit(scheduler.rs:2444) no longer re-offers deferred host copy-outs. The "no scheduling decision changes" claim now holds. retirereleases the request pin before emptying the slot.scheduler.rs:3149-3157now records the publication and callsunpin_request(prefix)beforeself.slots[..].request.take(); the old copy at3166-3170is gone. A failing release therefore leaves the request, its prefix and its pages intact and retryable instead of dropping the request value and leaking the pin. The reordering is behaviour-preserving:record_publication/unpin_requestreadself.request(handle)?, and nostatsread happens inside the window, so no scrape sees the transient state. Note the?onpublish_with_retentionat3124still returns early with the pin held, which is consistent (state unchanged, retry possible).- The
docs/api.mdratio/wording overstatement is fixed.docs/api.md:298-312now states that request-pinned checkpoints are also inflare_cached_kv_pages, that neither gauge counts pages draining through retirement or an in-flight restore ticket, that reserved pages sit outside the request gauge (sorequest + reservedis the vLLM-comparable figure), that values are last-published, and it cites theCache::statsdrift assertion (cache.rs:818-837) rather than the weak inequality. That matches the code:SchedulerStats::request_pages(scheduler.rs:1216-1222) sumsprivate_pagesonly over slots with a live request, andretire(scheduler.rs:3177-3191) moves the pages toself.retireduntiladvance_retirement(3033-3053).
Re-verified as correct in this pass
pin_prefix/unpin_prefixrefactor (scheduler.rs:2025-2040) preserves the pin kind at all three admission sites:request_pin = inbound.is_none()(1643) is true exactly when the pin belongs to the request itself; a ticket parent (inbound.is_some() && creating,1634-1642) keeps the plainpin/unpin, matchingfinish_inbound(1871,1889) andfail_ticket(1907). The refactor is a pure deduplication of the threeif inbound.is_none()blocks and cannot invert a kind.- Counter invariants unchanged:
pin_request/unpin_request(cache.rs:551-580) adjustrequest_pinned_pagesonly at 0↔1 transitions ofrequest_pins;retire_leaf(594) andcompact_ancestor(613) only run withpins == 0(guarded byeviction_candidates658-664andcancel_publication648-656), and compaction'sdebug_assert_eq!(node.request_pins, child.request_pins)(627) holds becauserequest_pinsis the subtree sum anddirect_pins == 0. - Metrics plumbing is unaffected by the push: the two gauges are stored unconditionally in the
Metrics::schedulerarray (metrics.rs:517-518), rendered as gauges next tocached_kv_pages(1309-1318), absent fromSnapshot::snapshot()(355-393), and neitherdashboard.rsnordocs/prefix-cache-offload.md:747(not opened) (which enumerates only host fields) needs a change.
Nits
docs/api.md:302-303— "The worker publishes both on every scheduler pass" overstates it:metrics.scheduler(...)is called only whenprogressis set (runtime.rs:1148-1153), plus once at startup (722) and once after a drained shutdown (745). A scrape in an idle loop reads the value of the last progressing pass, up to one loop later. "Publishes both on scheduler passes that make progress" would be exact.- Coverage: the new scheduler test (
scheduler/tests.rs:970-1035) drivesretire'sNonepublication path only. Nothing exercisespublish_boundary'sExisting { ready: true }re-pin (scheduler.rs:2994-3006), the one place a request moves from its own parent's request pin to a checkpoint another request already pinned. Thestatsdrift assertion would catch a cache-side error there, but no test reaches it — and that is exactly where a double count or a missing pin would hide. Cheap fix: assertstats.request_pagesbefore and after a second request's boundary publication onto an existing checkpoint. docs/api.mdfield table (332onward) gains no rows for the two gauges, so an operator reading only the table will not learn they exist; only the prose at298-312names them. Adding a row each with "none" in the Prometheus column, or a sentence saying they are text-only, would close it.- Process: the PR is still a draft and CI reports no checks on head
9cca87a; the live-scrape evidence is built on fork commit5ffe4d54that is not in this repository, so the measurements cannot be reproduced from this branch alone. Not a code defect. pin_prefix/unpin_prefixcarry the pin kind as a barebool; with only one call-site pair the risk is low, but an enum orRequestPinmarker would make an inverted argument a compile error if the API spreads.
#9 [high] Report of 2026-11-26, run 1358 (second pass on head 9cca87a)
Review — PR #549 "Report KV pages held by active requests" (correctness lens), head 9cca87a
Verdict: no blocking or should-fix issues remain; only nits. The push since the previous turn ("Keep page gauges out of the copy-out retry key", 9cca87ac) resolved both substantive findings; I re-verified the pin accounting it touched.
Previous findings, now resolved (verified in new code)
- Gauges no longer leak into the copy-out retry key.
helios/src/server/runtime.rs:2441-2454still embedsSchedulerStatswhole inCopyoutResources(PartialEqat1053-1059, compared at2455), but the two new fields are explicitly zeroed when the key is built (scheduler: SchedulerStats { request_pages: 0, reserved_pages: 0, ..self.scheduler.stats() }).runtime.rs:1056is the only placeSchedulerStatsis compared (grep ofSchedulerStatsshows uses only at scheduler.rs:113/666/762/1200, dashboard.rs:993, metrics.rs:50/476/1497/1574/1632/1701/1784, runtime.rs:1056/2446). So page-boundary movement incommit(scheduler.rs:2444) no longer re-offers deferred host copy-outs. "No scheduling decision changes" now holds. retirereleases the request pin before emptying the slot. scheduler.rs:3149-3157 records the publication and callsunpin_request(prefix)beforeself.slots[..].request.take()(3157); the old copy that ran after the take is gone. A failing release leaves the request, prefix and pages intact and retryable instead of dropping the request value and leaking the pin. Behaviour-preserving:record_publication/unpin_requestuseself.request(handle)?, and nostatsread happens inside the window, so no scrape sees the transient state. The?onpublish_with_retentionat 3124 still returns early with the pin held, which is consistent (state unchanged, retry possible).- docs/api.md ratio/wording overstatement fixed. docs/api.md:298-312 now states request-pinned checkpoints also appear in
flare_cached_kv_pages, that neither gauge counts pages draining through retirement or an in-flight restore ticket, that reserved pages are outside the request gauge sorequest + reservedis the vLLM-comparable figure, that values are last-published, and cites theCache::statsdrift assertion (cache.rs:818-837) instead of the weak inequality. Matches code:SchedulerStats::request_pages(scheduler.rs:1216-1222) sumsprivate_pagesonly over slots with a live request;retire(3177-3191) moves pages intoself.retireduntiladvance_retirement(3033-3053).
Re-verified correct in this pass
pin_prefix/unpin_prefixrefactor (scheduler.rs:2025-2040) preserves pin kind at all three admission sites:request_pin = inbound.is_none()(1643) is true exactly when the pin belongs to the request itself; a ticket parent (inbound.is_some() && creating, 1634-1642) keeps plainpin/unpin, matchingfinish_inbound(1871 plain unpin of ticket.parent, 1889 pin_request per waiter) andfail_ticket(1907). Pure deduplication of threeif inbound.is_none()blocks; cannot invert a kind.- Counter invariants unchanged:
pin_request/unpin_request(cache.rs:551-580) adjustrequest_pinned_pagesonly at 0↔1 transitions ofrequest_pins;retire_leaf(594) andcompact_ancestor(613) only run withpins == 0(guarded byeviction_candidates658-664 andcancel_publication648-656, wherenode.ready || node.pins != 0 || node.child_count != 0is rejected); compaction'sdebug_assert_eq!(node.request_pins, child.request_pins)(627) holds becauserequest_pinsis the subtree sum anddirect_pins == 0. Test-only full-scan assertion at cache.rs:818-837. - Metrics plumbing unaffected by the push: gauges stored unconditionally in
Metrics::scheduler's array (metrics.rs:517-518), rendered as gauges besidecached_kv_pages(1309-1318), absent fromSnapshot::snapshot()(355-393);dashboard.rs:993and docs/prefix-cache-offload.md:747 (host fields only) need no change. Test rows at metrics.rs:1784-1840 cover names and values.
Nits
- docs/api.md:302-303 — "publishes both on every scheduler pass" overstates:
metrics.scheduler(...)runs only whenprogress(runtime.rs:1148-1153), plus once at startup (722) and once after a drained shutdown (745). Suggest "on scheduler passes that make progress". - Coverage: scheduler/tests.rs:970-1035 drives
retire'sNonepublication path only. Nothing exercisespublish_boundary'sExisting { ready: true }re-pin (scheduler.rs:2994-3006) — the one place a request swaps its own parent's request pin for a checkpoint another request already pinned, where a double count or missing pin would hide. The stats drift assertion would catch a cache-side error there, but no test reaches it. Cheap fix: assertstats.request_pagesbefore and after a second request's boundary publication onto an existing checkpoint. - docs/api.md field table (from line 332) gains no rows for the two gauges, so a reader of only the table will not learn they exist; only prose 298-312 names them. Add a row each (Prometheus column "none") or say they are text-only.
- Process: still a draft; CI reports no checks on head 9cca87a; live-scrape evidence builds on fork commit 5ffe4d54 that is not in this repository, so measurements cannot be reproduced from this branch alone. Not a code defect.
pin_prefix/unpin_prefixcarry the pin kind as a barebool; with one call-site pair risk is low, but an enum/RequestPinmarker would make an inverted argument a compile error if the API spreads.
#11 [high] Report of 2026-11-28, run — PR #549 at head bca7358 — verdict clean
Review — PR #549 "Report KV pages held by active requests" (correctness lens), head bca7358
Verdict: clean. No blocking, no should-fix. The only push since my last turn (bca7358, "Fix KV-page docs ratio and fold duplicated page tests") refactors the pin bookkeeping and rewrites documentation/tests; I verified it changes no computed value.
The refactor in bca7358 is behaviour-preserving (verified line by line)
pin/unpin now delegate to pin_with/unpin_with (cache.rs:519-589), and pin_request/unpin_request call the same functions with request = true. Previously pin_request was pin + a second chain walk; now there is one walk that increments pins and request_pins together. I checked the ordering and error behaviour against the old bodies in the diff:
- All validation still happens before any mutation:
readycheck (520),direct_pins == u64::MAXor any chainpins == u64::MAX(524-528).direct_request_pins <= direct_pinsandrequest_pins <= pinsare invariants of the two entry points, so the request counters cannot overflow withoutpinsoverflowing first. unpin_withrejectsrequest && direct_request_pins == 0(547-549) before thedirect_pins == 0check (550-552), i.e. before any decrement, so a mismatched release leaves the cache untouched — same as the oldunpin_request.- The 0↔1 transitions of
request_pinsare the only placesrequest_pinned_pagesmoves (536-541, 561-567), unchanged from the previous head. - The one new assertion,
debug_assert!(node.request_pins > 0)(562), and compaction'sdebug_assert_eq!(node.request_pins, child.request_pins)(636) both hold from the subtree-sum definition ofrequest_pins(chainincludesid, cache.rs:312-321) plusdirect_pins == 0on the compacted node. Debug-only; no release-build behaviour. retire_leaf(603) andcompact_ancestor(622) are still reached only throughcancel_publication/eviction_candidates, which requirepins == 0on the leaf rule (659, 670), so a node withrequest_pins > 0never leavesnodesand the counter cannot be stranded.compact_ancestor's branch requiresdirect_pins == 0 && child_count == 1, and compaction leaves the pages in the heir, whoserequest_pinsis equal, so the counted total is unchanged (this is exactly what the extended test asserts at cache/tests.rs:357-360).
Test merge is coverage-neutral
request_pins_count_each_shared_page_once was folded into branching_pins_ancestors_and_prevents_direct_ancestor_unpin (cache/tests.rs:320-373). Every assertion from both tests survives: shared page counted once (334), plain pin/unpin for copy-out leaves the count unchanged (341-345), releasing the parent without a request pin errors (336), the count falls 3 → 2 on the first release (340), compaction into the pinned heir keeps it at 2 (358), and the last release reaches 0 (360). The scheduler fold (scheduler/tests.rs:970-1032) keeps the shared/private/reserved arithmetic against SchedulerStats and adds assert!(!shared_pages.is_empty()) plus the drain-to-zero check after both cancellations (1029-1031), so it is strictly stronger.
Docs ratio corrected
docs/api.md:298-310 now defines the comparable share as (flare_request_kv_pages + flare_reserved_kv_pages) / flare_total_kv_pages, says the request gauge is not disjoint from flare_cached_kv_pages, excludes retiring pages and a restore ticket's in-flight pages, and says the values are published when a pass makes progress plus at startup and after the shutdown drain. That matches the code: SchedulerStats::request_pages = Σ private_pages + cache.request_pinned_pages (scheduler.rs:1200-1220), reserved_pages = Σ reserved_pages, published only under if progress (runtime.rs:1148-1153), at 722 and after a drained shutdown at 745.
Nits (unchanged or newly relevant)
- docs/api.md:304-305 — "
flare_reserved_kv_pagescounts pages reserved for those requests' growth that are neither free, cached, nor written yet". A reserved page is not free (it was popped fromfree_pagesat admission, scheduler.rs:1714-1717), and it is not counted incached_pages(tail_pagescounts only checkpoint tails). But "not written yet" is imprecise at a boundary:commitpops reservations intoprivate_pagesbefore the GPU writes complete (2432-2444), so between commit and the completion fence the page is private (counted inrequest_kv_pages) and unwritten. Suggest "pages set aside for those requests that no request currently holds a page for". - docs/api.md field table (from line 330) still gains no rows for
flare_request_kv_pages/flare_reserved_kv_pages; only the prose names them. A reader of the table alone will not learn they exist. Add a row each with "none" in the Prometheus column, or state that they are text-only. - Coverage: the scheduler test drives
retire's no-publication path only.publish_boundary'sExisting { ready: true }re-pin (scheduler.rs:2987-2998), where a request swaps its own parent's request pin for a checkpoint another request already pinned, is still unexercised by a stats assertion. TheCache::statsdrift assertion (cache.rs:827-846) would catch a cache-side double count there, but nothing drives that path with a stats read. A test assertingstats.request_pagesacross a second request's boundary publication onto an existing ready checkpoint would settle it. pin_prefix/unpin_prefixcarry the pin kind as a barebool(scheduler.rs:2019-2033). With one call-site pair the risk is low; an enum or marker type would make an inverted argument a compile error if the API spreads.
Process
Still a draft with no CI checks on head bca7358, and the live-scrape evidence builds on fork commit 5ffe4d54, which is not in this repository, so the measurements cannot be reproduced from the branch alone. Not a code defect, but it blocks the evidence-based merge rule in the charter ("Bring real evidence").
#12 [high] Research summary
Reviewed PR #549 at head bca7358 through the correctness lens. Verdict: clean — no blocking, no should-fix findings; four nits.
The only new commit since my last turn (bca7358) folds pin_request/unpin_request into shared pin_with/unpin_with bodies (cache.rs:519-589), merges two duplicated test pairs, and rewrites the docs/api.md ratio paragraph. I verified the refactor is behaviour-preserving: validation still precedes every mutation (ready check, direct_pins/chain pins overflow guard 524-528, request-pin guard 547-549), request_pinned_pages still moves only at 0↔1 transitions of request_pins (536-541, 561-567), both new debug_asserts hold from the subtree-sum definition of request_pins, and retire_leaf/compact_ancestor remain gated on pins == 0, so a node with request pins can never leave nodes and strand the counter. The merged cache test keeps every assertion of the two it replaced (shared page counted once, plain copy-out pin inert, direct-ancestor release rejected, compaction keeping the count in the pinned heir, drain to zero), and the merged scheduler test is strictly stronger.
Docs now state (request + reserved) / total as the vLLM-comparable share and that the request gauge overlaps cached_kv_pages; both match the code (scheduler.rs:1200-1220, runtime.rs:1148-1153, 722, 745). Nits: the "not written yet" wording for reserved pages is imprecise across the commit→completion window; the docs field table still lacks rows for the two gauges; publish_boundary's Existing { ready: true } re-pin path has no stats assertion; and pin_prefix's bare bool pin kind is a latent footgun. Full findings are in scratchpad entry #11.
#13 [high] Re-verified at bca7358: pin symmetry, copy-out key, retire ordering, metrics plumbing
Confirmed at head bca7358 (the push touched only docs/api.md, cache.rs, cache/tests.rs, scheduler.rs, scheduler/tests.rs — runtime.rs and metrics.rs are unchanged, so the earlier fixes persist):
Every request-owned pin goes through the request API (current line numbers):
- admission when no inbound restore is in flight:
pin_prefix(id, request_pin)withrequest_pin = inbound.is_none()(scheduler.rs:1636-1638); both failure releases use the same flag (1649, 1671). - host ticket parent keeps the plain API:
creatingticket pinslookup.checkpointwithrequest_pin == false(1631-1638), released plain infinish_inbound(1864) andfail_ticket(1900). - ticket waiters:
pin_requestper waiter (1882). - boundary publication, Created:
pin_request(id)thenunpin_request(parent)(2970-2972). - boundary publication,
Existing { ready: true }in Snapshot/Finishing:pin_request(id)thenunpin_request(parent)(2990-2991). - retirement:
unpin_request(prefix)(3148) now runs beforeself.slots[..].request.take()(3150), withrecord_publicationstill guarded by!publish || error_code.is_some()(3144-3147). - host-store copy-out and export keep the plain API:
pin_checkpoint/unpin_checkpointarecache.pin/cache.unpin(2037-2043), used from runtime.rs:2360, 2364, 2396, 2480, 2496, 2705, 2710. So the new hard error "checkpoint has no request pin to release" (cache.rs:546-549) has no reachable caller.
Copy-out retry key (unchanged since 9cca87a): CopyoutResources { scheduler: SchedulerStats { request_pages: 0, reserved_pages: 0, ..self.scheduler.stats() }, .. } built in commit (runtime.rs:2440-2454) and compared at 2455; runtime.rs:1056 is the only SchedulerStats comparison in the tree. Page movement therefore cannot re-offer deferred copy-outs.
Gauge plumbing (unchanged): stored in Metrics::scheduler's array (metrics.rs:517-518), rendered as gauges beside cached_kv_pages (1309-1318), absent from Snapshot::snapshot() (355-393), covered by the text/value test rows at 1832-1833. docs/prefix-cache-offload.md:747 lists SchedulerStats host fields only, so no change is needed there.
Pin-symmetry invariant still holds: LiveRequest::prefix == Some(id) iff one direct_request_pins is held on id, across admission, ticket completion, both boundary outcomes, cancel, preemption (finish_early → retire), finish, and shutdown (release_after_shutdown → cancel for each live handle, 3067-3084).
#5 [medium] Nit candidate (unverified): request_pages excludes retired-but-unfenced slot pages
docs/api.md:298-305 (PR #549) says flare_request_kv_pages "counts the distinct KV pages that active requests reference" and that "Dividing flare_request_kv_pages by flare_total_kv_pages gives the KV share held by live requests".
SchedulerStats::request_pages (helios/src/scheduler.rs:1216-1222) sums private_pages.len() only over self.slots whose request is Some, plus cache.request_pinned_pages. RequestScheduler::retire (helios/src/scheduler.rs:3143-3183) takes the request out of the slot (self.slots[..].request.take()) and pushes its private_pages + reserved_pages into self.retired until advance_retirement reaches its fence (3027-3046). So between cancellation/completion and GPU drain those pages are neither free, cached, nor counted in request_pages/reserved_pages; a scrape in that window under-reports the "live share", and during shutdown drain (release_after_shutdown, 3068-3086) it drops to the cached-only level.
Also active_requests (1203-1207) has the same definition (slots with a live request), so at least the two gauges are consistent with each other; the exposure is only in the doc sentence promising a vLLM-comparable ratio, and in the issue #537 rationale. Settled by a scheduler test that cancels a request with pages in flight and asserts request_pages for that window, or by wording the doc as "pages held by requests still owning a slot".
Not verified: whether the resulting discrepancy is material at the documented poll interval, and whether flare_free_kv_pages also lags the same way (it does: retired pages return to free_pages only at the fence, 3037).
#6 [medium] Verified: metrics/dashboard/test wiring for the two new gauges
helios/src/server/metrics.rs:
request_pages/reserved_pagesatomics (265-266) are stored inMetrics::scheduler's store loop (517-518) and rendered as gauges (1310-1318) withmetric(.., "gauge", ..)inside the gauge block that ends at 1397; thetotal_kv_pages/kv_page_tokens/*_kv_tokensblock follows after it, so the text format stays valid. Noflare_request_kv_tokensequivalent — fine, consistent with the PR description.Metrics::snapshot(355-393) does not copy them into the JSONSnapshot, matching the description;Snapshothas no such fields sodocs/api.md's field table (325+) is untouched. That is consistent but the doc prose in the "Health and metrics" section now describes gauges absent from the JSON object — acceptable since it says "Beyond the JSON fields below, the text includes ...".SchedulerStatsderivesDefault, soSchedulerStats { ..Default::default() }literals at helios/src/server/metrics.rs:1497,1574,1701,1784 and helios/src/server/dashboard.rs:993 still compile; the two new fields default to 0. The dashboard test at dashboard.rs:1034 asserts "KV TOKENS 384 cached / 2560 free / 12800 total" and "!" contains("KV PAGES"), so the dashboard does not render the new gauges — no break there, but also no dashboard exposure.- Test-only drift assertion (cache.rs:819-837) now also compares
request_pinned_pagesagainst a fullnodesscan on everystats()call, so all cache/scheduler tests exercise the counter;Cache/tests.rs:318-341covers shared-page double counting and the wrong-API release error;scheduler/tests.rs:970-1035coversrequest_pages/reserved_pagesat two concurrent share-prefix requests and zero after cancel. The new test callsscheduler.cancel(first)thencancel(second)and asserts both gauges are 0 — becauserequest_pagesexcludes retired-but-unfenced slots (see the separate note), this assertion passes only if cancel returns pages synchronously enough in that fixture; worth knowing if the test is copied as a template. helios/src/cache/lifecycle_tests.rs:53-96forksPrefixCheckpointCacheby struct literal and was updated with the two new node fields andrequest_pinned_pages; that is the only place that must track new fields, so the fork stays in sync.
Gaps: no test drives pin_request through the shared-checkpoint Existing path in publish_boundary (2988-3000), i.e. the second request that reuses a just-published boundary checkpoint; and none covers the inbound-created ticket path's plain pin/unpin against the drift assertion, though the drift assertion in stats() would catch a mismatch in any test that exercises it. PR is still a draft with no CI checks recorded.