#1 [high] Should fix: scheduler test duplicates an existing test's entire 40-line scenario (~55 lines)
helios/src/scheduler/tests.rs:970-1034 (request_kv_pages_count_shared_prefix_pages_once, +66 lines) reproduces, step for step, the scenario already in helios/src/scheduler/tests.rs:1036-1081 (branching_requests_own_distinct_tail_pages_and_terminal_snapshots). Both: scheduler(2, 8, 5); admit spec(64,1); init(1); plan/commit Fence(2); complete records(seed,2,64,1,77,2); freeze(seed,3); finish(seed); two admit(spec(65,4)); init(4); plan/commit Fence(5); complete records(first,5,65,1,88,1); retain_prompt(6); assert next plan is Prefill on second; commit Fence(7); complete records(second,7,65,1,90,1). The existing test already asserts the two requests share shared_pages and differ in private_pages.
Smaller version: delete request_kv_pages_count_shared_prefix_pages_once and append its four assertions to the existing test:
let stats = scheduler.stats();
assert_eq!(stats.request_pages, shared + first.private_pages.len() + second.private_pages.len());
assert_eq!(stats.reserved_pages, first.reserved_pages.len() + second.reserved_pages.len());
scheduler.cancel(first).unwrap();
scheduler.cancel(second).unwrap();
let stats = scheduler.stats();
assert_eq!((stats.request_pages, stats.reserved_pages), (0, 0));
assert!(stats.cached_pages > 0);
Saves ~55 of the 66 added lines, loses nothing: the same shared/private/reserved quantities and the same cancel-drains-to-zero path are checked, and the shared prefix, private pages and zero-pin retirement are still covered.
#2 [high] Should fix: second gauge flare_reserved_kv_pages is outside the issue's request (~20-25 lines)
Issue #537 (body read in full) asks for one of: (1) flare_request_kv_pages, or (2) split flare_cached_kv_pages into pinned/idle, plus optionally a ready-made ratio. It never mentions the pages reserved for active requests' growth. The PR adds that as a second, independent gauge: SchedulerStats::reserved_pages (helios/src/scheduler.rs:132-133), its computation in stats() (scheduler.rs:1223-1228, 6 lines), Metrics::reserved_pages (helios/src/server/metrics.rs:266), the store row (metrics.rs:518), the gauge entry with help text (metrics.rs:1314-1318), the test fixture value (metrics.rs:1791) and assertion row (metrics.rs:1836), and docs/api.md:301-302 plus the "reserved_kv_pages" name in the PR description and evidence section. Chromium checks: reserved_pages (the Vec<PageId> on LiveRequest) already exists and is used by scheduling; only the reported gauge is new, and no caller/consumer besides the Prometheus text uses it — it is not in the JSON Snapshot (metrics.rs:99-110 has no such field, and docs/api.md:325+ table lists only cached_pages, free_pages, total_pages), so no dashboard, view or Snapshot function reads it.
Smaller version: delete the reserved_pages stats field, its six-line sum in stats(), the metrics atomic + store row + gauge triple, the two test lines, and docs/api.md:301-302 ("flare_reserved_kv_pages counts pages reserved ... written yet." and drop the reserved mention from the last sentence). Saves ~20-25 lines. Nothing #537 asks for is lost; flare_request_kv_pages alone gives the vLLM-semantics ratio the issue wants. If a maintainer does want reservation visibility, it belongs in its own change with its own justification, per the charter's "stay focused / smallest footprint" rule.
#6 [high] Total: 218 added lines, ~95-105 removable; the rest is minimal
Total added/removed from the diff (7 files, +218/-10): 218 added, 10 removed, of which the removable/consolidatable estimate is ~95-105 lines:
- scheduler test duplication: ~55 of 66
- reserved-page gauge (whole second feature): ~22-25 (stats field 2, stats() sum 6, metrics atomic 1, store row 1, gauge triple 5, test value+row 2, docs 4, plus the blank lines)
- direct_request_pins + guard: ~12-14
- cache test fixture duplication: ~10
Everything else is minimal and should stay:
Checkpoint::request_pins(one field),PrefixCheckpointCache::request_pinned_pages(one field + two-line update in each of pin/unpin_request), the compactiondebug_assert_eq!on request pins (2 lines — it is the invariant that lets compaction move pages into an heir without touching the counter), the extendedstatsdrift assertion (5 lines, test-only, catches every miscount in the whole suite),CacheStats::request_pinned_pages(3 lines), therequest_pagessum instats()(7 lines, the actual requested number), the metrics atomic/store/gauge forflare_request_kv_pages(7 lines), and docs/api.md:298-300 + 303-305 (5 lines, the definition the issue's dashboards need).
Also verified: no code the change supersedes or leaves dead. Cache::pin/unpin keep real callers (host-store ticket pins scheduler.rs:1647/1662/1688/1882/1918, pin_checkpoint/unpin_checkpoint runtime.rs:2360-2489), and no existing helper computes the same number (has_pins cache.rs:291 only answers "any direct pin", and SchedulerStats had no page-held field). No branch or dead path is left behind in admit_planned other than the inbound.is_none() pairs itself.
#8 [high] Research summary
Reviewed PR #549 (Report KV pages held by active requests) through the subtraction lens. All seven changed files and the code they touch (Cache::pin/unpin, chain, compact_ancestor, SchedulerStats::stats, admit_planned, finish_inbound, publish_boundary, retire, the metrics gauge table and the test fixtures) were read in place; findings are in the scratchpad.
Four confirmed subtractions, ~95-105 of the 218 added lines:
- Should fix (~55 lines):
helios/src/scheduler/tests.rs:970-1034re-runs, line for line, the scenario already inbranching_requests_own_distinct_tail_pages_and_terminal_snapshots(tests.rs:1036-1081). Its four assertions fold into that test. - Should fix (~22-25 lines):
flare_reserved_kv_pagesis a second feature; issue #537 asks only for the pages active requests hold, and nothing but the Prometheus text reads this value (it is not in the JSON snapshot). It can go with its stats field, metric slot, help text, test rows and docs sentence. - Nit (~12-14 lines):
Checkpoint::direct_request_pinsexists only for the "no request pin to release" guard, whichunpinalready enforces at the same call sites; the scheduler never releases a pin it did not take throughpin_request. - Nit (~10 lines):
helios/src/cache/tests.rs:322-328repeats the fixture of the test directly below it verbatim.
The rest is minimal and should stay: the two counter fields, the compaction debug_assert, the extended test-only drift assertion, and the request_pages sum are the smallest version of the requested number. Nothing the change supersedes is left dead. One candidate (the three pin/unpin branch pairs in admit_planned) was checked and rejected as load-bearing.
#9 [high] Charter citations and verification checklist for the report
Charter (read_charter, NVIDIA/hyperflare-inference) lines to cite:
- "How We Work / Solve the right problem in the right place ... Look for the smallest footprint in shared code, or a way to solve it without new code at all."
- "Stay focused ... We're not interested in piling on extra ... switches."
- "What gets merged: PRs that address a maintainer request, a roadmap item..." (line 35) — #537 is the maintainer-request target; it asks for pages held by active requests, not reservations.
- "Don't trade clarity for brevity" is my own review rule, which is why the admit_planned branch pairs (scratchpad entry 7) are not a finding.
Verification performed (so the report can say "checked", not "looks like"):
- Issue #537 read in full (read_item 537): its proposal lists
flare_request_kv_pages, a pinned/idle split offlare_cached_kv_pages, and an optional ratio gauge. No mention of reserved pages. - Callers of
unpin_requesttraced: scheduler.rs 1660, 1686 (paired with the pin at 1645), 2973 (paired at 2971), 2992 (paired at 2991), 3159 (paired with the request's own prefix, set at 1902/2979/2996). No unpaired release, so thedirect_request_pinsguard cannot fire andunpin(cache.rs:536-540) already errors on an empty release. Cache::pin/unpinretention checked: ticket pins (scheduler.rs 1882, 1918, 1647/1662/1688) andpin_checkpoint/unpin_checkpoint(server/runtime.rs 2360, 2364, 2396, 2473, 2489, 2698, 2703) still need the plain API, so neither becomes dead.reserved_pagesgauge consumers searched: only metrics.rs 266/518/1317; absent from the JSONSnapshot(metrics.rs ~99-110) and from docs/api.md's field table (325+), so no dashboard or view function reads it.- Duplicate test scenario diffed line by line: scheduler/tests.rs 970-1034 vs 1036-1081 share every admission, fence, completion record and plan assertion (seed 64/1, records 77, 88, 90, retain_prompt(6)).
- Cache test fixture: cache/tests.rs 322-328 vs 344-352 are character-identical.
statscost: the drift assertion is#[cfg(test)]only (cache.rs:817-837), so the counter is maintained for the gauge, not for the assertion.
Report ranking (by lines saved): 1) scheduler test duplication ~55; 2) reserved gauge ~22-25; 3) direct_request_pins ~12-14; 4) cache test fixture ~10. Then the "already minimal" list and the rejected candidate. Total: pr_diff counted +218/-10 across 7 files; ~95-105 removable (~45% of what was added).
#11 [high] Should fix: scheduler test duplicates an existing 40-line scenario (~55 lines saved)
Verified at head 9cca87ac (tests.rs unchanged since first review).
helios/src/scheduler/tests.rs:970-1034 request_kv_pages_count_shared_prefix_pages_once (66 added lines) is line-for-line the same scenario as branching_requests_own_distinct_tail_pages_and_terminal_snapshots (helios/src/scheduler/tests.rs:1036-1081), which sits immediately below:
- both: scheduler(2,8,5) → admit(spec(64,1)) → init(1) → plan/commit Fence(2) → complete(records(seed,2,64,1,77,2)) → freeze(seed,3) → finish(seed)
- both: admit(spec(65,4)) ×2 → init(4) → plan/commit Fence(5) → complete(records(first,5,65,1,88,1)) → retain_prompt(6) → assert prefill lane is
second→ commit Fence(7) → complete(records(second,7,65,1,90,1)) - the existing test already asserts shared pages equal, private pages differ, no terminal snapshots (tests.rs:1078-1080).
Only new content: the 5-tuple capture (tests.rs:1010-1022), 2 stats assertions (1024-1025), cancel both, 2 more assertions (1032-1033).
Smaller version: append to the existing test after tests.rs:1080, using LiveRequest::handle (pub, see runtime.rs:1164 handle: live.handle) because first/second are shadowed as &LiveRequest at 1076-1077:
// keep the existing asserts. `first`/`second` here are &LiveRequest.
assert!(!first.shared_pages.is_empty());
let (first, second) = (first.handle, second.handle); // or capture before shadowing
let stats = scheduler.stats();
assert_eq!(stats.request_pages,
shared + first_private + second_private);
assert_eq!(stats.reserved_pages, first_reserved + second_reserved);
scheduler.cancel(first).unwrap();
scheduler.cancel(second).unwrap();
let stats = scheduler.stats();
assert_eq!((stats.request_pages, stats.reserved_pages), (0, 0));
assert!(stats.cached_pages > 0);
(practically: reuse the capture block from tests.rs:1010-1022 verbatim, then the 6 assertion lines).
Saves ~55 of the 66 added lines. Nothing lost: same shared/private/reserved quantities, same shared-page-counted-once behaviour, same retire-drains-to-zero path, asserted on a fixture the suite already runs. Keep the !shared_pages.is_empty() assertion (1 line) so the count assertion is meaningful.
#12 [high] Should fix (scope): flare_reserved_kv_pages is outside issue #537 (~20-23 lines saved)
Verified at head 9cca87ac.
Issue #537 (read in full) proposes: (1) flare_request_kv_pages = private + shared/pinned prefix pages, each once, so request/total matches vLLM; or (2) split flare_cached_kv_pages into pinned/idle; plus optionally a ready-made ratio gauge. It never asks for pages reserved for growth. The PR introduces that as an independent goal ("pages reserved for active requests' growth are invisible: they are neither free, cached, nor written") — defensible for vLLM comparability (vLLM's used = total − free, which includes reserved blocks), but a separate change per the charter's "stay focused / smallest footprint".
Consumers: only helios/src/server/metrics.rs reads it (266 slot, 518 store, 1314-1318 gauge, 1791 fixture value, 1836 assertion row). Not in the JSON Snapshot (metrics.rs snapshot fields unchanged; docs/api.md:352 table lists only cached/free/total pages), so no dashboard/view/API reads it. LiveRequest::reserved_pages (scheduler.rs:255) already exists for scheduling; only the reported aggregate is new.
Delete:
- helios/src/scheduler.rs:132-133 (doc + field) 2
- helios/src/scheduler.rs:1223-1228 (six-line sum) 6
- helios/src/server/metrics.rs:266 1
- helios/src/server/metrics.rs:518 1
- helios/src/server/metrics.rs:1314-1318 5
- helios/src/server/metrics.rs:1791 1
- helios/src/server/metrics.rs:1836 1
- helios/src/server/runtime.rs:2448 (
reserved_pages: 0in the copy-out key) 1 - docs/api.md:301-302 + drop the reserved wording at 307-309 ~3 Total ~20-23 lines.
Nothing #537 asks for is lost: flare_request_kv_pages alone gives the vLLM-semantics ratio the issue names. If a maintainer wants reservation visibility, land it separately.
#16 [high] Total at 9cca87ac: 246 added lines, ~104-107 removable; rest minimal
Verified at head 9cca87ac. Sizes: docs/api.md +16, cache.rs +60/-1, cache/lifecycle_tests.rs +3, cache/tests.rs +24, scheduler.rs +51/-14, scheduler/tests.rs +66, server/metrics.rs +18, server/runtime.rs +8/-1 → +246/-16 (8 files), up from +218/-10 after push 9cca87ac.
Removable, ranked by lines:
- scheduler/tests.rs:970-1034 duplicate scenario — ~55.
- reserved gauge (scheduler.rs 132-133, 1223-1228; metrics.rs 266, 518, 1314-1318, 1791, 1831-1836; runtime.rs 2448; docs) — ~20-23.
- docs/api.md:302-312 internal prose — ~10.
- direct_request_pins + guard (cache.rs 82-83, 461, 553, 566-568, 570; lifecycle_tests.rs 77; cache/tests.rs 335) — ~10.
- cache/tests.rs:320-342 duplicate fixture — ~9. Total ~104-107 of 246 added lines (≈43%).
Considered and rejected:
- runtime.rs:2441-2450 copy-out key zeroing (+8/-1): it fixes a real behaviour leak (SchedulerStats is embedded whole in CopyoutResources, runtime.rs:1053-1059, compared at 2455) and the earlier review demanded it. It shrinks to ~4 lines once reserved_pages goes. Keep.
- Folding pin/pin_request and unpin/unpin_request into one
pin_with(id, request)body: saves ~10 lines net (two chain walks collapse) but adds a bool to a public API with ~15 plain-pin call sites or needs 4 wrapper lines; earlier review suggested it, but it trades call-site clarity for ~10 lines and is a rewrite, not a removal. Mention only as optional. - The three pin/unpin branch pairs in admit_planned: now already collapsed into
pin_prefix/unpin_prefixhelpers (scheduler.rs:2025-2040, +16 lines) — net neutral vs. the inline pairs; the ticket-parent branch is load-bearing (ancestor must be pinned before ensure_resources at 1675). Not a finding. - Cache::pin/unpin keep real callers (pin_checkpoint/unpin_checkpoint runtime.rs:2360-2489, ticket parent 1871/1907, tests), so no dead path is left behind. Minimal and load-bearing: Checkpoint::request_pins, PrefixCheckpointCache::request_pinned_pages + the two-line brackets, compaction debug_assert (cache.rs:626-627), the cfg(test) drift assertion (cache.rs:817-837), CacheStats::request_pinned_pages, the request_pages sum (scheduler.rs:1216-1222), the flare_request_kv_pages atomic/store/gauge triple and its two table rows.
#17 [high] Report of 2026-11-27, run after push 9cca87ac
Subtraction review — PR #549, "Report KV pages held by active requests" (head 9cca87ac)
Key findings
Of +246/−16 across 8 files, about 104–107 lines (≈43%) can go with no behaviour #537 asks for lost.
| # | Severity | Where | Lines saved |
|---|---|---|---|
| 1 | Should fix | scheduler/tests.rs:970–1034 repeats an existing test's whole scenario | ~55 |
| 2 | Should fix (scope) | flare_reserved_kv_pages — a second gauge #537 never asked for | ~20–23 |
| 3 | Should fix | docs/api.md:302–312: internal-detail prose around a 4-line definition | ~10 |
| 4 | Nit | cache.rs:82–83 direct_request_pins + guard duplicate unpin's own check |
~10 |
| 5 | Nit | cache/tests.rs:322–328 fixture copied verbatim from the test below | ~9 |
Rules cited (charter, read in full): "Look for the smallest footprint in shared code, or a way to solve it without new code at all"; "Stay focused… not interested in piling on extra … switches"; "What gets merged: PRs that address a maintainer request…" — #537 (read in full) is the maintainer request and bounds the scope: it names flare_request_kv_pages (or a pinned/idle split of flare_cached_kv_pages) and an optional ratio; reserved pages are not in it.
1. Should fix — scheduler test re-runs an existing test (~55 lines)
helios/src/scheduler/tests.rs:970–1034 request_kv_pages_count_shared_prefix_pages_once (+66) is line-for-line the scenario of branching_requests_own_distinct_tail_pages_and_terminal_snapshots right below it (tests.rs:1036–1081): same scheduler(2,8,5), same seed admit/init/Fence(2)/complete/freeze/finish, same two spec(65,4) admits, Fence(5) complete, retain_prompt(6), Prefill lane assertion, Fence(7) complete. The existing test already asserts the shared pages are equal and the private pages differ (1078–1079).
New content is only: the 5-tuple capture (1010–1022), two stats assertions (1024–1025), cancel both, two assertions (1032–1033).
Smaller version: move that capture and the six assertion lines into the existing test after 1080 (note first/second are shadowed as &LiveRequest at 1076–1077; LiveRequest::handle is pub, scheduler.rs:226). Saves ~55 of 66. Nothing lost: same shared/private/reserved quantities, same shared-page-counted-once behaviour, same retire-to-zero path, on a fixture the suite already pays for. Keep assert!(!shared_pages.is_empty()).
2. Should fix — flare_reserved_kv_pages is a second feature (~20–23 lines)
Issue #537 asks for exactly one of two things and no reservations. The PR adds the reserved gauge as an independent goal. Its only reader is the Prometheus text: scheduler.rs:132–133, 1223–1228, metrics.rs:266, 518, 1314–1318, 1791, 1836, runtime.rs:2448, docs/api.md:301–302, 307–309; nothing in the JSON Snapshot/dashboard reads it (docs/api.md:352 lists only cached/free/total pages). LiveRequest::reserved_pages (scheduler.rs:255) already exists for scheduling; only the aggregate is new.
Smaller version: delete those fields/lines and flare_request_kv_pages alone gives the vLLM ratio #537 names. If reservation visibility is wanted, it belongs in its own change (charter: stay focused).
3. Should fix — docs paragraph is mostly internals (~10 lines)
docs/api.md:298–312 spends 15 lines on two gauges. 302–303 (worker publishes, scrape reads atomics), 306–307 (pages draining through retirement / in-flight restore) and 310–312 (a #[cfg(test)] assertion in Cache::stats, cache.rs:817–837) are implementation detail no other gauge in this file carries. Keep the definition and the ratio:
`flare_request_kv_pages` counts the distinct KV pages that active requests
reference: their private pages plus the tail pages of the prefix checkpoints they
pin, each page counted once. Those pinned pages also appear in
`flare_cached_kv_pages`; dividing the gauge by `flare_total_kv_pages` excludes
idle cached prefixes and snapshot backing pages.
Saves ~10 (fewer with finding 2). Nothing a dashboard author needs is lost.
4. Nit — direct_request_pins exists only for its own guard (~10 lines)
cache.rs:82–83 (doc+field), 461 (init), 553 (+= 1), 566–568 (guard), 570 (-= 1), lifecycle_tests.rs:77 (fixture copy), cache/tests.rs:335 (the test that constructs the error). Every unpin_request caller releases the id it request-pinned (scheduler.rs 1645↔1656/1678/3155, 1889↔3155, 2977↔2979, 2997↔2998), and unpin already errors on a release with no direct pin (cache.rs:536–540). Smaller unpin_request = self.unpin(id)?; then the same chain loop. Caveat: this drops a defensive cache-side check no type enforces; a maintainer may keep the guard, but note the field and the check stand or fall together (a chain-level request_pins check cannot reproduce the unpin_request(parent) error at cache/tests.rs:335).
5. Nit — cache test fixture copied verbatim (~9 lines)
cache/tests.rs:322–328 is character-identical to 346–352. Because pin_request calls pin first (cache.rs:552), the existing branching_pins_ancestors_and_prevents_direct_ancestor_unpin can take its pins through pin_request and pick up request_pinned_pages assertions at 356/360/373 without breaking its pin_count() checks. Delete the new test (320–342), keep the 5 assertion lines inline. Saves ~9.
Already minimal — do not cut
Checkpoint::request_pins; PrefixCheckpointCache::request_pinned_pages with its two-line bracket in each of pin/unpin_request (this is what keeps Cache::stats from scanning nodes, the reason the approach was chosen); the compaction debug_assert_eq!(node.request_pins, child.request_pins) (cache.rs:626–627); the #[cfg(test)] drift assertion (817–837, best value per line in the change); CacheStats::request_pinned_pages; the request_pages sum (scheduler.rs:1216–1222); the flare_request_kv_pages atomic/store/gauge and its two table rows (metrics.rs:265, 517, 1309–1313, 1790, 1835).
Left behind / rejected
- Nothing the change supersedes is left dead:
Cache::pin/unpinkeep real callers (pin_checkpoint/unpin_checkpointruntime.rs:2360–2489, ticket parent 1871/1907, many tests). runtime.rs:2441–2450zeroing request/reserved pages out ofCopyoutResources(+8/−1): needed —SchedulerStatsis embedded whole in the key (1053–1059) and compared at 2455 — and it shrinks to ~4 lines once finding 2 lands. Keep.pin_prefix/unpin_prefix(scheduler.rs:2025–2040) replaced three inlineif inbound.is_none()pairs; line-neutral. The ticket-parent branch is load-bearing (the ancestor must be pinned beforeensure_resourcesevicts, 1675).- Optional, not counted: folding
pin_request/unpin_requestbodies into onepin_with(id, request)would remove onechainwalk per call (~10 lines) but pushes a bool through a public API with ~15 plain-pin call sites. Rewrite, not removal.
Verification
Read every changed file in place at head 9cca87ac plus callers; issue #537 and the charter read in full; diff line counts from pr_diff/pr_files. The suite was not run here (no checks on the head commit); this is a static subtraction review.
Total: ~104–107 of 246 added lines removable in 5 places (≈43%). Verdict: make it smaller first — finding 1 alone removes a fifth of the diff and finding 2 is a feature the issue did not request.
#18 [high] Research summary
Reviewed PR #549 at head 9cca87ac through the subtraction lens: all 8 changed files read in place with their callers, plus issue #537 and the charter. Verdict: make it smaller first — of +246/−16 lines, about 104–107 (≈43%) can go without losing anything #537 asks for.
Ranked: (1) ~55 lines — helios/src/scheduler/tests.rs:970–1034 re-runs the whole scenario of branching_requests_own_distinct_tail_pages_and_terminal_snapshots (1036–1081) and only adds six assertions; fold them in. (2) ~20–23 — flare_reserved_kv_pages is a second gauge issue #537 never asks for and only the Prometheus text reads; drop it, its stats field, runtime-key line and docs sentence. (3) ~10 — docs/api.md:298–312 is 15 lines of prose whose last ten are internals (publication cadence, transient retirement states, and a #[cfg(test)] assertion in Cache::stats). (4) ~10 — Checkpoint::direct_request_pins (cache.rs:82–83, 461, 553, 566–568, 570) exists solely for a guard every scheduler call site already respects, and unpin already errors on an empty release. (5) ~9 — helios/src/cache/tests.rs:322–328 copies the fixture below it verbatim; fold the assertions into branching_pins_ancestors_and_prevents_direct_ancestor_unpin.
Nothing the change supersedes is left dead (Cache::pin/unpin keep their checkpoint-copy and ticket-parent callers). The runtime.rs copy-out-key zeroing the last push added is necessary and shrinks to ~4 lines once the reserved gauge goes. The rest — request_pins, request_pinned_pages, the compaction assert, the drift assertion, the request_pages sum and the flare_request_kv_pages triple — is already the smallest form of what the issue asked.
Full report is scratchpad entry #17.
#3 [medium] Nit/Should fix: direct_request_pins and its guard duplicate unpin's own check (~12 lines)
Checkpoint::direct_request_pins (helios/src/cache.rs:82-83, initialised cache.rs:460, incremented cache.rs:553, decremented cache.rs:570) exists only for the guard at cache.rs:566-568: if self.checkpoint(id)?.direct_request_pins == 0 { return Err("checkpoint has no request pin to release") }. The scheduler, the only caller of unpin_request, releases exactly the id it pinned: admission rollback (scheduler.rs:1660, 1686 pairs with 1645), boundary republishing (2972-2973, 2992), ticket waiters (1900 with the release at 3159 on the request's own prefix), and retirement (3159). No path releases a checkpoint it did not pin through pin_request, so the guard cannot fire; unpin (cache.rs:536-540) already rejects a release with no direct pin, which catches the same misuse. The check is also unreachable from the new test's positive side, which pins parent through pin_request in order to exercise the error branch (helios/src/cache/tests.rs:335) — the error path has to be constructed.
Smaller version: delete direct_request_pins and its four touch points (field + doc comment 3 lines, init 1, += 1 1, -= 1 1) and the four-line guard, and delete the two lines in the Fixture::fork copy at helios/src/cache/lifecycle_tests.rs:77-78 plus the assert!(cache.unpin_request(parent).is_err()) and its setup at helios/src/cache/tests.rs:335. unpin_request becomes:
pub fn unpin_request(&mut self, id: CheckpointId) -> Result<()> {
self.unpin(id)?;
let chain = self.chain(id)?;
for ancestor in chain {
let node = self.nodes.get_mut(&ancestor).unwrap();
node.request_pins -= 1;
if node.request_pins == 0 { self.request_pinned_pages -= node.tail_pages.len(); }
}
Ok(())
}
Saves ~12-14 lines; the counter still counts tail pages of checkpoints with request_pins > 0, which is exactly what CacheStats::request_pinned_pages documents (cache.rs:188-189) and what the stats drift assertion checks (cache.rs:830-834).
#5 [medium] Nit: cache test repeats branching_pins test's fixture verbatim (~10 lines)
helios/src/cache/tests.rs:320-342 (request_pins_count_each_shared_page_once) opens with the same eight-line fixture as the test directly below it, branching_pins_ancestors_and_prevents_direct_ancestor_unpin (cache/tests.rs:344-352): let mut cache = cache(); let left = history(2, 0); let mut right = history(1, 0); right.append(&[999; 64], &[]).unwrap(); let parent = created(... proposal(None, 64, &[0], 0, 0)); let left_id = ...; let right_id = ... — character for character the same. The existing test already pins both children, asserts the shared parent's pin_count() is 2→1, compacts it, and checks page_chain stays [PageId(0), PageId(2)].
Smaller version: drop the duplicate preamble (cache/tests.rs:322-328) by moving the request-pin assertions into the existing test after its pin(left_id)/pin(right_id) pair, and keep only the four request-pin lines (pin_request ×2, the 3/2/0 counts and the plain-pin-leaves-it-unchanged line). Saves ~9-12 lines. The distinct behaviour still proven: the shared ancestor's page counts once for two request pins, plain pins do not move the count, and the count returns to zero. (The unpin_request(parent).is_err() line goes with the direct_request_pins finding.)
#13 [medium] Nit: direct_request_pins and its guard duplicate unpin's own check (~10 lines)
Verified at head 9cca87ac (unchanged by the last push).
Checkpoint::direct_request_pins (helios/src/cache.rs:82-83 doc+field, init cache.rs:461, += 1 cache.rs:553, guard cache.rs:566-568, -= 1 cache.rs:570) has exactly one reader: the unpin_request guard.
if self.checkpoint(id)?.direct_request_pins == 0 {
return Err("checkpoint has no request pin to release".into());
}
All callers of unpin_request are in scheduler.rs and release exactly the checkpoint they pinned as a request pin: admission pin (1645 pin_prefix with request_pin = inbound.is_none()) ↔ rollbacks (1656, 1678) and retirement (3155 unpins request.prefix, set by 1645/1889/2977/2997); boundary publications 2977→2979 and 2997→2998; ticket waiters 1889 ↔ retirement 3155. So the guard cannot fire in production. A mispair would already be caught by unpin's own direct_pins == 0 check (cache.rs:536-540), and request_pins -= 1 would panic in a debug build.
Removable: 2 (doc+field) + 1 (init) + 1 (+= 1) + 3 (guard) + 1 (-= 1) + 1 (lifecycle_tests.rs:77 fixture copy) + 1 (cache/tests.rs:335 assert!(cache.unpin_request(parent).is_err())) = 10 lines.
Smaller unpin_request:
pub fn unpin_request(&mut self, id: CheckpointId) -> Result<()> {
self.unpin(id)?;
for ancestor in self.chain(id)? {
let node = self.nodes.get_mut(&ancestor).unwrap();
node.request_pins -= 1;
if node.request_pins == 0 {
self.request_pinned_pages -= node.tail_pages.len();
}
}
Ok(())
}
The counter still counts tail pages of checkpoints with request_pins > 0 — exactly what CacheStats::request_pinned_pages documents (cache.rs:188-189) and the stats drift assertion checks (cache.rs:824, 830-834).
Caveat to state: this trades a defensive cache-side check for relying on the scheduler's pin/release pairing, which no type enforces. A maintainer may keep the guard; the field is still removable (a chain-level guard on request_pins exists, but it cannot distinguish direct from inherited pins — the test's unpin_request(parent) case at cache/tests.rs:335 relies on precisely that distinction, so the check and the field stand or fall together).
#14 [medium] Nit: cache test repeats the branching_pins fixture verbatim (~9 lines)
Verified at head 9cca87ac.
helios/src/cache/tests.rs:320-342 request_pins_count_each_shared_page_once opens with 7 lines (322-328) character-identical to branching_pins_ancestors_and_prevents_direct_ancestor_unpin (cache/tests.rs:346-352): cache(), history(2,0), history(1,0) + append, and the three created(...) calls over pages 0/1/2 with the same parents. The existing test then pins both children (355-356), asserts parent.pin_count() 2→1 (357, 361), compacts it (362-372) and asserts the heir's page chain.
Key: pin_request calls pin first (cache.rs:552), so switching the existing test's pin(left_id)/pin(right_id) to pin_request keeps every pin_count() assertion true and adds the request-pin coverage.
Smaller version: inside branching_pins_ancestors_and_prevents_direct_ancestor_unpin, after 356, insert:
assert_eq!(cache.stats().request_pinned_pages, 3); // shared page once for two request pins
cache.pin(right_id).unwrap();
assert_eq!(cache.stats().request_pinned_pages, 3); // plain pins do not move it
cache.unpin(right_id).unwrap();
assert_eq!(cache.stats().request_pinned_pages, 2);
and after 360 insert assert_eq!(cache.stats().request_pinned_pages, 2);, after 373 assert_eq!(cache.stats().request_pinned_pages, 0);. Delete the whole new test (320-342).
Saves ~9 lines (2 header + 7 fixture). All four behaviours survive: shared ancestor page counted once for two request pins, plain pin leaves it unchanged, count falls to 2 and then 0. (The unpin_request(parent) == Err line goes with finding 3.)
Note: no other test in the suite calls pin_request, so keep the assertions somewhere — folding, not deleting, is the saving.
#15 [medium] Should fix: docs paragraph carries internals and a test reference (~10 lines)
Verified at head 9cca87ac. docs/api.md:298-312 is 15 lines of prose for two gauges; 302-303 and 306-312 restate internals rather than user-facing behaviour:
- 302-303 ("The worker publishes both on every scheduler pass and a scrape reads the last published values") — implementation detail; the file never explains publication cadence for any other gauge (cf. the table at 332-362, one line per metric).
- 306-307 ("Neither gauge counts pages still draining through retirement or an admission ticket's in-flight restore") — about a transient internal state nobody can act on.
- 310-312 ("and the test-only assertion in
Cache::statscompares the maintained request-pinned count with a full scan of every checkpoint on each read") — an in-repo#[cfg(test)]assertion (cache.rs:817-837); nothing in the HTTP API documentation should cite a test.
Also 298-300 duplicates the gauge help text in helios/src/server/metrics.rs:1310-1311 nearly verbatim; some duplication is conventional here, but the extra four sentences are not.
Smaller version (5 lines, replacing 298-312):
`flare_request_kv_pages` counts the distinct KV pages that active requests
reference: their private pages plus the tail pages of the prefix checkpoints they
pin, each page counted once. Those pinned pages also appear in
`flare_cached_kv_pages`; dividing the gauge by `flare_total_kv_pages` excludes
idle cached prefixes and snapshot backing pages.
Saves ~10 lines (fewer if the reserved taguage is kept, see finding 2). Nothing functional is lost: the definition and the ratio statement #537 needs remain, and the help text still carries the metric's meaning at the scrape.
#19 [medium] Context facts for the report: PR state at head 9cca87ac
From pr_files/pr_diff and the orientation packet at head 9cca87ac:
- State: open draft, base main, opened 2026-11-26, no labels, no reviews, no CI checks on the head commit. Closes #537. Author WynnD (4 open PRs, none merged).
- Diff: 8 files, +246/-16 — docs/api.md +16; helios/src/cache.rs +60/-1; cache/lifecycle_tests.rs +3; cache/tests.rs +24; scheduler.rs +51/-14; scheduler/tests.rs +66; server/metrics.rs +18; server/runtime.rs +8/-1. (First review saw +218/-10 across 7 files; the 2026-11-26 push 9cca87ac added runtime.rs's copy-out-key zeroing and rewrote the docs paragraph.)
- Push 9cca87ac "Keep page gauges out of the copy-out retry key" did three things: replaced the three inline
if inbound.is_none()pin/unpin pairs in admit_planned withpin_prefix/unpin_prefixhelpers (scheduler.rs:2025-2040); moved the request-pin release ahead ofrequest.take()inretire(scheduler.rs:3149-3156); zeroedrequest_pages/reserved_pageswhen buildingCopyoutResources(runtime.rs:2441-2450). It fixed the earlier review's two findings in that area and did not change scheduler/tests.rs or cache/tests.rs, so findings 1, 4 and 5 stand verbatim; finding 3's target text changed to docs/api.md:302-312. - No code the change supersedes is left dead:
Cache::pin/unpinstill servepin_checkpoint/unpin_checkpointand the ticket-parent pins (verified at scheduler.rs:1871, 1907, 2044-2050; runtime.rs:2360-2489).has_pins(cache.rs:291) is not a duplicate of the new counter. - Suite not run here (no checks on head); line counts come from the diff and file reads at 9cca87ac.
#4 [low] Note: fixture and metrics-test line accounting
helios/src/cache/lifecycle_tests.rs:74-95 adds two fields to the Fixture::fork struct-literal copy (direct_request_pins, request_pins at :77-78) and one to the cache copy (request_pinned_pages at :95). These are forced only because the fixture hand-copies every private field; they disappear with the direct_request_pins removal (separate finding) except request_pins/request_pinned_pages, which are needed by the counter. Zero saving beyond that, noted so the count is not double-claimed.
helios/src/server/metrics.rs test: metrics.rs:1790-1791 and :1835-1836 add two fixture values and two rows to the fixed-name table in counters_expose_fixed_names_without_request_payloads. That test is a table of every gauge name; the two rows are the cheapest possible coverage (2 lines each, no new test) — keep.
Net: the only removable lines in the metrics test are the reserved_pages pair if that gauge goes (finding on issue scope).
#7 [low] Rejected candidate: the admit_planned pin branches
helios/src/scheduler.rs:1637-1649, 1657-1664, 1683-1690 hold three copies of the same 5-line if inbound.is_none() { unpin_request } else { unpin } pair. Considered and rejected as a subtraction: the branch is load-bearing. The ticket-parent pin (inbound.is_some() && creating) must be taken before ensure_resources (scheduler.rs:1682), because that call evicts checkpoints and the ancestor must survive until finish_inbound releases it (scheduler.rs:1882); moving the pin below, so all three sites could call pin_request, would leave the ancestor evictable during eviction. Factoring the pair into a two-line helper would save ~8 lines but adds an abstraction whose only purpose is to hide a genuine two-kind distinction, so it is not a net subtraction. No finding.