Key findings
Lens D (simplicity: what can be deleted). The change is mostly additive and lean — no fallback layer, no config switch beyond the requested flag, no parallel render path. Three things can be deleted or shrunk:
- should fix —
Timing::streaming(helios/src/server/protocol/encode.rs:79-80) is dead state and its guard inrecord_commit(:255-261) can never reject a call. Delete the field and the guard. - should fix —
ModelRuntime::generate_observed(helios/src/server/runtime.rs:847-849) is a third admission entry point identical togenerate_many_observedwith a one-element vec, kept alive by one call site (helios/src/server/http.rs:368-372). Delete it; that also lets the privateenqueuewrapper (:851-854) collapse intogenerate. - should fix — the new encoder tests (
helios/src/server/protocol/tests.rs:2317-2491) re-assert behaviour the served-worker phase tests already prove (helios/src/server/runtime/phase_tests.rs:4693-4797), including two assertions that are strictly weaker than HTTP-level ones; ~50 lines and two full worker runs can go while keeping the cases only the encoder can cover.
Plus two nits (a magic 6 in a key-count assertion, and a doc comment that restates docs/api.md).
Nothing in this lens is blocking. Everything below was checked in the code at head ce44060.
should fix — Timing::streaming is dead state; the record_commit guard is unreachable
Where: helios/src/server/protocol/encode.rs:79-80 (field), :244-253 (enable_request_metrics sets it), :255-261 (record_commit guard), :543-551 (only reader, via step_ns).
What is wrong: enable_request_metrics returns
streaming && matches!(self.metrics, Some(RequestMetrics::Single(_)))
(encode.rs:252), and http.rs:363 only sets commits when that returns true:
let commits = state.per_request_metrics && encoder.enable_request_metrics(decoded.stream);
GenerationEvent::Committed is emitted only for requests submitted with commits (runtime.rs:101-110 documents that), and record_commit is its only consumer (http.rs:527-530). So every call to record_commit reaches an encoder whose metrics is Single(_) and whose Timing::streaming was set from the same streaming == true. The && timing.streaming clause at encode.rs:257 therefore never rejects a call: it is unreachable-false. step_ns is written nowhere else and read only at :546-551 to stamp content_ns, so the field has no other use. It is a second copy of "is this a stream" that cannot diverge usefully.
Why it matters: it is dead state and an unprovable branch on the per-step path the PR specifically claims is cheap when the option is off (Committed handling), and it costs a reader time to prove the guard is unreachable. AGENTS.md:188-193 rejects switches and structure without a concrete requirement.
Fix: delete the field and the clause; the smaller version is
pub fn record_commit(&mut self, at_ns: u64) {
if let Some(RequestMetrics::Single(timing)) = &mut self.metrics {
timing.step_ns = Some(at_ns);
}
}
and drop streaming from the Timing { streaming, ..Timing::default() } literal at :250.
Correction to the obvious stronger version: do not also drop the streaming parameter of enable_request_metrics in favour of Encoder::streaming (encode.rs:97). Encoder::streaming is only ever written by set_logprobs (:190-193), which needs a Frontend (Arc<crate::frontend::Frontend>); the encoder tests construct encoders through metered() (tests.rs:2317-2331) and never call set_logprobs, so they would have no way to set streaming. The parameter also feeds placed at :245. Keep it; delete only the duplicate field.
should fix — generate_observed is a redundant third admission entry point
Where: helios/src/server/runtime.rs:843-869.
What is wrong: the three public entries are
generate(:843-845) →enqueue(prompt, None, false)generate_observed(:847-849) →enqueue(prompt, Some(timestamps), commits)generate_many_observed(:862-869) →enqueue_many(prompts, observation, commits)
with enqueue (:851-854) being enqueue_many(vec![prompt], …).map(|mut g| g.remove(0)). generate_observed is therefore exactly generate_many_observed(vec![prompt], Some(timestamps), commits).map(|g| g[0]). Its only non-test caller is http.rs:368-372:
} else if observation.token_ids && size == 1 {
state.model.generate_observed(prompts.remove(0), observation.timestamps, commits)
.map(|g| vec![g])
which immediately re-wraps the single Generation in a vec![] — so the caller's shape is Vec<Generation> either way.
Why it matters: this PR pays for the wrapper three times: it threads commits through generate_observed, through the private enqueue, and updates two test call sites (phase_tests.rs:3749, :3803) that exist only to exercise the wrapper. It is one of three parallel admission spellings the http handler chooses among, and prompts.remove(0) at position 0 of a Vec that is then dropped is pure ceremony. AGENTS.md:188-193 ("reject unsupported abstractions and churn … refactoring must … remove a demonstrated source of defects or cost") supports deleting a wrapper with one caller.
Fix: at http.rs:368-372 call state.model.generate_many_observed(vec![prompts.remove(0)], Some(observation.timestamps), commits); delete generate_observed. Then enqueue has a single caller (generate, :843-845), so inline it:
pub fn generate(&self, prompt: Prompt) -> Result<Generation> {
self.enqueue_many(vec![prompt], None, false).map(|mut group| group.remove(0))
}
and delete enqueue. Net: two functions and their commits plumbing removed; generate/generate_many remain for the option-off path (decisions/mod.rs:838 (not opened), response_lifecycle_tests.rs:122), generate_many_observed for everything observed.
should fix — the new encoder tests re-prove what the served-worker tests already prove
Where: helios/src/server/protocol/tests.rs:2317-2491 (new) against helios/src/server/runtime/phase_tests.rs:4693-4743, :4746-4797, :4800-….
What is wrong: four new/updated tests cover overlapping ground:
per_request_metrics_follow_vllm_placement_and_null_rules(tests.rs:2346-2444) asserts the carrier frame is unique,choices == [],usagepresent,response.completed, the null rules for messages/n>1/multi-prompt/missinginclude_usage, and the single-token null — the same placement and null contract.per_request_metrics_reach_completions_and_responses_where_vllm_places_them(phase_tests.rs:4746-4797) re-asserts the same carrier shape over HTTP:carrier["choices"] == json!([])(:4778) andcarrier["type"] == "response.incomplete"(:4780).content_instant_excludes_reasoning_tool_calls_and_suppressed_text(tests.rs:2456-2484, first half) asserts that reasoning and a tool call before the text do not set the content instant and thattime_to_first_content_token_msis two steps after TTFT;per_request_metrics_report_the_runtime_instants_of_a_stopped_reasoning_answer(phase_tests.rs:4693-4743) proves the same thing through the real worker, includingwithin(generating[2], served.content_ns.unwrap())and the>comparison (:4733-4734).per_request_metrics_are_absent_without_the_option_and_null_for_several_choices(phase_tests.rs:4800+) covers the flag-off andn = 2nulls at HTTP level, duplicatingtests.rs:2390-2400and:2425-2444.
What is genuinely unique is: exact numeric values and the all-null shape (encoder only); the named-tool-choice suppression (encoder only, tests.rs:2476-2491) and the tool-call/empty-content skipping inside one step; instant provenance inside worker steps and commits == stream (phase tests only, phase_tests.rs:4711, :4728-4737); the output-limit response.incomplete case (phase tests only, :4780).
Why it matters: AGENTS.md:194-199 requires tests to exercise the affected behaviour; the duplicated half of each pair exercises the encoder, not the layer it claims to test, and each served_through_worker run drives a whole fixture worker step by step. Two of the duplicated assertions (choices == [], response.incomplete) are strictly weaker than the encoder test's, so they add no coverage. AGENTS.md:191-192 also names test expansion as churn when it does not support the requested behaviour.
Fix: keep per_request_metrics_follow_vllm_placement_and_null_rules as the placement/null/value authority and in per_request_metrics_reach_completions_and_responses_where_vllm_places_them drop the carrier["choices"] == json!([]) / carrier-shape match at :4777-4782 (keep the response.incomplete arm) and the time_to_first_content_token_ms == time_to_first_token_ms equality at :4791-4794, keeping the generation/ttft/queue reconciliation. In content_instant_excludes_reasoning_tool_calls_and_suppressed_text, delete the reasoning-only first half (tests.rs:2457-2474); it is covered by phase_tests.rs:4693-4743. Keep the tool-call and named-tool-choice cases, which nothing else covers. Roughly 40-50 lines and one duplicated served-worker scenario.
nit — magic key count in the encoder test
Where: helios/src/server/protocol/tests.rs:2444-2446.
assert_eq!(unrecorded.as_object().unwrap().len(), 6) couples the test to a literal that has to be kept in step with the six keys spelled two lines earlier at :2353-2360 in the expected closure. Assert equality with the all-null object built from the same key list, e.g. assert_eq!(unrecorded, expected(Value::Null).as_object().map(|_| json!({...all nulls})).unwrap()), or simply build the all-null literal once and compare — then adding a field breaks one place, not two.
nit — the code doc comment restates the docs
Where: helios/src/server/protocol/encode.rs:238-243.
The comment enumerates placement for all four protocols, the multi-prompt omission, and the several-choice null. All of that is stated again, as prose and as a table, in the new ## Per-request metrics section of docs/api.md (added in this diff, ~50 lines), and partly again in enable_request_metrics's own body at :245-251 where it is executable. AGENTS.md:190-192 lists comment expansion as not a contribution by itself.
Fix: keep only the invariant a reader cannot infer from the code — that this decision is also what tells the worker whether to send commit instants — e.g.:
/// Places vLLM's per-request `metrics` (see docs/api.md) and returns whether the
/// content instant applies, i.e. whether the worker must send `Committed` events.
The placement and null rules live in docs/api.md; do not maintain a second copy here.
Checked and not reported (no deletion found in this lens)
RequestMetrics::{Suppressed, Single}(encode.rs:68-72) versusOption<Option<Timing>>: the named variants are the clearer of the two spellings for a three-state outcome (omit / null / object) and cost nothing; not a finding.metrics_value(encode.rs:270-294) builds all six keys withOptionmaps — no fallback path, no second render loop, no duplicated formatting.Bucket/Histogram(metrics.rs:211-300) already unify the render loops andpublish_gauges(runtime.rs:1227-1237) de-duplicates the two gauge stores; both are in the stacked #548 half and are the smaller version already.flare-cliflag plumbing (flare-cli/src/cli.rs:532,:646-649,:694-697,:725,:856-861,flare-cli/src/main.rs:355-357) is one three-line block per struct plus one conditional forward, mirroring--bypass-performance-check;config["per_request_metrics"]is only written when true, matching the "no config key" decision in the description. Nothing redundant.Bootstrapkey handling (helios/src/server/config.rs:353-357) is the minimal four-arm match and rejects non-booleans; no parallel parse path.output_event_capacity(runtime.rs:62-79) keeps one multiplication1 + observed + commitsinstead of a branch per flag; that is already the compact form.http.rs:412-413generated/first_scheduled_nsscratch values: both are needed because theFinishedhandler runs inside the stream generator while the post-loop body renders the response; no duplicate bookkeeping.
What could not be settled from code alone
- Whether the duplicated HTTP-level carrier assertions in
phase_tests.rs:4777-4782were added deliberately as an end-to-end guard against the encoder and the handler drifting apart. If a maintainer wants that guard, the finding shrinks to thetests.rs:2457-2474half only. A comment on the test stating that intent would settle it; nothing in the code does. - The
docs/api.md### Correspondence with vLLM metricstable (~35 rows, many "Not provided") belongs to the stacked #548 diff and is a docs-ownership question, not a code-simplicity one, so it is out of this lens. Its size is defensible if maintainers want the parity record in one place.