Skip to content

docs/api: enumerate accepted response_format JSON Schema keywords - #704

Open
jcartu wants to merge 1 commit into
NVIDIA:mainfrom
jcartu:docs/response-format-json-schema-keywords
Open

jcartu wants to merge 1 commit into
NVIDIA:mainfrom
jcartu:docs/response-format-json-schema-keywords

Conversation

@jcartu

@jcartu jcartu commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Refs #449

Structured-output JSON Schema constraints (response_format with type: "json_schema" on Chat Completions and Completions, text.format on Responses, and output_config.format on Messages) validate every schema node against a closed keyword allowlist in validate_schema_nodes (helios/src/grammar.rs), rejecting unsupported keywords such as deprecated, nullable, and uniqueItems with HTTP 400. Previously, docs/api.md documented the strict function-tool keyword subset but did not list the accepted keywords or admission bounds for structured-output JSON schemas, so API callers could not see which keywords are accepted without reading helios/src/grammar.rs. Documenting the allowlist in docs/api.md without modifying validate_schema_nodes preserves the closed allowlist rule while resolving the documentation gap noted on #449.

Before this change, the output-constraint section in docs/api.md stated that JSON output formats constrain the final answer and include the schema in the system prompt, without enumerating the accepted JSON Schema keywords, external $ref rejection, or schema size, depth, and node limits. After this change, docs/api.md adds a concise paragraph in the output-constraint section listing all 42 accepted keywords from validate_schema_nodes:

  • 29 structural and constraint keywords: $ref (same-document # references only), $defs, definitions, type, const, enum, anyOf, oneOf, allOf, properties, patternProperties, additionalProperties, required, minProperties, maxProperties, items, prefixItems, additionalItems, minItems, maxItems, minLength, maxLength, pattern, format, minimum, maximum, exclusiveMinimum, exclusiveMaximum, and multipleOf.
  • 13 metadata and annotation keywords: $anchor, $schema, $id, id, $comment, title, description, default, readOnly, writeOnly, examples, contentMediaType, and contentEncoding.
  • Explicitly notes that any other keyword (such as deprecated, nullable, uniqueItems, or compiler extensions like x-guidance), external $ref targets, and schemas exceeding 262,144 bytes, depth 64, or 8,192 nodes return HTTP 400.

As a result, API callers have a complete, present-state reference for accepted structured-output JSON Schema keywords and admission bounds, with no behavior, runtime, or core-compatibility changes.

Validation:

  • Verified programmatic 1:1 set parity between validate_schema_nodes in helios/src/grammar.rs at 3d1614cc and the documented keyword lists in docs/api.md (42 code keywords == 42 documented keywords: 29 structural and constraint keywords plus 13 metadata and annotation keywords, zero missing, zero extra, zero duplicates).
  • Verified MAX_GRAMMAR_BYTES (262,144), MAX_SCHEMA_DEPTH (64), MAX_SCHEMA_NODES (8,192), and protocol field mapping in helios/src/grammar.rs and helios/src/server/protocol/decode.rs.
  • Ran git diff --check (zero whitespace issues) and verified git diff --stat touches only docs/api.md.
  • Unrun checks: no Rust, Python, simulator, formal, or GPU test suites were run because this PR modifies documentation only.

Discord: jcartu

Structured-output JSON Schema constraints (`response_format` with
`type: "json_schema"` on Chat Completions and Completions, `text.format` on
Responses, and `output_config.format` on Messages) validate every schema node
against a closed keyword allowlist in `validate_schema_nodes`
(`helios/src/grammar.rs`), rejecting unsupported keywords such as `deprecated`,
`nullable`, and `uniqueItems` with HTTP 400. Previously, `docs/api.md`
documented the strict function-tool keyword subset but did not list the
accepted keywords or node limits for structured-output JSON schemas, so clients
could not determine which keywords are permitted without inspecting
`helios/src/grammar.rs`. Documenting the exact allowlist in `docs/api.md`
without altering `validate_schema_nodes` preserves the closed allowlist rule
while giving API callers an accurate specification.

Before this change, the output-constraint section of `docs/api.md` stated that
JSON output formats constrain the final answer and include the schema in the
system prompt, without specifying the accepted JSON Schema keywords, external
`$ref` rejection, or schema size, depth, and node bounds. After this change,
`docs/api.md` enumerates all 42 accepted keywords in `validate_schema_nodes`,
grouped into 29 structural and constraint keywords (`$ref` with same-document
`#` references only, `$defs`, `definitions`, `type`, `const`, `enum`, `anyOf`,
`oneOf`, `allOf`, `properties`, `patternProperties`, `additionalProperties`,
`required`, `minProperties`, `maxProperties`, `items`, `prefixItems`,
`additionalItems`, `minItems`, `maxItems`, `minLength`, `maxLength`, `pattern`,
`format`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, and
`multipleOf`) and 13 metadata and annotation keywords (`$anchor`, `$schema`,
`$id`, `id`, `$comment`, `title`, `description`, `default`, `readOnly`,
`writeOnly`, `examples`, `contentMediaType`, and `contentEncoding`), and notes
that any other keyword (such as `deprecated`, `nullable`, `uniqueItems`, or
compiler extensions like `x-guidance`), external `$ref` targets, and schemas
exceeding 262,144 bytes, depth 64, or 8,192 nodes return HTTP 400.

API callers now have a complete, present-state reference for accepted
structured-output JSON Schema keywords and admission bounds, with zero changes
to runtime validation, grammar compilation, or model core compatibility.

Validation:
- Verified programmatic 1:1 set parity between `validate_schema_nodes` in
  `helios/src/grammar.rs` at `3d1614cc` and the enumerated keywords in
  `docs/api.md` (42 code keywords == 42 documented keywords: 29 structural and
  constraint keywords plus 13 metadata and annotation keywords, zero missing,
  zero extra, zero duplicates).
- Verified `MAX_GRAMMAR_BYTES` (262,144), `MAX_SCHEMA_DEPTH` (64),
  `MAX_SCHEMA_NODES` (8,192), and protocol field wiring in
  `helios/src/grammar.rs` and `helios/src/server/protocol/decode.rs`.
- Ran `git diff --check` (zero whitespace issues) and confirmed `git diff --stat`
  modifies only `docs/api.md`.
- Unrun checks: no Rust, Python, simulator, formal, or GPU test suites were run
  because this commit modifies documentation only.

Refs NVIDIA#449

Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 704.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. documentation Improvements or additions to documentation triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 3, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

This is a single 17-line prose addition (docs/api.md:927-942, one file, +17/−0) that documents an existing closed-keyword policy, and I re-derived the headline claim at head 77941c4 rather than trusting the description: the doc's 29 + 13 = 42 keywords match validate_schema_nodes (helios/src/grammar.rs:877-958) exactly, with zero missing, extra, or duplicate. Bounds, strict-> enforcement, and HTTP 400 behavior all check out; no verified code bug or gate violation, so the remaining items are non-binding clarity nits.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 2 · Nits: 5
Walkthrough
  • Adds one paragraph at docs/api.md:927-942 in ## Conversation and tool semantics (heading :488), immediately after the existing output-constraint paragraph at :918-925.
  • Names the four wire locations and they are exactly right: Responses text.format (helios/src/server/protocol/decode.rs:466-506), Messages output_config.format (:561), Chat response_format reading format["json_schema"]["schema"] (:562→:568-570), Completions response_format reading format["schema"] (:562→:572).
  • Lists 29 "structural and constraint" keywords (:930-936) and 13 "metadata and annotation" keywords (:936-939) — verified 1:1 against grammar.rs:902, :913, :924, :935, :940, and the 30-key pass-through arm at :943-948.
  • States the rejections: other keywords (deprecated, nullable, uniqueItems, x-guidance), external $ref targets, and schemas over 262,144 bytes / depth 64 / 8,192 nodes return HTTP 400 — all traceable to grammar.rs:902-911, :949-954, :209, :884, and covered by the existing test unsupported_invalid_and_external_schemas_fail_before_admission (:1616-1644).
  • The second hunk pr_diff renders in docs/api.md (:257-262, typed error.code) is not this PR's change: that text already exists on main (merged helios/server: preserve typed error codes on HTTP request preparation failures #689). Likewise the AGENTS.md, docs/cli-design.md, docs/core-design.md, docs/TODO.txt, flare-cli/src/cli.rs, and flare-cli/src/orbit/* hunks are stale-local-base drift from already-merged PRs — pr_files correctly reports one file, and debian_man_page_documents_every_visible_subcommand is absent from main (I searched flare-cli/src/cli.rs at main: no match), confirming merged flare-cli, debian: sync flare.1 subcommands and fix "an orbit" wording #687 carries it, not docs/api: enumerate accepted response_format JSON Schema keywords #704.
Merge Risk: Low · up to 77941c4
  • Documentation-only: no runtime, wire, config, dependency, core-format, or captured-graph surface is touched, so docs/design-review.md:260-261 and :268-269 explicitly exempt it from simulator, formal, and GPU runs.
  • The only factual risk is future drift — nothing pins docs/api.md to validate_schema_nodes (no include_str! of docs/, no doc-vs-code test; helios/README.md:130 only links the file). A later keyword change would silently diverge.
  • Merge-conflict risk is the usual high-churn one for this file (items_touching shows 15 merged + 14 open PRs in 180 days), but nothing landed after the branch point touches these lines.
Pre-merge checks: ✅ 4 passed
  • ✅ Security / malicious screen: No code path, no injection or instruction-like content in the PR body, comments, or diff; nothing executed or sent.
  • ✅ Charter & value fit: Documents the "documented subset of … JSON Schema for structured outputs" (Charter line 33), is the maintainer-endorsed fix shape ("solve it without new code at all"), and states a reject-with-400 policy rather than weakening the #417 "don't silently ignore" rule.
  • ✅ Related / duplicate / conflict check: JSON-schema allowlist rejects the standard deprecated annotation keyword that neighbours like readOnly pass #449 is the only linked item and this implements its second ("list the accepted keywords") branch; no other PR or issue enumerates this allowlist. No commits after the branch point touch the changed lines.
  • ✅ Tests & verification evidence: Documentation-only, correctly discloses unrun suites; docs/design-review.md:260-261/:268-269 exempt pure documentation from simulator/formal/GPU runs, and no existing test asserts docs/api.md content, so no runnable check was skipped.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

Want a frontier second opinion? If these findings look noisy, request a one-time SuperAgent Review on 77941c4 (~3–4 min; re-adjudicates existing findings without re-running discovery).

To opt out, include #autobot:ignore in your post or comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. documentation Improvements or additions to documentation triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants