Prose scratchpad · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/1ccd206a-28dd-456a-84ad-4c49e09debc0.md

#1 [high] Should fix: docs/api.md says the gauges are "read on each scrape" but the worker caches them

docs/api.md:298-306 (new paragraph) says: "Both are gauges read from scheduler state on each scrape."

Not what the code does. Metrics::render only loads atomics (helios/src/server/metrics.rs:666, gauges at :1280-1318); the atomics are stored from SchedulerStats by Metrics::scheduler (helios/src/server/metrics.rs:476-522, new fields at :517-518). Only the serving worker calls it, and only on iterations where it made progress: helios/src/server/runtime.rs:1148-1153 if progress { self.metrics.scheduler(self.scheduler.stats()); ... }, plus once at worker start (:722) and once after shutdown (:745).

Consequence for an operator: a scrape reports the last value the worker published, so while the worker is idle or blocked (e.g. waiting on a long graph) the gauge can be stale, and a stopped worker keeps the last value. The doc sentence tells the reader the opposite (fresh per scrape).

Fix: "Both are gauges published by the serving worker as it advances, so a scrape reports the value from the worker's most recent scheduler update." Scheduler state is not readable at scrape time (the scheduler lives on the worker thread behind the metrics atomics).

Settled by reading, no test needed.

#2 [high] Should fix: api.md exclusion sentence omits reserved pages from the ratio

docs/api.md:298-305: "Dividing flare_request_kv_pages by flare_total_kv_pages gives the KV share held by live requests; idle cached prefixes and snapshot backing pages are outside that share."

