#1 [high] Research summary
Subtraction / Simplicity / Conventions review — PR #689
The production change in helios/src/server/http.rs is genuinely lean: the failure_response extraction (http.rs:26-31) removes duplicated body-building instead of adding a wrapper, rejection (http.rs:32-41) collapses to three lines, and PreparationError replaces the old rejection_details(…, AdmissionError::Invalid) hack with a two-branch classifier. No flags, config knobs, #[allow]s or new dependencies. Three findings, ordered by value.
1. make_state re-implements the existing http_state_for helper by hand — delete ~30 lines
helios/src/server/runtime/phase_tests.rs (new test, make_state closure starting at :8442 after http_state_for(fixture, sender, None, &[]); at :8452) builds a full HttpState literal at :8453-8474:
let base = http_state_for(fixture, sender, None, &[]);
let state = Arc::new(super::super::HttpState {
first_response: base.first_response.clone(),
log_to_stderr: false,
model: base.model.clone(),
frontend: base.frontend.clone(),
images: with_images.then(|| { … }),
grammar: base.grammar.clone(),
Field-for-field cloning of the base state is exactly what the sibling test already avoids at :5086-5087:
let mut state = http_state_for(fixture, sender, None, &[]);
Arc::get_mut(&mut state).unwrap().thinking_token_budget = Some(2);
Replace the whole literal with three Arc::get_mut assignments (images, context_hint, and the max_body_bytes = 4096 at :8467 the 4,200-byte case needs). Beyond the ~28 deleted lines, this removes a copy of every HttpState field that silently rots: the same-day sibling PRs #691/#692 also touch HttpState/http::generate, and any new field forces a second edit here.
2. The wire test repeats one loop shape three times — collapse to a single table
In the same test, sections "2. unsupported_feature" , "3. invalid_grammar" and "4. invalid_image" are the identical body:
] {
let (state, receiver) = make_state(false, "");
let (status, body) = send_raw(state, path, None, payload.to_string()).await;
assert_eq!(status, StatusCode::BAD_REQUEST, "{path}: {body}");
assert_envelope(path, &body, "invalid_request_error", "unsupported_feature");
assert!(receiver.try_recv().is_err(), "{path}");
}
differing only in the literal code string (unsupported_feature / invalid_grammar / invalid_image) and the make_state(false|true, "") argument. Folding them into one for (expected_code, with_images, path, payload) in [...] table over the existing (path, payload) arrays removes roughly 100 lines of boilerplate and, more importantly, makes the covered (code, route, payload-class) matrix readable at a glance instead of split across three blocks. (Coverage itself is good and should be kept — this is a shape change only.)
3. PreparationError's ImageDecode arm is dead in the only call path, and is the branch that creates the inconsistency
helios/src/server/http.rs:124-132:
fn preparation_error(error: Error) -> PreparationError {
match error {
Error::Admission(_) => PreparationError::Failure(error),
Error::Frontend(crate::FrontendError::ImageDecode(_)) => {
PreparationError::Failure(error.admission_context(AdmissionError::Image))
}
other => PreparationError::Http(StatusCode::BAD_REQUEST, other.to_string()),
}
}
Every image-decode site reachable from generate's closure is already re-typed before it can reach here: describe_images wraps check_batch, decode_encoded, describe_image, geometry and check_budget with .map_err(|error| error.admission_context(AdmissionError::Image)) at request.rs:1141, 1194, 1196, 1208, 1230, and the raw .. image rejects are constructed as AdmissionError::Image directly (request.rs:1152-1176). So this arm is a speculative second copy of request::prepare's mapping (request.rs:30-36) that cannot fire from prepare_validated_inference; if it ever did fire, its narrowness (only ImageDecode, not Asset/Template/Tokenizer/Input, error.rs:131-143) would be a correctness divergence rather than a safeguard. Simplification: drop the arm, keep Error::Admission(_) => Failure(error) and the other => fallback. That also lets the unit test at http.rs:759-761 and its 4-line panic-only expectation row go, and matches the charter's "Reject unsupported abstractions … fallback layers" rule.
(Optional, lower value: let body = decode_body(…) .map_err(|(status, message)| PreparationError::Http(status, message))?; at http.rs:212-213 is a hand-written From<(StatusCode, String)>; an impl From<(StatusCode, String)> for PreparationError makes it plain decode_body(&bytes, &encoding, prepare_state.max_body_bytes)?. One line, noted for completeness, not worth its own round trip.)
Not a finding
rejection correctly keeps log_failure + with_request_id while failure_response stays pure (http.rs:26-41); rejection_details is reused rather than duplicated, so both typed preparation failures and post-submission rejections share the context_hint/capacity_hint rendering. The unit test at http.rs:739-786 is partly a mirror of the error_code table (server.rs:743-755) already covered end-to-end by the wire test — trimming the five AdmissionError rows to just the untyped and ImageDecode cases would be tidier, but this is a good test and not worth flagging as more than a note.
#2 [high] PR #689 subtraction review — verdict: production diff lean, 3 findings
PR #689 (helios/server: preserve typed error codes on HTTP request preparation failures). Lens: Subtraction/Simplicity/Conventions.
VERDICT: production change in helios/src/server/http.rs is genuinely lean. failure_response extraction (http.rs:26-31) removes duplicated body building; rejection (http.rs:32-41) collapses to 3 lines delegating to it; PreparationError replaces the old rejection_details(...AdmissionError::Invalid) hack at the old http.rs:258-267 with a 2-branch classifier. No flags, config knobs, allow()s, new deps, or dead public API. All three findings are in the TEST code plus one speculative match arm.
FINDING 1 (high value, ~30 lines deleted): phase_tests.rs new test make_state closure hand-rebuilds HttpState field-for-field instead of mutating the existing helper.
- phase_tests.rs:8452-8474:
let base = http_state_for(fixture, sender, None, &[]); let state = Arc::new(super::super::HttpState { first_response: base.first_response.clone(), log_to_stderr: false, model: base.model.clone(), frontend: base.frontend.clone(), images: with_images.then(...), grammar: base.grammar.clone(), frontend_slots: ..., ingress_slots: ..., max_body_bytes: 4096, frontend_capacity: ..., ingress_capacity: ..., run: base.run, ids: Default::default(), api_key: None, thinking_token_budget: None, context_hint: context_hint.to_owned(), capacity_hint: String::new(), response_model: ..., started: base.started, generated: Default::default(), accepting: Mutex::new(true), }); - Existing helper http_state_for defined at phase_tests.rs:4236-4296 (HttpState literal at :4273).
- The established repo pattern is one line of mutation instead: phase_tests.rs:5086-5087
let mut state = http_state_for(fixture, sender, None, &[]); Arc::get_mut(&mut state).unwrap().thinking_token_budget = Some(2); - Replace the literal with 3 Arc::get_mut assignments (images, context_hint, max_body_bytes=4096 needed for the 4200-byte body case at :8788). Removes ~28 lines AND the copy of every HttpState field, which will rot: same-day sibling PRs #691/#692 also add fields/touch HttpState.
FINDING 2 (high value, ~100 lines): the wire test repeats the same 6-line loop body three times for unsupported_feature / invalid_grammar / invalid_image sections; only the expected code string and make_state(false|true, "") differ.
- Verbatim repeated block (appears at end of section 2, section 3, section 4):
] {
let (state, receiver) = make_state(false, "");
let (status, body) = send_raw(state, path, None, payload.to_string()).await;
assert_eq!(status, StatusCode::BAD_REQUEST, "{path}: {body}");
assert_envelope(path, &body, "invalid_request_error", "unsupported_feature");
assert!(receiver.try_recv().is_err(), "{path}");
}
- Fix: fold the three (path,payload) arrays into one table
for (expected_code, with_images, path, payload) in [...]. Keep coverage (good), change only shape.
FINDING 3 (medium): http.rs:124-132 preparation_error's ImageDecode arm is dead on the only call path and is the natural deletion point for the asymmetry.
fn preparation_error(error: Error) -> PreparationError {
match error {
Error::Admission(_) => PreparationError::Failure(error),
Error::Frontend(crate::FrontendError::ImageDecode(_)) => {
PreparationError::Failure(error.admission_context(AdmissionError::Image))
}
other => PreparationError::Http(StatusCode::BAD_REQUEST, other.to_string()),
}
}
- Evidence it cannot fire from
prepare_validated_inference: every image-decode site is already re-typed to AdmissionError::Image inside describe_images — request.rs:1141 (check_batch), :1194 (decode_encoded), :1196 (describe_image), :1208 (geometry), :1230 (check_budget), and raw rejects built directly as AdmissionError::Image at request.rs:1152-1176. - It is a second, narrower copy of request::prepare's mapping (request.rs:30-36 -> ImageDecode=>Image, everything else=>Invalid). Narrow because it excludes FrontendError::Asset/Template/Tokenizer/Input (error.rs:131-143).
- Simplification: delete the arm (keep Admission +
otherfallback); then delete the unit-test row http.rs:759-761 and shrink the winning-case matrix. - Optional micro: http.rs:212-213
.map_err(|(status, message)| PreparationError::Http(status, message))?== hand-written From<(StatusCode,String)>; an impl makes itdecode_body(...)?.
NOT A FINDING (state so report does not re-litigate): rejection correctly keeps log_failure + with_request_id while failure_response stays pure (http.rs:26-41); rejection_details (http.rs:60-72) is reused, not duplicated; unit test http.rs:739-786 partly mirrors error_code table (server.rs:743-755) but is a good test.
Repo conventions checked: AGENTS.md (root, read at main) — no flags/env/fallback abstractions; PR description has the required 4 parts; "Reject unsupported abstractions and churn … do not add fallback layers" supports finding 3. No AGENTS.md in helios/ (list_files **/AGENTS.md returned none).