PR #575 — Correctness, Contracts & System-Level Consequences review
Head a0d9065 ("Preserve raw JSON tool arguments in TmlOutput for strict TMLv0 calls"), 3 files, +237/−10. Bug is still live on main (helios/src/output/tml.rs:341-369, args.to_string() at :365), so this PR is not superseded.
Key findings
The fix is correct, minimal, and in the right layer. No Blocker. The gaps are contract/documentation (1 Major) and prompt-side symmetry plus test evidence (3 Minor). Nothing in the concurrency, contention, memory, failure-blast-radius, stale-state, platform-parity or metric-span areas is wrong — and I say that with evidence below rather than inventing an issue.
| # | Severity | Issue | Citation |
|---|---|---|---|
| A | Major | Verbatim args forwarding changes bytes for all TMLv0 calls and silently drops duplicate-key calls to visible text; neither is documented in docs/api.md nor tested for non-strict |
helios/src/output/tml.rs:343-372; docs/api.md:614-631; AGENTS.md:52-60 |
| B | Minor | Prompt-side mirror still round-trips arguments through Value, so the 30-digit id this PR preserves is shrunk to binary64 on the next turn |
helios/src/frontend/tml.rs:148-174, :488-494, :75-88 |
| C | Minor | No JSON-object guard before hand-off; raw bytes reach downstream re-parsers whose failure still maps to HTTP 500 | helios/src/output/tml.rs:352-353; server/output.rs:148-156, :1823-1827; protocol/encode.rs:539-541 |
| D | Minor | Test/claim gaps: order assertion cannot distinguish old from new code, the Python test is skipped without a live env, docs/TODO.txt item still open |
tests/server/test_inkling2.py:23-26,140-141; docs/TODO.txt:5-8 |
Area 1/2 — Correctness and system-level consequences
C — Minor: the parser no longer guarantees the args text is a parseable JSON object before downstream sinks re-parse it
helios/src/output/tml.rs:351-361:
let parsed: RawCall<'_> = serde_json::from_str(body).ok()?;
let args = parsed.args.get().trim();
if !args.starts_with('{')
|| !self.tools.iter().any(|tool| tool["function"]["name"] == parsed.name)
|| self.name.as_ref().is_some_and(|header| header != &parsed.name)
{
return None;
}
&RawValue guarantees args is a syntactically valid JSON value (it must parse for the wrapper to parse), so this is a one-character shape test, no longer main's filter(|v| v.is_object()) (main helios/src/output/tml.rs:345). Consumers that immediately re-parse and can turn a mismatch into a 500:
- Chat
helios/src/server/output.rs:148-156:serde_json::from_str(&call.arguments).map_err(... "tool arguments are not valid JSON" ...)thenif !value.is_object() { return Err(...) }. - Responses
helios/src/server/output.rs:1823-1827: same pattern,format!("invalid tool arguments: {e}"). - Strict buffered path
helios/src/server/protocol/encode.rs:539-541:.validate(&arguments)?, which re-tokenizes the exact bytes (helios/src/grammar.rs:645-647:if trie.decode_raw(&tokens) != text.as_bytes() { ... "cannot be represented by the tokenizer byte trie" }).
All of these become Error::Execution → helios/src/server.rs:735 _ => StatusCode::INTERNAL_SERVER_ERROR (and helios/src/server/http.rs:638-646 for the streaming path).
Impact: this is a net reduction of the 500 surface (the >u64 case is genuinely fixed, and the strict validator now sees the model's own bytes), so it is not a regression to block on. But the PR claims it "eliminates HTTP 500 failures on >64-bit integers" without noting that exact-byte forwarding shifts the burden onto the validator/tokenizer accepting the model's precise spelling, where before main fed them a canonical re-serialization.
Fix (cheapest, preserves main's all-or-nothing safety): after !args.starts_with('{'), also require serde_json::from_str::<&RawValue>(args).is_ok() (or that it deserializes to an object), returning None → visible text otherwise — exactly what main's .ok()? did.
Soundness (verified clean — no findings)
- Concurrency/contention:
call()touches onlyself.tools,self.calls,self.name(helios/src/output/tml.rs:342-376) — per-request, per-generation state. No shared lock, channel, or cross-request queue; parsing is still driven one token at a time from the decode loop, so no head-of-line blocking and no new serialized bottleneck. - Memory/allocation: net improvement.
mainbuilt a fullValuetree forargsplusargs.to_string()(main:342-365, two argument-byte allocations); head borrows&RawValueoverbodyand does oneargs.to_owned()(:372). Pre-existing bounds untouched: 1 MiB call boundhelios/src/output/tml.rs:303-305, 8 MiB argument boundhelios/src/server/output.rs:1803. - Failure blast radius / stale state: single-request only; no poisoning of coalesced peers.
finish()(:378-402) still clears buffer/pending and only completes a call atTermination::Eos(:394).deny_unknown_fieldscannot leave partial state — the parse is all-or-nothing before any mutation;self.callsincrements only on an accepted call (:362-363), as on main. - Platform parity: no new platform-conditional code;
serde_jsonalready enablesraw_valueunconditionally (helios/Cargo.toml:52), so ARM64/x86 and Unix/Windows take the same path. - Metric/rate/admission-pricing span check: N/A. No sampling, latency, or admission instrumentation appears in the diff; the measured span is unchanged.
Area 3 — Architecture and contracts
A — Major: a global, non-opt-in wire change with no contract update
Head helios/src/output/tml.rs:343-349, 352, 370-372:
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct RawCall<'a> {
name: String,
#[serde(borrow)]
args: &'a RawValue,
}
...
let args = parsed.args.get().trim();
...
Event::ToolArguments { index, text: args.to_owned() },
against main helios/src/output/tml.rs:342-366:
let value: Value = serde_json::from_str(body).ok()?;
let object = value.as_object()?;
let args = object.get("args").filter(|v| v.is_object())?;
if object.len() != 2 ...
text: args.to_string(),
Three behavioural changes apply to every TMLv0 call, not just strict: true ones:
- Byte-level output changes. On main,
args.to_string()re-serialized theValue, normalizing interior whitespace and escapes ({"a": 1}→{"a":1}). At head, only outer whitespace is trimmed (:352), so{"a": 1}reaches the client with interior spaces. - Duplicate wrapper keys now degrade to visible text. Main parsed into a
serde_json::Map(withpreserve_order), which collapses duplicate keys, so{"name":"lookup","name":"lookup","args":{}}satisfiedobject.len() != 2and was accepted as a call. Head'sdeny_unknown_fields(:343-344) rejects it, andcall_or_text(:331-340) emits the whole block asEvent::Content. The new unit test asserts exactly this (helios/src/output/tml.rs:632-641). - Number spelling and precision are now forwarded verbatim (the intent).
None of this is stated where clients and contributors look for contracts. docs/api.md:614-631 still describes strict TMLv0 only in terms of schema keywords and tool-name recognition, with nothing about raw-args forwarding, verbatim whitespace, or the duplicate-key fallback. AGENTS.md:52-60 requires that qualification and behaviour be stated ("State support as present qualification"; "State designed behavior that the code does not implement as a specification"), and the PR description itself lists the non-strict change only under "Caveats".
Impact: a silent wire-format change for the non-strict path (the overwhelmingly common one) that no client-facing doc mentions and no test pins.
Fix: document the raw-argument contract next to docs/api.md:614-631 (TMLv0 forwards generated argument bytes verbatim; only outer whitespace trimmed; a wrapper with duplicate or extra keys is shown as visible text), and either add one non-strict unit test asserting verbatim whitespace/escape forwarding, or scope verbatim forwarding to strict calls and keep main's canonicalization otherwise.
Charter/layering: correct — this is a bug fix in the output parser that owns wire formatting, not a per-model branch; TmlJson handling stays inside its own module and grammar/strict.rs gains only a test. No new deps, no new flags, no captured-graph op contract, so no owner sign-off requirement applies.
Area 1 — Prompt-side asymmetry
B — Minor: the prompt renderer still collapses the precision the output side now preserves
helios/src/frontend/tml.rs:148-174 (arguments), reached at :488-494:
let body = arguments(name, &function["arguments"])?;
prompt.frame(prompt.tokens.model, name, prompt.tokens.invoke, &body)?;
with :151-158 parsing the string arguments into Json and write_json (:75-88) printing floats via ryu::Buffer / number.as_f64().
Impact: the agentic loop this feature targets (client receives the tool call, executes it, sends it back with the assistant turn) re-renders the arguments through Value, so a 30-digit id the server just forwarded verbatim becomes 1.2345678901234568e29 in the next request's prompt. The precision the PR restores is one turn deep only.
Fix: carry the argument string as &RawValue/raw text in arguments() (only the outer {"name":…,"args":{…}} wrapper needs reassembly), and add a round-trip test: emit a 30-digit args block, feed it back as assistant history, assert all 30 digits appear in the rendered tokens.
Area 4 — Tests and claim accuracy
D — Minor
- Order assertion is not evidence.
tests/server/test_inkling2.py:140-141:
This passes onparsed = json.loads(call["function"]["arguments"]) assert list(parsed.keys()) == ["big_id", "city"] and parsed["city"] == "Paris"maintoo:helios/Cargo.toml:52enablespreserve_order, soargs.to_string()already preserved key order. Only thebig in …assertions (:139,:152,:192) exercise the fix. - The Python test never runs in-repo.
tests/server/test_inkling2.py:23-26module-skips unlessFLARE_RUN_CUDA_TESTS=1andFLARE_INKLING2_TEST_URLare set; the newtest_strict_tml_tool_calls_and_truncation(:121-209) is therefore collected and skipped by the CPU pytest workflow. It also re-fetches/v1/models(:123) instead of reusing the moduleservicefixture (:29-38), which is what the autobot's "test fixture reuse" nit points at. - Rust tests are consistent with the tree but the live claims are unverifiable.
helios/src/output/tml.rshas 7#[test]with the new one at:620(call_preserves_raw_json_arguments_including_arbitrary_precision_integers,:620-642);grammar::stricthas 28 plus one#[ignore]remaining; the newstrict.rstest'sraw_args.matches(big).count() == 5matches its fivebigleaves. The author's counts therefore check out arithmetically, but the "35/35 strict TMLv0 live serving tests" harness is not in the repository. docs/TODO.txt:5-8remains[ ]for exactly this qualification ("Close when a served TMLv0 core passes those checks and the result is recorded"). Because the result is not recorded in-repo, leaving it open is defensible — but the PR should say so instead of leaving reviewers to infer it.
Context the report must not misstate
- The bug is real and still present on
main; this PR is the fix. - The only review is the autobot "Ready To Merge / 0 blockers / 4 nits" of 2026-11-28, written against pre-rebase
c7fae93; it is stale fora0d9065, and there are zero human reviews. These findings have not been adjudicated by a maintainer. - The sign-off/digest concern from earlier passes is withdrawn — the commit now carries
design-review=2e5b, the digest maintainers treat as current.
Open questions / not verifiable with these tools
- Whether any CI check actually ran on
a0d9065, and whether a re-review is scheduled (not observable here). - The live 35/35 run and the new Python test's real result (needs a live Inkling 2 TP4 service).
- The commit's trailer identity was read from the author's comment, not the commit object; the sha256 correspondence of
2e5btodocs/design-review.md(not opened) at base571a4471is not recomputable here.