#1 [high] Duplicated termination predicate: drops_unfinished_call vs tagged.rs eos_decision
SUBTRACTION / DUPLICATION finding (strongest one).
New helper, helios/src/server/output.rs:476-480:
/// Whether a termination cause drops a tool call that was announced but never
/// completed, instead of reporting it as an incomplete call.
pub(crate) fn drops_unfinished_call(cause: Termination) -> bool {
cause != Termination::Eos
}
Existing, logically identical classifier in the lower layer, helios/src/output/tagged.rs:247-255:
fn eos_decision(&self, cause: Termination) -> EosDecision {
if matches!(
cause,
Termination::Cancelled
| Termination::ExecutionError
| Termination::UserStop
| Termination::OutputLimit
) {
EosDecision::Omit
Termination has exactly these five variants (helios/src/output.rs:51-58: Eos, OutputLimit, UserStop, Cancelled, ExecutionError), so matches!(cause, Cancelled|ExecutionError|UserStop|OutputLimit) == cause != Termination::Eos. The PR now spells the same rule twice, in two modules, in two directions (one as an inclusion list, one as an exclusion list), so a future sixth variant would silently change only one of them.
Suggested simplification: move the predicate down beside the enum (helios/src/output.rs, after the enum Termination block at output.rs:51-58) as pub(crate) fn drops_unfinished_call(cause: Termination) -> bool, use it in tagged.rs::eos_decision's first branch (if drops_unfinished_call(cause) { EosDecision::Omit } …) and delete the four-arm matches!, and delete the copy at server/output.rs:476-480. Net: one definition, one spelling, no behaviour change.
Secondary: both remaining uses of the helper are inside helios/src/server/output.rs (lines 164 and 1731), so even if it stays there pub(crate) is unnecessary visibility — a private fn suffices today; only the move to output.rs justifies crate visibility.
#2 [high] finish(cause) parameter sweep: 8 files of test churn for one production caller
SIMPLICITY / CHURN finding.
Accumulator::finish (helios/src/server/output.rs:163) and ResponseOutput::finish (output.rs:1730) gained a mandatory cause: Termination argument whose only production caller is Encoder::finish (helios/src/server/protocol/encode.rs:675 and :677):
if self.protocol == Protocol::Chat {
self.chats[index].finish(cause)?;
}
for change in self.outputs[index].finish(cause)? {
Every other caller in the tree is a test passing the constant Termination::Eos — ~60 sites, of which 8 changed files exist only for this argument:
- helios/src/output/argument_tags.rs:212, 287, 334, 435, 490
- helios/src/output/chatml.rs:418, 650, 833, 1097
- helios/src/output/gemma_call.rs:265
- helios/src/output/minimax_xml.rs:346
- helios/src/output/pipeline.rs:345, 492, 580, 685, 738
- helios/src/output/xtml.rs:464, 508
- helios/src/runtime_core/protobuf.rs:1160
- helios/src/server/runtime/phase_tests.rs:765, 973 (
out.finish(crate::output::Termination::Eos))
Suggested simplification: keep finish() argument-free and add one explicit method per type, e.g. pub(crate) fn drop_unfinished_call(&mut self) holding exactly the bodies now inlined at output.rs:164-168 and output.rs:1731-1738, then in Encoder::finish:
if drops_unfinished_call(cause) {
if self.protocol == Protocol::Chat { self.chats[index].drop_unfinished_call(); }
self.outputs[index].drop_unfinished_call();
}
This deletes the two-argument threading, reverts the 8 mechanical files to zero diff (no finish(Termination::Eos) sweep), and leaves the drop policy visible at the one place that owns the cause. It also makes the state change explicit rather than a hidden side effect of finish.
Honest counterweight to note in the report: threading cause is consistent with ModelOutput::finish(cause) in the same layer (helios/src/output.rs:92, 97), so a reviewer may accept it; the objection is the sweep of 8 unrelated dialect test modules for a single production caller, which AGENTS.md:188-193 ("Reject unsupported abstractions and churn … Unsolicited … sweeps") explicitly discourages. If the parameter is kept, the sweep is the cost, not a defect.
#6 [high] Research summary
Subtraction/Simplicity lens done for PR #685. Findings saved as scratchpad notes 1–5; five suggestions, all with exact citations and verbatim quotes, and the diff is otherwise lean.
High value
- One rule spelled twice. New
drops_unfinished_call(cause) { cause != Termination::Eos }(server/output.rs:476-480) is logically identical to the existingEosDecision::Omitinclusion list in tagged.rs:247-255 (Cancelled|ExecutionError|UserStop|OutputLimit, the only other four variants ofTerminationat output.rs:51-58). Suggest moving the predicate beside the enum and deleting the four-armmatches!ineos_decision; also, its two remaining uses are in the same module, sopub(crate)is unnecessary. finish(cause)sweep. The new mandatorycauseargument onAccumulator::finish(output.rs:163) andResponseOutput::finish(output.rs:1730) has exactly one production caller (encode.rs:675, 677); every other call site is a test passingTermination::Eos, and eight changed files exist only for that sweep (argument_tags, chatml, gemma_call, minimax_xml, pipeline, xtml, protobuf, phase_tests). Adrop_unfinished_call(&mut self)method called fromEncoder::finishremoves the parameter threading, the 8-file churn, and the hidden side effect — noting the counterweight that it matchesModelOutput::finish(cause)in the same layer.
Medium value
3. Same-named duplicate tests. a_truncated_second_call_keeps_the_completed_first_call (dsml.rs:939-960 vs protocol/tests.rs:3894) and a_header_only_call_is_omitted_when_the_response_truncates (dsml.rs:962-984 vs protocol/tests.rs:3964) exist twice with identical fixtures and assertions; the parser copies (~46 lines) can go. Two more dsml tests (~100 lines) largely re-check what the every-split test and the new OutputPipeline→Chat encoder test already cover.
4. docs/api.md duplication. api.md:547-551 restates the finish-reason mapping already specified at api.md:580-589; api.md:550-551 ("A client that received fragments … cannot complete") is design argument, not specification, and omits the real gap (abandoned content_block_start/output_item.added blocks). Also flags that api.md:570-572 documents the 1 MiB bound now tripping after publication — the reverse of #364, which is a maintainer decision per AGENTS.md:182-187.
5. One redundant line. call.check_size()? at dsml.rs:191 duplicates the loop-tail check at dsml.rs:218-220 with no state mutated between them; delete 191 (the one at dsml.rs:201 must stay, since that arm takes the call).
No new config knob, flag, env var, trait, or per-model branch was added; publish() is 6 lines and the Event::ToolBegin move is a net line deletion, so beyond the above the change is idiomatic.
#7 [high] Coverage, comparisons, and overall verdict for the simplicity lens
Scope of this lens and what was actually read (so the report can state coverage honestly).
Files read in full or in the changed regions: helios/src/output/dsml.rs (1-260, 260-400, 380-520, 600-1033), helios/src/server/output.rs (40-185, 455-560, 1540-1870), helios/src/server/protocol/encode.rs (540-632, 630-720), helios/src/server/protocol/tests.rs (3800-3880 + diff), docs/api.md (525-600), plus the diffs of the 8 mechanical files (argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, pipeline.rs, xtml.rs, runtime_core/protobuf.rs, server/runtime/phase_tests.rs), AGENTS.md, and the charter.
Comparison helpers/patterns searched for and reused:
Terminationvariants: helios/src/output.rs:51-58 (exactly five: Eos, OutputLimit, UserStop, Cancelled, ExecutionError) — this is what makes note 1 (predicate duplication) provable.- Existing peers that emit begin/arguments/end as a triple, for the "is the new code idiomatic" question: tagged.rs:266-275 (
emit_calls), xtml.rs:205-216, tml.rs:357-368. All three still publish atomically; dsml.rs:151 + 192 + 204 is now the only incremental publisher. That asymmetry is the documented contract (docs/api.md:540-547), not dead code. - Strict-tool parking encode.rs:564-621 unchanged;
Event::ToolBeginstill intercepted there beforeChange::Start, so the early ToolBegin does not leak a frame for strict tools.
Verdict for the report: the production change is small and idiomatic — DsmlOutput::publish (dsml.rs:49-62) is a 6-line method with a correct guard, the ToolBegin move (dsml.rs:145-156) is a net deletion of ~5 lines, and no new config knob, flag, env var, trait, enum variant, or per-model branch is introduced (so no #267/#334 violation). The subtraction cost sits in (a) the finish(cause) signature sweep over 8 unrelated dialect test modules (note 2), (b) the duplicate termination predicate (note 1), (c) ~240 lines of new tests with same-named duplicates (note 3), and (d) one redundant line (note 5). Nothing in the diff is dead or speculative.
#3 [medium] Duplicate same-named tests across dsml.rs and protocol/tests.rs
DUPLICATION finding in the new tests (+551 test lines total).
Two functions exist twice, under the same name, once in helios/src/output/dsml.rs::streaming_tests and once in helios/src/server/protocol/tests.rs:
a_truncated_second_call_keeps_the_completed_first_call- dsml.rs:939-960 (parser + Accumulator, loops OutputLimit/UserStop/ExecutionError)
- helios/src/server/protocol/tests.rs:3894-3962 (Encoder + Accumulator + all three protocols)
Same fixture text ("…invoke name="write"… path …b"), same assertions (one remaining call,
{"path": "a.txt"}, reasoning preserved).
a_header_only_call_is_omitted_when_the_response_truncates- dsml.rs:962-984
- protocol/tests.rs:3964-4002
Same assertion set (ToolBegin announced, no fragments,
message().get("tool_calls").is_none()).
Suggested simplification: delete dsml.rs:939-984 (~46 lines). The wire-level copies cover everything the parser-level copies assert, and the parser-level truncation contract is already asserted by a_truncated_call_keeps_its_published_fragments_and_omits_the_stored_call (dsml.rs:916-937). Same-named tests in two modules also break cargo test <name> targeting and make failures ambiguous.
Related, lower value: published_fragments_reconstruct_the_stored_arguments_at_every_split (dsml.rs:845-888) re-checks concatenation that protocol/tests.rs:4004 dsml_arguments_reach_the_chat_wire_while_the_call_is_open already checks end-to-end (fragments == expected and == stored); and a_call_opens_and_publishes_arguments_before_its_envelope_closes (dsml.rs:792-842) char-feeds the same fixture for a prefix assertion that the every-split test also covers (dsml.rs:883-887). Merging those two would keep the coverage and drop most of ~100 lines; the module is 285 lines of tests for ~60 lines of production change.
#4 [medium] docs/api.md: new parser paragraph duplicates the finish-reason paragraph and carries rationale
CONVENTION / DUPLICATION finding in docs/api.md (+25/-12).
New text, docs/api.md:547-551:
buffered response for every termination other than natural end-of-sequence, and
the response reports that termination's finish reason; only an output-limit
termination reports the output limit. A client that received fragments of such a
call has already seen a call that cannot complete. At natural completion,
restates the mapping already specified 30 lines later at docs/api.md:580-589:
The terminal event carries a termination cause, and each protocol maps the
cause to its finish reason. An output limit reports `length` on Chat
Completions and `max_tokens` on Messages, and `incomplete` with
`incomplete_details.reason` `max_output_tokens` on Responses, even when parsed
calls completed the answer.
Two statements of the same finish-reason rule in one section will drift. Suggested simplification: reduce the parser paragraph to the new fact only ("An announced call cut off before completion is omitted from a buffered response; it is an error only at natural end-of-sequence"), and put the one-line consequence next to the existing finish-reason paragraph at docs/api.md:580-589 where stop/length/stop_reason are already defined.
Second, docs/api.md:550-551 (A client that received fragments of such a call has already seen a call that cannot complete.) is an argument for the design, not a specification of behaviour, and mentions no protocol grammar (Messages content_block_start / Responses output_item.added are now emitted with no content_block_stop / output_item.done). AGENTS.md:52-60 says every repository document specifies architecture or instructs agents; a persuading sentence belongs in the PR description, and the missing piece is the terminal event a client should expect. Replace it with the designed behaviour (which terminal event follows the abandoned block) or drop it.
Third, docs/api.md:570-572 now documents the 1 MiB bound tripping after publication ("The bound is enforced on the append that crosses it, after the call name and earlier argument fragments were published and are not retracted"), which is the exact reverse of #364's reviewed property (bound checked before the first tool event). The text is honest, but the report should flag that the docs change is stated as a new contract rather than as a deliberate relaxation of #364 — a maintainer decision AGENTS.md:182-187 ("Reject weakened guarantees … Resolve conflicts through an explicit maintainer decision") reserves for @voipmonitor/@yatesdr.
#5 [medium] Redundant check_size in the argument-text arm
SUBTRACTION finding, one line.
helios/src/output/dsml.rs:190-193 (added by the PR):
call.arguments.push_str(source);
}
call.check_size()?;
call.publish(self.calls, events);
}
call.check_size()? at dsml.rs:191 duplicates the check the loop already performs after every action, dsml.rs:218-220 (unchanged by the PR):
if let Some(call) = &self.call {
call.check_size()?;
}
Nothing between 191 and 219 mutates call.arguments or call.name (publish only reads arguments and writes published_argument_bytes), so both calls test the same state and return the same error; and apply returns Err without emitting its events, so the earlier position buys no "don't publish past the bound" guarantee. Suggested simplification: delete line 191, keeping call.publish(...) at 192. The other added check, dsml.rs:201 (ToolCallArgumentsEnd arm), must stay: that arm take()s the call at dsml.rs:195-198, so the trailing check at 218 no longer sees it.
Net effect of the whole lens: the diff is otherwise lean. publish() (dsml.rs:49-62) is 6 lines of body and correctly encodes the literal-deferral rule; the Event::ToolBegin move is a net deletion of 5 lines; no new config knob, flag, env var, trait, or per-model branch is introduced; strict-tool parking (encode.rs:564-621) is untouched; the eight mechanical files exist only for the finish(cause) argument.