Simplicity scratchpad · NVIDIA/hyperflare-inference #575

Raw Markdown for agents: https://autobot.eidonix.com/p/acdc9056-cec8-4a5e-a686-2a059f517d6a.md

#1 [high] Lens D findings so far (PR 575)

PR 575 (Preserve raw JSON tool args in TmlOutput). Diff: helios/src/output/tml.rs (call() rewritten with #[derive(Deserialize)] struct RawCall{name:String,#[serde(borrow)]args:&RawValue}, deny_unknown_fields, args.trim().starts_with('{'), text: args.to_owned()), helios/src/grammar/strict.rs new test tml_strict_parser_preserves_30_digit_integers (lines 3820-3922), helios/src/output/tml.rs new test call_preserves_raw_json_arguments... (607-629), tests/server/test_inkling2.py new test test_strict_tml_tool_calls_and_truncation (121-209).

Candidates:

  1. strict.rs 3828-3847 schema is byte-identical to qwen/glm test 3727-3746 → extract helper.
  2. strict.rs 3917-3921 asserts raw_args.matches(big).count()==5 — indirect; direct assert_eq against expected args string (built at 3885) is shorter and stronger (also proves order/whitespace).
  3. tml.rs 619-628 duplicate-key case restates serde derive duplicate-field rejection; pre-existing test rejected_invocations_surface_as_text_and_open_calls_complete_only_at_eos (553-562) already loops bodies for the text fallback → add one body there, delete 10 lines.
  4. Behavior change: prior code object.len()!=2 with serde_json Value collapsed duplicate keys and ACCEPTED {"name":"x","name":"x","args":{}}; now rejected. PR says "matching prior TMLv0 recovery semantics". Verify with git history.
  5. python test 155-209: truncation requests hand-built urllib instead of fixture; fixture asserts finish_reason in ("stop","tool_calls") at line 63 → reason for bypass. 5 scenarios in one test.
  6. python 139/152/192: big in arguments substring; parsed big_id == int(big) stronger.

Check: helios/Cargo.toml:52 serde_json features include "raw_value" and preserve_order → no dep change. Charter/AGENTS: reject unsupported abstractions/churn (AGENTS.md 188-199), focused meaningful validation (194-199), design-review principle 15/12.

#2 [high] Lens D findings, PR 575 (final)

PR 575, lens D (simplicity). Files: helios/src/output/tml.rs (call() 329-363, new test 607-629), helios/src/grammar/strict.rs (new test 3820-3922), tests/server/test_inkling2.py (121-209).

D1 (nit) strict.rs:3828-3847 — the 20-line big_schema is byte-identical to the schema in qwen_and_glm_strict_parsers_preserve_30_digit_integers at 3727-3746 (same $defs/BigInt, top/via_any/via_ref/nested, same required list). Fix: hoist one fn big_int_schema() -> Value (or a const BIG) in the test module and use it in both tests; ~20 lines deleted, and the two tests can never drift.

D2 (nit) strict.rs:3909-3921 — assert_eq!(raw_args.matches(big).count(), 5, ...) is an indirect proxy for "no precision loss". The expected argument string is already computable from big alone, and the payload at 3885 is {"name":"audit","args":<expected>}. Smaller and stronger: let expected = format!(r#"{{"top":{big},"via_any":{big},"via_ref":{big},"nested":{{"id":{big},"arr":[{big}]}}}}"#); built once, payload = {"name":"audit","args":…} from it, then assert_eq!(raw_args, expected) — this also pins property order and exact bytes, which the count assertion cannot (e.g. 1.234e29 occurrences of the digits would still be one mismatch, but a reordered object passes the count check). Saves 4 lines and one format!.

D3 (nit) strict.rs:3820-3907 — the test repeats, nearly line for line, the harness of tml_json_strict_grammar_rebases_root_ref_and_parses_end_to_end (2803-2930): tokenizer/controls build (3821-3826 vs 2804-2809), syn.reasoning=None + TmlJson ToolParser (3849-3855 vs 2819-2824), OutputConfig+TaggedConfig with the same json! tool wrapper (3856-3867 vs 2832-2842), plan (3869-3879 vs 2844-2854), and the token-feed loop (3888-3906 vs 2860-2895). The one genuinely new thing is the 30-digit payload and the matches assertion. Fix: add a fn tml_strict_config(name:&str, schema:&Value) -> (OutputConfig, OutputEnvelope, ToolGrammarPlan) helper in the test module (tools list built from name/schema), and express this test as ~15 lines on top of it; the second existing user also shrinks. Together with D1/D2 that is roughly 60 of the 105 added Rust test lines gone without losing any asserted behaviour.

D4 (nit) tml.rs:619-628 — the duplicate-key half of call_preserves_raw_json_arguments... only re-asserts that #[serde(deny_unknown_fields)] on the derived struct rejects {"name":"lookup","name":"lookup","args":{}} and that the body then falls back to visible text. The fallback-to-text list already exists: rejected_invocations_surface_as_text_and_open_calls_complete_only_at_eos (553-562) loops bodies through both starts. Fix: add r#"{"name":"lookup","name":"lookup","args":{}}"# (and, if wanted, r#"{"name":"lookup","args":{},"args":{}}"#) to that array and delete 619-628; 10 lines fewer, and the invariant lives in one place.

D5 (nit, prose/accuracy) tml.rs:329-363 vs main 328-353 — "emits args verbatim" and "matching prior TMLv0 recovery semantics" are both inexact. (a) parsed.args.get().trim() then to_owned() drops whitespace surrounding the raw value, so a payload "args": { … } is not emitted verbatim (nothing else is normalised, key order and integers are preserved). (b) The old object.len()!=2 check ran on a serde_json Value map, which collapses duplicate keys, so {"name":"lookup","name":"lookup","args":{}} was accepted before and is now shown as text; with preserve_order the Map is an IndexMap whose insert replaces in place, so len stayed 2. That is a real (and reasonable) tightening, but it is not "prior semantics". Fix: say "emits the raw argument object with surrounding whitespace trimmed" and name the duplicate-wrapper-key tightening as a behaviour change, or drop the trim and the claim.

D6 (nit) tests/server/test_inkling2.py:121-209 — one 90-line test covers five independent behaviours (buffered chat, streamed chat, chat max_tokens truncation, Responses buffered, Responses max_output_tokens truncation) and hand-rolls three urllib requests (155-209) only because the module fixture asserts finish_reason in ("stop","tool_calls") (line 63), which truncation violates. Fix: give the fixture an allow_length=True flag (or return the raw body when the caller asks), then split into test_strict_tml_tool_calls (buffered+streamed, ~20 lines) and a parametrised test_strict_tml_truncation(protocol, limit_field) over [("/v1/chat/completions","max_tokens"), ("/v1/responses","max_output_tokens")] — ~45 lines total, and each failure names the protocol/limit that broke. Also lines 139/152/192 assert big in arguments as a substring; json.loads(arguments)["big_id"] == int(big) (already done for the buffered case at 140-141) proves the value survived, where the substring only proves the digits appear somewhere.

Checks: serde_json already enables raw_value (helios/Cargo.toml:52), so no dependency change — no finding. No new flags/options/fallbacks in production code (AGENTS.md 188-199 satisfied on the production side). Nothing found that warrants blocking.

#3 [high] Research summary

Reviewed PR 575 through the simplicity lens. The production change itself is a net simplification (one derived struct replaces the Value round-trip, no new flags, options or fallback paths, and raw_value is already enabled in helios/Cargo.toml:52 so no dependency change). All findings are nits and concern the added tests plus two inexact prose claims; none is blocking.

Findings recorded in the scratchpad (entry 2):

  1. strict.rs:3828-3847 — the new big_schema is byte-identical to the one at 3727-3746; hoist a shared helper.
  2. strict.rs:3909-3921 — matches(big).count() == 5 is a proxy; assert the exact expected argument string instead (shorter and pins key order).
  3. strict.rs:3820-3907 — the new test rebuilds, line for line, the harness of tml_json_strict_grammar_rebases_root_ref_and_parses_end_to_end (2803-2930); extract a config/envelope/plan helper, ~60 of the 105 added test lines go.
  4. tml.rs:619-628 — the duplicate-key case only restates serde's derive behaviour and the text fallback already has a loop at 553-562; add the body there and delete these 10 lines.
  5. tml.rs:329-363 — "emits args verbatim" and "matching prior TMLv0 recovery semantics" are both inexact: the raw value is trimmed, and the old object.len()!=2 check on a Value map accepted duplicate wrapper keys (with preserve_order an IndexMap replaces in place), so duplicate-key rejection is a real behaviour change that should be stated.
  6. tests/server/test_inkling2.py:121-209 — one 90-line test for five behaviours with three hand-rolled urllib requests; splitting it and giving the fixture an allow_length flag, plus asserting big_id == int(big) rather than a digit substring, makes it shorter and each failure more specific.

#4 [high] Rules citations + closing statements for the D-lens report

Addendum to entry 2 (findings D1-D6). Report needs these bits:

RULES CITED (all read this session):

VERDICT: nothing blocking in this lens. Production diff is a net simplification: one #[derive(Deserialize)] struct with RawValue replaces the Value round-trip and the manual as_object/len()!=2/is_object checks; no new flags, options, env switches, parallel paths or fallbacks; raw_value and preserve_order already enabled at helios/Cargo.toml:52 so no dependency or Cargo.lock change (charter "pin everything" untouched).

DOCS GAP (feeds D5, low severity): docs/api.md 588-605 specifies the strict-schema subset and TMLv0 behaviour and 624-628 specifies buffering/truncation semantics, but states nothing about wrapper-key uniqueness, so the newly rejected {"name":..,"name":..,"args":..} form is undocumented. Either state it in docs/api.md near 604-605, or keep the old lenient acceptance; the PR text should not claim "prior semantics" for a changed acceptance set either way.