Opened by a workflow run, Dec 2, 2026 4:24 PM EST. decide malicious: all_clear (100%): No malicious content found
explore
Author: jcartu (CONTRIBUTOR; 3 merged, 10 open PRs in 180 days, mostly docs and helios/src; part of a seven-PR same-day batch #686–#693; Discord jcartu)
Motivation: When Helios' output layer rejects a generated response (e.g. a ChatML tool-call parser rejection), the model worker only sees the reader dropping and counts the request as cancelled, so flare_requests_failed_total stays at zero and operators see failures as user aborts. Issue #679 reported exactly that, with journal evidence, and says only the accounting is wrong, not the rejection behaviour.
Scale: +1068 / −32 lines in 4 files
Proposal:
- Add a shared
RequestOutcomeAtomicU8state machine betweenIncoming(worker) andGeneration(consumer) so exactly one ofcompleted/cancelled/failedincrements at most once, never decrementing a monotonic counter. - Move completion out of the worker's stop path into
Incoming::emit_finished, which reserves a channel slot first and fails the request (rather than completing it) on event-budget overflow. - Add
ModelRuntime::generate_for_output, which defers worker completion until the consumer callscomplete_output()/fail_output()or drops theGeneration(counted cancelled). - Wire
http.rsand the decisions scoring path to the deferring entry point and settle everyDelivery::Failedexit withfail_output()plus a decoder abort. - Add two unit tests (including a 2-thread Barrier exactly-one-counter test) and four HTTP↔Worker integration tests covering parser rejections, post-completion rejections, client disconnects and multi-choice. Touches:
- helios/src/server/runtime.rs — worker completion/cancellation semantics and a new shared state machine in the hot path
- helios/src/server/http.rs — submission entry point and every failure exit
- helios/src/server/protocol/decisions/mod.rs — decision scoring settlement Related items:
- #679 Output-layer stream failures counted as cancellations (open): the issue this fixes, with operator timeline evidence
- #548 Add per-request histograms and vLLM-parity request metrics (open): rewrites the same counter sites; its review already flagged a runtime-vs-HTTP divergence of this kind
- #560 Emit vLLM-compatible per-request metrics from runtime instants (open): stacked on #548, adds fields to the same
Finishedevent - #691 report reused prompt tokens in continuous_usage_stats chunks (open): same author, changes the same
Incoming/Generationstructs, direct conflict - #133 GLM tool-arg rejections (closed): linked by #679 but a different defect, fixed by merged #129
Link: https://github.com/NVIDIA/hyperflare-inference/pull/692
Autobot comments: The title understates the change: it replaces completion/cancellation accounting across all HTTP and Decisions traffic, not just the failing paths, and silently removes
generate_many_observedwhile makinggenerate_observedtest-only. No CI has run on head 348c06c and all test evidence (1,884 helios tests, thecheck.py (not opened) --mutationsrun) is self-reported; the Pythontests/server/*.pysuites that assert the current counter expectations were not run.docs/design-review.md:234-240makes TLA+/conformance update blocking for completion/cancellation changes, and theResponseLifecycleharness only models the non-deferred half of the new state machine, whiledocs/api.md:700-702still documents cancelled-on-success for the parallel-tool-limit path.
Value Proposition
Value Proposition — PR #692: count output-layer stream failures under requests_failed_total
Charter alignment — strong
The change fixes a metric-attribution defect reported by an operator (#679, priority:P2, with a journal timeline and a code trace at a3c80e19) and lands where the counters actually live. The documented contract already promised the fixed behaviour (docs/api.md:332, metrics.rs:1092-1095), so this closes a docs-vs-implementation gap rather than inventing a new contract. No per-model branch, no new flag, no default moved, no wire/schema change — so the "runtime stays small and model-agnostic" and "smallest footprint" rules are not engaged. Fixing the root cause (a single absorbing terminal outcome) instead of retrying or swallowing an error matches "bug fixes need to address the root cause (#397)." The description has all four required parts.
Novelty & status — additive
No commits on main since the branch point (c513e46) touch the four changed files, so this is not obsolete. #548/#560 (WynnD) rewrite the same counters for a different purpose (per-request histograms, vLLM-parity timing); neither addresses #679's attribution, so this is genuinely additive, not superseded. Notably, #548's review thread already flagged a "runtime says cancelled, HTTP returns success" divergence that #692 changes the machinery for while leaving docs/api.md:700-702 and the parallel_tool_calls: false path untouched.
Value vs maintenance cost — real, but expensive
Beneficiaries are /metrics and alerting consumers. Weakener: #541's shipped Grafana example plots only completed and failed, so both the bug and part of the fix are invisible on the documented dashboard; no performance claim is made either.
Cost is large for a metrics fix: +1068/−32, a new Arc<AtomicU8> state machine in the hot worker path, rewritten completion sites for all HTTP and Decisions traffic, and undocumented internal API changes (generate_many_observed deleted, generate_observed now #[cfg(test)]). No CI has run on 348c06c; all evidence is self-reported. The deferred half of the state machine — the half the PR exists for — has no conformance transition in ResponseLifecycle.tla/fixtures, which engages the blocking-design clause at docs/design-review.md:234-245. The Python counter assertions closest to this behaviour (tests/server/test_protocols.py:676, test_decisions.py:230-261) were neither run nor disclosed as skipped. Coordination risk is high: textual conflicts with #548, #560 and the author's own #691.
Verdict: Worth it with changes
Genuinely additive, correctly located and root-cause-driven. Before merge, require: CI green on head; the Python counter suites run (and updated if deferred completion shifts their expectations); an explicit statement on whether the new PENDING→GENERATED→{COMPLETED,CANCELLED,FAILED} transitions extend ResponseLifecycle or fall under the "no bound change" exemption; and a rebase plan against #548/#560/#691.
No prompt-injection attempt was found in the reviewed material.
Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.
Classify intake
Selected: triage:review, priority:P2, bug, area:api
Threshold: 65%
Triage
- [✓]
triage:review: 99.9% -
triage:design-review: 0.0% -
triage:investigate: 0.0% -
triage:partial: 0.0% -
none: 0.0% -
triage:integration: 0.0% -
triage:validation: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
- [✓]
priority:P2: 99.0% -
none: 0.8% -
priority:P1: 0.2%
Type
- [✓]
bug: 95.3% -
community: 37.8% -
duplicate: 26.9% -
performance: 0.9% -
enhancement: 0.2% -
documentation: 0.0%
Area
- [✓]
area:api: 98.8% -
area:scheduling: 4.2% -
area:selene: 0.8% -
area:preparation: 0.4% -
area:engram: 0.2% -
area:memory: 0.2% -
area:kernels: 0.1% -
area:rocenante: 0.1% -
area:orbit: 0.1% -
area:packaging: 0.1% -
area:caching: 0.0%
Model
-
model:qwen3.8-flash-next: 0.7% -
model:deepseek-v4: 0.1% -
model:kimi-k3.1: 0.1% -
model:mimo-v2.6: 0.1% -
model:muse-glimmer: 0.1% -
model:inkling-small: 0.0% -
model:nemotron-3.5-bolt: 0.0% -
model:qwen3.8-27b: 0.0% -
model:glm-5.3: 0.0% -
model:deepseek-v4.1: 0.0% -
model:gemma4: 0.0%
Apply Labels (Intake)
Applied: +triage:review, +priority:P2, +bug, +area:api
Subtraction and simplicity
Subtraction/Simplicity review of PR #692 (helios outcome accounting). The diff is mostly principled and adds no config knob, env var, or compatibility shim, but it carries four clearly removable pieces of complexity.
S1 — six hand-rolled CAS loops differing only in constants (high). runtime.rs:138-295 repeats the same load/compare_exchange_weak loop; record_completed (:191-212), record_cancelled (:214-235), record_failed (:237-258) and the GENERATED arm of on_reader_drop (:275-291) differ only in the accepted from set, target state, and which AtomicU64 counter is bumped (metrics.rs:228-231). One settle(&self, from: &[u8], to: u8, counter: &AtomicU64) turns ~150 lines into ~40 with identical semantics.
S2 — delete defer_completion and the non-deferred half (high). The flag (runtime.rs:123-126) is threaded into enqueue_many (:1153-1158) and produces four branches in record_generated (:143-147, :155-157, :164-168, :176-180). Its only true callers are the two production entry points (http.rs:333, decisions/mod.rs:840); every false caller is a test (phase_tests.rs:3770/3784/3824/3857/3864/3869, response_lifecycle_tests.rs:122). Collapsing it also puts the TLA conformance harness on the deferred transitions docs/design-review.md:209-240 (not opened) cares about. This is the one AGENTS.md:188-193 hit (switch with one live value).
S3 — copied event-budget overflow arm (medium). runtime.rs:574-580 and :626-634 are byte-identical including the error literal at :577/:631; extract one event_budget_exceeded(). The duplicate is new code from this PR.
S4 — Incoming::record_cancelled forwarder (runtime.rs:550-552) with asymmetric call sites (low-medium). Three sites pair it with finish_cancelled (:1670-1671, :1683-1684, :1738-1740), the pending-retain site (:1650) does not; fold the recording into finish_cancelled (:523-532) and drop the forwarder.
Observation only: the new integration tests repeat for _ in 0..200 { admit(); sleep(2ms) } seven times (phase_tests.rs:8645, 8714, 8789, 8832, 8886, 8936, 8997) where existing fixtures use recv_timeout(5s) (:4487), and worker_for_http_state (:8467) duplicates Fixture::worker (:154). Also, the PR description omits that generate_observed became #[cfg(test)] and generate_many_observed was deleted.
Open: whether S2 is wanted given the author's stated intent to keep immediate completion for non-HTTP callers (no in-repo consumer found), and whether the polling loops should be replaced.
Correctness and contracts
PR #692's RequestOutcome state machine is mechanically sound — six absorbing states, exactly one counter increment per request, no decrements, no new locks on the hot path — and it genuinely fixes #679's failed/cancelled mis-attribution. The problems are contract and verification, not the CAS logic.
Findings, most important first:
- Major — metric contract drift:
flare_requests_completed_totaland_cancelled_totalsilently change meaning for HTTP and Decisions traffic, and now mean different things per entry point, while HELP text and docs still say "model generation completed" (metrics.rs:1077-1089,docs/api.md:330,runtime.rs:143-147,:260-295,:1136-1151). - Major — formal gate: the PR adds six protocol states and changes cancellation/completion transitions but extends no TLA+ action or conformance fixture for the deferred half; the harness drives only
generate_many(defer=false) and emits terminal events throughemitrather than the newemit_finished, so it cannot observe the transition the PR exists for (response_lifecycle_tests.rs:122,:151-165;docs/design-review.md:234-246calls this a blocking design failure). - Minor —
emit_finished'sClosedarm records completion with no consumer ever receivingFinished(runtime.rs:570-573). - Minor — a
max_new_tokens = 0choice is never submitted, so its output-layer rejection athttp.rs:445-450yieldsDelivery::Failedwhile no counter moves — the "failed exactly once" claim does not hold for that exit. - Minor — the two in-repo Python counter assertions closest to this change were not run and are not disclosed as unrun.
Open questions: merge/rebase order against #548/#560/#691; whether the deferred entry point is used by every in-crate user-visible producer; whether docs/api.md:700-702 needs amending.
Final review
Recommendation: Changes Requested
The core fix for #679 is technically sound: the shared RequestOutcome atomic state machine cleanly eliminates mid-stream cancellation misattribution, post-generation output-rejection misattribution, and event-budget double-counting with zero lock contention and strong unit, 2-thread concurrency, and HTTP-to-Worker integration tests. No correctness or concurrency blockers were found. However, before merge the PR should (1) update the Prometheus # HELP strings and API docs for requests_completed_total and requests_cancelled_total so they match the new deferred end-to-end semantics, (2) route the ResponseLifecycle conformance harness's terminal emission through the new emit_finished entry point instead of raw emit, and (3) get CI green on head 348c06c (and simplify the ~160 lines of duplicated CAS loops in RequestOutcome).
Merge Risk
Level: Medium
- Hot-path request-outcome rewrite: Replaces every request completion, cancellation, and failure counter site across
helios/src/server/runtime.rs,helios/src/server/http.rs, andhelios/src/server/protocol/decisions/mod.rswith a sharedArc<AtomicU8>state machine (RequestOutcome), changing whencompletedandcancelledincrement for all HTTP and Decisions traffic. - No CI runs on head (
348c06c): All test and lifecycle-check results are currently self-reported and await CI execution. - Active conflict surface: Touches the exact same structs (
Incoming,Generation),GenerationEvent::Finishedsites, andwait_for_first_tokenpath as open PRs#691(same author),#548, and#560.
Walkthrough
helios/src/server/runtime.rs: AddsRequestOutcome(runtime.rs:109-296), a six-state monotonicAtomicU8(PENDING,GENERATED,READER_DROPPED,COMPLETED,CANCELLED,FAILED) where each Prometheus counter increments only inside a successful CAS into an absorbing terminal state. Replaces eagermetrics.completedincrements atruntime.rs:2295-2314and:2592-2616withIncoming::emit_finished(:553-582), which suppressesFinishedafter a prior worker failure and reserves the channel slot viatry_reserve()before recording generation (failing onFullinstead of completing). AddsModelRuntime::generate_for_output(:1145-1151,defer_completion = true) while keepinggenerate/generate_manyon immediate worker completion (defer_completion = false). Ordersfinish_error(:583-595) to recordFAILEDbefore waking consumers and routes all four worker cancellation sites inWorker::admit(:1650,:1670,:1683,:1738) throughrecord_cancelled(). Adds unit tests for overflow/drop orderings and a 2-threadBarrierconcurrency test (:4471-4649).helios/src/server/http.rs: Switches submission togenerate_for_output(:328-334), settlesGenerationEvent::Finishedwithcomplete_output()orfail_output()(:561-566), and aborts the decoder withTermination::ExecutionError(verified idempotent athelios/src/server/output.rs:384-396) plus callsgeneration.fail_output()on everyDelivery::Failedexit holding an activeGeneration(:402-410,:426-434,:582-590).helios/src/server/protocol/decisions/mod.rs: Switchesscore()(:830-893) togenerate_for_outputand explicitly settles every exit withcomplete_output()orfail_output().helios/src/server/runtime/phase_tests.rs: Adds four tokio HTTP-to-Worker integration tests (:8441-9021) covering ChatML duplicate-parameter rejections across/v1/chat/completions,/v1/messages, and/v1/responses; mid-stream and at-EOS failures after worker completion (streaming and non-streaming); genuine client disconnects before and after worker completion; normal completions; and multi-choice (n = 2) output failures with both active and already-generated siblings.
Pre-merge Checks
- [PASS] Security / malicious screen: No prompt injection, suspicious I/O, unsafe code, or trust-boundary weakening found in the diff or PR conversation.
- [PASS] Charter & value fit: Fixes operator-reported P2 bug #679 at the root cause with no new config flags, wire changes, or per-model branches; PR description includes all four required sections.
- [WARN] Related / duplicate / conflict check: Genuinely additive (not superseded), but textually overlaps open PRs
#691(same author,Incoming/Generationandwait_for_first_token),#548, and#560(same counter/finish sites); needs rebase coordination. - [WARN] Tests & verification evidence: Substantial, well-isolated CPU unit/concurrency/integration tests exist and exercise real production
http::generate/Worker/Decoder/Encoderpaths, andcheck.py (not opened) --mutationsis reported passing, but no GitHub CI checks have run on head348c06cyet.
Blockers
None.
Should Fix
- Update metric
# HELPstrings and API docs for the shiftedcompleted/cancelledcontract (helios/src/server/metrics.rs:1076-1090,docs/api.md:330).metrics.rs:1077-1079still documentsrequests_completed_totalas"Requests whose model generation completed successfully, including explicit token stops."andmetrics.rs:1087-1089documentsrequests_cancelled_totalas"Queued or active model requests cancelled before completion."(docs/api.md:330mirrorscompleted).- Under
generate_for_output(defer_completion = true), HTTP and Decisions requests whose model generation completed successfully no longer incrementcompleteduntil output decoding/validation succeeds, and requests whose reader drops after worker completion (no longer queued or active) now incrementcancelled(explicitly tested athelios/src/server/runtime/phase_tests.rs:8983-9020). - Fix: Update the
# HELPdescriptions inhelios/src/server/metrics.rs:1076-1090and the table indocs/api.md:330(and add acancelledrow if missing) to reflect validated output completion and unread/unvalidated disconnects for served HTTP/Decisions traffic (noting in-processModelRuntime::generate*retains model-generation completion semantics).
- Exercise
Incoming::emit_finishedin theResponseLifecycleconformance tests (helios/src/server/runtime/response_lifecycle_tests.rs:155, 372).- Production worker completion now goes through
Incoming::emit_finished(helios/src/server/runtime.rs:2297, 2594), which usestry_reserve()and suppressesFinishedafter a prior failure. Bothresponse_lifecycle_tests.rs:155(action3in the TLA+ observed-edge harness) andresponse_lifecycle_tests.rs:372(the HTTP terminal-frame retention test) still call rawemit(GenerationEvent::Finished { ... }), bypassing the new production entry point (docs/design-review.md:215-218). - Fix: Switch both call sites to
.emit_finished(GenerationEvent::Finished { ... }). This preserves the exactResponseLifecycle.tlaprojection without adding TLA+ state-space blowup while keeping the harness on the production terminal path.
- Production worker completion now goes through
Subtract / Simplify
- Collapse the five duplicated CAS loops in
RequestOutcomeinto onetransitionhelper (helios/src/server/runtime.rs:138-295).record_generated,record_completed,record_cancelled,record_failed, andon_reader_droprepeat the same ~20-lineload(Acquire)/compare_exchange_weak(AcqRel, Acquire)/fetch_add(Relaxed)loop across ~160 lines.- Replace with one monomorphized helper:
Each of the five methods then becomes a 3–8 line transition table, cutting ~100 lines while keeping identical memory ordering and zero runtime overhead.fn transition(&self, next: impl Fn(u8) -> Option<(u8, Option<&AtomicU64>)>) { let mut current = self.state.load(Ordering::Acquire); while let Some((target, counter)) = next(current) { match self.state.compare_exchange_weak( current, target, Ordering::AcqRel, Ordering::Acquire, ) { Ok(_) => { if let Some(counter) = counter { counter.fetch_add(1, Ordering::Relaxed); } return; } Err(actual) => current = actual, } } }
- Deduplicate the event-budget overflow arm (
helios/src/server/runtime.rs:574-580vs:626-634).emit_finishedandemitcontain byte-identicalTrySendError::Fullhandlers (sameExecutionError::Completionerror string andcancelled.store(true, Ordering::Release)). Extract a singleIncoming::event_budget_exceeded(&self)helper called by both.
Nits
- Test admission-polling helper (
helios/src/server/runtime/phase_tests.rs:8645, 8714, 8789, 8832, 8886, 8936, 8997): Seven copies of thefor _ in 0..200 { let _ = worker.admit().unwrap(); ... sleep(2ms); }loop (400 ms budget) can be collapsed into onewait_for_admitted(&mut worker, count)helper (with a slightly more generous timeout under loaded CI). - Clarifying comment on
emit_finished'sClosedarm (helios/src/server/runtime.rs:570-573): Worth a one-line comment noting thatrecord_generated()settlesREADER_DROPPED -> CANCELLEDwhendefer_completionis true and preservesREADER_DROPPED -> COMPLETEDfor directgenerate/generate_manycallers. - Pair
record_cancelledinsidefinish_cancelled(helios/src/server/runtime.rs:523-532, 1670-1690): Movingself.outcome.record_cancelled()intoIncoming::finish_cancelledmakes it impossible for a future caller to emit a cancelledFinishedevent without settling the outcome (withrecord_cancelled()still called directly on the pending-drop path at:1650and:1738).
Dropped on verification
- Upstream claim (Correctness 3.2 / Value Prop / Dossier): "Blocking design failure because
ResponseLifecycle.tlawas not extended with the 6RequestOutcomestates." Dropped as a blocker: verified inverification/helios-lifecycle/ResponseLifecycle.tla:1-193andverification/helios-lifecycle/README.md:98-145thatResponseLifecycle.tlamodels host admission permit retention, bounded response queues, and producer/reader ownership — explicitly excluding HTTP/output encoder state (README.md:137) and not tracking Prometheus counters. Adding 6 per-cell outcome states to a 3-cell model already at 65,989 states / 365,508 edges would risk TLC state-space blowup with little value over the unit + 2-threadBarrierconcurrency tests (runtime.rs:4574-4649). Downgraded to the targetedShould Fix#2 (callingemit_finishedfromresponse_lifecycle_tests.rs). - Upstream claim (Subtraction S2): "Delete
defer_completionand the non-deferred half ofRequestOutcomeas dead production code; havegenerate/generate_manycallcomplete_output()instead." Dropped as incorrect/unsafe: verifiedModelRuntime::generate(runtime.rs:1127) andgenerate_many(runtime.rs:1141) arepubAPIs re-exported athelios/src/server.rs:34(not opened) (aligned with the charter's in-process Rust SDK roadmap) whileGeneration::complete_outputispub(super)(runtime.rs:348). Callingcomplete_output()insidegenerate/generate_manyat enqueue time is broken (it would settle requests asCOMPLETEDbefore execution, breaking worker failure and cancellation accounting), and forcing deferred semantics onto publicgenerate/generate_manycallers without a public settlement API would miscount every direct completion asCANCELLEDonDropand break existing tests (phase_tests.rs:571, 2003, 3770, 3784, 3824, 3864). - Upstream claim (Correctness / Dossier / Value Prop): "Python counter suites
tests/server/test_protocols.py:676andtests/server/test_decisions.py:230-261were skipped without disclosure." Dropped as false: verified attests/server/test_protocols.py:22-24andtests/server/test_decisions.py:16-18that both suites are gated byFLARE_API_TEST_URL(reason="requires a native Flare service"), which requires live GPU serving throughflare run— explicitly disclosed as unrun in the PR's Limitations section. Static inspection of both tests confirms theirflare_requests_cancelled_total > beforeassertions remain valid under PR #692. - Upstream claim (Dossier / Value Prop / Subtraction): "Silently breaks internal API by deleting
generate_many_observedand makinggenerate_observed#[cfg(test)]." Dropped as false/low-signal: verified onmain(helios/src/server/runtime.rs:895, 908) that both methods were already crate-internalpub(super)helpers, and both changes are explicitly noted in the PR's What Changed section. - Upstream claim (Correctness 1.2): "Zero-token output failure (
http.rs:445-450) is an uncovered hole because it does not incrementrequests_failed_total." Dropped as by-design / pre-existing: verified athttp.rs:311-315that zero-token choices bypassModelRuntimecompletely (never admitted, never incrementadmittedorcompletedeither), matching all other non-admitted HTTP rejections. - Upstream claim (Dossier / Correctness Open Question): "
emit_finished'stry_reserve()permit could be dropped without sending, leaving a request stuck inGENERATED." Dropped as speculative: verified atruntime.rs:562-569thatpermit.send(event)executes unconditionally on the line immediately afterself.outcome.record_generated()with no fallible call or branch in between.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 99.9% -
triage:design-review: 0.1% -
none: 0.0% -
triage:validation: 0.0% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes Decision to Test: no (99%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with. decide malicious: all_clear (100%): No malicious content found
explore
Author: jcartu (CONTRIBUTOR; 3 merged / 10 open PRs in 180 days; Discord jcartu)
Motivation: Helios counted responses that its own output layer rejected (e.g. a malformed ChatML tool call) as cancelled instead of failed, so flare_requests_failed_total stayed at zero while operators saw phantom cancellations. This PR makes the worker and the HTTP reader share one atomic outcome so exactly one of completed/cancelled/failed increments once per request.
Scale: +968 / −46 lines in 7 files (was +1068 / −32 in 4 files at the previously reviewed head 348c06c)
Proposal:
- Adds
RequestOutcome, a six-state monotonicArc<AtomicU8>with onetransition()CAS helper, shared byIncomingandGeneration; counters move only on a CAS into an absorbing terminal state. - Adds
generate_for_output(defer_completion = true) andIncoming::emit_finished, so completion is recorded only after output validation;Fullevent-budget overflow now fails instead of completing. - Rewrites every completion/cancellation/failure site in
runtime.rs,http.rsand decisionsscore()to settle the outcome explicitly. - Rewrites
metrics.rsHELP text anddocs/api.md(newcancelledparagraph), and routes theResponseLifecycleharness throughemit_finished. - Adds 2 unit/concurrency tests and 4 HTTP↔Worker integration tests; refactors the five CAS loops into one helper and collapses 7 polling loops per Autobot review. Touches:
helios/src/server/runtime.rs— new shared state machine on the request hot pathhelios/src/server/http.rs— submission and everyDelivery::Failedexithelios/src/server/protocol/decisions/mod.rs—score()settlement Related items:- #679 Output-layer stream failures counted as cancellations (open): the issue this fixes
- #691 report reused prompt tokens in continuous_usage_stats (open): same author, same structs, textual conflict
- #548 Add per-request histograms and vLLM-parity metrics (open): same counter sites
- #560 Emit vLLM-compatible per-request metrics (open): stacked on #548, same
Finishedevent - #689 preserve typed error codes on HTTP preparation failures (open): adjacent, no accounting overlap
Link: https://github.com/NVIDIA/hyperflare-inference/pull/692
Autobot comments: Amendments to my earlier file: the head moved twice (348c06c → 7f298698) and the PR grew to 7 files, which supersedes my finding that no doc change was needed — docs/HELP text were rewritten, and
cancellednow has prose for the first time (docs/api.md:349-354). TheResponseLifecycleharness now uses the productionemit_finished(response_lifecycle_tests.rs:155, :372), but still admits viagenerate_many, so the deferred GENERATED half — the half the PR exists for — remains unmodelled under docs/design-review.md:241-246. Still no CI on head; the 40-mutation claim is not CI-covered (helios-lifecycle.yml:34 omits--mutations) and the author verified at 512 MiB memlock where CI uses 64 MiB.requests_failed_totalHELP (metrics.rs:1092-1094) was deliberately left unexpanded while docs/api.md:332 was, an asymmetry a reviewer can drop. Also unmentioned in the description:generate_observedis now#[cfg(test)](runtime.rs:1044-1047) andgenerate_many_observedwas deleted — a real API-surface reduction.
Classify intake
Selected: triage:review, priority:P2, bug, area:api
Threshold: 65%
Triage
- [✓]
triage:review: 99.8% -
triage:design-review: 0.1% -
triage:validation: 0.0% -
triage:investigate: 0.0% -
triage:partial: 0.0% -
none: 0.0% -
triage:integration: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
- [✓]
priority:P2: 98.5% -
none: 1.1% -
priority:P1: 0.4%
Type
- [✓]
bug: 89.3% -
duplicate: 34.9% -
community: 29.4% -
performance: 1.8% -
enhancement: 0.9% -
documentation: 0.3%
Area
- [✓]
area:api: 99.6% -
area:preparation: 0.5% -
area:scheduling: 0.5% -
area:engram: 0.2% -
area:selene: 0.1% -
area:kernels: 0.1% -
area:memory: 0.1% -
area:caching: 0.0% -
area:rocenante: 0.0% -
area:orbit: 0.0% -
area:packaging: 0.0%
Model
-
model:nemotron-3.5-bolt: 0.9% -
model:kimi-k3.1: 0.5% -
model:deepseek-v4.1: 0.3% -
model:glm-5.3: 0.3% -
model:muse-glimmer: 0.1% -
model:qwen3.8-27b: 0.1% -
model:deepseek-v4: 0.1% -
model:inkling-small: 0.1% -
model:qwen3.8-flash-next: 0.1% -
model:gemma4: 0.0% -
model:mimo-v2.6: 0.0%
Apply Labels (Intake)
No label changes
Subtraction and simplicity
Subtraction/Simplicity review of PR #692 (head 7f298698). Three findings; everything else checked is lean.
-
(High)
RequestOutcome::defer_completion(runtime.rs:126) is a test-only mode switch. Itsfalsecallers aregenerate(:1040),#[cfg(test)] generate_observed(:1044) andgenerate_many(:1054), all reachable only from test harnesses; the soletruecaller isgenerate_for_output(:1058), used byhttp.rs:333anddecisions/mod.rs:840. The flag forces two extraCOMPLETEDarms inrecord_generated(:158-168), the dual-settlement branch/comment at:482-487, an unused third parameter onenqueue_many(:1066-1071), and the "direct in-process caller" carve-outs inmetrics.rs:91,:1078,:1088anddocs/api.md:330,:349-352. Delete the flag and the three wrappers; convert the ~7 test call sites togenerate_for_output+ explicitcomplete_output()/drop. Backed by AGENTS.md:188-193 ("configuration switches without a concrete requirement"). Caveat:generate/generate_manyarepub(re-exportedserver.rs:34(not opened)), so the fallback is to make deferral unconditional and keep them as wrappers that settle immediately. -
(Medium-high)
http.rsrepeats abort +fail_output()+encoder.failure()+yield Delivery::Failedat:402-410,:426-434,:445-450(correctly nofail_output(), zero-token choices hold noGeneration) and:582-589. One helper taking explicit mutable slices removes ~10 lines and makes the PR's central invariant auditable in one place. -
(Medium) The new tests copy a 7-line drain loop three times (
phase_tests.rs:8744-8750,:8828-8834,:8973-8979) and re-implement the image-input strip loop a third time (:8441-8453vs:59-67,:4784-4792). Extractdrain_to_retirementbeside the existingemit_worker_tokens/wait_for_admittedhelpers, andFixture::strip_image_inputs.
Explicitly lean: transition() CAS helper (:138-156), event_budget_exceeded (:493-501), emit_finished (:465-492), finish_cancelled (:434-443), the metrics/docs prose, and the 2-line emit_finished test switch.
Open: whether the pub generate* API may be removed; whether the flag has a planned non-test consumer (none visible).
Correctness and contracts
Correctness/contracts review of PR #692 (head 7f298698). No blockers: the CAS state machine, orderings, settlement coverage and hot-path cost are sound. Two Majors and four Minors follow.
- Major — the new contract "each request increments at most one of completed/cancelled/failed" (docs/api.md:349-354, metrics.rs:1086-1090) is contradicted by the PR's own tests: an n=2 output failure asserts failed==1 AND cancelled==1 (phase_tests.rs:8894-8898, :8950-8954). The invariant is per-choice, and the PR description's "leaves cancelled unchanged" is false for n>1.
- Major — the deferred half has no formal coverage: the ResponseLifecycle harness admits via generate_many (response_lifecycle_tests.rs:120-122, defer_completion=false), so GENERATED/READER_DROPPED and complete_output/fail_output/on_reader_drop (runtime.rs:158-206, :259-268, :289-294) are unreachable in ResponseLifecycle.tla. The 365,508-transition and mutation claims cover only pre-existing behaviour.
- Minor — zero-token choices hold no Generation (http.rs:311-316, :344-348), so a fully served all-zero request increments nothing, contradicting docs/api.md:330's new promise.
- Minor — completed is recorded at output validation (http.rs:561-566), not delivery, so a post-validation disconnect still counts completed; the doc should say so.
- Minor — emit_finished's suppression consults only Incoming.failure (runtime.rs:465-473); consumer-side fail_output leaves that None, so Finished is still sent. Counters stay correct.
- Minor — evidence is self-reported: figures byte-identical to the pre-fix run, no CI on head, and --mutations is never invoked by .github/workflows/helios-lifecycle.yml:33-34 (not opened).
Verified sound: transition() CAS with Relaxed fetch_add only on success (runtime.rs:138-156); all terminal states absorbing; fail_output records FAILED before cancel() (:263-268); finish_error records before notifying (:502-513); emit_finished try_reserves before record_generated (:465-492); event_budget_exceeded shared with emit (:493-501, :545-547); no double settle in http.rs (take() at :561 precedes the Err arm at :584); Decisions settles every exit (decisions/mod.rs:838-888). No new locks, allocations, buffering or platform-conditional code; the parallel_tool_calls:false note at docs/api.md:704-709 still matches the code and I am not flagging it.
Open: whether head actually re-ran the suites; whether the TLA+ model is meant to cover the deferred half; and confirmation that the counter invariant is per-choice.
Re-review
Recommendation: Ready To Merge
Commit 7f298698 cleanly addresses every Round 1 review item (metric # HELP and API docs updates, routing ResponseLifecycle terminal emission through emit_finished, collapsing the five CAS loops into RequestOutcome::transition, extracting Incoming::event_budget_exceeded, folding record_cancelled() into finish_cancelled, and consolidating test admission polling via wait_for_admitted) without introducing any correctness, concurrency, or performance regressions. The shared RequestOutcome atomic latch closes all three #679 misattribution paths by construction across streaming/non-streaming HTTP and Decisions endpoints. Once GitHub CI (native-serving and helios-lifecycle) passes on 7f298698, this PR is ready to merge.
Merge Risk
Level: Medium
- All-request terminal accounting path: Replaces every
completed,cancelled, andfailedcounter increment acrosshelios/src/server/runtime.rs,helios/src/server/http.rs, andhelios/src/server/protocol/decisions/mod.rswith the sharedRequestOutcomestate machine, changing whencompletedandcancelledsettle for all served HTTP and Decisions traffic. - Active conflict surface: Textually overlaps open PRs
#691(same author,Incoming/Generationandhttp.rs),#548, and#560(same counter and finish paths), requiring straightforward rebase coordination. - CI confirmation pending on head
7f298698: Author CPU test runs andcheck.py (not opened) --mutationsare self-reported (run locally at 512 MiB memlock vs CI's 64 MiBprlimitin.github/workflows/native-serving.yml:62-63(not opened)), so GitHub CI checks should be verified green on7f298698before merge.
Walkthrough
helios/src/server/runtime.rs: IntroducesRequestOutcome(:109-207), a six-state monotonicAtomicU8(PENDING,GENERATED,READER_DROPPED,COMPLETED,CANCELLED,FAILED) driven by a single CAS helpertransition(:138-156) that increments each Prometheus counter only on a successful CAS into its absorbing terminal state. Replaces prematuremetrics.completedincrements at:2209and:2506withIncoming::emit_finished(:465-492), which suppressesFinishedafter a prior worker failure and reserves the bounded channel slot viatry_reserve()before callingrecord_generated(). SharesIncoming::event_budget_exceeded(:493-501) betweenemit_finishedandemit(:545-547), ordersfinish_error(:502-514) to recordFAILEDbefore notifying admission/first-token/event channels, foldsrecord_cancelled()intofinish_cancelled(:434-444), addsModelRuntime::generate_for_output(:1058-1064,defer_completion = true) while keeping publicgenerate/generate_manyon immediate worker completion, and adds unit plus 2-threadBarrierconcurrency tests (:4383-4561).helios/src/server/http.rs: Switches HTTP submission togenerate_for_output(:333), settlesGenerationEvent::Finishedviagenerations[index].take()withcomplete_output()/fail_output()(:561-566), and aborts the failing decoder plus callsfail_output()on activeGenerationhandles acrossDelivery::Failedexits (:402-410,:426-434,:582-589).helios/src/server/protocol/decisions/mod.rs: Switchesscore()(:830-893) togenerate_for_outputand settles every exit path withcomplete_output()(:871) orfail_output()(:845,:853,:865,:879,:883), while preservingDrop -> on_reader_drop -> CANCELLEDon client disconnect.helios/src/server/metrics.rs&docs/api.md: UpdatesSnapshot::completed(metrics.rs:91), Prometheus# HELPstrings forrequests_completed_totalandrequests_cancelled_total(metrics.rs:1076-1090), and API metrics documentation (docs/api.md:330,332,349-354) to document validated output completion, unread/unvalidated disconnects, output-decoding/event-budget failures, and direct in-processModelRuntime::generate*semantics.helios/src/server/runtime/response_lifecycle_tests.rs&helios/src/server/runtime/phase_tests.rs: Routes both terminal emission sites inresponse_lifecycle_tests.rs(:155,:372) throughemit_finished, and adds four isolated HTTP-to-Worker integration tests (phase_tests.rs:8647-8989, with sharedwait_for_admittedhelper at:8632-8645) covering ChatML duplicate-parameter rejections across Chat/Messages/Responses, post-worker-completion failures, client disconnects before and after worker completion, normal completions, and multi-choice (n = 2) sibling cancellation.
Pre-merge Checks
- [PASS] Security / malicious screen: No prompt injection, suspicious I/O, unsafe code, or trust-boundary weakening found in the diff or PR discussion.
- [PASS] Charter & value fit: Fixes operator-reported P2 bug
#679at the root cause in the right layer with no new config flags, wire changes, or per-model branches; PR description contains all four required sections. - [WARN] Related / duplicate / conflict check: Genuinely additive (not superseded), but overlaps open PRs
#691,#548, and#560acrossruntime.rs,http.rs,metrics.rs,docs/api.md,phase_tests.rs, andresponse_lifecycle_tests.rs; rebase coordination needed. - [WARN] Tests & verification evidence: Unit, 2-thread concurrency, and real-pipeline HTTP↔Worker integration tests are well isolated with no global-state hazards, and
check.py (not opened) --mutationsis reported passing; verify GitHub CI (native-servingat 64 MiB memlock andhelios-lifecycle) passes on7f298698before merge (note.github/workflows/helios-lifecycle.yml:34(not opened) runscheck.py(not opened) without--mutations).
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Centralize HTTP
Delivery::Failedsettlement (helios/src/server/http.rs:402-410,:426-434,:445-450,:582-589) (optional): The fourDelivery::Failedexits repeatdecoders[idx].abort(Termination::ExecutionError), optionalgeneration.fail_output(), andencoder.failure(&err)(withgenerations[i]alreadyNonefor zero-token choices at:445-450). Extracting a small helper (e.g.,fail_choice(&mut decoders[idx], generations[idx].as_ref(), &mut encoder, &err) -> Frame) puts the "everyDelivery::Failedexit settles itsGeneration" invariant in one place. - Deduplicate new test helpers (
helios/src/server/runtime/phase_tests.rs:8744-8750,:8828-8834,:8973-8979,:8441-8453) (optional): The 7-linefor _ in 0..16terminal-drain loop is copied three times in the new tests and could become a smalldrain_to_retirement(&mut worker, &mut seq)helper next towait_for_admitted(:8632-8645). Similarly,text_http_fixture(:8443-8451) repeats the image-inputretainloop already present at:59-67and:4784-4792.
Nits
- Clarify per-choice / per-model-request granularity (
docs/api.md:349-354,helios/src/server/metrics.rs:1078,1088):docs/api.md:353-354states "Each request increments at most one offlare_requests_completed_total,flare_requests_cancelled_total, orflare_requests_failed_total." Because Helios runtime counters are per model request (one per choice forn > 1HTTP requests, or per question prompt in Decisions), a multi-choice output failure incrementsfailedfor the failing choice andcancelledfor dropped undelivered siblings (as verified inphase_tests.rs:8896-8898and:8952-8954). Clarifying "Each model request (each choice in a multi-choice request or scored question in Decisions)..." removes any ambiguity for dashboard/alert authors.
Dropped on verification
- Claim that
docs/design-review.md:241-246requires modeling deferredGENERATED/READER_DROPPEDmetric transitions inResponseLifecycle.tla: Verifiedverification/helios-lifecycle/ResponseLifecycle.tla:1-193models admission capacity retention (AdmissionRetained), bounded event queues (BufferedOutputBounded), and reader-drop cancellation (DisconnectedProducersCancel) — it does not model Prometheus outcome counters at all, and none of its modeled state transitions or bounds change betweendefer_completion = falseandtrue. Routingresponse_lifecycle_tests.rs:155,372throughemit_finishedalready exercises the production terminal emission path, whileRequestOutcome's transitions are verified byruntime.rs:4383-4561andphase_tests.rs:8647-8989. - Claim that
RequestOutcome::defer_completionis a test-only mode switch to delete (or replace by callingcomplete_output()immediately ingenerate/generate_many):ModelRuntime::generateandModelRuntime::generate_manyarepubAPIs re-exported athelios/src/server.rs:34(aligned with the in-process Rust SDK roadmap), whileGeneration::complete_output()/fail_output()are intentionallypub(super). Moreover, the proposed fallback of callingcomplete_output()immediately insidegenerate/generate_manywould transitionRequestOutcomeinto absorbingOUTCOME_COMPLETEDbefore worker execution, silently breaking worker failure and cancellation accounting. - Claim that a task panic after output validation transitions
completedtocancelled(http.rs:561-566): Verified false —generations[index].take()callscomplete_output()(absorbingOUTCOME_COMPLETED) and dropsGenerationimmediately at:561-566before frames are yielded, so a subsequent panic cannot transition the outcome toCANCELLED. The pre-flush validation span is already accurately stated indocs/api.md:330andmetrics.rs:1078. - Claim about uncounted all-zero-token choices (
http.rs:311-316,:346-348): Pre-existing behavior outside the scope of#692; zero-token choices never enterModelRuntimeor incrementrequests_admitted_total. - Claims about
emit_finishedchecking onlyIncoming.failure(runtime.rs:465-473) andrequests_failed_total# HELPspecificity (metrics.rs:1092-1094vsdocs/api.md:332): Both verified benign/low-signal — consumer-sidefail_output()already makesRequestOutcomeabsorbingFAILEDand matches the PR description's exact wording, andmetrics.rs:1093already covers "output processing". - Speculation that identical test/TLA+ counts in the Round 2 reply indicate suites were not re-run: Commit
7f298698refactored helpers and updated docs without adding/removing tests or TLA+ states, so identical counts are expected; the factual pre-merge gate is verifying GitHub CI runs green on7f298698.
Full report Decision to Test: no (56%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 97.3% -
none: 2.0% -
triage:design-review: 0.2% -
triage:validation: 0.2% -
triage:verify-for-closure: 0.1% -
triage:partial: 0.1% -
triage:investigate: 0.1% -
triage:integration: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes