#1 [high] Should fix: e2e histogram includes cancelled/tool-limited responses, contradicting the stated exclusion rule
helios/src/server/http.rs:631-635 (non-stream) and http.rs:614-617 (stream) observe flare_request_e2e_seconds in the Delivery::Complete arm. That arm is reached for responses whose generation the runtime counted as cancelled: at http.rs:563-567, when encoder.tool_limit_reached, generation.cancel() is called, and the runtime then counts it in metrics.cancelled, never in request_completed (runtime.rs:1343-1364 / 1334-1342). The terminal event still flows through GenerationEvent::Finished → Delivery::Complete → e2e observed.
Why it matters: docs/api.md (new paragraph, lines ~296-311) states "Cancelled and failed requests enter only flare_requests_cancelled_total and flare_requests_failed_total", and the PR description repeats "Cancelled and failed requests stay out of these histograms". For flare_request_e2e_seconds that is not true of the cancelled-by-tool-limit path, so a dashboard comparing flare_request_e2e_seconds_count against the runtime histograms/counters mixes populations.
Fix: gate the observation (e.g. skip when encoder.tool_limit_reached/termination is Cancelled), or narrow the documentation sentence so it covers only the runtime histograms (queue/prefill/decode/tpot/prompt tokens). Verified in code; a test with a tool-limit-reaching request would settle whether e2e is really observed there.
#6 [high] Research summary
Reviewed PR #548 (request latency histograms + Linux process metrics) through the correctness lens: read all 8 changed files in context (metrics.rs, runtime.rs, http.rs, latency.rs, server.rs, process.rs, phase_tests.rs, docs/api.md), followed both request_completed call sites, the reserve_and_pack/complete/publish/park paths, and both HTTP delivery arms, and checked the repo's rules (charter, AGENTS.md, docs/design-review.md).
Two findings worth fixing: (1) flare_request_e2e_seconds is observed on any Delivery::Complete, so responses the runtime counts as cancelled (the encoder.tool_limit_reached → generation.cancel() path at http.rs:563-567, which never reaches request_completed) still land in the e2e histogram, contradicting the new docs sentence and the PR description that cancelled requests appear only in flare_requests_cancelled_total; (2) streaming e2e is only recorded if the client drains the SSE body while the non-streaming path records before the body is polled, an asymmetry that makes flare_request_e2e_seconds_count diverge from flare_requests_completed_total for streamed requests and is not stated in docs/api.md.
Also noted as lower-severity items: first_scheduled_ns is stamped for GraphKind::Vision lanes too (question, may be intended given the docs wording); parse_stat's last-) heuristic returns Some on some malformed comms rather than omitting; process_open_fds counts its own directory read (+1 vs the standard exporter, but the HELP text says so). Verified-correct: the counter and histograms share one function with no leftover direct completed.fetch_add sites, bucket indexing and cumulative rendering are consistent, the non-Linux build of process.rs compiles cleanly (all libc use is Linux-cfg'd), and the JSON snapshot is untouched. Evidence limitation: the live scrape ran on a cherry-pick onto a fork commit, no CI checks exist on the head, and the Windows build and full suite were not run.
#7 [high] Citation sheet for the two findings and secondary items
Finding 1 (Should fix, e2e vs cancelled):
- helios/src/server/http.rs:563-567 —
if encoder.tool_limit_reached { if let Some(generation) = &generations[index] { generation.cancel(); } }; the terminalGenerationEvent::Finishedstill becomesDelivery::Completeat http.rs:598 (yield Delivery::Complete(response);). - helios/src/server/http.rs:614-617 (stream) and 631-635 (non-stream) —
request_e2e.observe(...)unconditional in theDelivery::Completearm, guarded only by!count(count_tokens). - Cancellation is counted in runtime.rs:1334-1342 (parked) and 1343-1364 (active) as
self.metrics.cancelled.fetch_add, and those paths never callrequest_completed. - Contradicted text: docs/api.md new paragraph (in the diff, after "The route returns one JSON object…" block start, ~lines 287-320): "Cancelled and failed requests enter only
flare_requests_cancelled_totalandflare_requests_failed_total." PR description: "Cancelled and failed requests stay out of these histograms."
Finding 2 (Should fix, streaming e2e requires body drain):
- http.rs:600-620 stream arm inside
delivery.filter_mapused bySse::new(events); observed only when the client polls to the end. - http.rs:629-641 non-stream arm observes in the handler before the body is polled.
- phase_tests.rs:4461-4465 asserts
flare_request_e2e_seconds_count 1for thepoll_body == falsecase, which proves the non-stream contrast. - Docs wording, docs/api.md: "
flare_request_e2e_secondscounts each successful generation from admission to the completed response" — no mention of body drain, while the adjacent sentence forflare_time_to_first_response_secondsdoes say "once the client reads it".
Secondary items:
- runtime.rs:2187-2203
reserve_and_packloopsstep.lanesand setsfirst_scheduled_nsbefore theif step.kind == GraphKind::Visionsplit at 2208, so vision lanes also stamp the queue end. - metrics/process.rs:19-32
parse_statlast-)heuristic; returns Some for ambiguous comms; module doc (lines 1-6) claims unreadable/unparsable sources omit the metric. - metrics/process.rs:65-67, 115-123
process_open_fdsincludes the read_dir handle, acknowledged in its HELP string. - metrics/process.rs:9-14 + helios/Cargo.toml:50
libcis non-optional and all uses arecfg(target_os = "linux"), so the Windows/non-Linux build has no new libc reference.
Coupling check: Metrics::request_completed at metrics.rs:452-480 is the only increment of completed; the two former sites were runtime.rs:1832 (user/text stop, now 1841-1846) and 1984 (natural finish, now 1993-1998).
#2 [medium] Should fix: streaming e2e depends on the client draining the SSE body, undocumented asymmetry with non-stream
http.rs:600-620: for streaming, the Delivery::Complete(_) arm runs inside the filter_map that back Sse, so flare_request_e2e_seconds is observed only if the client actually polls the stream to its end. A client that disconnects mid-stream (the common cancel path) never reaches it.
http.rs:629-641: the non-streaming path observes e2e in the handler before the JSON body is polled, so it records even when the client never reads the response — the added test first_response_http_nonstream_records_only_when_completed_body_is_offered (phase_tests.rs:4461-4465) asserts exactly that (count 1 for the poll_body == false case).
Why it matters: flare_request_e2e_seconds_count therefore diverges from flare_requests_completed_total for streamed requests (which are the majority for chat), in the opposite direction from the non-stream case, and docs/api.md says only "counts each successful generation from admission to the completed response" — unlike the neighbouring flare_time_to_first_response_seconds sentence, which does say "once the client reads it". The asymmetry is a real, operator-visible property that the docs do not state.
Fix: state in docs/api.md that streaming observations require the client to read to the end, and that non-streaming records at handler completion; alternatively record e2e on the runtime completion path for both. Verified by reading the two arms; the streaming early-disconnect case would need a test.
#3 [medium] Note: first_scheduled_ns is also stamped by GraphKind::Vision lanes
metrics.rs:452-480 request_completed divides decode / u64::from(generated_tokens - 1) for flare_time_per_output_token_seconds. decode is last_token_ns - first_token_ns, i.e. the interval between the first and last committed token. With exactly two tokens the denominator is 1, so TPOT equals the full first→last interval, which is correct-ish; with N tokens it divides by N-1, correct.
However at runtime.rs:1773-1775 the stamps are set inside the per-token loop only for tokens whose active[slot] entry matches a.request == token.request, and last_token_ns is overwritten for every emitted token of that request, including tokens that are then discarded by a stop (stopped.push + continue at 1780-1795 for reasoning/grammar failures, and 1822-1828 for emit_output failure). For a request that fails mid-step the stamps are updated but request_completed is never called, so no divergence in output — the observation is simply skipped, consistent with the doc.
Real edge found: reserve_and_pack (runtime.rs:2187-2203) stamps first_scheduled_ns for lanes of a GraphKind::Vision step too (it loops all step.lanes before the kind == Vision branch). A vision step is not a generation step that "includes the request" for prefill purposes, so for an image request the queue time ends at the vision step rather than at the first prefill step, making flare_request_queue_seconds understate queue delay and flare_request_prefill_seconds absorb the vision work. Worth confirming against how vision lanes are scheduled; the doc says "the first model step that includes the request", which the vision step arguably is, so this may be intended — flag as a question, not a defect, unless the lane kinds say otherwise.
#4 [medium] Nits/notes: process.rs parse heuristics and non-Linux compilation
process.rs:22-31 parse_stat splits on the last ). /proc/self/stat command name cannot contain )? It can — the comm field is parenthesized and may contain ) and spaces; the kernel does not escape them, so taking the last ) is the standard heuristic but is wrong for a process whose name itself ends with ) plus following text (e.g. comm == "a) b" gives tail from the inner )). This is a documented upstream ambiguity (proc(5) says use the last )); it only affects the metrics, never panics, and a misparse would shift all five fields consistently — but parse_stat returns Some rather than None in that case, so the reported CPU/memory would be wrong rather than omitted. The module doc claims a malformed file omits the metric; a systematic offset in the tail is not detected. Low practical impact (flare's own comm is fixed), so nit at most.
process.rs:65-67 process_open_fds counts entries of /proc/self/fd, and the read_dir handle itself is one of them — the code acknowledges this in the HELP text ("including the directory read that counts them"). Prometheus' client_golang excludes it, so the number is +1 relative to the conventional series. Since the HELP text says so, this is a documented deviation, not a defect; worth a nit only if parity with the standard exporter matters.
process.rs:79-114: process_cpu_seconds_total and process_start_time_seconds use (stat[0] + stat[1]) as f64 / ticks as f64; u64 addition can overflow only after ~2^64 ticks, not reachable. rlim_cur is printed via Display for rlim_t, fine.
process.rs:12-13 #[cfg(not(target_os = "linux"))] let _ = text; compiles on Windows — the functions parse_stat, parse_btime, metric, render_linux are all cfg(target_os = "linux"), and libc is a non-optional dependency in helios/Cargo.toml:50, so the non-Linux build of this module references no libc item. The Windows build was not run by the author (stated), but nothing in this file introduces a Windows-only compile error; libc::rlimit/getrlimit/RLIMIT_NOFILE are inside the Linux cfg. No blocking platform finding. Note helios/src/os.rs and dashboard.rs already use libc under unix cfgs, so precedent exists.
#5 [medium] Verified-correct items and evidence limitations
-
Cherry-picked base. Author states the branch was built on the AzallazA fork commit
5ffe4d54, cherry-picking this change because that model needs the fork's Engram encoding (upstream PR #482). The live-scrape evidence therefore exercises this diff on a fork, not onmain; the conflict resolution "kept only the added function". This is disclosed, so not a defect, but the merge-risk claim ("merges in either order" with #537) is asserted, not tested — CI on head has no checks (orientation packet) and the author did not run the full helios suite or Windows build. -
Prompt-token histogram includes tokens reused from the prefix cache (metrics.rs help text; docs/api.md).
prompt_tokensat runtime.rs:1838-1839 iscarried.prompt_tokens.unwrap_or(live.prompt_tokens), which is the full prompt length including reused tokens — consistent with the documented wording. Fine. -
Flare_time_to_first_response_secondshistogram lives inFirstResponseSamples(latency.rs:34-37) rather thanMetrics, so it is not exposed in the JSON snapshot (server.rs:645-658 returns before render_histogram) — consistent with docs "histograms appear only in the Prometheus text".render_histogramis called at server.rs:671 after the median gauge, before input metrics; no duplicate series names (checked: no otherflare_time_to_first_response_seconds). -
Histogram rendering emits
# HELP/# TYPEand buckets in ascending bound order with cumulative counts from per-bucket atomics;+Infbucket equals total, and_countuses the same cumulative value, so consistency holds even under concurrent observation only approximately (a concurrent observe between the last bucket load and the_countline cannot happen becausecumulativeis reused). Sum usesu64nanoseconds, so a >584-year total would wrap; irrelevant. -
Metrics::request_completedis called at both formercompleted.fetch_addsites (runtime.rs:1841 user/text stop incomplete, runtime.rs:1993 natural finish inpublish); grep confirms no remaining directcompleted.fetch_addin helios/src/server. Counter and histograms therefore cannot diverge for completed requests. Verified against main: the only two sites on main were runtime.rs:1832 and 1984. -
Bucket boundaries:
position(|bound| exposed <= bound)with the last bound infinite guarantees an index;unwrap_or(N-1)is unreachable.0.1etc. are exactly representable enough that100_000_000 ns → 0.1 slands in thele="0.1"bucket (test assertsle="0.1"is 0 for 169 ms... actually asserts 250 ms inle="0.25"and 0 inle="0.1"), matching Prometheus convention.
#8 [medium] Rules cited and evidence-limitation notes
Rules the review should cite:
- charter (read_charter): "Supported matrix & compatibility — Check interactions across every supported model, cache scheme, parallel layout, multi-host setup, and hardware target named in the docs." and "PR descriptions: Expect four parts: why, what changed, the claimed result, and the evidence."
- AGENTS.md:182-186 "Reject weakened guarantees… Do not remove validation, suppress errors…" (relevant only insofar as the docs claim an invariant the code does not hold).
- AGENTS.md:194-199 "Require focused, meaningful validation… Identify missing hardware, inputs, and unrun checks explicitly."
- docs/design-review.md principle 12 "Validate the real path and report evidence honestly… keep raw measurements and disclose unrun checks and material limitations."
Disclosed limitations in the PR description (accurate as far as I could check): Windows build not run; full helios suite not run; messages_image_hints_end_after_expansion_for_text_and_segmented_templates not run (needs FLARE_TEST_TEMPLATE_DIR from tests/frontend/prepare_templates.py). Live scrape was taken from a cherry-pick of this diff onto AzallazA fork commit 5ffe4d54 (upstream PR #482 dependency), not on main, and that instance also served the authoring agent's own requests, so the reported deltas exceed the three test requests — stated plainly in the description. CI on head ebecef1 has no checks (orientation packet). The claim that this PR and #537 "merge in either order" is asserted, not tested: they touch different functions in metrics.rs (request histograms beside the completion counter here; page gauges beside cached_pages there).
Also worth stating in the report: the author's own histogram observation buckets in the live scrape are consistent with the three-request window only after allowing for session requests (le="64" gained 1, le="2048" gained 4), which the description explains; nothing in that evidence contradicts the code reading.