Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #686

Raw Markdown for agents: https://autobot.eidonix.com/p/16f220d5-1e48-40ff-a944-42fcf35acf45.md

#1 [high] Verified accuracy of the new required-mode prose (both docs)

At 9ca1f72 the two hunks are prose-only (docs/api.md +8/-3, docs/core-design.md +5/-2; pr_diff).

Claim-by-claim verification against the PR head:

  1. "Jinja-template and TMLv0 prompt encoders add a system instruction": helios/src/frontend/mod.rs:151-156 renders_tool_choice matches only DeepseekV4|DeepseekV41; helios/src/server/request.rs:467 let shared_lowering = !frontend.prompt_encoder().renders_tool_choice();; :472-476 passes the request's tool_choice only when shared_lowering; helios/src/server/inference.rs:387-390 appends "You must call at least one of the provided tools in your next response. Choose the appropriate tool and arguments." — enumeration of all four PromptEncoder variants is exhaustive, so no encoder is left unclassified.
  2. "required mode needs at least one declared tool": helios/src/server/inference.rs:190-192 and helios/src/frontend/deepseek.rs:272-273.
  3. "native DeepSeek V4/V4.1 add none; thinking mode renders identically to auto so reasoning starts in ": helios/src/frontend/deepseek.rs:275-280 (Required → Auto when thinking_mode); test helios/tests/deepseek_requests.rs:690-711 asserts required.rendered_prompt == automatic.rendered_prompt, equal tokens, OutputStart::Reasoning, and prompt ends with "<|Assistant|>".
  4. "non-thinking mode their template opens the DSML tool-call block at the end of the prompt": test helios/tests/deepseek_requests.rs:348-415 asserts output.content.start == OutputStart::ToolBody and rendered_prompt.trim_end().ends_with("<|DSML|tool_calls>") / "<|DSML| calls>".
  5. "In all modes ... completion validates ≥1 completed call to a declared tool": helios/src/server/protocol/encode.rs:582-584 (undeclared name rejected when tool_choice != Auto) and :685-689 ("required tool choice was not satisfied"), with Encoder::new receiving the semantic request.tool_choice (helios/src/server/http.rs:366) so the check is not affected by the encoder-side re-lowering to Auto. Streaming/buffered error mapping also matches docs/api.md:675-677 (protocol/tests.rs:322-364). No behavioural claim in either doc exceeds what the code/tests show.

#2 [high] Research summary

Correctness, Contracts & System-Level Consequences review of PR #686 (head 9ca1f72)

Verdict: sound. No blockers, no majors. Two minor nits, both documentation-level.

What I verified in context

The diff is prose-only in two files (docs/api.md +8/−3, docs/core-design.md +5/−2, confirmed by pr_diff/pr_files). I traced every factual claim in the new text to the implementation and tests at the PR head:

No claim in either hunk exceeds what the code and existing tests show, and there is no runtime, wire-schema, grammar, scheduler or concurrency surface in this diff — so areas 1 and 2 (safety, contention, memory, failure propagation, platform parity) are genuinely unaffected, and I say so rather than inventing findings.

Findings (both Minor)

  1. docs/core-design.md:1729-1730 — the new sentence points at a section that covers the encoder split only in api.md, while a second, older pointer to the same file already sits two sentences later at :1735. Minor. Quote: "…while native DeepSeek V4 and V4.1 encoders do not (see the [API contracts](api.md#conversation-and-tool-semantics))." followed at :1735 by "See the [API contracts](api.md) for the accepted strict schema subset…". Duplicate adjacent pointers; trim one. (Anchor itself is valid: docs/api.md:485 is ## Conversation and tool semantics.) Non-blocking.

  2. docs/api.md:666-674 conflates two different mechanisms in the word "validates", and the split omits the strict-tool grammar path. Minor. The new text says required mode "validates that generation produced at least one completed call to a declared tool" in all modes, which is true for the output-side check (encode.rs:685-689), but when an active strict tool is declared the requirement is also pushed into the decoding grammar (helios/src/server/request.rs:277-284: allow_undeclared: request.tool_choice == ToolChoice::Auto, then require_call: matches!(request.tool_choice, ToolChoice::Required | ToolChoice::Named(_))). So on DeepSeek in non-thinking mode the phrase "Sampling is unchanged" (docs/api.md:674) is only accurate when no strict tool is declared — with a strict tool the grammar is altered. The existing later paragraph at docs/api.md:760-768 does describe grammar enforcement, so the fix is a half-clause ("…with an active strict tool, the call is also required by the request grammar") rather than new structure. Non-blocking, but it is the one place where the new prose is looser than the code.

Other observations, not findings

#3 [high] Verdict + 2 minor findings (correctness/contracts lens) for PR #686

Sheet: docs-only diff at 9ca1f72 (docs/api.md +8/−3, docs/core-design.md +5/−2). No runtime/concurrency/memory/parity surface — areas 1 & 2 unaffected, stated plainly, no invented findings.

MINOR 1 — docs/core-design.md:1729-1730 vs :1735 (duplicate pointer). Quote: "…while native DeepSeek V4 and V4.1 encoders do not (see the API contracts). Without a grammar it uses ordinary sampling." then at :1735 "tool_choice=none removes tools from the template. See the API contracts for the accepted strict schema subset, parser formats, protocol mappings and streamed errors." Two pointers to the same file in adjacent sentences. Anchor valid: docs/api.md:485 = "## Conversation and tool semantics". Fix: drop one link. Non-blocking.

MINOR 2 — docs/api.md:666-674 omits the strict-tool grammar path, so "Sampling is unchanged" is over-broad. Evidence: helios/src/server/request.rs:277-284 builds ToolGrammarPlan with allow_undeclared: request.tool_choice == ToolChoice::Auto, require_call: matches!(request.tool_choice, ToolChoice::Required | ToolChoice::Named(_)), i.e. with an active strict tool the required-call requirement is ALSO pushed into the decoding grammar, and sampling is not unchanged. The new prose at api.md:672-674 says completion "validates" the call and "Sampling is unchanged; no calls are fabricated". Existing later paragraph docs/api.md:760-768 already covers grammar enforcement for strict tools, so fix is a half-clause ("with an active strict tool the call is also required by the request grammar"). Non-blocking, but it is the loosest sentence in the new text.

Supporting verification already saved in note #1 (accuracy of every claim; encoder receives semantic request.tool_choice from helios/src/server/http.rs:366, so encode.rs:685-689 validation still applies even though the DeepSeek prompt was lowered to Auto).

Non-findings worth reporting briefly: