Subtractive scratchpad · NVIDIA/hyperflare-inference #575

Raw Markdown for agents: https://autobot.eidonix.com/p/f910edbd-8a1d-4410-aaf1-b193d57e3445.md

#1 [high] Should fix: strict.rs tml_strict_parser_preserves_30_digit_integers (107 lines) duplicates existing coverage

File: helios/src/grammar/strict.rs:3819-3922 (added, 107 lines) — tml_strict_parser_preserves_30_digit_integers.

What it does: builds the same big/big_schema (30-digit integer, top/via_any/via_ref/nested) as the pre-existing qwen_and_glm_strict_parsers_preserve_30_digit_integers (strict.rs:3723-3817), compiles the strict TML grammar, advances the payload token-by-token, then runs the same OutputPipeline + validate_strict_tool_schema + raw_args.matches(big).count() == 5 assertion.

Every behaviour it probes is already covered:

  1. TML strict grammar compiles, accepts its payload, and the pipeline emits arguments that the strict validator accepts: tml_json_strict_grammar_rebases_root_ref_and_parses_end_to_end (strict.rs:2802-2930) does exactly this (compile_presented_strict_tools + OutputPipeline + validator.validate) including $ref/root rebasing.
  2. Raw argument text survives TmlOutput::call unchanged for >64-bit integers: the new unit test in the same PR, helios/src/output/tml.rs:607-629, asserts exact string equality (assert_eq!(parsed.2, vec![("lookup".into(), args)])) on the same 30-digit value with a negative and a nested integer.
  3. The schema shape (anyOf/$ref/nested array-of-integer) is copied verbatim from the Qwen/GLM test at strict.rs:3727-3746; that test already proves the 5-occurrence count assertion for two parser kinds.

Smaller version: delete the whole test (lines 3819-3922). Zero loss: the implementation change is proven verbatim by the tml.rs unit test, and the grammar/pipeline path it would exercise is exercised by the existing TML test at 2802. If a reviewer wants the big integer to also appear in the TML pipeline test, the cheaper form is one extra assertion on the existing test's payload (3 lines), not a 107-line clone.

