Review of #461 — Document strict tool selection and numeric range precision
Lens A: correctness and consequences. Read: the full docs diff and its surrounding sections (docs/api.md:495-660), the changed test (helios/src/grammar/strict.rs:3888-3898), the strict-admission path (strict.rs:53-145, 147-175, 340-375, 555-595), the request-side strict plumbing (helios/src/server/request.rs:88-300, 704-769), and the pinned dependency (helios/Cargo.toml:62).
Key findings
- The change is documentation plus one test; the runtime is untouched. The diff is
docs/api.md(+27/−14) andhelios/src/grammar/strict.rs(+12/−0, a#[cfg(test)]function only, strict.rs:3888-3898). The PR's "no requests accepted onmainacquire a new HTTP 400" claim therefore holds structurally: nothing in the admission or decoding path changed. Verified. - The new selection sentences understate admission. docs/api.md:522-525 says the strict grammar attaches "when the selected function sets
strict: true", and :544-546 says "any activestrict: truefunction still attaches the strict request grammar". Grammar attachment is indeed selection-scoped (see "Callers" below), but schema admissibility is not:compile_strict_validatorsiterates everytool.stricttool regardless oftool_choiceand returns an admission error (HTTP 400) before inference (request.rs:88-113, :125). A reader can reasonably conclude an unselected strict tool cannot fail the request. It can. This is the one substantive issue. - The numeric-range prose matches the code. The doc no longer gates range bounds at
2^53(onlyconst/enumcarry that restriction, docs/api.md:599-603), which is what the code does: admission forminimum/maximum/exclusiveMinimum/exclusiveMaximumonly requires a finite number and never rounds or re-derives the value (strict.rs:575-584; the schema is handed to llguidance verbatim at strict.rs:144 viacompile_json_schema_text). The claim is a description of llguidance's behaviour, not of Helios logic, and the doc says so indirectly ("interpreted at binary64 precision"). - The new test covers only the
maximumcase the docs single out as exact. strict.rs:3891-3897 admitsmaximum: 10^18andmaximum: i64::MAX, validates the endpoint, and rejectsendpoint + 1. The two inexact examples the docs assert are not pinned anywhere in the repository.
Callers and configurations
compile_strict_validators(request.rs:88-113) is the admission gate; it is called first inprepare_inference_cached(request.rs:125), i.e. before prompt rendering and grammar compilation. It filtersrequest.tools.iter().filter(|tool| tool.strict)— notool_choiceterm. A strict tool with an inadmissible schema returns HTTP 400 even underToolChoice::NoneorToolChoice::Named(other). The existing testignored_strict_tools_still_require_compiler_admissible_schemas(request.rs:704-769) pins exactly this, looping overToolChoice::NoneandToolChoice::Named("selected")and assertingcompile_strict_validatorserrors once an invalid strict tool is added (request.rs:744-759). It also pins the cross-tool ambiguity error for a strict name duplicated by a non-strict tool (request.rs:760-767, logic at request.rs:103-111).- Grammar attachment is selection-scoped, so the doc's first sentence is right:
active_toolsis built only whentool_choice != ToolChoice::Noneand some tool is strict, and underToolChoice::Namedit keeps only tools whosenative_name()matches (request.rs:225-241).has_active_strict_toolthen gates grammar compilation (request.rs:242-279). Raw Completions with an active strict tool are rejected (request.rs:243-245) — an unchanged path the docs already cover at api.md:644-645. - Required mode adds a prompt instruction and does not change sampling elsewhere (documented at api.md:542-546); "Required mode by itself leaves sampling unconstrained" is consistent with the code path above, where the only sampling-affecting element is the compiled strict grammar.
- No per-model, per-parser or hardware-specific path is touched by this PR, so the "every model / cache scheme / parallel layout / multi-host / hardware target" sweep finds nothing new: the changed file is a docs page and a unit test using the CPU
byte_tokenizer()fixture (strict.rs:3890), which runs on any target. The PR reports it passing on x86_64; the reviewer's table was produced on aarch64. Both are consistent with a CPU-only grammar test.
Inactive and edge-case paths
- Inactive path that still 400s — the finding above. Concretely:
tool_choice: "none"plus a strict tool with an unsupported schema is a 400 today, and the new text at api.md:522-525 ("selection by itself adds no decoding constraint; when the selected function setsstrict: true…") reads as though nothing happens for unselected strict tools, while api.md:544-546 says "any activestrict: truefunction still attaches the grammar" — under named choice an unselected strict tool is not active, so the reader learns nothing about its admission requirement. api.md:644-645 ("invalid strict schemas return HTTP 400") is the only cover, and it sits in a later paragraph about active tools. Fix: add one clause to the named/required paragraphs, e.g. "Every declaredstrict: trueschema must also be admissible even when its tool is not selected; an unsupported or ambiguous strict schema returns HTTP 400 before generation." - Undefined term "active" — api.md:545, 614, 639, 644 all use "active
strict: truefunction"/"active strict tool" but the page never defines it, and in the code "active" means post-tool_choicefiltering (request.rs:225-241) and requires tools to be enabled. Since the change newly leans on the term at :545, defining it once would close the same ambiguity. Nit. - Edge case the new test does not reach:
maximum: 2^53is covered bystrict_bounds_do_not_round_integers_or_fractional_multiples(strict.rs:3006-3016:9007199254740992accepted,9007199254740993rejected), and10^18/i64::MAXby the new test (strict.rs:3888-3898).endpoint + 1in the new test isi64::MAX as u64 + 1 == 2^63, which stays insideu64and serializes as a JSON integer — no overflow or float coercion in the fixture itself. - The two inexact claims are untested. docs/api.md:607-609 asserts
minimum: 9007199254740993can admit9007199254740992andexclusiveMinimum: 9007199254740992can admit the endpoint. The only evidence is the reviewer's table onmainat6d6fe0c6(PR discussion, review of 2026-11-23: rows 1 and 2 "accepted"). Nothing in the repository would fail if the pinnedllguidance = "=1.9.1"(helios/Cargo.toml:62) changed rounding or if a future bump fixed it, leaving the docs stale and, worse, over-claiming a limitation. Nit — evidence does exist outside the repo — but the fix is cheap: extend the new test with the two inexact schemas and assert the documented outcome (accepted), so a fix in llguidance shows up as a failing test that forces the docs to be updated. - Removed literal range: the base text spelled out
[-9,007,199,254,740,991, 9,007,199,254,740,991]; the new text says "magnitude strictly below2^53" (api.md:600-603). Equivalent, and it matches the code's error text and the rejection of±9007199254740992(strict.rs:340-375, exercised at strict.rs:3910-3948). No issue.
State, graph and persistence consequences
None. The change adds no schema, cache, checkpoint, exported-core or graph-contract surface, so existing artifacts and cores continue to load, and no MTP/decode-width behaviour changes (the width rule is stated at api.md:639-643 and untouched). The only behaviour the docs newly describe is llguidance's existing rounding, which — as the PR states — is not fixed here.
Rules compliance (charter and repository guidance)
- Charter "Bring real evidence" and "bad docs" merge criterion: satisfied in kind — this is a docs correction with a real runtime regression test, and the PR explicitly declines a performance claim ("No GPU benchmark was run"). The issue count of the #418 review that drove this ("Or leave admission as it is and document the limit") is answered by the documentation route.
- Charter "Don't silently ignore API fields": unaffected; no field handling changes.
- The PR description's Compatibility section is accurate about HTTP 400s but, for the reason in Key finding 2, the docs it introduces do not tell the reader which strict tools must be admissible. That is the gap to close before merge.
Open questions
- Should "active strict tool" be defined once (api.md:545, 614, 639, 644)? It is now load-bearing for a new sentence.
- Should the two inexact rounding cases be pinned by a test so the documentation cannot drift from a pinned llguidance (helios/Cargo.toml:62)?
- Whether maintainers consider the unselected-strict-tool admission rule (
compile_strict_validatorsignoringtool_choice, request.rs:88-113) intentional API surface worth documenting, or a rule that should itself be relaxed to selection scope — the latter is a behaviour change and out of scope for this PR, but the docs should say what happens today either way.