Recommendation: Ready To Merge
All Round 1 blockers, should-fix items, and the #670 rebase conflict are resolved cleanly at head c897437: Chat top-level "medium" preserves TMLv0 (Inkling 2) native 0.7 via Effort::Medium while normalizing across GLM fallback and Qwen3.8 strict templates, non-JSON tagged argument scanning now runs in linear O(N) time via ToolDialect::scan_value_end and TaggedTools::in_value without weakening EOS rejection or the 1 MiB buffer cap, and docs/api.md plus Kani proofs are updated to match. No new correctness, safety, or hot-path regressions were introduced; the remaining items below are optional follow-up cleanups and minor nits.
Merge Risk
Level: Low
- Output parser hot path (
helios/src/output/):TaggedTools::pushretains the 1 MiB buffer bound (helios/src/output/tagged.rs:329-331), preserves strict-tool and EOS rejection (in_valueparticipates inEosDecision::Rejectattagged.rs:292), and scans open non-JSON values monotonically inO(N)with UTF-8 char-boundary safety across all threeIncompleteValuedialects (ArgumentTags,FunctionTags,GemmaCall). No shared state or locks are added. - Request decoding & effort resolution (
helios/src/server/protocol/decode.rs,helios/src/frontend/mod.rs): Template vocabulary probing runs once perFrontendinsideOnceLock::get_or_init(frontend/mod.rs:799, 843), adding zero per-request template renders or contention. TMLv0 Chat"medium"(0.7), Responses"medium"(0.9), and DeepSeek-V4.1"xhigh"(75) vs"max"(100) and numeric scores are preserved without shifting existing prompt contracts. - Cross-PR surface: Cleanly rebased over merged
#670(TaggedJson/JSON_BODY/with_tool_delimiters). Open docs PR#172(already inChanges Requestedwithdocs/api.mdmerge conflicts) will need to align its GLM effort wording when it rebases, which does not block#677.
Walkthrough
helios/src/server/protocol/decode.rs:chat_messages(:184-199) reads the first non-null ofreasoning_content,thinking, orreasoningonRole::Assistantmessages (keeping non-assistant roles onreasoning_contentonly) and returns HTTP 400 naming the offending key for non-string values.options(:596-638,:677-696) accepts nestedreasoning.efforton Chat Completions when top-levelreasoning_effortis absent or null, maps top-level Chat"medium"toEffort::Medium(leaving nested/Responses"medium"onEffort::High), and withholds normalized top-level Chat names (none,minimal,low,medium,high,max) fromoptions.templatewhile preserving passthrough for"xhigh", numeric scores, unknown top-level strings, explicitenable_thinking, andchat_template_kwargs.- Adds isolated unit tests (
:2436-2759) exercising realdecode+prepare_inferenceacross Jinja (GLM fallback & Qwen3.8 strict),TmlV0(Inkling 2), andDeepseekV41.
helios/src/server/inference.rs,helios/src/server/request.rs,helios/src/frontend/mod.rs:- Adds
Effort::Medium(inference.rs:121-122) with candidate ladder&["medium", "high"](request.rs:521). - Updates
Frontend::resolve_effort(frontend/mod.rs:853-880) to probe Jinja templates with sentinel"__flare_unknown_effort__"and exclude fallback-only"medium"when the template renders distinct levels, so GLM-stylelow/highelsemaxtemplates resolveEffort::Mediumto"high".
- Adds
helios/src/output/{tagged.rs,tagged/kani_proofs.rs,argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs}:- Replaces
Optionwith#[derive(Debug, PartialEq, Eq)] pub enum Candidate { Complete(...), InJsonString, IncompleteValue }(tagged.rs:31-37), addsToolDialect::scan_value_end(tagged.rs:61-63) andTaggedTools::in_value(tagged.rs:241, 292, 350-361, 400, 406, 419), and updatestagged/kani_proofs.rs:99-136to coverin_valueineos_decision. - Implements linear value-end scanners for
ArgumentTags(argument_tags.rs:117-123),FunctionTags(chatml.rs:30-47, 100-119), andGemmaCall(gemma_call.rs:176-181), adaptsMiniMaxXml(minimax_xml.rs:200-202), removes redundant mode flags, and adds split-sweep, single-char streaming, strict-tool, EOS/non-EOS, and 40,000-tag stress tests.
- Replaces
docs/api.md:- Documents literal closing tool tags inside non-JSON argument values (
:621-625) and assistant reasoning aliases, nestedreasoning.effort, Chat named effort normalization, and encoder vocabularies including TMLv00.7vs0.9(:975-995).
- Documents literal closing tool tags inside non-JSON argument values (
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, exfiltration, or prompt-injection vectors; 1 MiB parser buffer bound (
tagged.rs:329-331), strict schema validation, and fail-closed EOS rejection (tagged.rs:292) are preserved, andO(K·N)rescanning is eliminated. - [PASS] Charter & value fit: Aligns with documented OpenAI Chat Completions support, model-agnostic Helios layers (
Effort::Medium+ dialect-genericCandidate/scan_value_end), and requireddocs/api.mdupdates; minor bundling of two fixes remains noted under Nits. - [PASS] Related / duplicate / conflict check: Not a duplicate; cleanly rebased over merged
#670(TaggedJson,JSON_BODY,with_tool_delimiters); open docs PR#172will rebase its GLM effort note onto this. - [WARN] Tests & verification evidence: All new Rust tests are isolated, mutate no global state, and exercise real production entry points (with external unverified GPU/BFCL claims removed from the PR description); warning solely because
cargo-kani/cargo-mutantswere not run on the validation host (honestly disclosed;kani_proofs.rs:99-136verified statically) and test counts rely on CI/author execution.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Fail-closed default for
ToolDialect::scan_value_end(helios/src/output/tagged.rs:61-63): Every current dialect that emitsCandidate::IncompleteValue(ArgumentTags,FunctionTags,GemmaCall) overridesscan_value_end, whileMiniMaxXmlandTaggedJsonnever emitIncompleteValue. ReturningErr(0)instead ofOk(0)in the trait default keeps non-IncompleteValuedialects untouched while ensuring any futureIncompleteValuedialect fails immediately in its first functional test instead of silently falling back toO(K·N)reparsing. - Deduplicate Chat effort predicate and normalized-name list (
helios/src/server/protocol/decode.rs:596-629, 677-682):protocol == Protocol::Chat && !chat_nested_effortis repeated at:622and:627, and the six withheld level names at:681mirror the match arms at:614-626(excluding"xhigh"). Bindinglet chat_top_level = protocol == Protocol::Chat && !chat_nested_effort;once and returning(native, withhold)from the effort match (with"xhigh"returning(Some(Effort::Max), false)onchat_top_level) removes the duplicated list and prevents future drift. - Share
<parameter-boundary scan in ChatML (helios/src/output/chatml.rs:30-47, 197-208):FunctionTags::scan_value_endandparse_tool_candidatewalktail.match_indices('<')with the sameparameter_end/parameter_start/</function>predicates. Extracting a singlefn find_value_end(tail: &str) -> std::result::Result<(usize, usize), usize>letsscan_value_endbefind_value_end(tail).map(|(end, consumed)| end + consumed)andparse_tool_candidatereuse it directly, eliminating duplicate logic and drift risk. - Optional
Candidate::into_callshelper (helios/src/output/argument_tags.rs:108-112, 125-130,chatml.rs:130-134,gemma_call.rs:167-171, 183-187): Fiveparse/parse_eossites repeat the three-armCandidatematch to convertIncompleteValue/InJsonStringinto errors; a small helper method onCandidatewould trim ~15-20 lines.
Nits
- Sentinel-probe scope in
Frontend::resolve_effort(helios/src/frontend/mod.rs:863-880): No supported Flare model template falls back to"medium"on unknown values, so the heuristic works across all current templates (GLM/Kimielse 'max', Qwen3.8 strict, and effort-agnostic templates). A brief comment noting that a hypotheticallow/medium/hightemplate defaulting unknowns to"medium"would have"medium"excluded by render-equality probing — plus a unit test infrontend/mod.rsalongsideadvisory_effort_uses_the_prepared_templates_vocabulary(:1742-1777) exercising a fallback template — would document this boundary clearly. docs/api.mdprecision (docs/api.md:982-993): Mentioning that (a) non-standard/padded top-level Chatreasoning_effortstrings (like"xhigh"and numeric scores) pass through to the encoder/template, and (b) Chat nestedreasoning.effort: "medium"follows Responses semantics (Effort::High→0.9on TMLv0,"high"before"medium"on Jinja) rather than top-level ChatEffort::Medium(0.7), would make the docs exact on both edge cases.- PR scoping & Kani: The PR still bundles two independent fixes (Chat decode/effort and tagged tool-call parsing); keeping independent fixes in separate PRs simplifies review and bisecting in future work. Running
cargo kanionhelios/src/output/tagged/kani_proofs.rsin an environment with Kani installed is recommended before/during CI merge gating.
Dropped on verification
- Claim that default
scan_value_endreturningOk(0)causes an infinite loop (Discovery Dossier Finding 5 & Subtraction Lens Finding 1): Verified false. Athelios/src/output/tagged.rs:377,self.search_from = prev + consumedadvances past the closing tag beforeparse_candidatereturnsIncompleteValue; on the next iterationOk(0)clearsin_valueand scanning resumes strictly after the skipped closer. Impact for a hypothetical future non-overriding dialect isO(K·N)reparsing, not an infinite loop, and zero current dialects reach the default. - Claim that
Effort::Medium/ the sentinel filter inFrontend::resolve_effortis untested on Jinja (Discovery Dossier Open Question & Correctness Lens Finding 1.2 / §4): Verified false.helios/src/server/protocol/decode.rs:2565-2601directly exercises Chat"medium"(Effort::Medium) through a GLM-style fallback Jinja template where the sentinel filter fires and resolves"medium"→"high", anddecode.rs:2652-2671testsEffort::Mediumthrough a Qwen3.8 strict Jinja template. - Claim that
Effort::Mediumis a single-backend (TmlV0-only) enum variant that should be replaced with aTmlV0branch inrequest.rs(Subtraction Lens Finding 3): Verified false. Any Jinja template accepting both"medium"and"high"also distinguishesEffort::Medium(&["medium", "high"]atrequest.rs:521) fromEffort::High(&["high", "medium"]atrequest.rs:522). KeepingEffort::Mediumin the shared enum is more model-agnostic than hardcoding aPromptEncoder::TmlV0branch inrequest.rs. - Claim that unknown top-level Chat
reasoning_effortpassthrough is a regression or violates charter #417 (Correctness Lens Finding 1.3): Dropped as pre-existing behavior intentionally retained for numeric/padded/native-encoder inputs (DeepSeek, TMLv0, and strict Jinja still reject invalid values with HTTP 400, matchingmain); narrowed to a minor doc-precision nit. - Claim that omitting an unclosed non-JSON argument value on
OutputLimit/UserStop/Cancelled/ExecutionErroris an undisclosed compatibility hazard (Correctness Lens Finding 2.4): Dropped;tagged.rs:283-297aligns with the existing documented contract (docs/api.md:636-638: calls cut off by output limits or stop sequences are never recovered) and is explicitly tested atargument_tags.rs:896-910. - Minor factual corrections to Subtraction Lens Findings 4 & 5: There are 5 (not 6)
Candidatematch sites acrossargument_tags.rs,chatml.rs, andgemma_call.rs; and the suggestedfind_value_endwrapper forchatml.rsmust map(end, consumed)toend + consumed(not justconsumed).