Simplicity report · NVIDIA/hyperflare-inference #575

Raw Markdown for agents: https://autobot.eidonix.com/p/a2ebf70d-9a3a-48e0-9d42-c78062ccf083.md

Key findings (lens D — simplicity: what can be deleted)

The production change is itself a net simplification, and I found nothing blocking. One #[derive(Deserialize)] struct with a borrowed &RawValue (helios/src/output/tml.rs:329-363) replaces the old Value round-trip plus the hand-written as_object / object.len() != 2 / is_object checks (main: helios/src/output/tml.rs:328-356), and it deletes the args.to_string() re-serialization. No new flags, options, config switches, fallback layers or parallel paths are introduced, and no dependency change is needed because raw_value and preserve_order are already enabled at helios/Cargo.toml:52 — so AGENTS.md's "Reject unsupported abstractions and churn" (AGENTS.md:188-193) is satisfied on the production side.

The simplicity cost is entirely in the added tests (105 Rust lines in strict.rs, 23 in tml.rs, 89 in the Python suite) and in two inexact prose claims that hide a real behaviour change. Nothing here blocks; the largest single win is ~60 of the 105 added strict.rs lines.

Findings: 1 should-fix (prose/claim accuracy + undocumented acceptance change), 5 nits. Ordered by importance.


1. should fix — helios/src/output/tml.rs:329-363: two claims in the PR description are inexact, and one of them conceals a real acceptance change

What is wrong. The PR description says call "emits args.to_owned() verbatim" and that unknown or duplicate wrapper keys "fail deserialization and fall back to visible text, matching prior TMLv0 recovery semantics". Both statements are wrong as written:

(a) Not verbatim. Line 339 is let args = parsed.args.get().trim(); and line 359 emits args.to_owned(). Whitespace surrounding the raw argument object is dropped: a payload "args": { … } is emitted as { … }. Integers, key order and inner bytes are preserved — but "verbatim" is not the contract the code implements.

(b) Not prior semantics. The old code (main at helios/src/output/tml.rs:333) checked object.len() != 2 on a serde_json::Value map. With preserve_order enabled (helios/Cargo.toml:52) that map is an insertion-ordered map whose duplicate-key insert replaces in place, so {"name":"lookup","name":"lookup","args":{}} had len 2 and was accepted before this PR; #[serde(deny_unknown_fields)] on the derived struct now rejects it. That is a real (and defensible) tightening of the accepted input set, not preserved behaviour. The new test at helios/src/output/tml.rs:619-628 in fact pins the new behaviour, which contradicts the description.

Why it matters. AGENTS.md:194-199 requires each PR to "describe its problem, resulting behavior, validation, and material limitations"; AGENTS.md:196-197 forbids presenting behaviour as supported when it is not exactly what ships. A reviewer or downstream user reading "matching prior semantics" will assume no wire-format change, and nobody will learn that duplicate wrapper keys moved from accepted to visible-text. docs/api.md:588-605 documents the strict TMLv0 subset and docs/api.md:624-628 documents buffering/truncation, but neither says anything about wrapper-key uniqueness, so the newly rejected form is undocumented.

Fix. Pick one, and make text and code agree:


2. nit — helios/src/grammar/strict.rs:3828-3847: the 20-line schema is byte-identical to one that already exists in this module

big_schema in the new tml_strict_parser_preserves_30_digit_integers is the same literal as big_schema in qwen_and_glm_strict_parsers_preserve_30_digit_integers at helios/src/grammar/strict.rs:3727-3746 — same $defs.BigInt, same top / via_any / via_ref / nested{id,arr} properties, same required list, same additionalProperties: false. Two copies of a fixture that must stay materially identical (it is the thing both tests prove precision against) will drift the moment one is edited.

Fix / smaller version. Hoist one fixture in the test module and use it in both:

fn big_int_schema() -> Value {
    json!({ /* the body currently at 3728-3846, once */ })
}

and at both call sites let big_schema = big_int_schema();. ~20 lines deleted, and the two tests can never disagree about which schema constructs are covered. (AGENTS.md:188-193 — duplicated test scaffolding is churn that does not "directly support the requested behavior".)


3. nit — helios/src/grammar/strict.rs:3909-3921: the precision assertion is an indirect proxy where an equality would be shorter and stronger

assert_eq!(raw_args.matches(big).count(), 5, …) proves only that the 30-digit run appears five times somewhere in the output. It cannot fail on the two things the PR exists to protect in the neighbouring claims — a reordered object, or reformatted whitespace — and it needs a format!-built expected payload at 3885 whose full text it then declines to compare.

Fix / smaller version. The expected argument text is derivable from big alone and is already constructed once at 3885-3887; keep it separate from the wrapper and compare directly:

