#1 [high] Change: what PR #692 actually changes (verified against diff)
PR #692 (jcartu), head 348c06c, base main (branched at c513e46), open, ready for review, 4 files +1068/-32, no reviews, no CI checks. Files: helios/src/server/runtime.rs (+443/-15), helios/src/server/runtime/phase_tests.rs (+585/0), helios/src/server/http.rs (+20/-9), helios/src/server/protocol/decisions/mod.rs (+20/-8).
Mechanics (verified in the diff and head files):
- New
RequestOutcomein helios/src/server/runtime.rs:109-296:Arc<AtomicU8>with states PENDING/GENERATED/READER_DROPPED/COMPLETED/CANCELLED/FAILED plus adefer_completionflag; each ofrecord_generated/record_completed/record_cancelled/record_failed/on_reader_dropCASes into an absorbing terminal state and does exactly onemetrics.{completed,cancelled,failed}.fetch_add. Generationgainsoutcomefield pluscomplete_output()(runtime.rs:348-350) andfail_output()(runtime.rs:352-357: record_failed THEN cancel());Drop for Generationcallsoutcome.on_reader_drop()then cancel (runtime.rs:378-383).Incominggainsoutcomeandrecord_cancelled()(runtime.rs:550-552); newIncoming::emit_finished()(runtime.rs:553-582) replaces the twometrics.completed.fetch_add+emit(Finished)sites in the worker (old lines at diff hunks ~2290 and ~2576): it returns early if a failure is already recorded, usesevents.try_reserve(); on Ok it callsrecord_generated()then sends Finished; on Closed it sets cancelled + record_generated(); on Full it callsself.fail(...)("generation exceeded its output event budget") + sets cancelled.Incoming::finish_error(runtime.rs:583-595) now callsoutcome.record_failed()BEFOREnotify_admission/first-token/event send (ordering is deliberate: HTTP may drop the receiver as soon as admission errors).- Worker cancellation sites now call
record_cancelled()instead ofmetrics.cancelled.fetch_add: runtime.rs:1647-1653 (pending retain), 1667-1671 (parked, before finish_cancelled), 1680-1690 (active slot), 1735-1740 (readmit). - New
ModelRuntime::generate_for_output(prompts, observation) -> Vec<Generation>(runtime.rs:1145-1151) sets defer_completion=true;generate/generate_manykeep false; removedgenerate_many_observed;generate_observedis now#[cfg(test)](runtime.rs:1131-1134); all funnel throughenqueue_many(..., defer_completion)` (runtime.rs:1153-1158). - http.rs: submission collapsed to
state.model.generate_for_output(prompts, observation)where observation =(continuous_usage || (token_ids && size==1)).then_some(observation.timestamps)(http.rs:328-334).fail_output()+decoders[i].abort(ExecutionError)added on every Delivery::Failed exit: first-token wait (http.rs:402-410), echo apply error (426-434), zero-token finish error (445-450 — note: this one only aborts the decoder, no fail_output call because those generations are None for zero-token choices), event-loop Err arm (582-590). OnGenerationEvent::Finishedthe taken generation is settledcomplete_output()on Ok /fail_output()on Err (http.rs:561-566). - decisions/mod.rs
score()now usesgenerate_for_output(vec![prompt], None)and settles complete/fail on every exit (decisions/mod.rs:838-886). - Tests: 2 unit tests in runtime.rs tests module (
outcome_terminal_budget_overflow_and_deferred_drop_orderings,outcome_concurrent_worker_and_consumer_transitions_record_exactly_one_metric— 2-thread Barrier, 128 iterations × 3×3 pairs × 2 defer modes, asserts exactly one counter increment) plus 4 new tokio integration tests appended to helios/src/server/runtime/phase_tests.rs:8437-9020 (tool-call parse failure streams on chat/messages/responses; output failure after worker completion streaming+non-streaming+incomplete-at-EOS; client disconnect counted cancelled on 4 routes; normal completion across 4 routes × stream on/off and multi-choice n=2 failure/cancel accounting).
#2 [high] Why: issue #679 (filed same day) is the filed report this fixes
Issue #679 "Output-layer stream failures (tool-call parse rejection) are counted as cancellations; requests_failed_total stays 0", opened by ktsaou 2026-12-02 11:31, labels area:api, bug, priority:P2, triage:investigate, no discussion yet. PR #692 opened the same day and declares "Fixes #679" (read_item 679 shows #692 in "Referred to by" as fixes).
Evidence in the issue: engine main at a3c80e19 + two unrelated local patches, Qwen3.8-Flash-Next gb202 TP2, streaming Chat Completions with ChatML tool calls. Two server_error journal lines ("tool parameter names must be nonempty and unique", stage=stream) at 09:00:39 and 09:43:50; counters over the same period: completed 9046, cancelled 2, failed 0, with each cancelled increment 1 s after a journal line. An earlier occurrence on 2bdc8472 was a Responses stream ending "tool function requires parameter or closing tag".
Issue's code trace at a3c80e19: chatml.rs:136 rejects empty/duplicate parameter name → server/output.rs:359-364 aborts with Termination::ExecutionError → http.rs stream arm yields Delivery::Failed and drops receiver → runtime emit() sees TrySendError::Closed and sets cancelled (runtime.rs:387-388 at that revision) → counted at metrics.cancelled.fetch_add (runtime.rs:1402/1423/1442/1493) → metrics.failed only incremented in finish_error (runtime.rs:357).
The issue explicitly says "Failing the request is the right behaviour, and this issue does not ask to change it. The bug is only the outcome accounting." It asks only that output-rejected failures not appear as cancellations.
Related cited in the issue: #133 (closed, GLM sibling symptom, report-only), #548 (open; its review notes the parallel-tool-limit path where runtime says cancelled but HTTP completes), and #549 (unrelated local patch).
docs/api.md:330 documents completed = "Requests whose generation completed successfully"; docs/api.md:332 documents failed = "Requests failed by admission, execution, grammar, or output processing"; helios/src/server/metrics.rs:1093 HELP string says the same for requests_failed_total, and metrics.rs:1078 says completed_total = "Requests whose model generation completed successfully, including explicit token stops"; metrics.rs:1088 cancelled = "Queued or active model requests cancelled before completion." So the code was already documented as intending failed for output-processing failures.
#3 [high] Research summary
Summary of the case file for PR #692
The change (verified against the diff). PR #692 (jcartu, head 348c06c, base main, branched at c513e46, "ready for review", 4 files +1068/−32, no reviews, no CI checks on the head commit) adds a shared RequestOutcome state machine to helios/src/server/runtime.rs:109-296 — an Arc<AtomicU8> shared by Incoming (worker) and Generation (consumer) with states PENDING/GENERATED/READER_DROPPED/COMPLETED/CANCELLED/FAILED, where every transition CASes into an absorbing terminal state so exactly one of metrics.{completed,cancelled,failed} increments once per request. Completion moves out of the worker's stop path: two metrics.completed.fetch_add + emit(Finished) sites become Incoming::emit_finished() (runtime.rs:553-582), which reserves a channel slot with try_reserve() first and fails the request (rather than completing it) on Full. All four worker cancellation sites now call record_cancelled() instead of touching the counter directly (runtime.rs:1647-1653, 1667-1671, 1680-1690, 1735-1740). finish_error records FAILED before notifying admission/first-token/event channels (runtime.rs:583-595). A new deferring entry point ModelRuntime::generate_for_output (runtime.rs:1145-1151) parks worker completion in GENERATED until the consumer calls Generation::complete_output() (:348) or fail_output() (:352, record-FAILED-then-cancel), or drops the Generation (Drop → on_reader_drop, :378-383). HTTP submission collapses to a single generate_for_output call (http.rs:328-334, removing the generate_many_observed/generate_observed branches; generate_observed is now #[cfg(test)]), and fail_output() + decoders[i].abort(ExecutionError) are added on every Delivery::Failed exit (http.rs:402-410, 426-434, 445-450, 582-590), with complete_output()/fail_output() settling the taken generation on Finished (http.rs:561-566). Decision scoring switches to the same entry point and settles on every exit (decisions/mod.rs:838-886). Tests: two unit tests in runtime.rs (terminal budget overflow / deferred drop orderings, and a 2-thread Barrier test asserting exactly one counter increment across all worker×consumer pairs and both defer modes) plus four HTTP-to-Worker integration tests appended at phase_tests.rs:8437-9020 (ChatML duplicate-parameter rejections on chat/messages/responses; mid-stream and at-EOS failures after worker completion, streaming and buffered; genuine client disconnects on four routes; normal completions across four routes × stream and a n=2 failure/sibling-cancel case).
What the description does not say, and vice versa. The description does not mention that generate_observed loses its non-test visibility, that the observation plumbing in http.rs is re-expressed via .then_some(...), or that the decisions score() path is also converted and its mid-loop ok_or_else replaced by explicit fail_output() branches. Conversely, the description's claim that worker fail-then-cancel double counting is fixed matches the code: emit_finished/emit's Full arms still set cancelled, but record_cancelled can no longer reach an absorbing FAILED. The description does not say that docs/api.md/metrics.rs HELP text is left unchanged — but that text already promised exactly this behaviour (docs/api.md:332, helios/src/server/metrics.rs:1079,1088,1093), which supports the "no doc change needed" choice.
Why. Issue #679 (ktsaou, 2026-12-02 11:31, labels area:api/bug/priority:P2/triage:investigate, zero comments) is the operator report: two server_error frames from the ChatML parser tracked by two 1-second-later cancelled increments with failed at 0, at main a3c80e19. It explicitly says failing is correct and only the accounting is wrong, and it points at the same call chain the PR edits. #679 also cites #133 (closed; GLM sibling parser rejections, which turned out to be prepared-graph corruption fixed by #129 — so #133 is not the same defect as #679, despite the issue linking it) and #548.
Related work. Overlapping files: #548 and #560 (open, WynnD) both rewrite the same completion/cancellation accounting in runtime.rs — #548's review by lukealonso already flagged the parallel-tool-limit path where "runtime metrics count the request as cancelled rather than completed, despite the successful API response" (documented at docs/api.md:700-702), which #692 changes behaviour around without editing that doc; #560 stacks on #548 and touches the same GenerationEvent::Finished sites. #691 (same author, same day) changes the first_token oneshot payload to Result<u64> on the same Incoming/Generation structs #692 just extended with outcome — a likely textual conflict. #689 (same author) also touches http.rs+phase_tests.rs. #562/#552 (closed) and #560 are earlier attempts at the same metrics area. The ResponseLifecycle conformance harness in response_lifecycle_tests.rs drives generate_many/emit/cancel directly, which is why the PR keeps direct completion semantics for generate_many.
Evidence. The PR reports 1,884 helios tests passing, 254 flare, 245 flare-cli, and a full verification/helios-lifecycle/check.py (not opened) --mutations run (365,508 transitions against ResponseLifecycle.tla, 26 Rust guard mutations detected). None of that is verifiable from here — CI reports no checks on 348c06c. The lifecycle conformance is significant because docs/design-review.md (Layer 3, per lukealonso's review on #548) makes it mandatory for changes to worker admission/completion/publish/park paths, which this PR rewrites; the description names the run, and the accounting change is not reflected in any new TLA+ or conformance action. Not run: GPU-gated tests and live serving.
Project fit and reach. Charter line 9 ("solve the right problem in the right place") and the "bring real evidence / root cause" rule fit: this is a metric-attribution defect with an operator repro. Reach: /metrics consumers only (no request/response wire change, no config, no defaults). Behaviour that does change: mid-stream output failures now log failed not cancelled; deferred (HTTP/decisions) requests whose reader drops after the worker finished but before validation now count cancelled where they previously counted completed; a parallel_tool_calls: false cancellation still counts cancelled while the API returns 200, contradicting docs/api.md:700-702's wording only if the drop lands in GENERATED. tests/server/test_protocols.py:676 (cancel-count assertion) and tests/server/test_decisions.py:230-261 (decision-disconnect cancels) are the Python integration checks whose expectations this shift most directly depends on; they were not run in the stated evidence.
Process/community. Opened today, ready for review, no reviews, no comments, no CI, no labels; a third of a same-day batch from jcartu (#687-#693). Nothing has engaged with it yet. All detailed findings are in the scratchpad (entries 1-2 are the verified change map and the #679/why/documented-contract note).
#4 [high] Related work: overlapping PRs on the same completion/cancellation accounting
Overlapping open/closed PRs (related_items on 692 returned these as same-file changes; all verified via read_item/search):
- #548 (open, WynnD) "Add per-request histograms and vLLM-parity request metrics", +1383/-124, same 3 files (http.rs, runtime.rs, phase_tests.rs). Its history matters: lukealonso's 2026-11-28 review and Autobot's 2026-11-26 review both flagged exactly the split #692 now fixes — "On the parallel-tool-limit path (http.rs:471-476, :526, :563-567) the terminal event still reaches Delivery::Complete (:598) while the runtime only bumps cancelled/finish_cancelled (runtime.rs:293-302, :1317/:1338/:1360/:1407)". So the "runtime says cancelled, HTTP says success" divergence was already known in #548's review thread; #692 changes the accounting machinery #548 builds on. #548 cannot merge before or after #692 without rebasing (both rewrite
metrics.completed/cancelledsites andGenerationEvent::Finishedemission). - #560 (open, WynnD) "Emit vLLM-compatible per-request metrics from runtime instants", +2185/-163, explicitly stacked on #548 ("Depends on #548", "the branch stacks all of #548"). It adds
RequestTimestoGenerationEvent::Finished— the same event #692'semit_finishedconstructs — and touches runtime.rs/http.rs/phase_tests.rs. Rebase conflict likely; no supersede either way. - #691 (open, jcartu, same author, opened same day) "helios/server: report reused prompt tokens in continuous_usage_stats chunks", fixes #448. Changes the
first_tokenoneshot channel fromResult<()>toResult<u64>on the veryIncoming/Generationstructs #692 extended with theoutcomefield, and addsIncoming::observe_token_with/Generation::has_pending_first_token. Direct textual conflict; #692 also touches the samewait_for_first_tokencall site in http.rs (402-410). Note #692 callsgeneration.fail_output()there beforelet frame = encoder.failure(&error). - #689 (open, jcartu) typed error codes on HTTP preparation failures — same http.rs/phase_tests.rs area, no accounting overlap.
- #562 and #552 (closed, WynnD) earlier per-request-timing attempts superseded by #560/#548.
- #111 (closed) older metrics PR touching the same 4 files.
- #541 (open, jere357) Prometheus/Grafana example; its Autobot review notes the dashboard plots only completed and failed, not
flare_requests_cancelled_total— relevant to why mis-attributed cancellations are invisible on the shipped dashboard.
Why #133 is not the same bug: #679 links #133 (GLM argument-tag rejections, report-only) as a sibling, but #133's close-out (eduffd, 2026-10-28/11-05, closed 2026-11-08) traced those rejections to prepared-graph storage lowering, fixed by merged #129 and by re-exporting the package; original-el8's close-out explicitly says "Malformed tool calls from otherwise valid model output remain a separate parser/API concern." So #679/#692 is the accounting defect for genuinely malformed output, not the #133 graph defect.
#5 [high] Claims and evidence: what #692 asserts and what actually backs it
Claimed: helios --release --features runtime-core,server 1,884 passed / 0 failed / 84 ignored (lib 1,822 passed/47 ignored; 14 integration binaries 62 passed/37 ignored); flare 254 passed/4 ignored; flare-cli 245 passed/3 ignored; verification/helios-lifecycle/check.py --mutations exit 0 with all 8 TLA+ models, 365,508 Rust transitions against ResponseLifecycle.tla (states=65989 edges=365508 depth=10), 13 TLA+ mutations, 26 Rust guard mutations and 1 observed-edge safety violation (DispatchRing SlotReuseSafe) detected. All run on Linux CPU with chat templates from tests/frontend/prepare_templates.py via FLARE_TEST_TEMPLATE_DIR and a 512 MiB locked-memory limit (they say parallel Engram staging tests exceed 64 MiB when all unit tests run concurrently).
What backs it: nothing verifiable from the repository — CI on head 348c06c reports no checks (orientation packet). The counts are self-reported; the test code they point at does exist and is substantial (2 unit tests incl. the 2-thread Barrier exactly-one-counter test; 4 tokio HTTP↔Worker integration tests at phase_tests.rs:8437-9020). No benchmark/performance claims are made, so the charter's benchmark rule does not bite.
Why the TLA+ run matters: lukealonso's #548 blocker #1 cites docs/design-review.md Layer 3 requiring verification/helios-lifecycle/check.py plus --release tests whenever Worker admission/completion/publish/park paths or RequestScheduler::admit_planned_with_checkpoint_accounting change; #692 rewrites completion/cancellation inside the worker, so that gate applies. The PR reports the run but adds no new TLA+ action or conformance transition for the outcome state machine — the ResponseLifecycle harness (helios/src/server/runtime/response_lifecycle_tests.rs:100-195) drives generate_many/emit/cancel/fail directly and therefore only exercises the non-deferred (defer_completion=false) half of the new state machine.
Not run, disclosed: 84 ignored helios / 4 flare / 3 flare-cli checkpoint- and GPU-gated tests, live GPU serving via flare run, Kani harnesses (description says no completion-vector/state-view validators were touched). Not disclosed as unrun: the Python tests/server/*.py integration suites (e.g. tests/server/test_protocols.py:676 asserting cancelled increases on n=4 disconnect; tests/server/test_decisions.py:230-261 asserting decision disconnects increment cancelled; tests/server/test_deepseek41.py:78-79 and tests/server/test_scheduler.py:176-177 asserting failed stays flat while completed rises), which are the closest existing coverage of the counters whose semantics this changes.