Subtractive scratchpad · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/4e294b73-6bab-405a-ac65-b803c6a3cefc.md

#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:

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:

  1. Should fix (~55 lines): helios/src/scheduler/tests.rs:970-1034 re-runs, line for line, the scenario already in branching_requests_own_distinct_tail_pages_and_terminal_snapshots (tests.rs:1036-1081). Its four assertions fold into that test.
  2. Should fix (~22-25 lines): flare_reserved_kv_pages is 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.
  3. Nit (~12-14 lines): Checkpoint::direct_request_pins exists only for the "no request pin to release" guard, which unpin already enforces at the same call sites; the scheduler never releases a pin it did not take through pin_request.
  4. Nit (~10 lines): helios/src/cache/tests.rs:322-328 repeats 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:

Verification performed (so the report can say "checked", not "looks like"):

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:

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:

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:

  1. scheduler/tests.rs:970-1034 duplicate scenario — ~55.
  2. reserved gauge (scheduler.rs 132-133, 1223-1228; metrics.rs 266, 518, 1314-1318, 1791, 1831-1836; runtime.rs 2448; docs) — ~20-23.
  3. docs/api.md:302-312 internal prose — ~10.
  4. direct_request_pins + guard (cache.rs 82-83, 461, 553, 566-568, 570; lifecycle_tests.rs 77; cache/tests.rs 335) — ~10.
  5. cache/tests.rs:320-342 duplicate fixture — ~9. Total ~104-107 of 246 added lines (≈43%).

Considered and rejected:

#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

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.

#21 [high] Should fix: pin_prefix/unpin_prefix helpers cost 16 lines over inlining (~16 lines saved)

Head bca7358. helios/src/scheduler.rs:2018-2033 defines pin_prefix(id, request: bool) and unpin_prefix(id, request: bool); comment + 8 + 8 lines = 16 lines (plus blank line 2026/2034). Exactly three call sites: scheduler.rs:1638 (self.pin_prefix(id, request_pin)?;), 1649 and 1671 (self.unpin_prefix(id, request_pin)?), each replacing a one-line self.cache.pin(id)? / self.cache.unpin(id)? in the base.

Smaller: delete 2018-2034 and write, at 1636-1639 / 1648-1650 / 1670-1672:

    let request_pin = inbound.is_none();
    if let Some(id) = pinned {
        if request_pin { self.cache.pin_request(id)? } else { self.cache.pin(id)? }
    }
    ...
        if let Some(id) = pinned {
            if request_pin { self.cache.unpin_request(id)? } else { self.cache.unpin(id)? }
        }

(same for the second rollback). Precedent for the one-line conditional in this file: scheduler.rs:2991 if let Some(parent) = self.request(handle)?.prefix { self.cache.unpin_request(parent)?; }.

Saves ~16 added lines (8% of +202). Nothing lost: request_pin still names the concept, both branches still reachable (ticket parent pins plain, request admission pins request), and the two helpers have exactly one caller pattern each. Verified there are no other callers (search_code pin_prefix|unpin_prefix).

#22 [high] Should fix (scope): flare_reserved_kv_pages is still outside issue #537 (~20 lines saved)

Head bca7358. Issue #537 (read via read_item) asks for exactly one gauge: "A gauge flare_request_kv_pages: distinct KV pages referenced by active requests (private pages plus shared/pinned prefix pages), each page counted once. Then flare_request_kv_pages / flare_total_kv_pages matches vLLM's metric." Reservations are not mentioned; the PR adds them as an independent goal.

Exact lines:

Consumers: only the Prometheus text (metrics.rs render list); not in the JSON Snapshot (docs/api.md:330-360 table has only cached/free/total pages). LiveRequest::reserved_pages already exists for scheduling (scheduler.rs:1726, 2390, 2435); only the aggregate is new. #548 (open, same author) mentions the combined ratio in its description, so the number does have a cross-PR narrative, but #537's own text makes request/total sufficient.