let args = format!(r#"{{"top":{big},"via_any":{big},"via_ref":{big},"nested":{{"id":{big},"arr":[{big}]}}}}"#);
let payload = format!(r#"{{"name":"audit","args":{args}}}"#);
…
assert_eq!(raw_args, args, "TmlJson lost 30-digit precision");

Four lines shorter, one format! fewer, and it pins property order plus exact bytes (OutputEncoder validates those bytes, so this is the behaviour that matters). If the intent really is only "no float rounding", then assert!(!raw_args.contains('e')) would be the honest minimal form — the digit count is neither.


4. nit — helios/src/grammar/strict.rs:3820-3907: the new test restates an existing test's harness line for line

tml_strict_parser_preserves_30_digit_integers rebuilds the whole TML strict setup that tml_json_strict_grammar_rebases_root_ref_and_parses_end_to_end (helios/src/grammar/strict.rs:2802-2930) already contains: tokenizer + controls (3821-3826 vs 2804-2809), syn.reasoning = None + ToolParser { kind: TmlJson, … } (3849-3855 vs 2819-2824), OutputConfig + TaggedConfig with the same json!({"type":"function","function":{…}}) tool wrapper (3856-3867 vs 2832-2842), the ToolGrammarPlan literal (3869-3879 vs 2844-2854), and the advance/feed loop (3888-3906 vs 2860-2895). The only genuinely new content is the 30-digit payload and its assertion.

Fix / smaller version. Extract one helper in the test module:

fn tml_strict_setup(name: &str, schema: &Value)
    -> (GrammarCompiler, OutputEnvelope, ToolGrammarPlan, OutputConfig, u32, u32)

(tool list built from name/schema, start: OutputStart::RecipientHeader), then express the new test as ~15 lines: schema from finding 2, let (compiler, env, plan, cfg, invoke_id, end_id) = tml_strict_setup("audit", &big_schema);, feed the payload, compare args per finding 3. The existing test at 2802-2930 also shrinks. Together with findings 2 and 3 this removes roughly 60 of the 105 added strict.rs lines without losing a single asserted behaviour — the strongest simplicity item in the diff (AGENTS.md:188-193; AGENTS.md:194-199 "tests must exercise the affected behavior", which they still do).


5. nit — helios/src/output/tml.rs:619-628: the duplicate-key half of the new test re-asserts serde's derive, and the fallback list already exists

Lines 619-628 feed r#"{"name":"lookup","name":"lookup","args":{}}"# and assert the body surfaces as visible text. That is exactly what rejected_invocations_surface_as_text_and_open_calls_complete_only_at_eos (helios/src/output/tml.rs:550-573) already does: it loops [other name, non-object args, extra key, non-string name, incomplete] through both OutputStart::RecipientFrame and OutputStart::ToolBody and asserts the body text comes back (553-562). The new case contributes no new mechanism — it demonstrates #[serde(deny_unknown_fields)] on line 331, i.e. the standard library derive.

Fix / smaller version. Add two literals to the existing array at 553-559 — r#"{"name":"lookup","name":"lookup","args":{}}"# and r#"{"name":"lookup","args":{},"args":{}}"# — and delete 619-628. Ten lines fewer, the recovery invariant stays in one place, and the original call_preserves_raw_json_arguments_including_arbitrary_precision_integers keeps a single purpose (the precision round-trip at 609-617).


6. nit — tests/server/test_inkling2.py:121-209: one 90-line test covers five behaviours, and hand-rolls three requests to dodge a fixture assertion

test_strict_tml_tool_calls_and_truncation asserts: (i) buffered chat strict call preserving the 30-digit integer and property order (136-141), (ii) streamed chat strict call buffered into one delta (144-152), (iii) chat max_tokens truncation (155-171), (iv) Responses buffered (176-192), (v) Responses max_output_tokens truncation (194-209). Requests (iii), (iv) and (v) bypass the module fixture and hand-build urllib.request.Request with model_id re-fetched at 122-123, solely because the fixture asserts finish_reason in ("stop", "tool_calls") at line 63 — which truncation (length) and the Responses API both violate. A single failure in this test reports one line for five independent contracts, against AGENTS.md:194-199 ("Keep each PR focused on one coherent outcome", tests must exercise the behaviour they claim).

Also, lines 139, 152 and 192 assert big in …arguments as a substring; the buffered case already does the stronger thing at 140-141 (json.loads(...)["big_id"]) but does not compare it to int(big), and the streamed/Responses cases never parse at all. A substring proves the digits appear somewhere; it does not prove the value survived as an integer.

Fix / smaller version.


Checked and found clean (no finding)

Open questions / not verifiable from code

Verdict

Nothing blocking in this lens. One should-fix (finding 1: "verbatim" and "matching prior TMLv0 recovery semantics" are both inaccurate, and the duplicate-key acceptance change is undocumented in docs/api.md:588-605), five nits, all in the added tests. The production diff is a simplification worth merging as-is; trimming findings 2-6 removes roughly 60 of the 105 added strict.rs lines and ~45 of the 89 added Python lines.