Architecture scratchpad · NVIDIA/hyperflare-inference #575

Raw Markdown for agents: https://autobot.eidonix.com/p/b01dde78-1d46-45fd-bc3d-8ac860221e4b.md

#1 [high] PR 575 overview and rules

PR #575 (open, ready for review, no CI checks, author fordbmorris/GitHub assoc NONE, 3 open PRs, 0 merged). Head c7fae93, base main @167f22c. 3 files, +237/-10. Files: helios/src/output/tml.rs (TmlOutput::call rewritten to serde struct with deny_unknown_fields + borrowed serde_json RawValue args, emits args verbatim; new unit test), helios/src/grammar/strict.rs (new test tml_strict_parser_preserves_30_digit_integers), tests/server/test_inkling2.py (new live test test_strict_tml_tool_calls_and_truncation).

Repo rules read:

Lens: Architecture and scope.

#2 [high] Should fix: docs/TODO.txt TMLv0 strict-tool entry not closed

AGENTS.md "Task tracking" (lines ~514-517 as read): "Use docs/TODO.txt for miscellaneous follow-up items ... Update or remove entries as work is completed." docs/TODO.txt:5-8 (unchanged by this PR): "[ ] 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. Close when a served TMLv0 core passes those checks and the result is recorded." PR body says "This addresses the strict TMLv0 tool-calling qualification tracked in docs/TODO.txt" and reports the live 4-Spark TP4 run (35/35, incl. the truncation checks). pr_files shows only helios/src/output/tml.rs, helios/src/grammar/strict.rs, tests/server/test_inkling2.py — no docs/TODO.txt edit. Severity: should fix. Fix: remove the TODO entry (or record the qualification result there) in the same PR, per AGENTS.md task-tracking rule.

#4 [high] Architecture: change sits in the right shared layer

Architecture verdict: the fix belongs in Helios and is the right layer. TmlOutput (helios/src/output/tml.rs) is the shared parser for ToolParserKind::TmlJson cores; the defect is a lossy serde_json::Value round-trip in that parser, not a model-specific path. The change adds no flag, enum, or per-model branch (AGENTS.md "Architecture and ownership"; design-review principle 1/3) and matches the raw-token preservation already used by the shared tagged-strict path (helios/src/output/tagged.rs:806-860 RawArguments + strict_nonstring_raw) and tag/DSML parsers. Emitting args verbatim is also consistent with the OutputEncoder contract: strict validators (TextGrammar::validate, helios/src/grammar.rs:631-656) are byte-exact, and the grammar that constrains generation (embed_schema_in_tml_wrapper, strict.rs:873-892) emits exactly the name/args wrapper the parser now reads. RawValue does not require enabling serde_json arbitrary_precision, so no dependency-feature change (helios/Cargo.toml:52 already has raw_value). No core/Protobuf change → principle 13 compatibility is preserved; existing cores gain the fix, which the PR states. Second-order note (not a defect, evidence claim): server/output.rs Accumulator::apply (line 113) and Responses/Anthropic encoders (encode.rs:300,334) still re-parse arguments with serde_json::Value, so a 30-digit integer survives only as raw text in arguments strings; response.output_item.done/Anthropic tool_use.input remain binary64-rounded. That is pre-existing and outside this PR's raw-text claim, but the PR's "preserving exact JSON argument text ... matching the Qwen, GLM and DSML parsers" claim should not be read as covering those typed projections. Scope: the new tests/server/test_inkling2.py case matches the tests/server convention (service-gated, FLARE_RUN_CUDA_TESTS; AGENTS.md "Run tests", verification.md) and tests/server survives 17bb3c4a, so the file is still a legitimate home. No scope expansion.

#6 [high] Research summary

Reviewed PR #575 through the architecture-and-scope lens. All three changed files were read in context (helios/src/output/tml.rs including TmlOutput::call, call_or_text, drain and finish; helios/src/grammar/strict.rs including embed_schema_in_tml_wrapper, compile_strict_tml, validate_strict_tool_schema and the new test; tests/server/test_inkling2.py), together with the rules in docs/design-review.md, AGENTS.md, docs/verification.md, docs/api.md and docs/TODO.txt.

Verdict: the change belongs where it is. The defect is a lossy serde_json::Value round-trip inside the shared TmlJson output parser, not a per-model path, and the fix adds no flag, enum value, or per-model branch — it matches the raw-token preservation already used by the shared tagged strict path (RawArguments/strict_nonstring_raw) and the DSML/tag parsers. It needs no serde_json feature change (raw_value is already enabled), no core or Protobuf change, so existing exported TMLv0 cores gain the fix without re-export, consistent with the model-core-compatibility principle. The strict grammar produces exactly the {"name","args"} wrapper the parser now reads, and the byte-exact strict validator is what consumes the emitted text, so the approach closes the reported HTTP 500 at the right layer.

