#1 [high] Subtraction/simplicity review findings for #685 (head b9864ab)
Lens: subtraction/simplicity/conventions. Read at PR head (files 15, +722/−80). pr_diff is broken in this environment (git "could not parse commit c513e46a"), so all evidence is file reads at head + main reads via ref.
FINDING 1 (high) — the abandoned-block dance is over-built. helios/src/server/output.rs:1745-1755:
/// The block `finish` closed for a truncated call, to remove once its
/// closing frame has been rendered.
pub fn take_abandoned(&mut self) -> Option<usize> {
self.abandoned.take()
}
pub fn drop_abandoned(&mut self, index: usize) {
if index + 1 == self.blocks.len() {
self.blocks.pop();
self.calls.pop();
}
}
plus field abandoned: Option<usize> (output.rs:1703) set at :1739, and its only caller helios/src/server/protocol/encode.rs:677-689:
let changes = self.outputs[index].finish(cause)?;
let abandoned = self.outputs[index].take_abandoned();
if let Some(block) = abandoned {
self.outputs[index].drop_abandoned(block);
}
Unreachable guard: finish (output.rs:1731-1741) always sets abandoned = Some(self.blocks.len() - 1) and the encoder renders changes (which never mutate blocks) before calling in, so index + 1 == self.blocks.len() is always true; the else is a silent no-op that would leak the block into response(). Also matches!(self.blocks.last(), Some(Block::Tool { .. })) at :1735 cannot fail when self.open.is_some() (open is always the last block). REPLACE with one method and a bool:
pub fn discard_abandoned(&mut self) {
if std::mem::take(&mut self.abandoned) {
self.blocks.pop();
self.calls.pop();
}
}
encoder becomes one trailing call self.outputs[index].discard_abandoned();. Net: −2 public methods, −1 unreachable branch, −1 dead conjunction, −1 encoder line.
FINDING 2 (high) — passing Termination into the Chat accumulator churns 9 files for a boolean. helios/src/server/output.rs:163-173:
pub(crate) fn finish(&mut self, cause: Termination) -> Result<()> {
if drops_unfinished_call(cause)
&& self.calls.last().is_some_and(|call| !call.ended)
{
self.calls.pop();
}
if self.calls.iter().any(|call| !call.ended) {
return Err("incomplete emitted tool call".into());
}
Ok(())
}
cause is used only through drops_unfinished_call (output.rs:478-480, cause != Termination::Eos). Keep finish(&self) as on main (main helios/src/server/output.rs:163-168) and add discard_unfinished_call(&mut self) (pop last if !ended); Encoder::finish (encode.rs:674-676) then does if drops_unfinished_call(cause) { self.chats[index].discard_unfinished_call(); } self.chats[index].finish()?;. This reverts pure signature churn in 9 files / ~17 call sites: argument_tags.rs:212,287,334,435,490; chatml.rs:418; gemma_call.rs:265; minimax_xml.rs:346; xtml.rs:464,508; protobuf.rs:1160; pipeline.rs:345,492,580,685,738; server/runtime/phase_tests.rs:767,977; deepseek/other dsml tests. Evidence main vs head: main argument_tags.rs:212 output.finish().unwrap(); → head output.finish(Termination::Eos).unwrap();. AGENTS.md:188-193 rejects churn/expanded surface without requirement.
FINDING 3 (medium) — the truncation matrix is re-expressed six times. helios/src/server/protocol/tests.rs:3979-4017 a_header_only_call_is_omitted_when_the_response_truncates duplicates :3809-3907 an_announced_call_publishes_fragments_and_truncation_omits_it with only the Event::ToolArguments apply removed and the same per-protocol finish-reason/empty-body assertions; fold by parameterising the fragment list (for fragments in [vec![], vec![Event::ToolArguments{..}]]) and delete the 39-line test. Same shape in helios/src/output/dsml.rs:962-984 vs :917-937 (same for cause loop, same message().get("tool_calls").is_none() assertion; only the pre-cut differs) — fold to one test with the cut offset/fragment expectation as a parameter. Also inconsistent cause lists between the twins (:3912-3916 omits ExecutionError, :3982-3986 omits Cancelled) — a fold fixes that too.
FINDING 4 (medium) — a false justification should be deleted, not rewritten. docs/api.md:543-547:
byte for byte. The tagged tool parsers publish a call only when its envelope is
complete, because they build its arguments from parameter syntax and the
declared schemas rather than copying the model's text: values are coerced to
declared types, strict container parameters are parsed, and wrapping newlines
are trimmed.
TAGGED_JSON (#670, merged 2026-12-02; helios/src/output/tagged_json.rs:14-49,57) parses the model's own JSON object and re-serialises it with no schema coercion, so the "because" clause is false against main and blocks any rebase. Delete the clause and the non-normative sentence at :550-551 ("A client that received fragments of such a call has already seen a call that cannot complete."), keeping only "tagged parsers publish a call only when its envelope completes".
Checked and NOT worth flagging (load-bearing / already lean): Call::publish + published_argument_bytes (dsml.rs:49-62) — needed because close_literal may rewrite a string="false" value; publishing per parameter instead of per text fragment would lose per-token granularity (the live 566-frame claim). The three check_size() calls (dsml.rs:191, 201, 218-220) are each load-bearing: :191 keeps the bound-crossing append unpublished, :201 covers the closing text after call is taken, :218-220 covers name/label appends. validate_arguments visitor, drops_unfinished_call itself, Event reuse and the no-new-trait design are all minimal. Test helpers in the new streaming_tests/rejection_tests modules are compact.
#4 [high] Research summary
Subtraction/simplicity/conventions lens done. The diff is mostly lean — the streaming core (Call::publish + published_argument_bytes, the three load-bearing check_size() sites, validate_arguments, drops_unfinished_call, the two new dsml test modules) is justified and should not be trimmed. Four concrete simplifications remain, all with file:line, verbatim quotes and replacements in the scratchpad (entry 1, with a correction in entry 2):
- The abandoned-block machinery in
helios/src/server/output.rs:1745-1755is over-built — two public methods, anabandonedfield, an unreachableindex + 1 == self.blocks.len()guard and amatches!(blocks.last(), Some(Block::Tool …))test that cannot fail whenopen.is_some()— to express oneVec::poppair. Collapse to a singlediscard_abandoned(&mut self)and one trailing call inencode.rs:687-689. Accumulator::finish(cause)churns 9 files for a boolean (output.rs:163-173); the cause is only consulted throughdrops_unfinished_call. Restorefinish(&self)as onmainand adddiscard_unfinished_call(&mut self), caller sideencode.rs:674-676, reverting ~17finish(Termination::Eos)edits across argument_tags, chatml, gemma_call, minimax_xml, xtml, protobuf, pipeline, phase_tests and dsml tests — AGENTS.md:188-193 rejects exactly this churn.- Truncation test matrices are expressed six times:
protocol/tests.rs:3979-4017duplicates:3809-3907,dsml.rs:962-984duplicates:917-937; fold each pair by parameterising the pre-cut/fragment list (which also fixes the inconsistent cause lists). docs/api.md:543-547's "because" clause is factually false againstmain(TAGGED_JSON, #670, re-serialises the model's own JSON with no schema coercion) and blocks any rebase: delete the clause and the non-normative sentence at:550-551.
One convention item: the rewritten test assertion at helios/tests/deepseek_output.rs:515 accommodates the behaviour change instead of testing it (AGENTS.md:182-187, 201-207) and should be withdrawn rather than kept. Caveat: pr_diff is unusable in this environment (git cannot parse base commit c513e46a), so all evidence is from file reads at head with main read via ref.
#5 [high] Verbatim anchors for findings 2 and 4, and fold sketch for finding 3
Anchors the report needs, in addition to entries 1-3.
FINDING 2 verbatim. main (helios/src/server/output.rs:163-168):
pub(crate) fn finish(&self) -> Result<()> {
if self.calls.iter().any(|call| !call.ended) {
return Err("incomplete emitted tool call".into());
}
Ok(())
}
Head caller to become two lines, helios/src/server/protocol/encode.rs:674-676:
if self.protocol == Protocol::Chat {
self.chats[index].finish(cause)?;
}
→
if self.protocol == Protocol::Chat {
if drops_unfinished_call(cause) {
self.chats[index].discard_unfinished_call();
}
self.chats[index].finish()?;
}
New helper, sitting beside finish:
pub(crate) fn discard_unfinished_call(&mut self) {
if self.calls.last().is_some_and(|call| !call.ended) {
self.calls.pop();
}
}
drops_unfinished_call (output.rs:478-480) stays: ResponseOutput::finish (output.rs:1733) still calls it. Signature churn reverted at: argument_tags.rs:212,287,334,435,490; chatml.rs:418 (Harness::finish, where it becomes self.output.finish()?); gemma_call.rs:265; minimax_xml.rs:346; xtml.rs:464,508; runtime_core/protobuf.rs:1160; pipeline.rs:345,492,580,685,738; server/runtime/phase_tests.rs:767,977; dsml.rs:456,500,567,631,699,789 and the new streaming/rejection modules keep cause where they genuinely vary it (dsml.rs:932-934, 951-953, 980-981 pass a real cause, so those stay).
FINDING 4 verbatim targets in docs/api.md. The false clause, :543-547:
byte for byte. The tagged tool parsers publish a call only when its envelope is
complete, because they build its arguments from parameter syntax and the
declared schemas rather than copying the model's text: values are coerced to
declared types, strict container parameters are parsed, and wrapping newlines
are trimmed.
Delete from "because" to "trimmed." — keep "The tagged tool parsers publish a call only when its envelope is complete." The non-normative admission to drop, :550-551:
termination reports the output limit. A client that received fragments of such a
call has already seen a call that cannot complete.
Keep the first sentence's content; drop the second sentence only.
FINDING 3 fold sketch. protocol/tests.rs: parameterise the shared body with for fragments in [vec![], vec![Event::ToolArguments { index: 0, text: r#"{"query":"par"#.into() }]], apply them, and assert fragments.len() frames accordingly; both :3809-3907 and :3979-4017 then become one test whose cause list is the union [OutputLimit, UserStop, Cancelled, ExecutionError] (the first omits nothing, the second omits Cancelled). dsml.rs: :917-937 and :962-984 differ only in the cut offset and whether a fragment is expected, so fold to one test taking (cut, expect_fragment) and iterate [(text.find("</|DSML|parameter>").unwrap(), true), (text.find(">\n</|DSML|invoke>").unwrap(), false)].
Caveat to state in the report: no code was run; pr_diff/git cannot resolve base commit c513e46a in this environment, so comparisons of head vs main are from read_file/search_code with explicit ref: main.
#2 [medium] Corrections to findings 1 and 2
Correction to entry 1, FINDING 1: leave the field type as Option<usize> and write
pub fn discard_abandoned(&mut self) {
if std::mem::take(&mut self.abandoned).is_some() {
self.blocks.pop();
self.calls.pop();
}
}
(no field-type change needed; the index + 1 == self.blocks.len() guard at output.rs:1751 is unreachable and should go).
FINDING 2 note: drops_unfinished_call (output.rs:478-480) must stay — ResponseOutput::finish (output.rs:1733) still needs it. Only the Chat Accumulator::finish parameter is the churn. Head accumulators/call sites to revert: docs-api-neutral, listed in entry 1.
#3 [medium] Convention items and verified-lean list
Conventions lens (structural), agreeing with the dossier rather than re-deriving it:
helios/tests/deepseek_output.rs:515—assert_eq!(parsed.ended, 0, "a rejected call reported an end");replacesmain:511'sassert!(published.is_empty()). The test was changed to accept the new behaviour instead of the behaviour being brought in line with the test; under AGENTS.md:182-187 ("Do not remove validation, suppress errors … to obtain passing checks") and :201-207 ("Apply these criteria to documentation and test changes that would weaken the rules"), the accommodation should be withdrawn, not kept. Same category atdocs/api.md:547-549(announced-but-truncated call omitted) which documents a removed error rather than a maintainer-approved behaviour.- These are the only convention items; no other AGENTS.md rule touched structurally (no new flags/enums/traits;
Eventreused unchanged; no new abstraction layer).
Verified lean and should NOT be simplified: Call::publish/published_argument_bytes (dsml.rs:49-62); the three check_size() sites (dsml.rs:191, 201, 218-220); validate_arguments (dsml.rs:398-426); drops_unfinished_call (output.rs:478-480); the new dsml test modules (streaming_tests dsml.rs:749-985, rejection_tests dsml.rs:987-1032).