Subtraction & Simplicity audit — PR #708
Scope: the 7 files in pr_files (+736/−56). Verdict up front: the Ignition half is nearly lean, the Helios runtime half is not — it buys per-request error isolation by triplicating the same seven-line recovery block and by deepening a 90-line match by one indentation level, and two of the three new isolation arms guard failure modes that the request pipeline already rejects twice upstream. There is ~30–40 lines of removable plumbing in Worker::admit and two dead/self-disabling knobs in VisionState.
Findings are ordered by value. All line numbers are at head 4fee325.
1. [High] Triple-duplicated isolation block, and two of the three guarded failures are already rejected twice upstream
helios/src/server/runtime.rs:1641-1648, :1652-1663, :1667-1683 contain the identical recovery sequence three times:
self.scheduler.cancel(handle)?;
incoming.fail(error);
progress = true;
continue;
The TokenStops/TextStops variants have to continue from inside what used to be a plain Option::unwrap_or arm, which is the only reason the PR rewrote let parked = match parked { Some(parked) => parked, None => Parked { … } } (:1649-1716) into a nested form — ~65 lines of Parked construction pushed one level deeper purely to host two continues.
Both of those two failure sources are pure functions of incoming.prompt, and both are already validated twice before the worker sees the request:
helios/src/server/request.rs:336-339:let stop_sequences = opts.token_stops.clone(); super::stops::TokenStops::new(stop_sequences.clone(), config.contract.vocabulary)?; … super::stops::validate_strings(&stop_strings, !stop_sequences.is_empty(), grammar.is_some())?;helios/src/server/runtime.rs:949-957(same two calls, on the samePromptthe worker later receives).
TokenStops::new (helios/src/server/stops.rs:14-31) has no state and no dependency on the handle, the scheduler, or the admission; TextStops::new → StringStops::new → the identical validate_strings (stops.rs:94-95) likewise.
Simplification: hoist the matcher construction above Admission::from_continuation (it needs nothing the admission produces), so the only code that can now fail after self.scheduler.admit is the admission itself. That deletes two of the three isolation arms, restores let parked = match parked { … } to a one-expression unwrap_or_else-shaped arm, and leaves exactly one cancel-and-fail site:
let stops = TokenStops::new(incoming.prompt.stop_sequences.clone(), self.config.contract.vocabulary)?; // pre-admit
let request_admission = match Admission::from_continuation(…) { Ok(a) => a, Err(e) => { … one site … } };
Net: roughly −30 lines and two fewer indentation levels in the hottest function in the file, with the same guarantees. (The new test worker_admit_isolates_admission_and_stop_matcher_failures_without_killing_worker at phase_tests.rs:9326 mutates bad.prompt.stop_sequences after preparation, so it exercises a state production code cannot reach — worth knowing before treating those two arms as load-bearing.)
Related inconsistency introduced alongside: the pre-existing admission-rejection path at runtime.rs:1572-1575 does incoming.reject_admission(error); continue; with no progress = true, while the three new failure paths set it. Same class of event (a request dies, a slot is freed). Pick one; a reviewer will ask which is correct.
2. [High] VisionState.inject carries a parameter it no longer reads, and image_token is now a knob that disables its own check
ignition/components/vision_state.py:51:
def inject(self, metadata, embedding):
The body (:52-61) never touches metadata. Before this PR it did (torch.where((metadata.token_ids == self.image_token)[:, None], …)). It is now a required positional argument that every caller must supply for nothing.
Second, :26 makes image_token=None the default, and image_token's only remaining use is the cross-check at :45-46:
if self.image_token is not None:
valid &= ~visual | (tokens == self.image_token)
So the class now has an optional field whose sole effect, when omitted, is to silently drop a validation rule — an invalid state (index-driven injection with a token check nobody asked for, or vice versa) is representable, and defaulting to None is the strictest-weakening direction. The PR's own thesis is that the index is the invariant; either the token id is a real requirement (keep it positional/required, as all 5 in-tree call sites in tests/components/test_vision_state.py:17,39,55,81 already pass it) or it is not needed (delete the field and :45-46 entirely, and drop the metadata parameter with it). Carrying it as "required before, optional now, used once, disable-able by omission" is the one shape worth subtracting.
Caveat for whoever applies this: the 9 recipes are external (AGENTS.md:382-396 (not opened)), so dropping the metadata argument is a call-site edit there; the if self.image_token is not None weakening can be removed with no external churn by making the argument required again.
3. [Medium] validate_prefill repeats the ~visual | … plumbing three times; inject already shows the one-conjunct form
ignition/components/vision_state.py:43-49:
visual = index >= 0
valid = (index == -1) | (visual & (index < self.count[slot]) & (index < self.arena.shape[1]))
if self.image_token is not None:
valid &= ~visual | (tokens == self.image_token)
valid &= ~visual | (self.generation[slot] == b.row_generations[0])
valid &= ~visual | ((self.feature_slot >= 0) & (self.feature_slot < self.arena.shape[0]))
return (~live | valid).all()
Three separate valid &= ~visual | X lines are equivalent to one conjunction, and inject right below (:55-60) already computes exactly that conjunction as a single visual mask. Collapsing to
visual = index >= 0
indexed = (index < self.count[slot]) & (index < self.arena.shape[1]) \
& (self.generation[slot] == b.row_generations[0]) \
& (self.feature_slot >= 0) & (self.feature_slot < self.arena.shape[0])
valid = (index == -1) | (visual & indexed)
if self.image_token is not None:
valid &= ~visual | (tokens == self.image_token)
keeps the exact semantics (including the tested index == -1 vs index < -1 distinction, test_vision_state.py:111-112) and makes the two methods read as the same rule, which is the stated goal of the PR. It also removes the duplicated (self.feature_slot >= 0) & (self.feature_slot < self.arena.shape[0]) expression that currently appears verbatim at :48 and :58-59.
4. [Medium] Two of the three new wrappers have no production caller left
The PR adds four names (validate_continuation_prompt_data, Admission::validate_continuation, Admission::from_continuation, plus initial_prompt_tokens threading) while keeping three thin delegating wrappers:
helios/src/model.rs:406-408—validate_prompt_data→validate_continuation_prompt_data(…, tokens.len()). Two production callers (admission.rs:218,model/prompt.rs:138(not opened)).helios/src/model/admission.rs:72-74—Admission::validate→validate_continuation(config, self.prompt.len()). Callers after this PR:helios/src/model/tests.rs:2521andhelios/src/server/runtime/phase_tests.rs:6424only — zero production callers.helios/src/model/admission.rs:122-137—Admission::from_prompt→from_continuation(…, prompt.tokens.len(), …). Caller after this PR:phase_tests.rs:6412only — zero production callers.
Admission::from_prompt was what Worker::admit called (runtime.rs before-diff line); the PR replaced the last production use. If these are not part of an intentionally published API (they are pub, so that is a judgement call for the author), deleting Admission::validate and Admission::from_prompt removes ~30 lines of indirection whose only remaining consumers are tests — and the tests at tests.rs:2521-2522 and phase_tests.rs:6412-6424 exist specifically to assert the wrappers' tokens.len() behaviour, so they would go too. validate_prompt_data is worth keeping: its two callers are real and its name states the strict-prefix policy.
5. [Medium] validate_continuation_prompt_data checks the same array length twice, in two different blocks
helios/src/model.rs:427-428 and :453:
|| (!data.vision_token_indices.is_empty()
&& (data.vision_token_indices.len() != tokens.len() // 428
…
if data.vision_token_indices.len() != tokens.len() // 453
The second only fires when the array is empty and an image_tokens layout exists, because the first is gated on !is_empty(). That is one rule split across two places for a gating accident; hoisting the length check once (before the geometry chain, applied whenever the array is non-empty, or restated as data.vision_token_indices.len() != tokens.len() unconditionally when image_tokens is set) makes it legible and lets the image_tokens block start directly with the bijection.
Adjacent, lower value but same function: the 30-line boolean chain at :421-449 mixes geometry, vision indices, spans and vocabulary and reports all of them as one string, "prompt arrays violate prepared geometry" (:450). Two of this PR's own new invariants are boundary-argument checks (initial_prompt_tokens == 0 && !tokens.is_empty(), initial_prompt_tokens > tokens.len()); folding them into a message that also means "your spans overlap" will make the first field report of a bad boundary essentially undebuggable. Splitting into 3–4 named checks with distinct messages costs no lines and is the only change here I would call a correctness-of-diagnostics issue rather than a style one.
6. [Low] The new phase test hand-rolls a drive loop the file already provides twice
helios/src/server/runtime/phase_tests.rs:9061-9082 and :9121-9163 are two near-identical plan → reserve_and_pack → completion → complete → publish → drain budget events loops (~40 lines total) differing only in the sampling predicate and the break condition; the file already has advance, planned, budget_pass helpers for exactly this (:355, :394, :426). The 154-line vlm_feature_token_survives_preemption_and_thinking_budget_readmission is the single largest test added and roughly a third of it is loop scaffolding duplicated from its own inner section. Extract one local closure drive(&mut worker, …) -> bool and the test drops ~40 lines — the +374 test lines are the bulk of the PR's size and are worth one pass before merge.
7. [Low] Naming collision between the two new continuation validators
helios/src/model/admission.rs:76 Admission::validate_continuation and helios/src/model.rs:414 validate_continuation_prompt_data are two layers of the same rule with almost the same name, one calling the other (admission.rs:105). The outer one validates sampling, core parameters, grammar mask and prompt length and then the metadata; a name that says so (validate_request_for_prompt_boundary) or inlining the boundary into validate_continuation_prompt_data's own caller would avoid a future reader assuming they are duplicates of each other. Cosmetic, but it is the kind of ambiguity this repo's docs/design-review.md (not opened) wording rules single out.
What is already lean (no action)
helios/src/model/admission.rs:15-57—PromptMetadataMut::extend_textis untouched and remains the single source of the-1continuation indices; the PR correctly reuses it rather than adding a parallel path.helios/src/server/runtime.rs:1629-1632—parked.as_ref().and_then(|p| p.carried.prompt_tokens).unwrap_or(incoming.prompt.tokens.len())is the minimal correct read of the existingCarriedfield; no new state was added, no newOptionwas introduced. Good.helios/src/model/admission.rs:25-56/model.rsdiff — no new config knob, no newModelContractfield, no capability flag, no CLI surface. The PR adds zero operator-visible state; the four-name API addition is confined to validation. This is the right shape.ignition/components/vision_state.py:33-36— arena/generation/count allocation untouched;images_slots=Nonehandling unchanged.tests/components/test_vision_state.py(+67) — five focused assertions reusing the existing fixture style, no duplicated setup helpers.- No CLI flags, no config keys, no dead feature gates, and no duplicated helper that already existed elsewhere, beyond the items above.
Bottom line
Ship the Ignition semantics (they are right), but before merge: (1) hoist TokenStops/TextStops above the admission call in Worker::admit and collapse the three isolation arms into one, restoring the flat match parked — this is the single biggest subtraction available (~30 lines, two indentation levels, and it also resolves the progress = true inconsistency against runtime.rs:1573); (2) decide whether image_token is required or gone, and drop the now-unread metadata parameter of inject; (3) collapse the three valid &= ~visual | … lines in validate_prefill into the one conjunction inject already uses; (4) delete Admission::validate / Admission::from_prompt if they are not published API — they have no production callers left after this PR.