Candidate brief — PR #575 "Preserve raw JSON tool arguments in TmlOutput for strict TMLv0 calls"
Head c7fae93b, base main, +237/−10 across 3 files: helios/src/grammar/strict.rs (+105/−0), helios/src/output/tml.rs (+41/−10), tests/server/test_inkling2.py (+91/−0). Discussion on the PR is a single flare-autobot case-file comment; no CI checks are reported on head, so there was no red-check/runner-infra noise to filter.
Deduplicated from six upstream lenses (Architecture, Conventions, Simplicity, Correctness, Prose, Subtractive) into 7 surviving candidates: 0 blockers, 2 should-fix, 2 subtract, 3 nits, each with the exact code quoted below.
Key findings
- No blocker. All six lenses agree the production change is correct and is itself a net simplification: one
#[derive(Deserialize)]struct with a borrowed&RawValue(helios/src/output/tml.rs:330-336) replaces main'sValueround-trip plus hand-writtenas_object()/len() != 2/is_object()checks, and deletes theargs.to_string()re-serialization that rounded >u64 integers. No new flag, option, config switch, per-model branch, Protobuf or model-core change;raw_valuewas already enabled athelios/Cargo.toml:52(features = ["preserve_order", "float_roundtrip", "raw_value"]) andarbitrary_precisionappears nowhere in the tree (only in the test fn name attml.rs:608), so the raw-text fix is the right lever rather than a process-wide numeric change. - Two should-fix, both bookkeeping/hygiene rather than defects:
docs/TODO.txt:5-8(the qualification entry the PR's own evidence satisfies) is untouched; andtests/server/test_inkling2.py:121-209hand-rollsurllibfor 4 of its 6 requests instead of using the module's ownservicefixture, so the effort parametrization never reaches the strict path and an HTTP 500 arrives without its body. - Two clean subtractions: ~105 lines of new grammar test (
strict.rs:3819-3922) duplicate the adjacent parameterized test's fixture and assertions; ~10 lines attml.rs:619-628re-assert a recovery path already looped attml.rs:551-573. - Five upstream sub-findings are wrong and are not forwarded (details in "Corrections applied"):
.trim()attml.rs:339is a no-op, so the whole "verbatim is overstated" family is false;accepts_bytescannot carry TML control tokens, so Conventions' prescribed fix is unworkable; the TML negative case already exists (strict.rs:4219-4228/:4320-4331); and the "described as prior semantics" findings quote a sentence not present in the description at head.
Corrections applied before hand-off (verified by opening the files)
| Upstream claim | Reality | Effect |
|---|---|---|
| Architecture#3, Conventions (verified-clean note), Simplicity#1(a), Correctness#4: "arguments are whitespace-trimmed, so 'verbatim' is overstated" | .trim() at helios/src/output/tml.rs:339 is a no-op: serde_json's RawValue span begins at the value's first non-whitespace byte and ends at its last, so parsed.args.get() is already exactly the object text. |
Whole family dropped; survives only as nit N1 ("trim is dead code", 0 lines saved). |
Conventions#1 fix: "assert through accepts_bytes so the new negative case comes for free" |
accepts_bytes (strict.rs:2471-2487) advances raw bytes and cannot carry TML's `< |
content_invoke_tool_json |
| Conventions#1: "the new test silently lost the negative assertion, so a TML rejection regression would not be caught" | False — strict.rs:4219-4228 is a TML Case with a NumericRange constraint whose invalid payload is exercised at :4320-4331; strict.rs:2913-2915 also asserts rejection of an extra-property payload. |
Coverage-lost argument dropped; only the duplication argument kept. |
| Prose#1, Simplicity#1(b): description says duplicate-key rejection "matches prior TMLv0 recovery semantics" | The description at head contains no such sentence; it discloses the tightening twice — "Note: this also passes non-strict TMLv0 args verbatim … and rejects duplicate wrapper keys as visible text" and Caveats: "duplicate wrapper keys fall back to visible text." |
Both findings dropped as resting on text absent from the reviewable diff; residue folded into N3. |
Architecture#1 / Conventions#3 / Subtractive#2: PR body says "This addresses the strict TMLv0 tool-calling qualification tracked in docs/TODO.txt" |
The body says the HTTP 500 is "(tracked in docs/TODO.txt)" and Caveats say "Qualified live on Inkling 2 Small NVFP4 (4× GB10 ARM64 TP4)". |
Finding survives on the merits (entry's own closing condition is met), but the adjudicator should weigh the narrower wording — see open questions. |
Verified as not PR defects (mention-only limits, not findings): Messages tool_use.input still round-trips through Value (helios/src/server/protocol/encode.rs:334) and strict: true on Messages tools is rejected at admission (docs/api.md:634-635), so the reported 500 cannot recur there; that residue is pre-existing and shared with the Qwen/GLM/DSML raw paths, and the fix belongs in docs/api.md wording (N3), not this diff.
Candidate Blockers
None. Every lens reported no blocking issue, and I found none on inspection of the changed code (helios/src/output/tml.rs:329-363), its rejections/fallbacks (tml.rs:317-327), and the downstream consumers (Chat accumulator at helios/src/server/output.rs:83-87,113-120,140; Chat/Responses encoders at helios/src/server/protocol/encode.rs:313; strict validation at encode.rs:517-553; truncation at tml.rs:377-384).
Candidate Should Fix
S1 — docs/TODO.txt:5-8: the qualification entry this PR's own evidence satisfies is left open
Merged from Architecture#1 + Conventions#3 + Subtractive#2.
docs/TODO.txt:5-8 (unchanged by the PR — the file list is only the three code/test files):
5 [ ] Qualify `strict: true` function tools on a TMLv0 core (ToolParserKind::TmlJson,
6 e.g. Inkling 2) served by `flare run`. Check Chat Completions and Responses,
7 buffered and streamed, including max_tokens and max_output_tokens truncation.
8 Close when a served TMLv0 core passes those checks and the result is recorded.
The rule, AGENTS.md:514-517:
514 Use [docs/TODO.txt](docs/TODO.txt) for miscellaneous follow-up items. Keep entries
515 brief and link to detailed design or performance notes when needed. Update or
516 remove entries as work is completed. Keep this file focused on durable project
517 guidance rather than task lists or progress notes.
The entry's own closing condition ("Close when a served TMLv0 core passes those checks and the result is recorded") is met by the PR's reported evidence: 35/35 on a live 4× GB10 ARM64 TP4 Inkling 2 Small NVFP4, Chat Completions and Responses, buffered and streamed, max_tokens/max_output_tokens truncation 8/8 — the exact axes lines 6-7 enumerate. Leaving it open makes the repository's single record of open qualification work disagree with the merged code.
Fix: remove lines 5-8 in this PR, or narrow them to what genuinely remains (other TMLv0 cores). If the live run used a locally built binary rather than the released flare artifact, the entry may legitimately stay — then the description should say which sub-check is outstanding instead of implying closure.
S2 — tests/server/test_inkling2.py:121-209: the new server test bypasses its own module fixture
Merged from Conventions#2 + Simplicity#6 + Subtractive#4 (subtractive resolution preferred).
The module's fixture is the file's established convention and encodes invariants the new test silently gives up — tests/server/test_inkling2.py:29, :41-44, :60-64:
29 @pytest.fixture(scope="module", params=[None, "none"], ids=["default-effort", "zero-effort"])
...
41 def ask(content, **options):
42 body = dict(model=model["id"], messages=[dict(role="user", content=content)],
43 seed=1234, max_tokens=1024, return_token_ids=True)
44 if request.param is not None:
45 body["reasoning_effort"] = request.param
...
60 except urllib.error.HTTPError as error:
61 pytest.fail(f"HTTP {error.code}: {error.read().decode()}")
62 choice = result["choices"][0]
63 assert choice["finish_reason"] in ("stop", "tool_calls"), result
64 assert result["usage"]["completion_tokens"] == len(choice["token_ids"])
The new test departs from it — tests/server/test_inkling2.py:122-123 re-fetches /v1/models the fixture already fetched at :31-38, and :155-169 (pattern repeated at :176-192, :194-209) hand-builds requests with hardcoded zero effort:
122 url = os.environ["FLARE_INKLING2_TEST_URL"].rstrip("/")
123 model_id = json.load(urllib.request.urlopen(url + "/v1/models", timeout=10))["data"][0]["id"]
...
155 trunc_req = urllib.request.Request(
156 url + "/v1/chat/completions",
157 json.dumps(dict(
158 model=model_id,
...
162 reasoning_effort="none",
163 max_tokens=10,
Two consequences for claims the PR makes: (a) because :162, :183 and :201 hardcode "none", the fixture's default-effort parameter never reaches the strict TML path, so "default effort and zero effort" coverage is only half real; (b) because the raw calls sit outside the HTTPError → pytest.fail wrapper at :60-61, the exact failure this PR fixes — a live HTTP 500 "strict tool arguments does not match its grammar" — would surface as an unhandled exception with no response body, losing the diagnostic the fixture exists to provide.
Subtractive fix (preferred over adding lines): add one helper/flag beside ask() inside the fixture (skip the :63 finish_reason assertion for truncation, switch path to /v1/responses), then route all six requests through it; drop the :122-123 re-fetch. The sibling tests/server/test_muse_spark.py:63-68 already shows the one-request()-helper pattern. Keep :135-152 as the template.
Candidate Subtract / Simplify
X1 — delete or fold helios/src/grammar/strict.rs:3819-3922 (~105 added lines): a verbatim re-derivation of the adjacent parameterized test
Merged from Conventions#1 + Simplicity#2/#3/#4 + Subtractive#1.
The adjacent test's shared scaffold — strict.rs:3727-3748:
3727 let big_schema = json!({
3728 "type": "object",
3729 "$defs": {"BigInt": {"type": "integer"}},
3730 "properties": {
3731 "top": {"type": "integer"},
3732 "via_any": {"anyOf": [{"type": "integer"}, {"type": "null"}]},
3733 "via_ref": {"$ref": "#/$defs/BigInt"},
...
3746 });
3747 let validator = validate_strict_tool_schema(&compiler, "audit", &big_schema).unwrap();
3748 for (kind, wire) in [
...and its assertion, strict.rs:3811-3815:
3811 assert_eq!(
3812 raw_args.matches(big).count(),
3813 5,
3814 "{kind:?} lost 30-digit precision: {raw_args}"
3815 );
The new test re-creates the same 20-line big_schema byte-for-byte (strict.rs:3828-3847 == 3727-3746), the same validator call (:3848), the same syn/cfg/env/plan block (:3849-3879), the same raw_args.matches(big).count() == 5 assertion (:3917-3921), and a third copy of the byte_tokenizer_with(&CONTROL_MARKERS) + controls idiom already at :2804-2809 and :4247-4251 — strict.rs:3821-3826:
3821 let tokenizer = byte_tokenizer_with(&CONTROL_MARKERS);
3822 let controls: Vec<_> = CONTROL_MARKERS
3823 .iter()
3824 .map(|marker| (tokenizer.token_to_id(marker).unwrap(), (*marker).to_owned()))
3825 .collect();
3826 let compiler = GrammarCompiler::new(&tokenizer, 320, &[256, 257], &controls).unwrap();
AGENTS.md:188-193 rejects this churn ("Refactoring must directly support the requested behavior"). After deletion nothing is lost: TML strict end-to-end ($ref/anyOf/nested through root rebasing, plus a rejected payload) is tml_json_strict_grammar_rebases_root_ref_and_parses_end_to_end (strict.rs:2802-2930), TML generation-time rejection is the Case table row at strict.rs:4219-4228 exercised at :4320-4331, and raw 30-digit exact-string preservation is tml.rs:607-617.
Fix (either): add a third row to the loop at strict.rs:3748, encoding the TML markers→control tokens as the new test already does at :3888-3897; or add a Case (with valid/invalid) to the table at strict.rs:4229, whose encode() closure (:4290-4306) already performs that substitution. Then delete :3819-3922. (Note: accepts_bytes cannot be used for TML — see corrections table.)
X2 — fold helios/src/output/tml.rs:619-628 into the existing recovery loop (~10 lines deleted)
Merged from Simplicity#5 + Subtractive#3.
The new block:
619 let duplicate = r#"{"name":"lookup","name":"lookup","args":{}}"#;
620 assert_eq!(
621 run(
622 OutputStart::RecipientFrame,
623 &[MODEL, "lookup", JSON_CALL, duplicate, END],
624 Termination::Eos,
625 )
626 .1,
627 duplicate
628 );
...re-asserts the contract already looped at tml.rs:551-561 over five malformed bodies, on both OutputStart::RecipientFrame and OutputStart::ToolBody:
551 fn rejected_invocations_surface_as_text_and_open_calls_complete_only_at_eos() {
552 let frame = OutputStart::RecipientFrame;
553 for body in [
554 r#"{"name":"other","args":{}}"#,
555 r#"{"name":"lookup","args":[]}"#,
556 r#"{"name":"lookup","args":{},"extra":1}"#,
557 r#"{"name":7,"args":{}}"#,
558 "incomplete",
559 ] {
560 assert_eq!(run(frame, &[MODEL, JSON_CALL, body, END], Termination::Eos).1, body);
561 assert_eq!(run(OutputStart::ToolBody, &[body], Termination::Eos).1, body);
Fix: add the two duplicate literals to the array at :553-559 and delete :619-628, leaving call_preserves_raw_json_arguments_including_arbitrary_precision_integers single-purpose (the precision assertion at :609-617, which is the actual regression guard).
Candidate Nits
N1 — helios/src/output/tml.rs:339: .trim() is dead code (0 lines saved)
339 let args = parsed.args.get().trim();
RawValue::get() excludes surrounding whitespace, so this can never change the value. It is harmless and reads fine; removing it would make "verbatim" literally true in the description. Counted as a nit only — the four lenses that raised this as a behaviour/prose defect are wrong (see corrections table).
N2 — duplicate keys inside args now pass through byte-for-byte, unlike the DSML parser
helios/src/output/tml.rs:339-359 forwards raw text, so {"a":1,"a":2} reaches the client intact where the old Value round-trip collapsed it last-wins. The DSML parser explicitly rejects that — helios/src/output/dsml.rs:394-400:
394 let mut keys = HashSet::new();
395 while let Some(key) = map.next_key::<String>()? {
396 if key.is_empty() || !keys.insert(key) {
397 return Err(serde::de::Error::custom(
398 "tool argument names must be nonempty and unique",
399 ));
400 }
and docs/api.md:449-452 documents that rule. Strict grammars forbid duplicate properties (additionalProperties: false + a single name/args wrapper), so the strict path — the PR's claim — is unaffected; only non-strict TMLv0 traffic differs, and the description's Caveats do disclose the verbatim forwarding. Fix: either document the divergence in the TMLv0 paragraph (docs/api.md:588-605) or add the DSML unique-key check to the TML path.
N3 — one combined documentation/evidence item: the raw-text guarantee is not documented, and three evidence entries are not reproducible
(a) docs/api.md:588-605 describes the strict TMLv0 acceptance contract and :624-628 the buffering/truncation behaviour, but neither states the user-visible outcome this PR delivers (arguments returned as raw JSON text, key order and >64-bit integers preserved) nor its boundary — Messages tool_use.input still rounds:
// helios/src/server/protocol/encode.rs:334
334 json!({"type":"tool_use","id":id,"name":name,"input":if complete{serde_json::from_str::<Value>(arguments).unwrap_or(json!({}))}else{json!({})}})
One or two sentences in the same paragraph covering both would match the file's existing level of detail (docs/api.md:634-635 already states that strict: true on Messages tools returns HTTP 400, so no 500 can occur there).
(b) The description's evidence cites server::protocol::tests::strict — no module by that name exists; the two tests are plain functions at helios/src/server/protocol/tests.rs:1751 (strict_function_tools_decode_and_gate_streaming_and_buffered_output_across_protocols) and :2026 (strict_tool_wires_reach_encoder_only_after_parser_completion).
(c) The five server::request::tml_tests:: tests are all #[ignore]d and cannot pass under the stated command — helios/src/server/request/tml_tests.rs:103,161,247,264,313:
#[ignore = "requires FLARE_INKLING2_TEST_SNAPSHOT with the Inkling 2 tokenizer"]
They need --ignored plus FLARE_INKLING2_TEST_SNAPSHOT; and the 35/35 live inventory does not separate the in-repo test (tests/server/test_inkling2.py:121-209, which covers 5 cases) from the out-of-repo qualification driver that produced the rest. AGENTS.md:103-112 asks exactly for this disclosure.
Dropped as noise (not forwarded)
- The "verbatim is overstated / whitespace trimmed" family (Architecture#3, Conventions' verified-clean note, Simplicity#1a, Correctness#4) —
.trim()is a no-op attml.rs:339; folded into N1. - "Duplicate-key tightening described as prior semantics" (Prose#1, Simplicity#1b) — the quoted sentence is not in the description at head, which discloses the tightening in What Changed and Caveats; residue folded into N3.
- "The new test lost the only TML negative coverage" (Conventions#1) — false;
strict.rs:4219-4228+:4320-4331, andstrict.rs:2913-2915. - "Assert through
accepts_bytes" (Conventions#1 fix) — unworkable for TML control tokens; replaced by thestrict.rs:3748/Case-table options in X1. - "Assert equality instead of
matches(big).count() == 5" (Simplicity#3) — nitpicking a useful precision assertion whose sibling already uses the same form; no forward. big_schemahoisting into a helper (Simplicity#2) — subsumed by X1 (deleting the duplicate test removes the second copy outright; subtraction beats a new helper).- Correctness' Messages/
tool_use.inputprecision finding — real, but pre-existing, out of this PR's diff, and unobservable through any strict path (strict is rejected on Messages); reduced to the documentation wording in N3. - CI/runner-infra notices — none reported on head
c7fae93; nothing invented.
Open questions for the adjudicator
- S1 disposition: delete
docs/TODO.txt:5-8, narrow it to cores beyond Inkling 2 Small NVFP4, or keep it open because the live qualification used a locally built binary? The entry's literal closing condition ("a served TMLv0 core passes those checks and the result is recorded") reads as satisfied; only the author can settle whether "a TMLv0 core" was meant to cover more than the one qualified. - Commit body: head is
c7fae93b"Preserve raw JSON tool arguments in TmlOutput for strict TMLv0 calls". I did not read the commit body, so I cannot say whether it, rather than the description, still uses the "matching prior TMLv0 recovery semantics" wording; if so, the same one-sentence compatibility fix applies there. - Not verifiable from the repository: the 35/35 live qualification, the 6/6 HTTP 400 admissions, and the checkpoint-based Rust suites rest on the description's evidence; only the added CPU unit tests (
tml.rs:607-629,strict.rs:3819-3922) were inspected in code, and no CI run is reported on head. - Whether the chat-streamed strict case (
test_inkling2.py:143-152) is wanted for a reason not visible in code — the buffering contract it checks is already pinned athelios/src/server/protocol/tests.rs:2026andstrict.rs:3811-3815, and Subtractive proposes dropping it (~10 lines) as part of S2.