Removing it also shrinks the copy-out key guard at runtime.rs:2441-2450 to a single request_pages: 0, line (that block stays: CopyoutResources.scheduler is the whole SchedulerStats, compared at runtime.rs:2455).

#24 [high] Should fix: smaller leftovers after the test fold (~12 lines)

Head bca7358. The last push folded the two duplicated tests as asked; what remains is small.

  1. helios/src/scheduler/tests.rs:1010-1031 (+22/-5 now). The scenario is now shared, but the added block carries a 5-line tuple destructure (1016-1020), a redundant assert!(!first_request.shared_pages.is_empty()) (1013), a 3-line comment (1024-1026) and renamed locals: about 6-8 lines removable by writing
    let stats = scheduler.stats();
    assert_eq!(stats.request_pages, first_request.shared_pages.len() + first_request.private_pages.len() + second_request.private_pages.len());
    assert_eq!(stats.reserved_pages, first_request.reserved_pages.len() + second_request.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);

(2 lines longer as written; the saving is dropping the tuple + comment + the is_empty assert = ~5.) Report ~5.

  1. docs/api.md:298-310 (14 added lines). Two sentences are internals no other gauge in the file carries: 302-304 "Neither gauge counts pages draining after a request retires, or a restore ticket's in-flight pages" and 305-307 "The worker publishes both when a scheduler pass makes progress, and again at startup and after the shutdown drain; a scrape reads the last published values." Dropping them saves ~5 lines; the definition, the cached-overlap note and the ratio stay. (The prior round's #[cfg(test)] sentence is already gone.)

  2. helios/src/server/runtime.rs:2443-2445: the three-line comment on the copy-out key can be one line ("Decode moves page counts without moving cache resources; keep them out of the key.") — 2 lines.

Total for this note: ~12 lines.

#25 [high] Total at bca7358: 202 added lines, ~55-58 removable; rest minimal

Head bca7358 (pr_files): +202/-34 across 8 files — docs/api.md +14, cache.rs +73/-5, cache/lifecycle_tests.rs +3, cache/tests.rs +15/-4, scheduler.rs +49/-19, scheduler/tests.rs +22/-5, server/metrics.rs +18, server/runtime.rs +8/-1.

Removable, ranked:

  1. helios/src/scheduler.rs:2018-2034 pin_prefix/unpin_prefix (new in the last push) — 16 lines, three call sites take a one-line if/else instead (#21).
  2. flare_reserved_kv_pages (#22) — ~20 lines.
  3. Leftovers: scheduler test tuple/comment/is_empty (~5), docs internals sentences (~5), runtime comment (~2) — ~12 (#24).
  4. direct_request_pins + guard (#23) — ~7-10. Total ~55-58 of 202 added lines (~28%).

Must stay (verified):

Left behind: nothing. Cache::pin/unpin keep callers (scheduler.rs:1864, 1900, 2037-2043; runtime.rs pin_checkpoint/unpin_checkpoint; ~13 test sites). has_pins (cache.rs:291) is not superseded by the new counter.

#26 [high] Research summary at bca7358 and ranked findings

PR #549 at head bca7358 ("Fix KV-page docs ratio and fold duplicated page tests"), base main, open, no reviews, no CI checks, closes #537. The push did exactly what the previous round asked: folded request_kv_pages_count_shared_prefix_pages_once into branching_requests_own_distinct_tail_pages_and_terminal_snapshots and the cache test into branching_pins_ancestors_and_prevents_direct_ancestor_unpin, replaced the two separate pin/unpin request bodies with pin_with/unpin_with, and removed the #[cfg(test)] sentence from docs. Diff fell from +246/-16 to +202/-34.

Findings for the report (ranked by lines saved):

  1. Should fix — pin_prefix/unpin_prefix (scheduler.rs:2018-2034, 16 lines): two bool-dispatch wrappers with three call sites; inline if request_pin { pin_request } else { pin } and delete. Charter: "smallest footprint in shared code".
  2. Should fix (scope) — flare_reserved_kv_pages (~20 lines): issue #537 asks only for request-held pages; no reader beyond the Prometheus text; not in the JSON snapshot table (docs/api.md:330-360).
  3. Should fix — leftovers (~12 lines): scheduler test tuple destructure + 3-line comment + redundant !shared_pages.is_empty(); docs/api.md:302-307 two internals sentences; runtime.rs:2443-2445 three-line comment.
  4. Nit — direct_request_pins and its guard (~7-10 lines).

Verdict: make it smaller first, but the gap is closing — after the fixes the change is close to minimal. Charter line 35 ("PRs that address a maintainer request…") bounds scope to #537; the compaction/refactor work in cache.rs is the irreducible core.

#27 [high] Report of 2026-11-28: PR #549 at bca7358

Verdict: make it smaller first — but the gap is closing. Verdict is much milder than last round: head bca7358 folded the two duplicated tests and merged the request-pin bodies, so the diff fell from +246/−16 to +202/−34, and only ~55–58 added lines (≈28%) remain removable, all of them small and mechanical.

The change: 8 files, +202/−34 — docs/api.md +14, helios/src/cache.rs +73/−5, cache/lifecycle_tests.rs +3, cache/tests.rs +15/−4, scheduler.rs +49/−19, scheduler/tests.rs +22/−5, server/metrics.rs +18, server/runtime.rs +8/−1.

Findings, ranked by lines saved

  1. Should fix — pin_prefix/unpin_prefix are two wrappers with three callers (16 lines). helios/src/scheduler.rs:2018–2034 (new in the last push) adds a doc comment and two eight-line helpers that only dispatch on a bool, and their three call sites (1638, 1649, 1671) each replaced a one-line self.cache.pin(id)?. Delete 2018–2034 and write if request_pin { self.cache.pin_request(id)? } else { self.cache.pin(id)? } at each site — the same one-line conditional style the file already uses at 2991. request_pin keeps naming the concept; both branches stay reachable (the ticket parent pins plain, admission pins for the request). Charter: "Look for the smallest footprint in shared code."

  2. Should fix (scope) — flare_reserved_kv_pages is a second gauge #537 did not ask for (~20 lines). Issue #537 asks for one thing: "A gauge flare_request_kv_pages: distinct KV pages referenced by active requests … Then flare_request_kv_pages / flare_total_kv_pages matches vLLM's metric." It never mentions reserved growth. The lines: scheduler.rs:132–133, 1204, 1208, 1221; metrics.rs:266, 518, 1314–1318, 1791, 1836; runtime.rs:2448; docs/api.md:304–305, 308–309; scheduler/tests.rs:1019, 1023, 1030. Nothing but the Prometheus text reads it — it is absent from the JSON snapshot table (docs/api.md:330–360) and LiveRequest::reserved_pages already serves scheduling. Removing it also shrinks the copy-out-key override (runtime.rs:2441–2450) to a single request_pages: 0,. Charter line 35 bounds merges to the maintainer request; #548 (same author) can carry reservations separately.

  3. Should fix — leftovers around the new code (~12 lines). (a) scheduler/tests.rs:1013–1020: a redundant assert!(!shared_pages.is_empty()) (the following assert_ne! on private pages and the count assertions already fail if shared is empty), a three-line tuple destructure, and a three-line comment (1024–1026) — keep the two stats assertions and the cancel-to-zero check; ~5 lines. (b) docs/api.md:302–307: two sentences of internals no other gauge in the file carries — draining/restore-ticket transients and publication cadence — ~5 lines; the definition, the cached-overlap note and the ratio stay. (c) runtime.rs:2443–2445: a three-line comment that fits in one, ~2 lines.

  4. Nit — direct_request_pins and its guard (~7–10 lines). cache.rs:82–83, 461, 531, 547–549, 556, plus lifecycle_tests.rs:77. Its only reader is the guard, and since direct_request_pins ≤ direct_pins the direct_pins == 0 check immediately below already rejects an empty release; every unpin_request site (scheduler.rs:1649, 1671, 1870, 2972, 2991, 3148) releases a prefix that path pinned through pin_request. The request_pins chain counter alone still produces request_pinned_pages and the drift assertion still checks it. Caveat: this trades a cache-side caller check for the scheduler's pairing, which no type enforces — a maintainer may keep it.

Do not cut (checked): Checkpoint::request_pins and PrefixCheckpointCache::request_pinned_pages with the two zero-crossing brackets — exactly what keeps Cache::stats from scanning nodes, the reason the description gives; the #[cfg(test)] drift assertion (cache.rs:827–846), the best value per line in the change; the compaction agreement assert (635–636); pin_with/unpin_with themselves (one body instead of two request paths, with four public wrappers the plain-pin API needs at ~13 test call sites plus pin_checkpoint/unpin_checkpoint); request_pages and its per-slot loop (it now also carries active_requests, so no extra pass); the flare_request_kv_pages atomic/store/gauge triple and its test rows; and runtime.rs:2441–2450, which fixes a real leak because CopyoutResources.scheduler is the whole SchedulerStats compared at 2455.

Left behind: nothing dead. Cache::pin/unpin keep callers (scheduler.rs:1864, 1900, 2037–2043; runtime.rs checkpoint pins; ~13 test sites), and has_pins is not superseded.

Total: ~55–58 of 202 added lines removable in 4 places (≈28%). The cache-side bookkeeping is the irreducible core; what is left to cut is one wrapper pair, one unrequested gauge, and comment/test polish.

#28 [high] Research summary

Reviewed PR #549 at head bca7358 through the subtraction lens: read all 8 changed files in place with their callers, issue #537, and the charter. The last push folded the two duplicated tests and merged the request-pin bodies, so the diff fell from +246/−16 to +202/−34 and about 55–58 added lines (≈28%) remain removable.

Ranked: (1) pin_prefix/unpin_prefix (scheduler.rs:2018–2034), 16 lines of bool-dispatch wrappers with three call sites that a one-line if/else replaces — should fix; (2) flare_reserved_kv_pages, ~20 lines across six files for a gauge #537 never asked for and nothing but the Prometheus text reads — should fix (scope); (3) ~12 lines of leftovers in the scheduler test block, two internals sentences in docs/api.md:302–307, and a three-line comment in runtime.rs; (4) Nit: direct_request_pins and its guard (~7–10 lines), whose only reader duplicates unpin's own empty-release check.

The cache-side bookkeeping (request_pins, request_pinned_pages, the drift assertion, the compaction assert) is the irreducible core and should stay; nothing the change supersedes is left dead. Full report is entry #27, with the per-finding detail in #21–#26.

#29 [high] Charter citations to attach per finding (bca7358)

Quotes available from the charter (read_charter, as summarised in the orientation packet) to attach to each finding:

Map: finding 1 → smallest-footprint + line 12; finding 2 → line 35; findings 3/4 → smallest-footprint (polish), line 35 does not apply; "do not cut" list → line 42.

#30 [high] Verified-at-bca7358 checklist and caveats for the report

Checked at head bca7358, so the report can state these as verified rather than assumed:

  1. Push bca7358's folds are correct and complete. request_kv_pages_count_shared_prefix_pages_once no longer exists; its scenario now runs inside branching_requests_own_distinct_tail_pages_and_terminal_snapshots (helios/src/scheduler/tests.rs:970-1032), and request_pins_count_each_shared_page_once no longer exists; its assertions are inline in branching_pins_ancestors_and_prevents_direct_ancestor_unpin (helios/src/cache/tests.rs:320-373, assertions at 334, 340, 343, 345, 358, 360). No residual duplicate test remains to remove.
  2. pin_with/unpin_with (cache.rs:519-589) replaced two separate request bodies: net the change is one body plus four wrappers, which is shorter than the previous pin_request calling pin and then re-walking chain (the old code walked the chain twice per request pin). So this push already banked the ~10 lines the previous round listed as optional — do not re-raise it as a finding.
  3. The #[cfg(test)] sentence is gone from docs/api.md (previous round's finding 3): the paragraph at 298-310 no longer cites a test. What remains as internals is only 302-307 (draining/restore-ticket transients and publication cadence).
  4. Cache::pin/Cache::unpin still have real callers at head: scheduler.rs:1864 and 1900 (ticket parent), 2037-2043 (pin_checkpoint/unpin_checkpoint, used from server/runtime.rs), and ~13 test sites (cache/tests.rs, cache/lifecycle_tests.rs:181/432/452/653/667, scheduler/cache_memory.rs, sharing/tests.rs, vision_window_tests.rs). No dead path was left behind.
  5. has_pins (cache.rs:291) still has its one caller (scheduler.rs:1262); the new counter does not supersede it.
  6. SchedulerStats::stats() builds its per-slot loop once (scheduler.rs:1202-1209) for active_requests, request_pages and reserved_pages, so the new page counts add no second pass; with the reserved gauge removed the loop still needs active_requests and request_pages, so the loop itself stays.
  7. Suite not run here (no CI checks on the head commit in this environment); all line counts come from pr_diff and file reads at bca7358. Say so in the report and do not restate the author's test counts as verified.

#32 [high] Should fix (scope): flare_reserved_kv_pages is a second gauge, ~20 lines

Verified at bca7358 (all reads at head; no CI checks on the commit).

Delete reserved_pages entirely:

What proves nothing else reads it: search_code reserved_pages under helios/src/server returns only the metrics field/tests and runtime.rs:2448. The JSON snapshot table (docs/api.md:330-360) lists cached_pages/free_pages/total_pages only; Snapshot (metrics.rs:70) has no request/reserved field; dashboard.rs:515-529 renders cached/free/total only. No script/test under scripts/ reads it (search: no hits).

Scope evidence: issue #537's proposal 1 is exactly "A gauge flare_request_kv_pages: distinct KV pages referenced by active requests (private pages plus shared/pinned prefix pages), each page counted once." The author additionally exposes reserved growth pages. The author's own live numbers (PR comment 2026-11-28) put reserved at 16-22 pages of 20,480 and 2-3 of 21,504, so the ratio this PR documents moves by ~0.1% — the second gauge buys almost nothing on the ratio it is documented for. AGENTS.md:165-169 ("Every contribution must address an explicit maintainer request... Hypothetical future consumers... do not establish a need") and design-review.md:125 (reject scope expansion).

Smaller version: the ratio line in docs/api.md becomes flare_request_kv_pages over flare_total_kv_pages; runtime.rs:2441-2450 shrinks to scheduler: crate::scheduler::SchedulerStats { request_pages: 0, ..self.scheduler.stats() }, (that zeroing must stay: CopyoutResources derives PartialEq on the whole SchedulerStats, runtime.rs:1053-1059/2455).

Must NOT cut: LiveRequest::reserved_pages (scheduler.rs:255) is scheduling state, unaffected.

#33 [high] Should fix: pin_prefix/unpin_prefix bool-dispatch helpers, ~16 lines

helios/src/scheduler.rs:2018-2033 at bca7358:

/// Pins `id` for an active request, or for a host admission ticket's parent.
fn pin_prefix(&mut self, id: CheckpointId, request: bool) -> Result<()> {
    if request { self.cache.pin_request(id) } else { self.cache.pin(id) }
}
fn unpin_prefix(&mut self, id: CheckpointId, request: bool) -> Result<()> {
    if request { self.cache.unpin_request(id) } else { self.cache.unpin(id) }
}

Call sites (search_code pin_prefix|unpin_prefix → only these plus the definitions): 1638 (self.pin_prefix(id, request_pin)?), 1649 and 1671 (self.unpin_prefix(id, request_pin)?). Each call site becomes one line, and the file already uses that one-line form (scheduler.rs:1553 } else { self.cache.lookup(&history)? };, 2991 if let Some(parent) = ... { self.cache.unpin_request(parent)?; }):

if let Some(id) = pinned { if request_pin { self.cache.pin_request(id)? } else { self.cache.pin(id)? } }

Net ~16 lines (17 lines of helper block minus the one extra line at each of the three sites, if the if/else is written on one line). Nothing lost: request_pin (1636, inbound.is_none()) still names the concept, and both branches stay reachable — 1631-1635 pins the ticket ancestor plainly when creating && inbound.is_some(), and the request's own prefix when inbound.is_none().

Charter: "Look for the smallest footprint in shared code" and "we're not interested in piling on extra ... switches" (read_charter, How We Work); design-review.md:16 "Keep Helios as simple as possible".

#34 [high] Should fix: leftovers in the scheduler test, docs prose and runtime comment, ~12 lines

All at bca7358.

(a) helios/src/scheduler/tests.rs:1010-1031. The scenario is now shared with the existing test (good, that fold is complete), but the added block carries a redundant assert!(!first_request.shared_pages.is_empty()) (1013 — the assert_ne! on private pages and the two count assertions fail on an empty set anyway), a three-line tuple destructure (1016-1020) and a three-line comment restating the two cancel assertions (1024-1026). Smaller:

let stats = scheduler.stats();
assert_eq!(stats.request_pages,
    first_request.shared_pages.len() + first_request.private_pages.len() + second_request.private_pages.len());
scheduler.cancel(first).unwrap();
scheduler.cancel(second).unwrap();
let stats = scheduler.stats();
assert_eq!(stats.request_pages, 0);
assert!(stats.cached_pages > 0);

≈5 lines.

(b) docs/api.md:302-307 — two internals nobody reads: "Neither gauge counts pages draining after a request retires, or a restore ticket's in-flight pages" and "The worker publishes both when a scheduler pass makes progress, and again at startup and after the shutdown drain; a scrape reads the last published values." No other gauge in this file documents publication cadence or transient states (cf. the free/cached page descriptions, api.md:350-352, one line each in the field table). Keep the definition (298-301), the flare_cached_kv_pages overlap note (301-302), and the ratio. ≈5 lines, of which 304-305 also go with the reserved gauge.

(c) helios/src/server/runtime.rs:2443-2445 — three-line comment for a two-field override; one line ("Decode moves the page counts without moving cache resources.") says it. ≈2 lines.

Total ~12.

#36 [high] Total at bca7358: 202 added lines, ~55-56 removable; rest is the irreducible core

At bca7358 (pr_files): +202/-34 across 8 files — docs/api.md +14, cache.rs +73/-5, cache/lifecycle_tests.rs +3, cache/tests.rs +15/-4, scheduler.rs +49/-19, scheduler/tests.rs +22/-5, server/metrics.rs +18, server/runtime.rs +8/-1.

Removable: #32 reserved gauge ~20, #33 pin_prefix/unpin_prefix ~16, #34 leftovers ~12, #35 direct_request_pins ~7-8. Total ~55-56 of 202 added lines (~28%).

Must stay (verified in code):

Left behind: nothing dead. Cache::pin/unpin and has_pins (cache.rs:291, caller scheduler.rs:1262) keep callers. No flag, config or doc elsewhere describes the old state. The new fields are additive on public structs (SchedulerStats, CacheStats, Checkpoint is private-typed but the struct is rebuilt in cache/lifecycle_tests.rs:74-97, updated).

Caveats: suite not run here (no CI checks on the head commit); all counts from pr_diff and file reads at bca7358.

#37 [high] Report of 2026-11-28, run after the live-validation comment: PR #549 at bca7358

Verdict: make it smaller first — but only just. About 55 of the +202 added lines can be deleted in four places; the rest is the irreducible core.

Head bca7358, base main, +202/−34 across 8 files. No CI checks on the commit; all counts are static readings of the diff and the files at head.

Ranked findings

1. Should fix (scope) — flare_reserved_kv_pages is a second gauge (~20 lines)

Issue #537's proposal names one gauge: "A gauge flare_request_kv_pages: distinct KV pages referenced by active requests … Then flare_request_kv_pages / flare_total_kv_pages matches vLLM's metric." Reserved growth pages are not in it, and nothing outside the Prometheus text reads them: search_code reserved_pages under helios/src/server returns only the metrics field, its store, its gauge block and its two test lines; Snapshot (metrics.rs:70-110) has no such field, docs/api.md:330-360 lists only cached/free/total pages, dashboard.rs:515-529 renders cached/free/total only, and scripts/ does not read it. The author's own live numbers put reserved at 16-22 of 20,480 pages and 2-3 of 21,504, so the documented ratio moves by ~0.1%.

Delete: scheduler.rs:132-133 (doc + field), 1204, 1208, 1221; metrics.rs:266, 518, 1314-1318, 1791, 1836; runtime.rs:2448; docs/api.md:304-305 and the + flare_reserved_kv_pages at 308-309; scheduler/tests.rs:1019, 1023 and the reserved half of 1030. Nothing replaces it; the ratio becomes flare_request_kv_pages over flare_total_kv_pages, and runtime.rs:2441-2450 shrinks to scheduler: crate::scheduler::SchedulerStats { request_pages: 0, ..self.scheduler.stats() },. Citations: AGENTS.md:165-169 (need must be a maintainer request, not a hypothetical consumer); design-review.md:125 (reject scope expansion); charter "What gets merged" (line 35).

2. Should fix — pin_prefix/unpin_prefix (~16 lines)

scheduler.rs:2018-2033: a doc comment and two seven-line helpers that only dispatch on a bool, with exactly three call sites (1638, 1649, 1671 — search_code pin_prefix returns nothing else). Each site takes a one-line if request_pin { self.cache.pin_request(id)? } else { self.cache.pin(id)? }, the style the file already uses at 1553 and 2991. Nothing lost: request_pin (1636) still names the concept and both branches stay reachable (1631-1635 pins the ticket ancestor plainly when creating && inbound.is_some(), the request's own prefix when inbound.is_none()). Charter, How We Work: "Look for the smallest footprint in shared code"; design-review.md:16.

3. Should fix — leftovers around the new code (~12 lines)

4. Nit — direct_request_pins (~7-8 lines)

cache.rs:82-83, 461, 531, 547-549, 556 plus cache/lifecycle_tests.rs:77. Its only reader is the guard at 547-549, and direct_pins <= direct_request_pins means the direct_pins == 0 check at 550-552 already rejects an unpinned release; every unpin_request site matches a pin_request (scheduler.rs 1649/1671↔1638, 1882↔3148, 2970↔2972, 2990↔2991). The request_pins counter still yields the pages and the drift assertion still checks it. Counterargument a maintainer may accept: AGENTS.md:182-186 rejects weakened validation, and the pairing is not type-enforced.

Do not cut

Checkpoint::request_pins / request_pinned_pages with the #[cfg(test)] drift assertion (cache.rs:827-846) is the whole mechanism that keeps Cache::stats scan-free, as the description and #537 require; the compaction agreement assert (cache.rs:635-636) and the debug_assert! at 562 follow charter line 42; pin_with/unpin_with is already the shorter shape (one body, four wrappers) and the plain wrappers keep ~30 call sites; the stats loop at 1202-1209 replaces the old active_requests count and so costs nothing; the pin release moved before request.take() (3142-3149) is a real ordering requirement.

Left behind

Nothing dead. Cache::pin/unpin and has_pins (cache.rs:291) keep their callers; no flag, config or doc elsewhere describes the old state.

Caveat: the suite was not run here (no checks on the head commit), so the author's "809 passed" is taken as given. Total: ~55-56 of 202 added lines removable (~28%), in 4 places.

#38 [high] Research summary

Reviewed PR #549 at head bca7358 (no new commits since the last round; the only activity is the author's live-validation comment, which changes no code and did not affect any finding). Read all 8 changed files in place with their callers, plus issue #537, the charter, AGENTS.md's contribution criteria and docs/design-review.md.

Verdict: make it smaller first — about 55 of the +202 added lines (~28%) can simply be deleted, in four places; the rest is the irreducible core of the counter.

Everything else was checked and must stay: the request_pins/request_pinned_pages counters with the test-only drift assertion (that is what keeps Cache::stats scan-free), the compaction agreement assert, the pin_with/unpin_with merge (already the shorter shape), the stats loop (it replaced the old active_requests count, so costs nothing), and the copy-out-key zeroing (needed because CopyoutResources compares the whole SchedulerStats). Nothing is left dead behind. The suite was not run — the head commit has no CI checks here.

Full report is scratchpad entry #37; the four findings are #32-#35 and the line accounting is #36.

#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:

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:

#23 [medium] Nit: direct_request_pins and its guard (~7-10 lines)

Head bca7358 (unchanged by the latest push). helios/src/cache.rs:82-83 (doc + field), 461 (init), 531 (+= 1), 547-549 (the guard), 556 (-= 1), plus helios/src/cache/lifecycle_tests.rs:77 (fixture copy) = 7 added lines.

Its only reader is the guard at 547-549, if request && self.checkpoint(id)?.direct_request_pins == 0 { return Err("checkpoint has no request pin to release") } (the sole occurrence of that string in the tree — search_code). Since direct_request_pins <= direct_pins, unpin_with's own direct_pins == 0 check (550-552) already covers a release of a checkpoint with no pins at all; the extra guard only fires on a caller that holds a plain pin and no request pin, which no scheduler path does (every unpin_request call site — scheduler.rs:1649, 1671, 1870 retire, 2972, 2991, 3148 — releases a prefix that the matching path pinned through pin_request: 1638, 1882, 2970, 2990, and the prefix recomputed at 3144).

Smaller: delete the field, its init, its two increments, and the 3-line guard; the request_pins chain counter alone still yields request_pinned_pages and the drift assertion still checks it. Saves ~7 lines (10 with the lifecycle fixture line and, if wanted, the cache-test release-error assertion).

Caveat: this trades a cache-side caller check for relying on the scheduler's pairing, which no type enforces. Flag as Nit; keep the debug_assert!(node.request_pins > 0) at 562.

#35 [medium] Nit: direct_request_pins and its guard duplicate unpin's own check, ~7-8 lines

helios/src/cache.rs:82-83 (doc + field direct_request_pins), 461 (init), 531 (+= 1), 547-549 (the guard), 556 (-= 1), plus helios/src/cache/lifecycle_tests.rs:77 (fixture copy copies it).

Its only reader is the guard: if request && self.checkpoint(id)?.direct_request_pins == 0 { return Err("checkpoint has no request pin to release".into()); }

Since direct_request_pins <= direct_pins, the direct_pins == 0 check immediately below (cache.rs:550-552) already rejects a release on an unpinned checkpoint, and every unpin_request site releases a prefix pinned through pin_request: scheduler.rs 1649/1671 ↔ 1638, 1882 ↔ 3148, 2970↔2972, 2990↔2991. The request_pins chain counter alone still yields request_pinned_pages (cache.rs:539/565), and the #[cfg(test)] drift assertion (cache.rs:827-846) still checks it against a full scan.

Delete field, doc, init, the two updates and the three-line guard: ~7 lines, ~8 with the fixture line. Caveat: this trades a cache-side caller check for the scheduler's pairing, which no type enforces — a maintainer may keep it, so Nit. AGENTS.md:182-186 ("Reject weakened guarantees... Do not remove validation") is the counterargument; the drift assertion is what actually guards the count.

#39 [medium] PR state for the 2026-11-28 report round (head bca7358)

PR #549 "Report KV pages held by active requests", base main, head bca7358, open and ready for review. Opened 2026-11-26, last updated 2026-11-28. 8 files, +202/-34. No CI checks on the head commit; no reviews.

Since the previous report (scratchpad #31): no new commits. New activity is only

These numbers are the author's, not verified here: they corroborate finding #32 (reserved pages are 2-3 of 21,504 — the ratio moves ~0.1%).

State the caveat clearly: the suite was not run from this environment, so "809 passed, 1 failed" is taken as given.

#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.