Architecture and scope review — PR #457
Key findings
- The PR ships an HTTP-visible behaviour change with no API specification update. A TMLv0 turn that previously completed now fails the response at EOS, yet
docs/api.md— which documents both the TMLv0 parser and adjacent failure modes — says nothing about the new rule (helios/src/output/tml.rs:399-401;docs/api.md:585-602,docs/api.md:535-545,docs/api.md:621-625). AGENTS.md:47-55 requires repository documents to state present behaviour, anddocs/TODO.txtis for unresolved items, not specifications. Should fix. - The PR applies its own ambiguity-avoidance design to only one of the two TMLv0 grammar paths.
compile_content_headersfactors the unnamed header through one JSON-schemaenum(helios/src/grammar.rs:382-390), with the description explaining this avoids N-way Earley ambiguity across large tool sets.compile_strict_tmlinstead emits a per-tool alternation(@payload_0 | ... | @payload_k)(helios/src/grammar/strict.rs:1599-1603) — exactly the shape the other path avoids — and the live evidence for this path is a single strict tool (get_weather). Should fix (consistency and evidence, not a demonstrated defect). - The unrun-checks list omits the strict-TMLv0 combinations that
docs/TODO.txt:25-28names and that this PR's changedsingle_callending directly governs. Nit. - Everything else in this lens passes: no per-model branch, no new flag or env switch, no weakened grammar guarantee, correct layer for the fix, and no measured-performance claim that needs benchmarks. Details below.
Angle: does this belong in the repository (scope)
In scope and in-role — no finding. The change fixes a real serving defect (silent reasoning-only completion for Responses/Chat clients, described in the PR body) and aligns two grammars with the runtime parser. The charter's "What gets merged" list accepts "a reproducible bug" and "bad docs" (charter, Standards & Contributions), and its How We Work section demands "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error" — which is what helios/src/output/tml.rs:399-401 does, rather than suppressing the discarded header text. This is not a new model recipe, alias, hardware path, or format; the charter's new-model and alias restrictions do not apply.
Placement is right — no finding. The failure is raised in the TML output parser (helios/src/output/tml.rs:376-403), not in the HTTP or encoder layer; the HTTP layer only observes the existing error path (helios/src/server/output.rs:332-341 → helios/src/server/protocol/encode.rs:760 Encoder::failure). Grammar work lives in the grammar compiler next to the sibling parsers. The charter's "Solve the right problem in the right place … Look for the smallest footprint in shared code" is satisfied: the footprint is four files, one of them test-only.
Finding — should fix — docs/api.md:585-602 (and the TMLv0 material near docs/api.md:535-545, docs/api.md:621-625): the new failure mode is not specified.
- What is wrong:
TmlOutput::finishnow returnsErratTermination::Eoswhen a non-empty model header closed on<|end_message|>/<|content_model_end_sampling|>with no content-kind token and nothing emitted (helios/src/output/tml.rs:282-288,:399-401). Combined withhelios/src/server/output.rs:332-341andhelios/src/server/protocol/encode.rs:760this turns a previouslystatus: "completed"response intoresponse.failed/ HTTP 500server_error— asserted by the PR's own test (helios/src/server/request/tml_tests.rs, newa_model_frame_without_a_content_kind_reports_a_failed_response). - Why it matters:
docs/api.mdis the API contract for exactly this surface. The same section already spells out comparable rules ("Malformed envelopes and empty names still fail parsing",docs/api.md:535-536; "Missing calls … produce HTTP 500",docs/api.md:543-545; "EOS inside such a call produces an error",docs/api.md:621-625) and documents the TMLv0 strict-tool behaviour atdocs/api.md:585-602. A search ofdocs/finds TMLv0 mentioned only atdocs/api.md:587,docs/api.md:601,docs/model-preparation.md:1547(not opened),docs/model-preparation.md:1706(not opened) anddocs/TODO.txt:4; the untyped-header rule appears in none of them. AGENTS.md:47-55 states that documents must "State support as present qualification: what is implemented … and what is not qualified", and that unresolved items belong indocs/TODO.txt— so this cannot be deferred to a TODO entry, because it is implemented behaviour. - Fix: add one sentence to the TMLv0 paragraph near
docs/api.md:585-602: a non-empty model header closed by<|end_message|>or<|content_model_end_sampling|>without a content-kind token, in a turn that produced no visible text and no tool call, fails the response at EOS (response.failed/ HTTP 500); empty headers, non-model role headers, external terminations, and turns that emit text or a call are unaffected.
Finding — nit — docs/TODO.txt:25-28 versus the PR's unrun list: strict TMLv0 qualification is incomplete and undisclosed.
- What is wrong:
docs/TODO.txt:25-28records an open qualification item: "Qualifystrict: truefunction tools on a TMLv0 core (ToolParserKind::TmlJson, e.g. Inkling 2) served byflare run. Check Chat Completions and Responses, buffered and streamed, including max_tokens and max_output_tokens truncation." The PR changescompile_strict_tml, including thesingle_calland non-single_callendings (helios/src/grammar/strict.rs:1606-1619), and its live GPU evidence covers only/v1/responseswith"strict": trueon oneget_weathertool. Its "Unrun Checks and Limitations" mentions non-TMLv0 families and non-model role frames but not Chat Completions strict TMLv0, streamed strict calls, ormax_tokens/max_output_tokenstruncation of a strict TMLv0 call. - Why it matters: AGENTS.md:189-194 requires PRs to "Identify missing hardware, inputs, and unrun checks explicitly" and to keep validation focused on the affected contract; truncation is precisely the path the new
(answer ({restart} thinking* tool)? | tools)single-call ending has to behave correctly under, anddocs/api.md:621-625already promises "An output limit or user stop omits a strict call that began but did not finish; EOS inside such a call produces an error." - Fix: either run the four combinations the TODO item names for strict TMLv0 and record them, or list the unrun combinations in the PR's limitations with a pointer to
docs/TODO.txt:25.
Angle: is the approach right (design-review principles)
No per-model special case, no flag — no finding. The new state is parser-internal (AnswerState at helios/src/output/tml.rs:78-83, :104, :139, set at :216-222, :282-288, :334-344, read at :399). No model name, recipe id, capability boolean, or environment switch is introduced; grammar selection stays keyed on the prepared parser kind (helios/src/output/pipeline.rs:183-190 → helios/src/grammar.rs:241-246 → compile_content_headers / compile_strict_tml). That respects the charter's "Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches (#267, #334)" and docs/design-review.md:31-49 on forbidding per-model booleans/capability flags.
Constraints are not weakened — no finding. The new preamble form (answer ({restart} thinking* tool)* | tools) (helios/src/grammar.rs:403-406; helios/src/grammar/strict.rs:1613-1619) still admits at most one @answer frame and, under single_call, at most one tool; the new tests assert rejection of {answer}{call}{answer} (helios/src/grammar.rs new content_headers_grammar_allows_preamble_before_tools) and of the two-tool preamble under single_call (helios/src/grammar/strict.rs, new strict_tml_grammar_allows_unnamed_headers_and_preamble_before_tools). The unnamed header in the content-header path is backed by a schema enum over registered names (helios/src/grammar.rs:382-390), so unregistered tools are still rejected — consistent with docs/api.md:600-602. AGENTS.md:177-182 ("Reject weakened guarantees … Do not remove validation, suppress errors") is satisfied: this change adds rejection where output was previously silently accepted.
Finding — should fix — helios/src/grammar/strict.rs:1599-1604: the two TMLv0 grammar paths diverge in the ambiguity handling the PR argues for.
- What is wrong: the PR description justifies
tool_unnamedincompile_content_headersas a "single JSON schemaenumover registered tool names, avoiding N-way Earley ambiguity across large tool sets" (helios/src/grammar.rs:382-390). The strict path instead writestool_unnamed: <|content_invoke_tool_json|> (@payload_0 | … | @payload_k) <|end_message|>, an alternation over every active tool schema (helios/src/grammar/strict.rs:1599-1603), plus each tool's owntool_{index}rule (:1587-1591). With many strict tools this re-creates the branching the sibling path was designed to avoid. - Why it matters: architecture consistency. Two grammars that are both supposed to mirror
TmlOutputnow differ in construction as well as in evidence, and the design rationale in the description is only half-applied. The workspace's own heap/nodes/bytes budgets (helios/src/grammar.rs:22,helios/src/grammar/strict.rs:2451-2453) bound total size but not Earley ambiguity, so size budgets do not settle it either way. The PR's live strict evidence is one tool (get_weather), and the 178-tool measurement was taken on the non-strict custom-grammar path only. - Fix: either state in the PR why the alternation is acceptable for strict tools (for example, strict tools are few by construction, or the composed grammar's per-tool payloads are already disjoint by
constname) and add a test at a representative tool count, or factor the strict unnamed rule the same way the content-header path does. A test that compiles and advances a strict grammar with, say, 178 tools and records compile time and acceptance would settle what the code alone cannot.
No unsupported abstraction or churn — no finding. The change adds one small enum, three rule strings, and tests; no refactor, no new extension point, no compatibility layer (AGENTS.md:183-188).
No unmeasured performance claim — no finding. The only efficiency argument (factoring the unnamed rule to avoid N-way ambiguity) is a grammar-shape argument tied to observed behaviour on a live server, not a GPU throughput/memory claim, so the charter's benchmark requirement (#210; docs/design-review.md:94-102) does not apply. The separately claimed 0/5 → 5/5 tool-call improvement is measured on a specific SM120 setup, which is the right kind of evidence for a behaviour fix.
Bounded, proportionate, focused — no finding. Four files, +431/−7, one of them tests; the failure message is a single string (helios/src/output/tml.rs:400). The PR body follows the four-question structure AGENTS.md:67-75 requires and separates "Unrun Checks and Limitations" as AGENTS.md:189-194 asks.
Angle: compatibility with what exists
No finding in code. TmlOutput continues to ignore non-model role frames (helios/src/output/tml.rs:213-215, :289-301) and to preserve OutputLimit, UserStop, Cancelled, ExecutionError terminations (helios/src/output/tml.rs:378-383, :399 gates on Termination::Eos), which the new unit test empty_model_headers_other_roles_and_external_stops_keep_their_termination pins. The one compatibility surface that is not covered is the client-visible API contract — that is the docs/api.md finding above.
Open questions and what I could not verify
- Whether the strict-path
(@payload_0 | … | @payload_k)alternation is slow or ambiguity-prone at the tool counts the PR targets (178 tools). Only compiling and advancing such a strict grammar, with timing, would settle it. - Whether maintainers consider the missing
docs/api.mdsentence a merge blocker or a follow-up; AGENTS.md:47-55 and the existing density of failure-mode documentation in the same section argue for updating it in this PR. - I could not build or run the test suite here (no execution access), so all statements above are read from source and from the PR's own reported results, not independently reproduced. The
helios/src/server/output.rs:332-341call path was established during research and is cited from those notes rather than re-read in this final pass;helios/src/server/protocol/encode.rs:760(Encoder::failure) was re-checked directly.