Architecture scratchpad · NVIDIA/hyperflare-inference #457

Raw Markdown for agents: https://autobot.eidonix.com/p/bfa8b217-9461-4c2b-9a8e-da995e47a7a8.md

#1 [high] B-lens: approach is in-role; TMLv0 parser is shared typed-enum code

Scope/placement verdict: OK.

#2 [high] should fix: docs/api.md not updated for the new TMLv0 failure mode

helios/src/output/tml.rs:399-401 returns Err at Termination::Eos when a non-empty model header closed without a content kind and nothing was emitted. Through helios/src/server/output.rs:332-341 (Decoder::finish -> parser.finish(cause)?) and helios/src/server/protocol/encode.rs:760 (failure) this turns a previously successful response into response.failed / HTTP 500 server_error (asserted in helios/src/server/request/tml_tests.rs:274-281).

docs/api.md is the API specification for output parsing and failure behavior: it documents the TMLv0 tool parser at docs/api.md:585-602 and failure modes such as "Malformed envelopes and empty names still fail parsing" (docs/api.md:535-536) and "Missing calls ... produce HTTP 500" (docs/api.md:543-545). I searched docs/api.md for the TMLv0/untyped-header rule and it is absent: grep for TML in docs gives only docs/api.md:587,601. AGENTS.md:47-55 requires documents to state present behavior ("State support as present qualification: what is implemented...") and docs/TODO.txt carries unresolved items, not design specs.

Why it matters: a client sees a new 500/server_error path for model-generated output on Inkling 2 TMLv0 cores; without the spec sentence, the API contract in docs/api.md still implies such a turn completes. Fix: add one sentence to the TMLv0 paragraph in docs/api.md (near lines 585-602): a non-empty model header closed by <|end_message|>/<|content_model_end_sampling|> with no content-kind token and no visible text or tool call fails the response at EOS, while empty headers, non-model role headers, and turns that emit text/calls are unaffected.

#4 [high] Architecture checks that passed (no violation): flags, weakened constraints, layering

No violation found for these, and they were checked in code, so the report can say the lens found nothing here:

  1. No per-model branch / flag. The new state is parser-internal (AnswerState, helios/src/output/tml.rs:78-83,104,139) and all new grammar is keyed on the prepared parser kind through OutputPipeline::grammar_envelope (helios/src/output/pipeline.rs:176-190 -> helios/src/grammar.rs:241-246 -> compile_content_headers / compile_strict_tml). AGENTS.md:346-358, docs/design-review.md:31-49 forbid per-model booleans/capability flags; none added. Charter: "Keep the runtime small and model-agnostic."
  2. No weakened constraint. The preamble form (answer ({restart} thinking* tool)* | tools) (grammar.rs:403-406, strict.rs:1613-1619) still permits at most one @answer frame and, under single_call, at most one tool; the tests assert rejection of {answer}{unnamed_call}{answer} (grammar.rs new test) and preamble_two under single_call (strict.rs:4631-4633). The unnamed tool rule is backed by a JSON schema enum of registered names (grammar.rs:382-390) so unregistered tools are still rejected — this is consistent with docs/api.md:600-602 ("With an active strict tool, TMLv0 recognizes only declared tool names").
  3. Evidence for performance/complexity claim: PR states it avoids N-way Earley ambiguity by one payload_any enum schema rather than duplicating a payload per tool; that is a compile-time grammar-size argument, not a measured GPU/performance claim, so AGENTS.md's "measured evidence for performance claims" (charter #210; docs/design-review.md:94-102) does not bite. The declared grammar still respects MAX_GRAMMAR_BYTES budgets (grammar.rs:22; strict.rs budget.value on payloads at 1580).
  4. Layering: fix lives in the output parser (parsing layer), not in HTTP/encoder code; the HTTP layer only observes the existing error path (helios/src/server/output.rs:332-341).
  5. Note for the report: the added long error string and 4 test additions are proportionate; no churn/refactor beyond the changed functions (AGENTS.md:183-188).

Caveat to record honestly: I could not run cargo (no tool access to build), so all of the above is read from source, not from executing the tests.

#3 [medium] nit: TODO strict-TMLv0 qualification unrun for Chat/streamed/truncation

nit — docs/TODO.txt:25-28 carries "[ ] Qualify strict: true function tools on a TMLv0 core (ToolParserKind::TmlJson, e.g. Inkling 2) served by flare run. Check Chat Completions and Responses, buffered and streamed, including max_tokens and max_output_tokens truncation." The PR changes compile_strict_tml (helios/src/grammar/strict.rs:1599-1619) and claims live SM120 verification of strict tools only via /v1/responses with strict get_weather (PR description, "Live SM120 GPU verification"), but its own "Unrun Checks" does not mention Chat Completions strict TMLv0, streamed strict calls, or max_tokens/max_output_tokens truncation of a strict TMLv0 call.

Why it matters: AGENTS.md:189-194 "Identify missing hardware, inputs, and unrun checks explicitly" and AGENTS.md:473-489 / docs/verification.md require validating the affected execution path and capacities; truncation of a strict TMLv0 call is exactly the path touched by (answer ({restart} thinking* tool)? | tools) under single_call. docs/api.md:621-625 states "An output limit or user stop omits a strict call that began but did not finish; EOS inside such a call produces an error."

Severity: nit (description/evidence disclosure, not code). Fix: either run the TODO item's four combinations for TMLv0 strict tools and record them in the PR's evidence, or add the unrun combinations (Chat Completions strict, streamed strict, max_tokens/max_output_tokens truncation) to the "Unrun Checks and Limitations" list and reference docs/TODO.txt:25.