#1 [high] PR 457 orientation & rules
PR #457 (open, ready for review), head aacbca1, base main b9cac839. 4 files, +431/-7:
- helios/src/output/tml.rs: new
AnswerStateenum (Empty/HeaderWithoutContent/Emitted) on TmlOutput;finish()errors on Eos when HeaderWithoutContent; call_or_text marks Emitted before parsing. - helios/src/grammar.rs compile_content_headers: new
tool_unnamedrule + @payload_any enum schema when tools non-empty; ending changed from "(answer | tools)" to "(answer ({restart} thinking* tool)* | tools)". - helios/src/grammar/strict.rs compile_strict_tml:
tool_unnamedwith(@payload_0 | ... | @payload_k); ending now single_call -> "(answer ({restart} thinking* tool)? | tools)". - helios/src/server/request/tml_tests.rs: 3 new #[ignore] snapshot tests.
Relevant repo rules read:
- charter (read_charter): "Solve the right problem in the right place... Look for the smallest footprint in shared code, or a way to solve it without new code at all." "Keep the runtime small and model-agnostic."
- AGENTS.md:179-194: "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement." "Require focused, meaningful validation. Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness."
- docs/design-review.md principles 1 (keep Helios as simple as possible), 12 (validate the real path and report evidence honestly), 15 (reject scope expansion), 16 (write without hidden context).
- .agents/skills/repo-prose/SKILL.md: comments explain invariants, not change history.
#2 [high] should fix: two snapshot tests replay the same captured token list
helios/src/server/request/tml_tests.rs:246-282 a_model_frame_without_a_content_kind_reports_a_failed_response and :393-439 inkling_stress_untyped_closed_header_must_surface_failure feed the same token sequence: [200001, 200008] + encode("Inspect the branch.") + [END_MESSAGE, 200001] + the same 15 ordinary IDs [33131,1,70469,1,25,1,3960,150309,12,68206,155417,152664,1,92,92] + [END_MESSAGE, 200006], through the same Decoder/Encoder pair built from the same Inkling fixture, and both assert decoder.finish(Eos) errors and the SSE frame is response.failed / status failed. The only differences: request tool_choice field, and the first also asserts frame.data["response"]["error"]["code"] == "server_error" and the per-push reasoning-only invariant.
Fix: delete inkling_stress_untyped_closed_header_must_surface_failure (lines 393-439) and keep the earlier, stronger test; add the tool_choice:"auto" variant as a parameter of that one if it matters. That removes ~47 lines and one ignored test that cannot fail unless the kept one also fails.
Rules: AGENTS.md:189-194 "Require focused, meaningful validation"; charter "look for the smallest footprint in shared code"; .agents/skills/repo-prose/SKILL.md (no development chronology).
#3 [high] should fix: wire-token encoder closure copied a fourth time in tests
The new test strict_tml_grammar_allows_unnamed_headers_and_preamble_before_tools (helios/src/grammar/strict.rs:4572-4588) copies verbatim the encode closure from strict_tool_wire_grammars_enforce_constraints (strict.rs:4205-4221). The same marker-splitting routine also exists at helios/src/server/protocol/tests.rs:469 and :2057, and the new grammar.rs test instead uses tokenizer.encode(...) (grammar.rs:1987-1994) because its tokenizer happens to be a byte-level BPE - so there are now two different ways in the same PR to turn a TML wire string into tokens.
Fix: add one #[cfg(test)] pub(crate) fn wire_tokens(controls: &[(u32, String)], wire: &str) -> Vec<u32> next to byte_tokenizer_with in helios/src/grammar.rs tests, use it in strict.rs:4205, strict.rs:4572 and in content_headers_grammar_allows_preamble_before_tools, and delete the three copies. ~35 lines removed, and the two new tests then test the same encoding.
#4 [high] should fix: tool_unnamed is not on the custom-Lark path the PR credits
helios/src/grammar.rs:381-391 adds a payload_any subgrammar + tool_unnamed rule that duplicates what the named rules already express, and it cannot fire in the configuration the PR says it fixes.
Claim in PR: "activating a custom grammar (such as start: /(?s:.+)/ alongside declared tools)" masked <|content_invoke_tool_json|> after <|message_model|>. But the bundled answer subgrammar is only referenced by the answer rule (grammar.rs:403-407); with start: /(?s:.+)/, the top-level grammar is the custom regex and the tool rules are unreachable, so adding tool_unnamed cannot change what that request accepts. The live 0/5 -> 5/5 claim is therefore attributed to the wrong line, and only the (answer ({restart} thinking* tool)* | tools) ending (grammar.rs:405) plus the unnamed rule matter for strict: true. The test content_headers_grammar_allows_preamble_before_tools also cannot show the fix: it calls compile_lark_in("start: /(?s:.+)/", Some(&envelope)) (grammar.rs:1985) and then asserts two {answer}{tool} strings are accepted - which the unmodified (answer | tools) ending also rejects... i.e. the test does exercise the new ending, but the regex start makes it exercise a path that a real grammar: "start: /(?s:.+)/" request never reaches (see the same structure at grammar.rs:1884-1929 where the envelope is what is under test). Fix: state plainly which grammar path the live measurements used, and drop the enum/payload_any machinery if the named tool_{index} rules already cover strict-schema validation for unnamed headers (they do not: this is the one real addition, so keep it but say why the enum is needed instead of reusing tool_{index}); if the enum is kept, note in the PR description that with an explicit Lark start the tool rules are unreachable and say what the 0/5 measurement was actually blocked on.
#5 [high] nit/should fix: self-referential and duplicated tml.rs tests
-
helios/src/output/tml.rs:646-653
empty_model_headers_other_roles_and_external_stops_keep_their_terminationalready covers what lines 644-647 offrames_without_headers_and_frames_of_other_authors(tml.rs:540-562) shows about USER/SYSTEM/TOOL headed frames producing no content:run(frame, &[USER, TEXT, "echo", END, MODEL, "bob", TEXT, "hi", END, TOOL, "lookup", TEXT, "x", END], ...)asserts content == "hi", i.e. non-model frames contribute nothing. The new test'svec![USER,"name",END],vec![TOOL,"lookup",END],vec![SYSTEM,"name",END]cases repeat that in a third form. Smaller version: keep onlyvec and the four external Termination causes and the TURN_END case, and rely on the existing test for the role frames - or drop the role-frame loop from the old test. Either way one of the two should go. -
helios/src/output/tml.rs:626-639
a_closed_untyped_header_allows_visible_content_and_completed_callstakesexpected = run(frame, valid, Eos)from the same function it is testing, then assertsrun(frame, header ++ valid) == expected. If the header ever started contributing content or errors this still passes as long as it contributes equally in both orders; it can only catch an order-dependent difference. The behaviour is already pinned by the olderframes_without_headers_and_frames_of_other_authors(tml.rs:552-561) andrejected_invocations_...(tml.rs:564-587). Smaller version: assert against literal expected tuples (as those tests do), e.g.(String::new(), "done".into(), vec![]), rather than againstrun(...)of the same parser - otherwise the test proves nothing about what the header does.
Severity: nit for (1), should-fix for (2) since a test that compares the parser with itself cannot catch a regression in the header path.
#8 [high] should fix: new snapshot tests inline token IDs instead of extending the golden fixture
The new ignored snapshot tests hard-code tokenizer IDs (200001, 200008, 33131, 1, 70469, ..., tml_tests.rs:265-270 and 418-424) and build their own Decoder/Encoder, instead of adding a case to tests/frontend/inkling2_tml.json outputs, which is the file's documented pattern: tml_tests.rs:7-12 says the checkpoint tests compare Helios with the fixture "generated by tests/frontend/generate_inkling2_fixtures.py", and that generator already records each case's reference_parse, including {"error": <kind>} for cases tml-renderers itself rejects (generate_inkling2_fixtures.py:399-417).
Why it matters: a hard-coded token list inside Rust proves only that this sequence trips the new check; it does not show that tml-renderers rejects the same sequence, which is the contract TmlOutput is written against (tml.rs:7-15 "as tml-renderers parses it"). If tml-renderers instead parses that suffix as a message, the new error is a Helios-only interpretation.
Fix: add one output(...) case in generate_inkling2_fixtures.py for the malformed terminal header, regenerate the fixture, and let a single test in tml_tests.rs assert (a) Helios fails at EOS and (b) the fixture's reference_parse.error kind. That replaces both hand-rolled tests with one and adds the cross-implementation evidence the PR is missing; if the fixture cannot be regenerated, say so in "Unrun Checks" instead of inlining IDs.
Related: PR claims a 178-tool live measurement, but no test in the diff exceeds two tools, and content_headers_grammar_allows_preamble_before_tools uses one tool. The N-tool ambiguity claim in the description ("avoiding N-way Earley ambiguity across large tool sets") is therefore unverified by the diff.
#9 [high] Summary of lens-D findings for PR 457
Reviewed every changed hunk in context through lens D (simplicity). Files read in full at PR head aacbca1: helios/src/output/tml.rs (1-688), helios/src/grammar.rs (190-440, 920-1060, 1740-1998), helios/src/grammar/strict.rs (1480-1660, 4020-4300, 4460-4637), helios/src/server/request/tml_tests.rs (1-479), plus callers in helios/src/server/request.rs:225-290 and the fixture generator tests/frontend/generate_inkling2_fixtures.py:340-500.
Findings, in severity order:
- should fix, tml_tests.rs:393-439 vs 246-282: two ignored snapshot tests replay the identical captured token list and assert the same failure. Delete the later (entry 2).
- should fix, tml_tests.rs:265-270 / 418-424: hand-inlined tokenizer IDs instead of a generated
outputsfixture case withreference_parse.error, so nothing shows tml-renderers rejects the same sequence (entry 8). - should fix, output/tml.rs:626-639:
a_closed_untyped_header_allows_visible_content_and_completed_callscomparesrun(frame, header++valid)againstrun(frame, valid)- the parser against itself; assert literal expected tuples (entry 5, item 2). - should fix / needs explanation, grammar.rs:381-391 + test at 1932-1997:
tool_unnamedis unreachable when the request suppliesgrammar: "start: /(?s:.+)/"(the custom-Lark start the PR blames), so the live 0/5 -> 5/5 attribution is to the wrong code path or the description is wrong (entry 4). - nit, output/tml.rs:78-83, 282-288, 399:
AnswerState::EmittedandHeaderWithoutContentare never distinguished at the only read; abool(or two) expresses the same decision (entry 7). - nit, output/tml.rs:644-647: role-frame cases duplicate
frames_without_headers_and_frames_of_other_authors(entry 5, item 1). - nit, grammar/strict.rs:1599-1604 vs grammar.rs:381-391: two shapes for the same rule, only one justified; add the one-sentence reason and delete the
payload_refsstaging vector (entry 6).
Nothing in the lens blocked: the change is a correctness fix in the right layer (helios output parser + grammar compiler, no model branching), matching design-review principle 1. The simplicity debt is concentrated in the tests (+~200 of the +431 lines), not the production code (~60 lines).
#6 [medium] nit: named-tool rules differ in shape between grammar.rs and strict.rs without explanation
helios/src/grammar/strict.rs:1599-1604 vs helios/src/grammar.rs:381-391: the same fix (accept an unnamed <|message_model|><|content_invoke_tool_json|> header) is written two different ways in one PR. grammar.rs uses a single payload_any subgrammar with {"name":{"enum": tools},"args":{"type":"object"}}; strict.rs uses an N-way alternation (@payload_0 | ... | @payload_k). The PR explains the grammar.rs choice as "avoiding N-way Earley ambiguity across large tool sets" - but the strict compiler now has exactly that N-way ambiguity, and it is the path reached when "strict": true is set with 178 tools (the measured configuration). The reason the strict side cannot use the enum trick is real: embed_schema_in_tml_wrapper (strict.rs:873) folds the tool name into each payload as a const, so name and args cannot be split.
Fix (smaller, not larger): add one comment above strict.rs:1599-1604 saying that the payloads embed the tool name, so unnamed headers must alternate over them, and that this is why grammar.rs factors an enum instead. Without it the next reader will "unify" the two, or wonder which is deliberate. If the strict alternation does measurably slow large tool sets, that belongs in the PR's limitations, not in code.
Also nit: strict.rs:1566 payload_refs is a vector that only exists to be joined at line 1602 - tool_unnamed could be appended inside the loop's format string or built from tool_rules; harmless, but the repo asks for the smallest footprint.
#7 [medium] nit: AnswerState collapses to a boolean in every read
helios/src/output/tml.rs:78-83 AnswerState has three variants, but HeaderWithoutContent and Emitted are both terminal for the only decision that reads them (tml.rs:399). Reading the whole file, answer transitions in exactly three places: emit (219, non-thinking content), call_or_text (338, non-empty body that is or is not a valid call), Header (282-288). Because line 285 guards on self.answer == AnswerState::Empty, once anything is emitted a later untyped header is never recorded at all - so HeaderWithoutContent and Emitted never need to be distinguished at the check; a single answered: bool (set true by emit/call_or_text and by the untyped-header close) would express the same decision with a two-state field and no new enum:
// in Header, after computing name/marker
if model && at > 0 && matches!(marker, END | TURN_END) { self.answered = true; }
...
if cause == Termination::Eos && self.header_seen_without_answer { ... }
The distinguishing fact the error needs is "a non-empty model header closed and nothing was ever emitted". Two booleans (emitted, bare_header) or one enum with two meaningful values do it; the third value (Emitted as distinct from HeaderWithoutContent) is unreachable at the check because the guard at line 285 prevents overwriting. Confirmed by reading: no other read of self.answer exists (grep self.answer -> tml.rs:139, 219, 285, 287, 338, 399).
Severity: nit. It is 6 lines of new type for a two-state decision, on the charter's "smallest footprint" rule (charter: "Look for the smallest footprint in shared code"); not worth blocking a correctness fix over.