Code review summary scratchpad · NVIDIA/hyperflare-inference #575

Raw Markdown for agents: https://autobot.eidonix.com/p/04efbdde-a45a-4aeb-b9ee-3565f8532deb.md

#1 [high] PR #575 facts: diff, files, head, description

PR #575 "Preserve raw JSON tool arguments in TmlOutput for strict TMLv0 calls", head c7fae93b, base main, +237/-10, 3 files: helios/src/grammar/strict.rs (+105-0), helios/src/output/tml.rs (+41-10), tests/server/test_inkling2.py (+91-0). Only discussion = flare-autobot case-file bot comment (no reviewer comments, no CI checks reported).

Description (read_item 575) EXPLICITLY discloses the duplicate-key tightening, both in "What Changed" ("Note: this also passes non-strict TMLv0 args verbatim without serde re-serialization and rejects duplicate wrapper keys as visible text") and in Caveats: ("Non-strict TMLv0 calls now also forward raw args text verbatim, and duplicate wrapper keys fall back to visible text"). So Prose#1 and Simplicity#1(b), which quote "matching prior TMLv0 recovery semantics" as the description's words, are quoting text that is NOT in the current description -> pre-filter as noise (maybe earlier revision or commit body).

New code (helios/src/output/tml.rs:329-363) replaces main's tml.rs:328-356 Value round-trip:

#2 [high] TODO.txt item claimed as addressed but untouched

