Recommendation: Ready To Merge
Commit 4695d84 resolves all four items from the prior review cleanly and introduces no regressions: AdmissionError::Invalid now stays on invalid_request_error alongside untyped HTTP 400 checks, the dead FrontendError::ImageDecode branch is gone, make_state reuses http_state_for, and docs/api.md documents the four typed HTTP 400 error.code values on OpenAI-shaped endpoints. The implementation fixes #446 at the right layer with exact parity on HTTP status codes, x-request-id/logging boundaries, Anthropic envelopes, and spawn_blocking permit lifetimes; confirm green CI on 4695d84 before merging.
Merge Risk
Level: Low
- Changes are confined to
helios/src/server/http.rs(+107/−23),helios/src/server/runtime/phase_tests.rs(+327/−0), anddocs/api.md(+6/−3); no model-core, scheduler, prefix-cache, worker, or CUDA-graph code is touched, and no HTTP status codes change (all reachable preparationAdmissionErrorvariants map to HTTP 400 athelios/src/server.rs:733-741). - No concurrency, contention, permit-lifetime, or common-path overhead regression:
frontend_slots(_permit),ingress_slots(_ingress), andextragroup permits insidespawn_blocking(helios/src/server/http.rs:209-284) retain identical acquisition and drop scopes,first_responseobservation is unchanged, andfailure_responseruns post-join on error paths only. - On OpenAI-shaped endpoints (
/v1/chat/completions,/v1/completions,/v1/responses), onlyerror.codechanges on the four typed 400 classes (context_length_exceeded,unsupported_feature,invalid_grammar,invalid_image), whileerror.type(invalid_request_error),error.param(null), general 400s (invalid_request_error), and Anthropic/v1/messagesenvelopes remain unchanged.
Walkthrough
- Shared failure renderer (
helios/src/server/http.rs:26-41): extractsfailure_response(&HttpState, Protocol, Error) -> Responseusingprotocol.failure(&failure)andrejection_details(state, failure)for hint-suffixed messages;rejectiondelegates tofailure_responsewhile keepinglog_failureandwith_request_idpost-submission only (matchingdocs/core-design.md:1119-1121anddocs/api.md:261-262). - Preparation error classifier (
helios/src/server/http.rs:119-132): adds privatePreparationError::{Http, Failure}andpreparation_error(Error)soError::Admission(AdmissionError::Invalid(_))and non-admission errors map toPreparationError::Http(StatusCode::BAD_REQUEST, ...), while all otherError::Admission(_)variants stay typed asPreparationError::Failure. - Generation preparation dispatch (
helios/src/server/http.rs:209-293): routesprotocol::decode,GrammarCompiler::compile_text,Request::generation_count,request::compile_strict_validators, andrequest::prepare_validated_inferencethroughpreparation_error, dispatchingPreparationError::Failuretofailure_responseandPreparationError::Httptohttp::errorwhile leavingdecode_body(400/413/415), oversized groups (400), and ingress exhaustion (429) onhttp::error. - Documentation (
docs/api.md:257-261): documents that on Chat Completions, Completions, and Responses, typed HTTP 400 rejections seterror.codetocontext_length_exceeded,unsupported_feature,invalid_grammar, orinvalid_imagewhile keepingerror.typeasinvalid_request_error. - Tests (
helios/src/server/http.rs:739-807,helios/src/server/runtime/phase_tests.rs:8438-8763): unit-testspreparation_erroracross allAdmissionErrorvariants plus untyped strings, and driveshttp::generateend-to-end across/v1/chat/completions,/v1/completions,/v1/responses,/v1/messages, and/v1/messages/count_tokens(buffered andstream: true) asserting typed codes,context_hint,invalid_request_errorfor bothAdmissionError::Invalid(stop> 4) and untyped validation (max_tokens: 0), 400/413/415 handling, absentx-request-id, and zero queue admissions (receiver.try_recv().is_err()).
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, external I/O, or prompt-injection/instruction-directing content in the PR description, comments, or diff.
- [PASS] Charter & value fit: Fixes maintainer-confirmed bug #446 in Helios's shared HTTP layer with no per-model branches, flags, magic defaults, or new dependencies, and includes all four required PR description sections.
- [PASS] Related / duplicate / conflict check: No competing PR; cleanly aligned with
main(open same-author PRs #691 and #692 touchhttp.rs/phase_tests.rswith disjoint intent and may only need a textual rebase depending on merge order). - [WARN] Tests & verification evidence: Added CPU tests are isolated (per-test PID/serial temp dirs cleaned up immediately in
Fixture::with_template, no global state) and exercise realhttp::generatewithout mocks; scheduler/formal lifecycle gates do not apply. Only author-local release test runs are reported on4695d84(no CI check runs visible yet, and live GPU /tests/server/test_protocols.py(not opened) were not run, as disclosed) — confirm green CI before merging.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Collapse duplicate
PreparationError::Httparms (helios/src/server/http.rs:124-132, optional): Arms 1 and 3 ofpreparation_errorconstruct the identicalPreparationError::Http(StatusCode::BAD_REQUEST, ...)expression. They can be combined into two arms so the "allAdmissionErrorexceptInvalid" rule appears once:fn preparation_error(error: Error) -> PreparationError { match error { Error::Admission(kind) if !matches!(kind, AdmissionError::Invalid(_)) => { PreparationError::Failure(Error::Admission(kind)) } other => PreparationError::Http(StatusCode::BAD_REQUEST, other.to_string()), } }
Nits
None.
Dropped on verification
docs/api.md:257-261"contradictsdocs/api.md:250-251" (flagged as Blocker by Correctness lens, and raised in Discovery/Subtraction): Dropped as false/over-flagged. Throughoutdocs/api.md:250-257, the parenthetical values (invalid_request_error,authentication_error,request_too_large,rate_limit_error, andserver_error/api_erroron Messages) documenterror.typeacross all protocols (including Messages, which carries noerror.code), and lines 257-261 explicitly reconcile the distinction ("while keepingerror.typeasinvalid_request_error").- Reported test totals unchanged between
2f72e1band4695d84(flagged in Discovery, Correctness #5, Subtraction open Q2): Dropped as false. Commit4695d84edited assertions inside the two existing test functions (helios/src/server/http.rs:739-807andhelios/src/server/runtime/phase_tests.rs:8438-8763) without adding new#[test]functions, socargo test's per-test-function count (1,880 passed / 84 ignored) is expected to remain identical. expected_typeparameter inassert_envelopeis constant"invalid_request_error"(Subtraction #5): Dropped as factually false.helios/src/server/runtime/phase_tests.rs:8760passes"request_too_large"for HTTP 413; inlining"invalid_request_error"at line 8504 would break the test.send_rawduplicateshttp_generation_request_observed(Subtraction #3): Dropped as false/low-signal.http_generation_request_observed(phase_tests.rs:4461-4490) hardcodesFixture::new(), accepts only validserde_json::Value, and blocks expectingreceiver.recv_timeout(...)to succeed (which panics on preparation rejections);send_rawsends raw strings (including malformed JSON and oversized bodies), setsanthropic-version/content-encoding, assertsx-request-idabsence, and expects zero queue admissions.- Typed preparation failures are not logged or counted in
requests_failed_total(Correctness #2): Dropped as pre-existing by-design behavior.docs/api.md:261-262anddocs/core-design.md:1119-1121scopex-request-idand failure logs to post-preparation/model-submission failures, andrequests_failed_total(helios/src/server/metrics.rs:1092-1094) counts model requests rather than HTTP pre-submission rejections (which incrementhttp_requests[metric]). preparation_error's catch-all arm maps non-admission errors to HTTP 400 (Correctness #3): Dropped as parity withmainandrequest::prepare. Bare string validation errors acrossrequest.rs(Error::from(&str)->ExecutionError::Stateathelios/src/error.rs:174-183) and client-inducedFrontendErrors are intentionally HTTP 400 (request.rs:35); the lens's suggested narrowing toExecutionError::Statewould regress client-inducedFrontendErrors to HTTP 500.- Unit test covers unreachable
Capacity/Unavailablevariants and omitscapacity_hint(Correctness #4 / Subtraction #2): Dropped as low-signal. Exhaustively unit-testingpreparation_erroracross allAdmissionErrorvariants in ~68 lines of fast pure-Rust assertions is sound, andrejection_details(http.rs:60-72) was not modified by this PR.