The share also excludes flare_reserved_kv_pages, which the two preceding sentences introduce as pages "reserved for active requests' future growth that are neither free, cached, nor written yet". Code: helios/src/scheduler.rs:1216-1229 — request_pages = sum of live private_pages + cache.request_pinned_pages; reserved_pages is summed separately and never enters request_pages. So the documented ratio understates the KV an active request actually holds by exactly the reserved set, which is the point of the new second gauge (#537 asked for vLLM kv_cache_usage_perc semantics, and vLLM counts the blocks it has already allocated to running requests).

The sentence enumerates every exclusion except the most relevant one, and a reader computing the ratio to compare with vLLM will be low by the reserved amount without any hint. Fix: add "reserved pages for live requests' growth are also outside it; flare_request_kv_pages plus flare_reserved_kv_pages is the figure that covers both." (Verify the sum is the intended operator guidance before stating it; that phrasing is the author's call, but the omission of reserved pages must be repaired.)

#3 [high] Should fix: api.md and PR description overstate coverage — inbound restore pages are in neither gauge

docs/api.md:298-300 says flare_request_kv_pages "counts the distinct KV pages that active requests reference", and the PR description claims "the KV pages held by active requests ... become scrapeable". That is false while an admitted request is in RequestPhase::Inbound (waiting for a host-store restore).

Code: helios/src/scheduler.rs:1699-1730 pops inbound.pages page ids out of self.free_pages into the Ticket (pages), and the live request is created with shared_pages = Vec::new(), private_pages = Vec::new() (helios/src/scheduler.rs:1736-1737, 1802-1803). SchedulerStats::request_pages (helios/src/scheduler.rs:1216-1222) sums only live slots' private_pages plus cache.request_pinned_pages; reserved_pages (1223-1228) is a disjoint set. The ticket's pages are in neither gauge, yet they are neither free (popped), nor cached (not a checkpoint), nor written (restore in flight). So both new gauges read zero for the restore destination pages of an active request, for as long as the host restore runs — which for a large prefix is the biggest block the request holds.

The gauge and help text describe the checkpoint-pinned and private pages correctly for every other phase; the doc sentence needs the exception, e.g. "...flare_request_kv_pages excludes pages of a host-store restore still in flight, which are held by the restore ticket until the request starts from them." Same repair applies to the description's "the KV pages held by active requests become scrapeable".

Verified by reading scheduler.rs:1699-1741 and 1216-1229; a test could settle the exact phase boundary (assert both gauges during RequestPhase::Inbound).

#4 [high] Should fix: description contradicts its test — "counts once for every request" vs counted once in total

PR description, helios/src/cache.rs bullet: "A page shared through a pinned ancestor therefore counts once for every request that references it."

That is the opposite of the implemented and tested behavior. request_pinned_pages adds a node's tail_pages.len() only when its request_pins rises from 0 (helios/src/cache.rs:553-561), so a shared ancestor page is counted once in total no matter how many requests reach it. The PR's own test asserts exactly this: request_pins_count_each_shared_page_once (helios/src/cache/tests.rs:320-341) pins two children over a shared parent and asserts request_pinned_pages == 3, "rather than 4". Read literally, the description states 4.

Per AGENTS.md:96-102 and docs/design-review.md:125-150 the description must state the resulting behavior precisely; a reviewer who trusts this sentence will expect the gauge to grow with sharing (per-request accounting, as vLLM's num_running blocks would) and read the small observed values as a bug.

Fix: "A page in a shared ancestor's tail is counted once in the total, however many requests pin checkpoints below it; the per-request count comes from summing private pages separately."

#7 [high] Research summary

Prose review of PR #549 ("Report KV pages held by active requests"). I read the charter, AGENTS.md, docs/design-review.md and the repo-prose skill, then the full diff and each changed function in context (cache.rs pin/unpin/compact/stats, scheduler.rs admission/ticket/boundary/retire, metrics.rs render/scheduler/snapshot, docs/api.md), plus the issue it closes (#537).

Six findings recorded in the scratchpad, judged against AGENTS.md §"Required PR descriptions" (four-part scheme, precise before/after, evidence tied to claims) and principle 16 of docs/design-review.md.

Two blocking-adjacent accuracy problems in the new api.md paragraph: it says both gauges are "read from scheduler state on each scrape", but they are atomics the worker publishes only on iterations where it made progress (runtime.rs:1148-1153), so a scrape can be stale; and the documented request/total ratio paragraph omits that the reserved pages introduced one sentence earlier are also outside the share (scheduler.rs:1216-1229).

The description itself overstates coverage in two ways: pages popped from the free list into an inbound host-restore ticket are in neither gauge while a request is in RequestPhase::Inbound (scheduler.rs:1699-1741), and "a page shared through a pinned ancestor counts once for every request" is the opposite of the implementation and of the PR's own request_pins_count_each_shared_page_once test, which asserts 3 rather than 4.

Three nits: the JSON-snapshot omission is unstated in api.md, and "a checkpoint leaves nodes only at zero pins" is inaccurate for compaction, which removes ancestors with nonzero pins that the heir carries.

Every finding was verified in the code by reading; each note says what a test would settle.

#8 [high] Review frame: rules applied and their citations

Rules used for this Prose-lens review (all read in full):

Note on scope: the PR does satisfy the four-part structure and labels its measurement ("Live scrape on the local two-GPU DeepSeek-V4.1-Flash setup", "No comparison with another runtime is claimed", "Not run here: the Windows build and the full helios suite"). The findings are about specific sentences inside "What changed", "Claimed result" and the new api.md paragraph, not about the overall scheme.

#11 [high] Should fix: "What changed" omits the runtime.rs copy-out retry key change

Commit 9cca87ac "Keep page gauges out of the copy-out retry key" adds a behavioural change in helios/src/server/runtime.rs:2441-2454: the CopyoutResources key now builds a SchedulerStats { request_pages: 0, reserved_pages: 0, ..self.scheduler.stats() } instead of the full stats, and copyout_resources is compared at runtime.rs:2455.

The PR description's "What changed" section lists only cache.rs, scheduler.rs, metrics.rs and docs/api.md. It never names helios/src/server/runtime.rs, never says the two fields are zeroed when building the deferred host copy-out retry key, and gives no reason (the code comment says decode moves the two counts without moving cache resources, so including them re-offered deferred copy-outs needlessly).

Why it matters: AGENTS.md:88-94 requires the description to name the affected components and make the before/after explicit, including where behaviour such as re-offering deferred work changes; docs/design-review.md:137-152 rejects descriptions a reviewer must reconstruct. A reviewer reading the description concludes the change is gauges-only, while it also changes what the worker treats as a resource change. It also makes the "Claimed result" sentence "No allocation, eviction, or scheduling decision changes" read as if copy-out offering were unchanged, when the head commit changes precisely that.

Fix: add a helios/src/server/runtime.rs bullet to "What changed": the deferred host copy-out key embedds SchedulerStats whole and now zeroes request_pages/reserved_pages, because decode moves those counts without moving cache resources. Add a matching clause to "Evidence" if the blocked-host-cache tests exercise the re-offer path; otherwise state that the re-offer path was not separately measured.

#12 [high] Should fix (still open): description's shared-ancestor sentence contradicts code and its own test

Commit 9cca87ac rewrote the pin_request doc comment (helios/src/cache.rs:548-550) to say the request pins "count the tail pages of the pinned checkpoints, each page once; a request's own private pages are counted by the scheduler", which fixes the doc-comment half of the earlier finding.

The PR description body is unchanged however: "A page shared through a pinned ancestor therefore counts once for every request that references it." (cache.rs bullet in "What changed"). That is the opposite of the code and of the PR's own test:

Why it matters: AGENTS.md:96-102 and docs/design-review.md:95-102 require the claimed behaviour to be stated precisely; this is the sentence a reviewer or dashboard author uses to predict the gauge, and it also makes the small live values (399/402 of 21504) look wrong.

Fix: "A page in a shared ancestor's tail is counted once in the total, however many requests pin checkpoints below it; per-request totals add each request's private pages." The new code comment at cache.rs:548-550 is the correct wording to lift.

Note: the api.md sentence at docs/api.md:298-300 ("each page counted once even when several requests reference it") is already correct.

#13 [high] Verification at head 9cca87a: three api.md findings repaired

Re-checked against head 9cca87a. Three of the four earlier should-fix items are repaired in the new api.md paragraph (docs/api.md:298-312):

  1. "read from scheduler state on each scrape" is gone; replaced by "The worker publishes both on every scheduler pass and a scrape reads the last published values." (docs/api.md:302-303). Correct in substance (runtime.rs:1148-1153, 722, 745). Nit only: the worker stores only on iterations where progress is true, so "on every scheduler pass" overstates the frequency; when nothing changed the previous value is still correct, so the sentence is not misleading.
  2. Reserved pages are now named as outside the request gauge and request + reserved is documented as the comparable figure (docs/api.md:307-309). Repaired.
  3. The in-flight restore exclusion is now stated: "Neither gauge counts pages still draining through retirement or an admission ticket's in-flight restore." (docs/api.md:306-307). Repaired. Matches scheduler.rs:1693-1708 (ticket pages popped from free_pages), 3179-3191 (retired drain), 1216-1228.
  4. The cache.rs pin_request doc comment now states only the cache's half (helios/src/cache.rs:548-550). Repaired. The same defect survives in the PR description body — see the separate note (entry 12).

Still open from the earlier round: the PR description's shared-ancestor sentence (entry 12), and the new behavioural change in runtime.rs, which the description does not mention at all (entry 11).

#16 [high] Report of 2026-11-27: PR #549 prose review at head 9cca87a

Verdict: should-fix issues only (prose lens). No blocking prose defect.

Head reviewed: 9cca87a (draft, +246/−16, 8 files). Rules: AGENTS.md:43-65, 72-113, 114-140, 142-153; docs/design-review.md:137-152 (principle 16); .agents/skills/repo-prose/SKILL.md:26-46, 56-59, 74-88.

Fixed since the last report

Should fix

  1. Description omits the head commit's behavioural change. The "What changed" section never names helios/src/server/runtime.rs, where commit 9cca87ac now zeroes request_pages/reserved_pages when building the deferred host copy-out retry key (runtime.rs:2441-2455). AGENTS.md:88-94 requires the components and before/after to be explicit; a reader is told the change is gauges-only while deferred copy-out offering also changes. Fix: add the runtime.rs bullet with its reason (decode moves the counts without moving cache resources) and, if unmeasured, say the re-offer path was not separately measured.
  2. Description still contradicts the code and its own test. "A page shared through a pinned ancestor therefore counts once for every request that references it" (cache.rs bullet). request_pinned_pages rises once per node when request_pins goes 0→1 (cache.rs:551-563), and request_pins_count_each_shared_page_once asserts 3, "rather than 4" (cache/tests.rs:320-342). Only the source comment was repaired; the description still promises per-request accounting and makes the live 399/402 values look wrong. Fix: one sentence, taken from the repaired comment.

Nits

  1. api.md:309-310 "Dividing either gauge … excludes idle cached prefixes and snapshot backing pages" — muddled for the reserved gauge, which by construction is neither cached nor snapshot-backed (scheduler.rs:1223-1228). Scope the sentence to the request gauge.
  2. api.md:311-312 puts a #[cfg(test)] drift assertion (cache.rs:817-837) into shipped API docs; AGENTS.md:52-60 keeps unrun checks and process notes out of documents. It already appears in the description's evidence. Delete it.
  3. api.md still does not say both gauges are missing from ?format=json (metrics.rs Snapshot has no such fields; the description says it). One sentence.
  4. api.md:302-303 "on every scheduler pass" overstates: the worker stores only on iterations where progress is true (runtime.rs:1148); the value stays correct, so this is wording only.

Not prose defects

Structure, ordering, Discord line, and evidence scoping (single two-GPU instance, no cross-runtime claim, Windows build and full helios suite named as unrun) all comply. Merge-order note with #548 is consistent from both sides.

#17 [high] Research summary

Prose review of PR #549 at head 9cca87a: no blocking prose defect, two should-fix items and four nits. Full detail in scratchpad entry #16, with the supporting verification notes in #11–#15.

The pushed commit repaired three of the four earlier api.md/cache.rs (not opened) findings: the doc no longer claims the gauges are "read from scheduler state on each scrape", it now names reserved pages as outside the request gauge and gives request + reserved as the comparable figure, it now states that pages draining through retirement and an admission ticket's in-flight restore are in neither gauge, and the pin_request doc comment now describes only the cache's half.

What remains: (1) the description's "What changed" section never names helios/src/server/runtime.rs, where the head commit zeroes request_pages/reserved_pages in the deferred host copy-out retry key (runtime.rs:2441-2455), so a reader is told the change is gauges-only while copy-out offering also changes — AGENTS.md:88-94 requires the before/after to be explicit; (2) the description still says a shared ancestor's page "counts once for every request that references it", contradicting cache.rs:551-563 and the PR's own request_pins_count_each_shared_page_once test (asserts 3, "rather than 4"). Nits are the "either gauge" exclusion sentence in api.md:309-310, the shipped #[cfg(test)] drift assertion at api.md:311-312, the unstated absence from the JSON snapshot, and "on every scheduler pass" in api.md:302-303.

Evidence scoping, structure, ordering and the Discord line all comply with AGENTS.md:72-153 and .agents/skills/repo-prose/SKILL.md (not opened).

#20 [high] Report of 2026-11-28: PR #549 prose review at head bca7358

Verdict: nits only (prose lens). No blocking or should-fix prose defect at head bca7358.

Reviewed: PR description as currently published, one docs hunk (docs/api.md:298-310), the new code comments in cache.rs (81-86, 188, 219-224, 580-582, 635-636), scheduler.rs (130-133, 2018, 3142-3143), runtime.rs (2441-2449), and metrics.rs help strings (1309-1318), plus test names/comments.

Fixed since run 1502 / the 9cca87a report:

Verified accurate at head (no finding): the description's cache.rs mechanics (pin_with/unpin_with, 0->1 and 1->0 tail-page crossings at cache.rs:536-541/561-566, unpin_request rejecting a release without a request pin at :547-549); compaction assertion cache.rs:636 and heir page move :638-641; retirement release ordering scheduler.rs:3142-3149 before request.take() at :3150; ticket-parent plain pins scheduler.rs:1864/1900; cost claims (two u64 per checkpoint cache.rs:81-86, one usize at :219-224, one chain walk :519-570); stats pass scheduler.rs:1200-1221; metrics.rs storage :517-518 and gauges :1309-1318 with no JSON snapshot fields (Snapshot at metrics.rs:106 has cached_pages only); api.md:298-304 claims (pinned checkpoints stay published and overlap cached; retired pages and a restore ticket's in-flight pages are in neither gauge — ticket pages are popped from free at scheduler.rs:1686-1688 and only pinned at :1882); docs ratio definition matches the math for free_pages (reserved and private pages are removed from free at scheduler.rs:1714-1717/1412-1418); Discord line last, no leading @ (AGENTS.md:142-151).

#23 [high] Research summary

Verdict: nits only (prose lens) at head bca7358 — no blocking or should-fix prose defect.

Fixed since my previous report at 9cca87a: the description now names helios/src/server/runtime.rs and explains the copy-out retry key zeroing (matches runtime.rs:2441–2449); the shared-ancestor sentence now says "counts once, however many requests reference it", matching cache.rs:536–541 and cache/tests.rs:331–334; the compaction sentence now correctly says there is no zero-pin rule for leaving nodes (cache.rs:622–641); api.md dropped the #[cfg(test)] drift-assertion sentence, replaced "dividing either gauge" with the (request + reserved) / total share, and now says the worker publishes "when a scheduler pass makes progress, and again at startup and after the shutdown drain" (verified: runtime.rs:1148–1153, 722, 743–746).

Remaining nits (2, detail in scratchpad #21): (a) docs/api.md:298–310 never says both gauges are absent from the ?format=json snapshot, though the description says so and the JSON table at docs/api.md:330–360 lists no such field (metrics.rs Snapshot has none either) — one sentence fixes it; (b) docs/api.md:308–310 claims the ratio "is the share comparable to vLLM's kv_cache_usage_perc" with no qualification, while the description disclaims any cross-runtime comparison — AGENTS.md:55–57 asks for present qualification. A third, small consistency point: api.md:298 says "requests owning a model slot" while scheduler.rs:130 and metrics.rs:1311 say "active requests"; both describe slot.request.as_ref() (scheduler.rs:1205), and unifying the wording would remove a reader question about Inbound waiters.

Everything else in the description's "What changed", "Claimed result" and "Evidence", and every new code comment and metric help string, was checked against the code and is accurate (recorded in scratchpad #20).

#24 [high] Exact quotes and citations for the final report at head bca7358

Scope at head bca7358 (from pr_diff): 8 files, +202/−34. The only documentation change is one hunk inserting docs/api.md:298-310 (13 lines) between the metrics preamble (api.md:281-296) and the JSON/Accept paragraph (api.md:312-319). No other docs file changes. Everything else is code, tests, and the description.

Nit 1 — verbatim passage (docs/api.md:298-310), showing the omission: "flare_request_kv_pages counts the distinct KV pages that requests owning a model slot reference: their private pages plus the tail pages of the prefix checkpoints they pin, each page counted once even when several requests reference it. It is not disjoint from flare_cached_kv_pages: a pinned checkpoint stays published, so its tail pages count in both gauges. Neither gauge counts pages draining after a request retires, or a restore ticket's in-flight pages. flare_reserved_kv_pages counts pages reserved for those requests' growth that are neither free, cached, nor written yet. 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. (flare_request_kv_pages + flare_reserved_kv_pages) over flare_total_kv_pages is the share comparable to vLLM's kv_cache_usage_perc; idle cached prefixes and snapshot backing pages are outside it."

Contrast that shows why the omission matters: docs/api.md:292-296 already routes text-only families explicitly ("Beyond the JSON fields below, the text includes speculative and proposal counters ... embedding row-cache counters, HTTP admission gauges, and uptime"), and the JSON field table at docs/api.md:330-360 has no request_pages/reserved_pages row. The description says outright "They are not added to the JSON snapshot." In code, Metrics gains the two atomics (metrics.rs:265-266, stored at :517-518) and Snapshot (metrics.rs:106 area) gains nothing. Fix sentence: "Neither gauge appears in the JSON snapshot."

Nit 2 — verbatim sub-clause (docs/api.md:308-310): "(flare_request_kv_pages + flare_reserved_kv_pages) over flare_total_kv_pages is the share comparable to vLLM's kv_cache_usage_perc; idle cached prefixes and snapshot backing pages are outside it." Against the description: "No comparison with another runtime is claimed; the measurements describe this two-GPU instance only." and "Live scrape on the local two-GPU DeepSeek-V4.1-Flash setup ... The request gauge over the total measured 0.0186 and 0.0187; the share the documentation defines, (request + reserved) / total, is 0.0187 and 0.0188 by arithmetic on the same counts." Rule: AGENTS.md:55-57 ("State support as present qualification: what is implemented, the hardware and configurations on which it is qualified, and what is not qualified") and AGENTS.md:95-102 (state the expected or observed effect precisely, distinguishing expectation from measurement). Fix options: "matches the definition of vLLM's kv_cache_usage_perc" (definitional, no measurement implied), or one clause saying no side-by-side vLLM run was made.

Third, minor consistency point (not counted as a nit): api.md:298-299 "requests owning a model slot" vs scheduler.rs:130 "Distinct KV pages active requests reference" vs metrics.rs:1311 "Distinct KV pages referenced by active requests". All three describe self.slots.iter().filter_map(|slot| slot.request.as_ref()) (scheduler.rs:1205-1209), which includes Inbound waiters; api.md's wording is the exact one and the other two could adopt it.

Rule set applied (unchanged and re-read at head): AGENTS.md:43-65 required prose review; :52-60 documents specify architecture or instruct agents, qualification stated, unrun checks to docs/TODO.txt; :72-113 the four required questions in order; :114-140 hierarchy, resolved references, no process assurances, "Do not publish it if the rationale, exact change, claimed benefit, supporting evidence, or material limitations must be guessed"; :142-151 Discord line after the technical explanation with no leading @ — PR #549 ends with "Discord: oystersmiles", compliant. Charter line 35 (what gets merged) and line 44 (GPU kernel scope, not engaged).

#26 [high] Report of 2026-11-28, run 2: PR #549 prose review, description rewritten again

Verdict: nits only (prose lens). Head unchanged at bca7358 (search_history: 5ed7af86, 9cca87ac, bca7358c); no new commits. The PR description has been rewritten since my previous report, so I re-verified the current text (read_item #549) rather than reusing earlier findings. Two of my earlier nits lost their support because the sentences they contrasted against were removed from the description:

Nits (4):

  1. docs/api.md:298-307 never says the two gauges are absent from the ?format=json snapshot. Evidence in code/std docs: the JSON field table at docs/api.md:330-360 has no request_pages/reserved_pages row; Snapshot (helios/src/server/metrics.rs:70ff, page fields at :106/:108) gains no field; request_pages/reserved_pages occur in metrics.rs only at :265-266 (fields), :517-518 (store), :1310-1317 (help/gauge), :1790-1791 (test fixture). The neighbouring paragraph docs/api.md:292-296 already routes text-only families explicitly ("Beyond the JSON fields below, the text includes ..."), so the convention exists and this family is the one unexplained exception; docs/api.md:317-318 says Snapshot "reads absent fields as zero", so a JSON reader sees 0. Rules: .agents/skills/repo-prose/SKILL.md:30-37 (state conditions and support) and AGENTS.md:55-57. Fix: "Neither gauge appears in the ?format=json snapshot."

  2. docs/api.md:308-310 "…is the share comparable to vLLM's kv_cache_usage_perc" and the description bullet that repeats it assert comparability with no run making the comparison. Issue #537 (which this PR closes) is itself the only cross-runtime observation, and it reports a mismatch (vLLM ~9% vs Flare's 16% upper bound). AGENTS.md:55-57 (state support as present qualification) and :95-102 (distinguish expectation from measurement). Fix: say it matches vLLM's definition, or state that no side-by-side vLLM run was made.

  3. Description, cache.rs bullet: "Compaction moves the count into the surviving checkpoint." No count is adjusted in compaction — compact_ancestor (helios/src/cache.rs:622-655) removes the node and its counts via uncount (:625), appends the tail pages to the heir (:638-640), and relies on the new debug_assert_eq!(node.request_pins, child.request_pins) (:636) plus the comment ":635" to show the sum is unchanged. What happens is that the pages move and the heir was already counted, not that the count is transferred. Rule: SKILL.md:38-39 (comments/prose state invariants, not a narrative of change) and AGENTS.md:88-94 (before/after must be exact). Fix: "Compaction keeps the count correct because the surviving checkpoint already holds the same request pins."

  4. Description "Evidence", both live-run bullets (RTX PRO 6000 / Qwen3.8-Flash and two-GPU DeepSeek-V4.1-Flash) do not say the image was built with #548 and #560 merged; the author's 2026-11-28 03:26 comment says so ("The image was built from upstream main with this PR, #548, and #560 merged"). AGENTS.md:99-100: "Distinguish component measurements from whole-model or service results, and isolated changes from combined-stack results." Low impact because neither PR touches KV page accounting, but the description should name the build.

Verified sound in the current description (not findings): the cache.rs mechanics (single pin_with/unpin_with walk, helios/src/cache.rs:519-570; 0→1 add at :536-541, 1→0 subtract at :561-566; unpin_request rejecting a release without a request pin at :547-549); "Compaction moves … " assertion at :636; "Plain pins for host copy-out and export are not counted" (scheduler.rs:2037-2043 pin_checkpoint → cache.pin; ticket-parent plain pins at :1631-1638, :1864, :1900); scheduler.rs bullet (every request-owned pin uses the request API at :1882, :2970-2972, :2990-2991, and admission via pin_prefix :1636-1639/:2018-2033; retirement releases the request pin at :3144-3149 before the slot is emptied at :3150); runtime.rs bullet (retry key zeroes both fields, helios/src/server/runtime.rs:2441-2450 with the reason in the comment :2443-2445); metrics bullet (gauges at metrics.rs:1310-1317, published only when a pass makes progress at :1148-1153, plus startup :722 and post-drain :745); "Request-pinned checkpoint pages also appear in flare_cached_kv_pages" (cached_pages is tail_pages, cache.rs:850, and request-pinned nodes are not removed from nodes); the test-only drift assertion (cache.rs:826-846); the stated cost (two u64 fields per checkpoint cache.rs:82-85, one usize counter :222-224, one pass over live slots scheduler.rs:1200-1209).

Rules: AGENTS.md:43-65, :72-113, :114-140, :142-151 (Discord line last, no leading @ — "Discord: oystersmiles" compliant); SKILL.md:25-46, :56-59; docs/design-review.md principle 16. Charter line 35 (what gets merged); line 44 (GPU kernels) not engaged.

#27 [high] Research summary

Verdict: nits only. No blocking or should-fix prose defect at head bca7358. Note the description was rewritten again since my previous pass, and two earlier nits lost their support because the sentences they contrasted against were removed (the "not added to the JSON snapshot" sentence and the "No comparison with another runtime is claimed" disclaimer). I re-verified the current text against the code.

Four nits remain, all recorded in scratchpad entry #26:

  1. docs/api.md:298-307 still never says the two gauges are absent from the ?format=json snapshot — the JSON field table at api.md:330-360 has no such row, Snapshot in metrics.rs gains no field, and api.md:292-296 already routes text-only families explicitly, so this is the one unexplained exception. docs/api.md:317-318 ("reads absent fields as zero") makes the omission actively misleading.
  2. docs/api.md:308-310 and the matching description bullet call the ratio "the share comparable to vLLM's kv_cache_usage_perc" with no qualification, while issue #537 itself (which this PR closes) reports a cross-runtime mismatch. AGENTS.md:55-57 asks for present qualification; say it matches vLLM's definition, or note no side-by-side run was made.
  3. Description, cache.rs bullet: "Compaction moves the count into the surviving checkpoint" — no count is adjusted in compact_ancestor (cache.rs:622-655); the pages move into an heir that was already counted, and the new debug_assert_eq!(node.request_pins, child.request_pins) at :636 is what carries the invariant.
  4. The two live-run evidence bullets do not say the image was built with #548 and #560 merged (the author's 2026-11-28 comment does), which AGENTS.md:99-100 asks for when reporting combined-stack results.

Everything else in the current description — the cache mechanics, the plain-pin exclusion, the scheduler and runtime bullets, the metrics publish conditions, the drift assertion, and the stated cost — matches the code.

#28 [high] Verbatim current description text and scope facts for the #549 prose report

Scope at head bca7358 (read_item 549; pr_diff): 8 files, +202/−34. Only documentation change: one hunk inserting docs/api.md:298-310 (14 lines) between the /metrics preamble (docs/api.md:281-296) and the JSON/Accept paragraph (docs/api.md:312-319). Commits (search_history on pr/549): 5ed7af86 "Report KV pages held by active requests", 9cca87ac "Keep page gauges out of the copy-out retry key", bca7358c "Fix KV-page docs ratio and fold duplicated page tests" — subjects only, bodies not readable with the available tools (as noted in earlier entries).

The description AS CURRENTLY PUBLISHED (it has been rewritten since the 9cca87a review; these are the sentences the report must judge):

Opening: "/metrics reports free and cached KV pages but not the pages live requests hold, so an operator cannot compute the KV share in use, and pages reserved for requests' growth are invisible (neither free, cached, nor written). #537 asks for this. Cache::stats deliberately avoids scanning the checkpoint graph, so the cache maintains a count as request pins change, and the scheduler adds its live slots' private and reserved pages."

What changed bullets:

Result: "Pages held and reserved by active requests become scrapeable; allocation, eviction, and scheduling are unchanged. Cost: one counter update per page-count crossing on request pin and release, and one pass over live slots per stats call, in the loop that already counted them."

Evidence: "cargo test --features runtime-core,server --lib -- server:: scheduler:: cache::: 809 passed; 1 failed, a template test that needs FLARE_TEST_TEMPLATE_DIR and is unrelated. A test-only assertion compares the maintained count with a full scan on every Cache::stats call. Scheduler and cache tests cover shared prefixes (three distinct pages count 3, not 4), plain pins, compaction, and cancellation back to zero." / "Live, on one RTX PRO 6000 Blackwell serving the prepared local-inference-lab/Qwen3.8-Flash-Next-FLARE gb202 package (20,480 pages) with 16 concurrent streams, mid-run scrapes reported 54–80 request pages and 16–22 reserved pages. On a two-GPU DeepSeek-V4.1-Flash deployment with two concurrent chats, the gauges read 399–402 and 2–3 of 21,504 pages." / "Not run: the Windows build."

Tail: "This PR and #548 (request histograms) are independent and merge cleanly in either order." then "Closes #537" then "Discord: oystersmiles" (compliant with AGENTS.md:142-151: last, no leading @).

Author comment 2026-11-28 03:26 (WynnD) supplies what the description omits: "The image was built from upstream main with this PR, #548, and #560 merged." Table: mid-run scrapes 16 streams 54–80 / 16–22; two-GPU DeepSeek-V4.1-Flash 399–402 / 2–3 of 21,504; merge with #548 clean either order; unit tests 809 passed, 1 template test needs FLARE_TEST_TEMPLATE_DIR.

Code quotes backing each finding:

Also worth mentioning in the report but not a nit: docs/api.md:298 says "requests owning a model slot" while helios/src/scheduler.rs:130 says "active requests" and helios/src/server/metrics.rs:1311 says "active requests" — all three describe self.slots.iter().filter_map(|slot| slot.request.as_ref()) (helios/src/scheduler.rs:1205), which includes Inbound waiters. The docs wording is the precise one; adopting it in the two code sites would remove a reader question.

#5 [medium] Nit: api.md does not say the new gauges are Prometheus-text only

docs/api.md:298-306 introduces the two new gauges inside the paragraph list of what the Prometheus text adds "beyond the JSON fields below" (api.md:287-296), but never says they are absent from the ?format=json snapshot. Code: Snapshot (helios/src/server/metrics.rs:68-129) has no request_pages / reserved_pages field; Metrics::snapshot (:355-393) never sets them; they exist only as atomics rendered in the text (:1310-1318). A dashboard fed by GET /metrics?format=json (the documented path at api.md:307-314) gets no such field and no indication why.

Fix: end the paragraph with "Neither appears in the JSON snapshot." The author already states this in the PR description, so the doc sentence is just missing.

#6 [medium] Nit: description's "leaves nodes only at zero pins" is wrong for compaction

PR description: "Compaction asserts that the removed ancestor and its heir agree on request pins, and a checkpoint leaves nodes only at zero pins."

Second half is inaccurate. cancel_publication requires node.pins == 0 (helios/src/cache.rs:650) and leaf eviction only picks a candidate with pins == 0 && child_count == 0 (helios/src/cache.rs:659-663), so leaves do leave at zero pins. But compact_ancestor runs for a candidate matched by the second clause direct_pins == 0 && child_count == 1 (helios/src/cache.rs:662, 686-690), which permits pins > 0, and the new assertion it adds is debug_assert_eq!(node.request_pins, child.request_pins) (helios/src/cache.rs:627) — the ancestor can therefore be removed with nonzero pins and nonzero request_pins, because the heir carries them. What the change actually guarantees is that no request pin is lost when an ancestor is folded into its heir.

Fix: "Compaction asserts that the removed ancestor and its heir agree on request pins, so folding an ancestor into its heir preserves the request pin count and the pages it covers; leaf retirement still requires zero pins."

Same imprecision in the code comment at helios/src/cache.rs:626 ("Both nodes are counted or neither is, and the pages move into the counted heir") only reads oddly; it is defensible. The description sentence is the one to fix.

#9 [medium] Checked and found sound; one evidence gap (commit message body not read)

Candidates verified as sound, so not reported as findings:

Evidence gap I could not close: search_history returns only the commit subject — "Report KV pages held by active requests" (5ed7af86, Wynn Drahorad) — so I reviewed the PR description, not the full commit message body. If the commit body repeats the sentences I flagged (shared-ancestor counting, "leaves nodes only at zero pins"), the same repairs apply there; AGENTS.md:38-41 requires the message to pass the same check.

#14 [medium] Nits: api.md "either gauge" muddle, test-only assertion in docs, JSON omission unstated

Nits at head 9cca87a:

  1. docs/api.md:309-310 — "Dividing either gauge by flare_total_kv_pages excludes idle cached prefixes and snapshot backing pages". The exclusions were written for the request share; applying them to "either gauge" is muddled, since reserved pages are by definition neither cached nor snapshot-backed (scheduler.rs:1223-1228 sums slots' reserved_pages, disjoint from cache.cached_pages). Fix: "Dividing flare_request_kv_pages by flare_total_kv_pages gives the share held by live requests' written and pinned pages, excluding idle cached prefixes and snapshot backing pages."

  2. docs/api.md:311-312 — "and the test-only assertion in Cache::stats compares the maintained request-pinned count with a full scan of every checkpoint on each read." A #[cfg(test)] assertion (helios/src/cache.rs:817-837) is not observable API behaviour; AGENTS.md:52-60 says documents specify architecture or instruct contributors, and that unrun checks and process notes belong in docs/TODO.txt, not the docs. This sentence belongs in the PR description's evidence section, which already states it. Fix: delete the clause from api.md.

  3. docs/api.md:298-312 still does not say the two gauges are absent from the ?format=json snapshot. .agents/skills/repo-prose/SKILL.md:30-34 asks for qualification to be stated where it matters; the PR description says it ("They are not added to the JSON snapshot") and the JSON section follows at docs/api.md:314-321. Fix: one sentence, "Neither gauge appears in the JSON snapshot."

  4. docs/api.md:302-303 — "on every scheduler pass" (see entry 13 for the slight overstatement).

#15 [medium] Verified sound at head: structure, evidence limits, new comments

Checked at head 9cca87a and found sound, so not reported:

#18 [medium] Scope confirmation: single docs hunk, and the exact rule lines the report cites

Scope at head 9cca87a (from pr_files and pr_diff):

Exact rule lines the report cites, so quotes are not paraphrased:

#21 [medium] Nits at head bca7358: JSON-snapshot omission and unqualified vLLM comparability

  1. docs/api.md:298-310 never says the two gauges are absent from the ?format=json snapshot, although the PR description states it ("They are not added to the JSON snapshot") and the JSON section follows immediately at docs/api.md:312-320, whose table (docs/api.md:330-360) lists no such field (also metrics.rs Snapshot at :106 has no request/reserved field). The neighbouring paragraph at docs/api.md:292 explicitly tells the reader which text-only families exist ("Beyond the JSON fields below, the text includes ..."), so the omission is visible to a dashboard author. Rule: .agents/skills/repo-prose/SKILL.md (present-state specification; state a limit where it matters) and AGENTS.md:52-60 (support stated as present qualification). Fix: one sentence, "Neither gauge appears in the JSON snapshot."

  2. docs/api.md:308-310 asserts the ratio "is the share comparable to vLLM's kv_cache_usage_perc" without qualification, while the PR description says "No comparison with another runtime is claimed; the measurements describe this two-GPU instance only." The mapping is definitional (vLLM counts blocks held by running requests over total blocks), so it may be intended as a definition, but the docs state a cross-runtime equivalence that the PR never verified against a vLLM instance. Rule: AGENTS.md:55-57 (state support as present qualification: what is qualified and what is not) and :95-102 (distinguish expectation from measured result). Fix: either mark it as the vLLM definition being modelled ("matches vLLM's kv_cache_usage_perc definition") or add that no side-by-side vLLM comparison was made; if the author did measure it, say so in Evidence.

Also worth noting but not a defect: the docs and the description differ in phrasing for which requests count — api.md:298-299 "requests owning a model slot" vs SchedulerStats doc comment scheduler.rs:130 "active requests" and metrics.rs:1311 help "active requests". Both are consistent with slot.request.as_ref() at scheduler.rs:1205; unifying the wording (e.g. all three saying "requests holding a model slot") would remove a reader question about whether an Inbound waiter counts. The docs sentence is the precise one.

#22 [low] Correction: api.md:292 phrasing in nit 1

Entry 21, nit 1: I paraphrased docs/api.md:292 as saying "Beyond the JSON fields below, the text includes ...". The actual text at docs/api.md:292-296 is: "Beyond the JSON fields below, the text includes speculative and proposal counters by batch, width, or depth, graph launches by kind, embedding row-cache counters, HTTP admission gauges, and uptime." — read directly at result 3 (lines 292-296), the phrase "Beyond the JSON fields below" IS present at line 292. So no correction needed to the substance; the only nuance is that it introduces a list of text-only families, which supports the nit that the two new gauges are text-only but the paragraph never says so.