Strongest surviving candidate (Architecture#1, Conventions#3, Subtractive#2 — merged).

docs/TODO.txt:5-8 (unchanged by PR; pr_files lists only the 3 code/test files):

[ ] 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.

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." PR body says "This addresses the strict TMLv0 tool-calling qualification tracked in docs/TODO.txt" and reports 35/35 live on 4x GB10 TP4 Inkling 2 Small NVFP4 (Chat + Responses, buffered/streamed, max_tokens/max_output_tokens 8/8). Unknown whether the TODO entry itself names "TmlOutput" defect; it names the qualification only. Nuance for adjudicator: only Inkling 2 Small NVFP4 was qualified, so "narrow rather than delete" is a legitimate alternative; and if the live run used a locally built binary, the entry may legitimately stay open — then the description should not imply closure.

#3 [high] Merged survivor list (7 candidates) + dropped noise

Merged/deduped survivor list (7 items), after cross-lens dedupe and noise drop.

SHOULD FIX 1 — docs/TODO.txt:5-8 still open (Architecture#1 + Conventions#3 + Subtractive#2 merged). Note correction: description does NOT say "This addresses the strict TMLv0 tool-calling qualification"; its Why says the HTTP 500 is "(tracked in docs/TODO.txt)" and Caveats say qualified live on Inkling 2 Small NVFP4. Entry's own closing condition ("Close when a served TMLv0 core passes those checks and the result is recorded") is met by the reported 35/35. AGENTS.md:514-516 requires update/remove on completion.

SHOULD FIX 2 — tests/server/test_inkling2.py:121-209 hand-rolls urllib for 4 of 6 requests (Conventions#2 + Simplicity#6 + Subtractive#4 merged). Consequences: hardcoded reasoning_effort="none" (:162) / reasoning=effort none (:183,:201) means the fixture's default-effort param (:29 params=[None,"none"]) never reaches the strict path; no HTTPError→pytest.fail body wrapper (:60-61), so the exact 500 this PR fixes arrives bare; duplicate /v1/models fetch (:122-123) already done by fixture (:31-38). Why they bypassed: fixture asserts finish_reason in ("stop","tool_calls") at :63, violated by truncation (length) and by Responses shape. Subtractive resolution preferred: add one flag/helper, drop :122-123 refetch, drop redundant streamed chat case :143-152 (buffering already pinned at helios/src/server/protocol/tests.rs:2026 strict_tool_wires_reach_encoder_only_after_parser_completion and strict.rs:3811-3815).

SUBTRACT A — helios/src/grammar/strict.rs:3819-3922 (~105 added lines) duplicated by qwen_and_glm_strict_parsers_preserve_30_digit_integers (3723-3817): identical big/big_schema (3828-3847 == 3727-3746), same validate_strict_tool_schema, same syn/cfg/env/plan block (3849-3879 vs 3762-3795), same raw_args.matches(big).count()==5 (3917-3921 vs 3811-3815). Also a 3rd copy of byte_tokenizer_with(&CONTROL_MARKERS)+controls (2804-2809, 4246-4251) and bypasses accepts_bytes (2471-2487). Preferred: add a TML row to the 3748 loop (or to the Case table at 4167-4333, which already has a TML row 4219-4228) and delete the test. Uniqueness left after deletion ≈ zero: TmlJson end-to-end incl. negative is tml_json_strict_grammar_rebases_root_ref_and_parses_end_to_end (2802-2930) and raw 30-digit exact equality is tml.rs:607-617.

SUBTRACT B — helios/src/output/tml.rs:619-628 (10 lines): duplicate-wrapper-key block re-asserts the recovery path already looped at 551-573 over 5 malformed bodies on both OutputStart::RecipientFrame and ToolBody. Fold the two duplicate literals into the 553-559 array.

NIT N1 — tml.rs:339 .trim() is a no-op: serde_json RawValue spans exclude surrounding whitespace, so emitted text is already byte-exact; every "verbatim is overstated / whitespace trimmed" finding (Architecture#3, Simplicity#1a, Correctness#4, Conventions) is behaviourally false → dropped, replaced by "trim is dead code, 0 lines saved". NIT N2 — duplicate keys INSIDE args now pass through byte-for-byte, whereas DSML validates nonempty+unique argument names (dsml.rs:386-414; docs/api.md:449-452). Strict grammars forbid duplicates so strict path unaffected; non-strict TML only. NIT N3 — one combined docs/evidence item: docs/api.md:588-605/624-628 never states arguments are returned as raw text nor the boundary (Messages tool_use.input still rounds via encode.rs:334, and strict is rejected on Messages at decode.rs:373-377 / api.md:634-635 so no 500 there); and the evidence section's server::protocol::tests::strict filter matches no module (the two fns are protocol/tests.rs:1751, 2026), the five server::request::tml_tests:: are all #[ignore] (103,161,247,264,313) so need --ignored + FLARE_INKLING2_TEST_SNAPSHOT, and the 35/35 live inventory does not separate the in-repo test from the out-of-repo driver.

Candidate Blockers: NONE (all lenses agree; production change is a net simplification). Dropped as noise: CI/setup-java runner notices (none reported on head anyway); "duplicate-key tightening undocumented / described as prior semantics" (description's What Changed + Caveats disclose it at head); "verbatim overstated" family (trim is no-op); Conventions' claim the new test lost the only TML negative coverage (false: strict.rs:4219-4228 + 4320-4331 covers TML rejection).

#4 [high] Verified corrections that void 4 lens sub-findings

Caveats/corrections the adjudicator must know (all verified by opening the files):

  1. .trim() at tml.rs:339 is a NO-OP. serde_json's RawValue span starts at the first non-whitespace byte of the value and ends at its last, so parsed.args.get() is already exactly the object text. Evidence in-tree: the golden fixture tests/frontend/generate_inkling2_fixtures.py:465 feeds '{ "args": {"q": "x", "n": 2.50}, "name": "search" }' and tml_tests.rs:241 compares parsed values, so the padded form is tolerated; emitted text is now {"q": "x", "n": 2.50} (inner spacing/order preserved, no outer padding to trim). => Kill the whole "verbatim is overstated / whitespace is trimmed" family (Architecture#3, Conventions-verified-clean note, Simplicity#1a, Correctness#4). Keep only "trim() is dead code" as a 0-line nit.

  2. accepts_bytes (strict.rs:2471-2487) advances raw BYTES, so it cannot carry TML's control tokens (<|content_invoke_tool_json|>). Conventions#1's fix ("assert through accepts_bytes so the negative case comes free") is not directly workable for TML. The workable homes are (a) the existing dialect loop at strict.rs:3748-3761 plus control-token encoding like strict.rs:3888-3897, or (b) the Case table at strict.rs:4188-4329 whose encode() closure (4290-4306) already substitutes markers→control tokens and already has a TML row (4219-4228).

  3. The new strict.rs test did NOT remove the only TML negative coverage: strict.rs:4219-4228 (TML Case with NumericRange) is exercised by 4320-4331, and strict.rs:2913-2915 asserts the extra-property payload is rejected. Drop Conventions' "regression would not be caught" reasoning; keep only the duplication argument.

  4. Description AT HEAD discloses the duplicate-key tightening twice (What Changed note + Caveats:), so Prose#1 and Simplicity#1(b) rest on quoted text not present at head. If the same sentence exists only in the commit body, it is out of the reviewable diff → demote to the single combined docs/prose item.

  5. No CI checks are reported on head c7fae93 (pr_comments = bot case-file comment only). Nothing to accept or drop as infra noise; do not invent red checks.

  6. Verified pre-existing/out-of-scope, not a PR defect: Messages tool_use.input still round-trips through Value (encode.rs:334) and strict on Messages is rejected at admission (decode.rs:373-377), so the 500 cannot recur there. Always-mention-limit only.

#6 [high] Research summary

Produced the candidate brief for PR #575 (head c7fae93), deduped from the six lenses into 7 surviving candidates and delivered with exact quoted code under each: no blockers; 2 Should Fix (docs/TODO.txt:5-8 qualification entry untouched despite the PR's evidence; tests/server/test_inkling2.py:121-209 bypassing the module's service fixture); 2 Subtract (delete/fold the 105-line duplicate strict.rs:3819-3922; delete tml.rs:619-628 into the existing 553-561 recovery loop); 3 Nits (trim() dead code at tml.rs:339; duplicate keys inside args vs dsml.rs:394-399; one combined docs/evidence item).

Before passing anything downstream I opened every cited file and found four lens claims that are wrong and were removed or rewritten rather than forwarded: .trim() at tml.rs:339 is a no-op (so the whole "verbatim is overstated / whitespace trimmed" family is false); accepts_bytes (strict.rs:2471) cannot carry TML control tokens, so Conventions' suggested fix is unworkable; the TML negative case already exists (strict.rs:4219-4228/4320-4331), voiding the "coverage lost" argument; and the description at head explicitly discloses the duplicate-wrapper-key tightening twice, so the "described as prior semantics" findings quote text not present at head. No CI/runner-infra notices were present on head to drop. Details and citations are in the scratchpad (entries 1-5), including the judgment calls left for the adjudicator on the TODO entry (delete vs narrow vs keep open).

#7 [high] Exact quoted lines per candidate (S1, S2, X1, X2, N1-N3)

Exact lines for the final report (all read at head c7fae93b).

S1 docs/TODO.txt:5-8 (unchanged by 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." AGENTS.md:514-516: "Use docs/TODO.txt for miscellaneous follow-up items. Keep entries brief and link to detailed design or performance notes when needed. Update or remove entries as work is completed."

S2 tests/server/test_inkling2.py:29 "@pytest.fixture(scope="module", params=[None, "none"], ids=["default-effort", "zero-effort"])" :43-44 "if request.param is not None: body["reasoning_effort"] = request.param" :60-61 "except urllib.error.HTTPError as error: pytest.fail(f"HTTP {error.code}: {error.read().decode()}")" :63 "assert choice["finish_reason"] in ("stop", "tool_calls"), result" :122-123 'url = os.environ["FLARE_INKLING2_TEST_URL"].rstrip("/")' / 'model_id = json.load(urllib.request.urlopen(url + "/v1/models", timeout=10))["data"][0]["id"]' :155-169 trunc_req = urllib.request.Request(url + "/v1/chat/completions", json.dumps(dict(model=model_id, messages=..., tools=chat_tools, tool_choice="auto", reasoning_effort="none", max_tokens=10, seed=1234)).encode(), {"Content-Type": "application/json"}) ; with urllib.request.urlopen(trunc_req, timeout=120) as resp: trunc = json.load(resp) :162 reasoning_effort="none"; :183 and :201 reasoning=dict(effort="none") :139/:152/:192 "big in ...arguments" substring asserts. Pattern to copy: tests/server/test_muse_spark.py:63-68 "def request(self, path, body=None): try: with self.open(path, body) as response: return json.load(response) except urllib.error.HTTPError as error: pytest.fail(f'{path}: HTTP {error.code}: {error.read().decode()}')"

X1 strict.rs:3727-3748 existing fixture+loop, :3811-3815 "assert_eq!(raw_args.matches(big).count(), 5, "{kind:?} lost 30-digit precision: {raw_args}")", new :3821-3826 byte_tokenizer_with(&CONTROL_MARKERS)+controls, :3828-3847 duplicate big_schema, :3849-3879 duplicate syn/cfg/env/plan, :3888-3897 hand-rolled marker→token feed, :3917-3921 duplicate assertion. Case table: :4219-4228 TML row (kind TmlJson, start RecipientHeader, controls &CONTROL_MARKERS, NumericRange), :4290-4306 encode() closure. accepts_bytes :2471-2487 advances bytes only.

X2 tml.rs:619-628 duplicate block; tml.rs:553-561 existing loop of 5 malformed bodies run on both OutputStart::RecipientFrame and OutputStart::ToolBody.

N1 tml.rs:339 "let args = parsed.args.get().trim();" (no-op). N2 dsml.rs:394-400 "let mut keys = HashSet::new(); while let Some(key) = map.next_key::()? { if key.is_empty() || !keys.insert(key) { return Err(serde::de::Error::custom("tool argument names must be nonempty and unique",)); }" ; docs/api.md:449-452 documents the DSML uniquenames rule. N3 docs/api.md:588-605 (strict acceptance, no raw-text/precision statement), :624-628 (buffering/truncation), :634-635 ("strict: true on custom or Messages tools ... return HTTP 400"); encode.rs:334 anthropic_block "input":if complete{serde_json::from_str::<Value>(arguments).unwrap_or(json!({}))}else{json!({})}; decode.rs:373-377 Messages strict rejected; protocol/tests.rs:1751 strict_function_tools_decode_and_gate_streaming_and_buffered_output_across_protocols, :2026 strict_tool_wires_reach_encoder_only_after_parser_completion; tml_tests.rs:103,161,247,264,313 all "#[ignore = "requires FLARE_INKLING2_TEST_SNAPSHOT with the Inkling 2 tokenizer"]".

#5 [medium] Final brief delivered — section map

Delivered brief structure (final answer already written in-conversation):