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.