Lines saved: ~107 (of the PR's 237 added lines).

#2 [high] Should fix: docs/TODO.txt entry the PR claims to address is left in place (4 lines)

docs/TODO.txt:5-8 still reads:

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

The PR description states: "This addresses the strict TMLv0 tool-calling qualification tracked in docs/TODO.txt", and its live evidence claims 35/35 across exactly those checks (Chat/Responses, buffered/streamed, truncation). AGENTS.md:512-517 ("Task tracking": Update or remove entries as work is completed) and AGENTS.md:58-60 require the completed entry to go in the same change.

Leaving it means the same work is claimed in two places and the TODO list keeps asking for a qualification the PR says is done.

Fix: delete docs/TODO.txt lines 5-8 (and the blank separator if needed). Lines saved: 4. If maintainers judge the qualification incomplete, the PR should say so in the description instead of claiming it.

#5 [high] Research summary

Reviewed PR #575 (3 files, +237/−10) through a subtraction lens. The production change itself is minimal and needed — TmlOutput::call (helios/src/output/tml.rs:329-363) is a 12-line swap of Value for a borrowed &RawValue wrapper, raw_value is already enabled in helios/Cargo.toml:52, and the repo already uses &RawValue the same way at helios/src/frontend/mod.rs:250-259 and helios/src/output/tagged.rs:806-859, so nothing is duplicated there and nothing is left dead. The TODO item at docs/TODO.txt:5-8 is a real tracked qualification.

The weight is in tests and bookkeeping: ~107 of the 237 added lines are one grammar/strict.rs test that re-derives the schema and assertions of the adjacent Qwen/GLM 30-digit test while covering a path already tested twice; ~12 lines of the Python test repeat encoder-level coverage and re-fetch a model id the fixture already has; ~10 lines of the tml.rs unit test pin an unreachable duplicate-key shape; and the TODO entry the PR says it closes is left in place against AGENTS.md:512-517. Total removable ≈ 130 of 237 added lines, with no loss of the behaviour this fix exists to guarantee. Findings recorded in the scratchpad with line numbers and smaller versions.

#6 [high] Verified: the production change is needed and already minimal (nothing to cut in tml.rs call())

Need (not a hypothetical): docs/TODO.txt:5-8 tracks exactly this qualification ("Qualify strict: true function tools on a TMLv0 core (ToolParserKind::TmlJson, e.g. Inkling 2) ... Chat Completions and Responses, buffered and streamed, including max_tokens and max_output_tokens truncation"). AGENTS.md:165-169 requires an explicit request or demonstrated defect; this is both. Failure mechanism is confirmed in code: the old object.get("args").filter(|v| v.is_object()) + args.to_string() round-trips through Value, and helios/src/grammar/strict.rs:3018-3024 already asserts that a 30-digit integer must validate against an {"type":"integer"} schema, while helios/src/grammar.rs:653 is the "does not match its grammar" error the PR reports as HTTP 500.

Minimality of the code (nothing to subtract):

Dropped candidates (checked and rejected — do not raise in the report):

#3 [medium] Nit: test_inkling2.py streamed strict block duplicates encoder tests (~12 lines)

File: tests/server/test_inkling2.py:143-152 (added, 10 lines, plus comment line 143).

    # Chat Completions streamed: buffers strict arguments into one validated delta.
    events = service(prompt, tools=chat_tools, tool_choice="required", stream=True)
    arg_chunks = [...]
    assert len(arg_chunks) == 1 and big in arg_chunks[0], arg_chunks

That "strict arguments arrive as one validated delta" contract is already proven at the encoder level by helios/src/server/protocol/tests.rs:1893-1929 (Argument fragments in generation order remain private until ToolEnd, asserting pre_frames.is_empty() and non-empty frames only at ToolEnd) and strict.rs:3811-3815 asserts the 30-digit text on the pipeline path. The live test adds no transport-specific code path for the streamed case: the same service fixture streaming plumbing (test_inkling2.py:50-58) is already exercised by test_streamed_reasoning_and_answer (line 80).

Also flat duplicate: test_inkling2.py:122-123 re-reads /v1/models and re-derives model_id although the module fixture (line 30-38) already fetched it.

Smaller version: delete lines 143-152 and reuse the fixture's model id (expose it on the fixture function, as service.chunk already is) → ~12 lines. If streamed strict coverage is wanted for the TMLv0 core, the Responses streaming path is the one with no coverage at all, so keeping chat-streamed independently proves the same behaviour twice while the cheaper swap is to keep one streaming case.

Lines saved: ~12.

#4 [medium] Nit: tml.rs duplicate-key test block (~10 lines) proves an unreachable shape

File: helios/src/output/tml.rs:619-628 (added, 10 lines).

        let duplicate = r#"{"name":"lookup","name":"lookup","args":{}}"#;
        assert_eq!(run(... ).1, duplicate);

Nothing in the request path can produce a duplicate wrapper key: the strict wrapper schema (strict.rs:1567-1578, additionalProperties: false with name/args required) and the non-strict fallback wrapper both emit exactly one name and one args. The identical visible-text fallback path is already asserted by rejected_invocations_surface_as_text_and_open_calls_complete_only_at_eos (tml.rs:551-562) for {"name":"lookup","args":{},"extra":1} and {"name":7,"args":{}}. So the duplicate block only pins a serde-derive side effect of deny_unknown_fields, not a behaviour the fix needs.

Smaller version: keep the precision assertion only (lines 608-617); drop 619-628. Also parsed.args.get().trim() (line 339): RawValue already excludes surrounding whitespace, so .trim() is a no-op — harmless, 0 lines.

Lines saved: ~10.