Architecture & scope review — PR #575 (Preserve raw JSON tool arguments in TmlOutput)
Key findings
- No blocking issues. The change sits in the correct, shared layer and needs no flag, enum, per-model branch, model-core or Protobuf change.
- Should fix (1):
docs/TODO.txt:5-8— the strict-TMLv0 qualification entry that the PR body says it "addresses" is not updated, contrary to the repository's own task-tracking rule (AGENTS.md:512-517). - Nits (2):
#[serde(deny_unknown_fields)]also tightens acceptance of duplicate wrapper keys for non-strict TMLv0 traffic (untested for duplicateargs, undocumented); and emitted arguments are whitespace-trimmed, so "verbatim"/"exact JSON argument text" in the description is slightly overstated. - Verified non-issues: scope (no expansion), layer placement, dependency features, model-core compatibility, and the test file's home are all correct. One pre-existing limitation (
Accumulator::apply/ typed projections still go throughserde_json::Value) is outside this PR's claim and should not be read as covered by it.
Project rules applied
docs/design-review.md:16principle 1 "Keep Helios as simple as possible";:40principle 3 "Preserve canonical model semantics and shared mechanisms";:106principle 12 "Validate the real path and report evidence honestly";:116principle 13 "Preserve model core compatibility";:135-136principle 15 "Reject scope expansion and weakened constraints";:163principle 17 (Discord contact).AGENTS.md:512-517§ Task tracking: "Use docs/TODO.txt for miscellaneous follow-up items. Keep entries brief ... Update or remove entries as work is completed."docs/api.md:588-605documents the strict/TMLv0 contract, including which schema keywords and numeric precision are supported.
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:
[ ] 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. 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)
- Correct layer, shared mechanism.
TmlOutput::call(helios/src/output/tml.rs:329-363) is the parser forToolParserKind::TmlJsoncores; the defect was a lossyserde_json::Valueround-trip inside it, not a model-specific path. No new flag, enum value or per-model branch (docs/design-review.md:16,40). The approach matches the raw-token preservation already used by the shared tagged-strict path (RawArguments/strict_nonstring_raw) and the tag/DSML parsers. - No dependency-feature change.
RawValueneedsraw_value, already enabled athelios/Cargo.toml:52(features = ["preserve_order", "float_roundtrip", "raw_value"]);arbitrary_precisionis not needed, so the raw text is preserved without changing how any otherserde_jsonnumber is handled. That is the right trade-off: enablingarbitrary_precisionwould have altered numeric behaviour process-wide. - Compatibility (principle 13). No model core, Protobuf schema or re-export change, so existing exported TMLv0 cores gain the fix on binary upgrade — consistent with
docs/design-review.md:116. - Validator contract. The consumer of the emitted text is the byte-exact strict validator (
TextGrammar::validate), and the emitting grammar (strict.rs:873-892) produces exactly the{"name","args"}wrapper the parser now reads, so emitting raw text closes the reported HTTP 500 at the right layer rather than papering over it. - Test placement / evidence. The new
tests/server/test_inkling2.pycase follows the existing service-gated convention intests/serverand the testing hierarchy indocs/design-review.md:180-210; principle 12 (docs/design-review.md:106) asks for live validation, which the description reports (35/35 on 4× GB10 TP4).docs/design-review.md:163(Discord contact) is satisfied ("Discord: woooflet"). No CI checks are reported on headc7fae93— worth confirming the Rust suites named in the description ran there, but this is the testing lens's call, not an architecture defect. - Scope. Fix, unit tests and one live test only — no scope expansion, no weakened validation (the strict path still validates the exact bytes emitted).
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.