Findings: one "should fix" and two nits. Should fix: docs/TODO.txt lines 5-8, the strict-TMLv0 qualification entry the PR says it addresses, is not updated even though AGENTS.md's task-tracking rule requires entries to be removed when the work completes; the live 35/35 result reported in the description is exactly that recording. Nit: #[serde(deny_unknown_fields)] also makes duplicate wrapper keys reject a call that the previous object.len() == 2 check executed, which only affects non-strict TMLv0 traffic and should be stated in the TMLv0 recovery paragraph of docs/api.md or covered by the unit test. Nit: the emitted arguments are whitespace-trimmed, so "verbatim" is slightly overstated; harmless for generated strict payloads. I also noted, without treating it as a defect of this PR, that the accumulator and the Responses/Anthropic encoders still re-parse arguments through serde_json::Value, so typed projections such as Anthropic tool_use.input remain binary64-limited.

No scope expansion, no weakened validation, and no architectural violation found. Details and citations are in the scratchpad.

#7 [high] Consolidated findings list for the report

Confirmed findings for PR #575 (architecture and scope lens). Nothing blocking.

  1. SHOULD FIX — docs/TODO.txt:5-8, "Qualify strict: true function tools on a TMLv0 core ... Close when a served TMLv0 core passes those checks and the result is recorded." The PR body says "This addresses the strict TMLv0 tool-calling qualification tracked in docs/TODO.txt" and reports the live 4x GB10 TP4 qualification (35/35, including the max_tokens / max_output_tokens truncation checks the entry names). AGENTS.md "Task tracking" requires: "Use docs/TODO.txt for miscellaneous follow-up items ... Update or remove entries as work is completed." pr_files shows no docs/TODO.txt change. Why it matters: the entry is the repository's own record of the qualification; leaving it open contradicts the stated evidence and duplicates future work tracking. Fix: close or record the entry in this PR (or state in the description why it must stay open).

  2. NIT — helios/src/output/tml.rs:330-338 (#[serde(deny_unknown_fields)] struct RawCall). Replacing the object.len() == 2 check with a deny-unknown-fields struct also rejects duplicate wrapper keys, so a payload such as {"name":"lookup","args":{},"name":"lookup"} executed before and now falls back to visible text via call_or_text (tml.rs:317-327). Only duplicate name is tested (tml.rs:619-628); duplicate args is untested. Wrapper duplicates cannot come from the strict grammar (embed_schema_in_tml_wrapper, strict.rs:873-892 sets required + additionalProperties:false), so strict live traffic is unaffected; the tightened acceptance only touches non-strict TMLv0 cores, which the description does not mention. Fix: state the tightened wrapper acceptance in docs/api.md's TMLv0 recovery paragraph, or add the duplicate-args case to the unit test.

  3. NIT — helios/src/output/tml.rs:339,359 emits parsed.args.get().trim(), so emitted arguments are whitespace-trimmed rather than byte-verbatim; the description and commit message claim "verbatim"/"exact JSON argument text". Strict generated payloads cannot contain that padding (the strict schema emits canonical spacing), and trimming preserves the previous normalized behavior, so no code change is required — only soften the claim or note the trim.

Not findings (verified, worth stating in the report):

#3 [medium] Nit: duplicate wrapper keys now reject calls the old code executed

helios/src/output/tml.rs:329-363 (new call). Before: serde_json::Value + object.len() == 2. After: #[serde(deny_unknown_fields)] struct RawCall { name: String, args: &RawValue }. Consequence beyond the precision defect: a wrapper that repeats a key was previously accepted (Value map with preserve_order collapses duplicates, len stays 2 → call executed) and now fails deserialization → falls back to visible text (call_or_text, tml.rs:317-327). Example {"name":"lookup","args":{},"name":"lookup"} executes today, becomes text after the change. Only the duplicate-name case is tested (tml.rs:619-628); duplicate args is untested. Wrapper-level duplicates are not emitted by the strict grammar (embed_schema_in_tml_wrapper has required+additionalProperties:false, strict.rs:873-892), so live strict traffic is unaffected — the change only touches non-strict TMLv0 cores. Severity: nit. Fix: state the tightened acceptance in docs/api.md's TMLv0 recovery paragraph, or add the duplicate-args case to the unit test.

#5 [low] Nit: "verbatim" args are whitespace-trimmed

helios/src/output/tml.rs:338-339 — let args = parsed.args.get().trim(); then if !args.starts_with('{'), and text: args.to_owned() (line 359). So the emitted text is trimmed of leading/trailing whitespace; the "verbatim" claim in the PR body/commit is slightly overstated for a padded payload (e.g. "args": { ... }). The strict grammar admits no whitespace at those positions, so generated strict payloads are unaffected; trimming also keeps the pre-change behavior (args.to_string() normalized) aligned with the prior is_object() check. Also note tml.rs:339 accepts a payload whose first non-space byte is { even if the object is later followed by trailing text — serde rejects that inside RawCall, so it is not reachable. Severity: nit at most, already recorded here for accuracy; no code change needed.