Prose review — PR #548, "Add request latency histograms and process metrics"
Head ebecef1, base main, draft, 8 files, +545/−20. Rules applied: AGENTS.md:43-70 (required prose review), AGENTS.md:72-140 (required PR descriptions, four-part scheme), .agents/skills/repo-prose/SKILL.md (not opened), and docs/design-review.md:137-152 (principle 16, which restates the scheme and requires an explicit before/after and claims connected to evidence).
Key findings
The PR's prose is in good shape. The description answers why / what exactly changed / what result is claimed / what evidence supports it, in that order, and labels the claim honestly: "Observability only: latency, prompt-size, and process resource distributions become scrapeable, and nothing about serving changes", followed by what it explicitly does not claim. Every "What changed" bullet I checked against the code held. The Discord line is present. The code comments are invariant-style rather than chronology, and the new module doc in helios/src/server/metrics/process.rs:2-6 states source, degradation rule and non-Linux behaviour in three sentences without narrating the work.
The defects are all in the one prose artifact that describes the metrics to operators, docs/api.md, and all three are ordinary accuracy problems inside the newly added section: one paragraph claims a per-generation rate the exposition text itself contradicts, one pre-existing sentence is falsified by the paragraph this PR adds under it, and one sentence describes the end of the e2e interval as model completion when the code ends it at delivery.
No blocking finding: nothing in the changed prose is missing its rationale, out of order, or unsupported by the evidence. The three should-fix items are each a one-sentence repair.
Should fix
1. docs/api.md:305-313 — "one observation per completed generation" is false for two of the six histograms
Passage (added by this PR):
The runtime records one observation per completed generation in
flare_request_queue_seconds...flare_request_prefill_seconds...flare_request_decode_secondsfrom the first to the last committed generated token,flare_time_per_output_token_secondsas decode time divided by generated tokens after the first, andflare_request_prompt_tokensfor prompt tokens including tokens reused from the prefix cache.
Why it is wrong. Metrics::request_completed observes decode and time-per-output-token only inside a guard on the generated-token count:
helios/src/server/metrics.rs:470-479—if let Some(first) = times.first_token_ns && generated_tokens > 1 { ... self.request_decode.observe(...); self.time_per_output_token.observe(...) }.
The HELP strings added by the same PR say so explicitly:
helios/src/server/metrics.rs:1406-1409— "First to last committed generated token, for completed requests with at least two generated tokens."helios/src/server/metrics.rs:1413-1418— "Decode time divided by generated tokens after the first, for completed requests with at least two generated tokens."
The queue, prefill and prompt-token HELP strings at metrics.rs:1395-1404 and :1419-1424 say "for completed requests" with no such qualification, which matches the code (metrics.rs:460-469). So the operator-facing doc contradicts the exposition text it is describing, and an operator reconciling flare_request_decode_seconds_count against flare_requests_completed_total finds a gap the doc says cannot exist. It also contradicts the PR description's own Evidence section, which relies on decode counts differing from completed counts.
Fix: split the sentence by eligibility, e.g. "one observation per completed generation in flare_request_queue_seconds, flare_request_prefill_seconds and flare_request_prompt_tokens, and, for generations with at least two tokens, in flare_request_decode_seconds and flare_time_per_output_token_seconds."
Already pinned by test: request_histograms_bucket_completed_request_timings re-calls request_completed with generated_tokens = 1 and asserts the decode count does not move. No further validation needed.
2. docs/api.md:288-290 — the naming rule is falsified by the paragraph this PR adds
Passage (pre-existing, but the PR makes it false):
Counter and gauge names start with
flare_, such asflare_generated_tokens_total,flare_active_requests, andflare_free_kv_pages.
The PR adds, two paragraphs later (docs/api.md:315-318):
On Linux the text also carries
process_cpu_seconds_total,process_resident_memory_bytes,process_virtual_memory_bytes,process_start_time_seconds,process_open_fds, andprocess_max_fdsfor the serving process.
Those six are emitted verbatim by helios/src/server/metrics/process.rs:79-132, and their names are fixed by the Prometheus convention the change exists to satisfy (issue #536 asks for the standard process metrics so generic dashboards find them). So the absolute rule at :288 is now wrong on the same page as its counterexample. An operator who reads the naming rule and greps ^flare_ misses the process series entirely; the document already handles this correctly for the image-preparation counters at docs/api.md:334-336, which it describes as present "under its Prometheus name without the flare_ prefix", so the fix is to follow that precedent.
Fix: scope the rule to runtime metrics — "Runtime counter and gauge names start with flare_ ..." — and let the new paragraph name its exception, or add "except the standard process_* series below" to :288-290.
Settled by reading docs/api.md:287-318 and metrics/process.rs:43-132; no test needed.
3. docs/api.md:301-304 — the e2e interval is described as ending at the response, but is recorded at delivery and skipped for unpolled streams
Passage:
flare_request_e2e_secondscounts each successful generation from admission to the completed response, andflare_time_to_first_response_secondscounts each response that offers answer or reasoning text, from admission to that text, once the client reads it.
The TTFR half of that sentence carries the right caveat ("once the client reads it"). The e2e half does not, and it needs the same one, because the observation sits inside the streaming body, not in the runtime:
- Streaming:
helios/src/server/http.rs:614-617—Delivery::Complete(_) => { if !count { metrics.request_e2e.observe(... admitted_at.elapsed() ...) } None }, inside thefilter_mapthat becomes the SSE body athttp.rs:604-626. TheDelivery::Completearm is reached only when the body is polled to that point. - Non-streaming:
helios/src/server/http.rs:631-641— the same observation runs when the body event is pulled, and the response body is then returned as a stream wrapped inmap, so a client that never consumes it has already recorded here but a client that disconnects mid-stream has not. - The runtime's own timestamp helper is
admitted_at(HTTP admission), and the existing module doc for the sibling measurement states the limit plainly: "Server-side admission-to-output timing; this does not measure client receipt" (helios/src/server/latency.rs:2), repeated for the sampler atlatency.rs:12-14.
Consequences the doc hides: (a) the interval ends at delivery completion, not at the model's last committed token, so it is not comparable to flare_request_decode_seconds end-to-end; (b) an abandoned or never-polled stream records nothing, so "counts each successful generation" overstates coverage in exactly the case an operator investigating slow clients cares about. The PR's own test asserts this behaviour (helios/src/server/runtime/phase_tests.rs:4407-4486, "an unpolled response body models socket backpressure", with the e2e count asserted 0 at :4432), so the behaviour is intended and only the sentence is wrong.
Fix: "... counts each successful generation whose response is delivered to the client, from admission to delivery completion, once the client reads it", keeping the TTFR caveat as is. If the author prefers to name the exclusion directly: "... and an abandoned stream records nothing."
Settled by code reading; the pointing test already exists.
Nits
docs/api.md:305— the request histograms are never stated to be cumulative since server start, while the object they sit beside includes a 60-second windowed median (docs/api.md:331-334,latency.rs:9,:19-26). A reader can reasonably take "one observation per completed generation" plus the windowedfirst_responseblock as implying the histograms are windowed too. The page states the convention for the table at:329-330("Totals count from server start"), so one clause in the new paragraph ("cumulative from server start") would remove the doubt.docs/api.md:300-301— "Request histograms observe the served response" is a vague lead-in: "observe" is the implementation verb, and "the served response" does not say whether the subject is latency or size. The following two sentences then switch subject from e2e/TTFR to the runtime's five timings without saying so. Name the two groups: HTTP-level response timing (e2e, TTFR) and runtime per-request timing (queue, prefill, decode, time per token, prompt tokens).- PR description, "What changed → HTTP" — "The existing first-response sampler observes
flare_time_to_first_response_secondswhen it offers answer or reasoning text; its median gauge and 60-second window are unchanged." The "it" can attach to the sampler or to the histogram; the code makes the sampler the subject (latency.rs:107-120), so "when the sampler offers ..." or "when that response offers ..." is clearer. - PR description, "Evidence", live-scrape paragraph — "this commit was cherry-picked onto it" and "the fork predates the persistent-worker metrics function" leave the reader to work out whether the measured tree is the branch head. Since the counts are load-bearing for the histogram claims, say so: "the measured tree equals
ebecef1plus no code changes, rebased onto5ffe4d54."
Checked and found sound
- Description scheme. AGENTS.md:74-80 requires why → what exactly changed → claimed result → evidence, in order. The description does exactly that, and AGENTS.md:95-112's demand to distinguish expectation from measurement, attach scope and limitations, and state what remains untested is met: "Observability only ... This claims no performance or memory improvement, and it does not report cancelled or failed requests in the request histograms", plus the explicit "Not run here: the Windows build; the full helios suite; and
messages_image_hints_end_after_expansion...". That also satisfies SKILL.md:35-37 ("disclose missing hardware, inputs, and unrun checks"). - "What changed" assertions held.
Incomingkeeps its stamps through parking and readmission (helios/src/server/runtime.rs:2094-2121,:1553-1575);reserve_and_packstamps the first scheduled step (runtime.rs:2187-2201);completestamps first and last committed token (runtime.rs:1774-1775); the tworequest_completedcall sites really do replace direct counter increments (runtime.rs:1841-1846user/text stop,:1993-1998natural finish), andcompleted.fetch_addnow exists only atmetrics.rs:459; cancelled and failed requests are counted only bycancelled.fetch_add(runtime.rs:1317,:1338,:1360,:1407) andfailed.fetch_add(runtime.rs:330);count_tokensis excluded from e2e vialet count = request.uri().path() == "/v1/messages/count_tokens"(http.rs:131, guards at:615and:632); the JSON branch never renders the histograms (helios/src/server.rs:645-659versus text at:671,:709); non-Linux writes nothing (metrics/process.rs:8-14). - Code comments. Invariant and intent form, no chronology:
metrics.rs:450-451("so the two cannot diverge"),process.rs:19-25(why the fields are parsed after the last)),process.rs:73-74(thegetrlimitsafety note).metrics.rs:1398"Model-scheduler arrival" resolves the shorthand the docs then reuse. The one thing the comments do not do is explain thegenerated_tokens > 1exclusion inrequest_completed— finding 1 is the doc-side consequence, and a one-line comment atmetrics.rs:470-471would keep the next editor from "fixing" it. - Discord line present as
Discord: oystersmiles, no@, after the technical explanation (AGENTS.md:142-150, design-review principle 17). - No design-document drift. Nothing in the change belongs in
docs/TODO.txt; the new prose states present behaviour, and no "designed, not implemented" marking is warranted (AGENTS.md:52-60). - Merge-interaction note. "This PR and #537 add different regions of
helios/src/server/metrics.rs... They merge in either order" is the kind of logistics AGENTS.md:120-121 allows at the end, and it is placed after the technical explanation.
Open questions and what I could not settle
- "CI covers the first two." The Evidence section ends the not-run list with "CI covers the first two", referring to the Windows build and the full helios suite. At the time of review the head commit
ebecef1carries no checks, so "covers" is an expectation about configuration rather than an observed run. AGENTS.md:108-109 says test labels cannot stand in for the tested contract and result, and SKILL.md:30-34 requires distinguishing implementation from qualification. If CI does run the Windows target and the full suite on this head, a sentence naming the job would close it; if it does not, the sentence overstates. Settled only by the CI configuration plus a run on this head. - Commit message body.
docs/design-review.md:139-145requires the commit message body to follow the four-part scheme, and the repository's hooks reference aDesign-Signed-Off-Byacknowledgment (AGENTS.md:38-41). The history view exposes only the subject line ("Add request latency histograms and process metrics",ebecef1), so I could not check the body.git show ebecef1settles it; nothing in the diff suggests a problem, since the description reads as if derived from a compliant body. - Cross-check with #549 (same author, open, "Report KV pages held by active requests") — they touch
helios/srcin the same period and may edit the samedocs/api.mdmetrics section. I did not diff them against each other; if both land, the naming-rule sentence in finding 2 may need the same edit twice.