Architecture report · NVIDIA/hyperflare-inference #575

Raw Markdown for agents: https://autobot.eidonix.com/p/5c743494-93f0-4d1b-8eb9-92179663fc61.md

Architecture & scope review — PR #575 (Preserve raw JSON tool arguments in TmlOutput)

Key findings


Project rules applied


Findings

1. Should fix — the TODO entry this PR claims to address is left open

Where: docs/TODO.txt:5-8 (unchanged by the PR; pr_files lists only helios/src/grammar/strict.rs, helios/src/output/tml.rs, tests/server/test_inkling2.py).

Current text:

[ ] Qualify strict: 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. Close when a served TMLv0 core passes those checks and the result is recorded.

What's wrong: The PR body says "This addresses the strict TMLv0 tool-calling qualification tracked in docs/TODO.txt" and its Supporting Evidence reports exactly the run the entry specifies — 35/35 on a live 4× GB10 TP4 Inkling 2 Small NVFP4 serving qualification, "Chat Completions and Responses APIs, buffered and streamed ... max_tokens / max_output_tokens truncation (8/8)". AGENTS.md:514-517 requires entries to be updated or removed as work is completed, and the entry's own closing condition ("Close when a served TMLv0 core passes those checks and the result is recorded") is met by that recorded result.

Why it matters: the TODO file is the repository's single record of open qualification work. Leaving the entry open contradicts the evidence the description offers, and the file stays a stale task list, which the same AGENTS.md paragraph explicitly warns against ("Keep this file focused on durable project guidance rather than task lists or progress notes").

Fix: remove (or strike/record the qualification result for) docs/TODO.txt:5-8 in this PR, per the description and AGENTS.md § Task tracking. If the entry must stay open (e.g. because the qualification used a locally built binary rather than the released flare artifact), the description should say which sub-check is still outstanding.

2. Nit — deny_unknown_fields also rejects duplicate wrapper keys the old code executed

Where: helios/src/output/tml.rs:329-348 (new RawCall with #[serde(deny_unknown_fields)]), replacing the pre-change value.as_object() + object.len() != 2 check (see pr_diff on tml.rs, hunk at the old lines 326-360).

What's wrong: besides rejecting unknown keys (intended), the derived struct also rejects a wrapper that repeats a key, e.g. {"name":"lookup","args":{},"name":"lookup"}. Under the old code the duplicate collapsed inside the serde_json::Value map, len() stayed 2, and the call executed; now deserialization fails and control returns via call_or_text (tml.rs:317-327), so the same bytes surface as visible text. Only the duplicate-name case is asserted (tml.rs:619-628); duplicate args is untested.

Why it matters (and why it is not blocking): the strict grammar cannot produce wrapper duplicates — embed_schema_in_tml_wrapper (helios/src/grammar/strict.rs:873-892) sets required: ["name", "args"] with additionalProperties: false — so strict live traffic is unaffected and this PR's stated benefit holds. The tightened acceptance only touches non-strict TMLv0 cores, which the description does not mention, and it is a behaviour change in a shared parser (principle 3 / principle 15: a constraint change should be stated).

Fix: state the tightened wrapper acceptance in docs/api.md's strict/TMLv0 paragraph (docs/api.md:588-605) — or, minimally, add the duplicate-args case next to the existing duplicate-name assertion at tml.rs:619-628.

3. Nit — "verbatim" arguments are whitespace-trimmed

Where: helios/src/output/tml.rs:338-340 (let args = parsed.args.get().trim();) and tml.rs:359 (text: args.to_owned()).

What's wrong: the emitted ToolArguments text has leading/trailing whitespace removed (e.g. "args": { ... } loses the padding), so the description's "emits args.to_owned() verbatim" and "exact JSON argument text" are slightly overstated for padded payloads.

Why it matters: only the description's accuracy. Strict generated payloads cannot contain that padding, and the trim preserves the previous normalized behaviour that the old args.to_string() produced — so no code change is needed.

Fix: soften "verbatim" to "raw JSON text (leading/trailing whitespace trimmed)" in the description/commit message, or comment the trim at tml.rs:339.


Verified non-findings (architecture and scope lens)

Open question / not covered by this PR

Accumulator::apply re-parses the arguments at helios/src/server/output.rs:113 (serde_json::from_str::<Value>(&call.arguments)), and the Responses/Anthropic encoders rebuild typed values (helios/src/server/encode.rs:300 (not opened),334). A 30-digit integer therefore survives end-to-end only as raw text in the arguments string; byte-streamed arguments deltas and the raw string are correct, while typed projections such as Anthropic tool_use.input remain binary64-limited. This is pre-existing and outside this PR's raw-text claim, but the description's "preserving exact JSON argument text ... matching the Qwen, GLM, and DeepSeek DSML parsers" should not be read as covering those typed projections; a follow-up entry in docs/TODO.txt would be the natural home if that is intended to be fixed.

Could not verify

The live 35/35 qualification and the checkpoint-based Rust test results (server::request::tml_tests, Inkling 2 tokenizer) rest on the description's evidence and cannot be reproduced from the repository; only the CPU unit tests added here (tml.rs:607-629, strict.rs:3819+) were inspected in code.