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

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/6a1f5811-4f4d-4dfe-a85e-8ab36cac5dd9

Opened by a workflow run, Dec 3, 2026 6:47 AM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: jcartu (CONTRIBUTOR; 6 merged, 3 closed, 9 open PRs in 180 days; docs + helios/src focus; Discord: jcartu) Motivation: Callers sending a structured-output JSON Schema could not learn which keywords are accepted without reading helios/src/grammar.rs; maintainers on issue #449 said the closed allowlist is intentional, so this PR documents the accepted set instead of widening it. Scale: +17 / −0 lines in 1 file (docs/api.md) Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #704 docs/api: enumerate accepted response_format JSON Schema keywords

Charter alignment: strong. The charter targets "the documented subset of … JSON Schema for structured outputs," and "What gets merged" includes bad docs and maintainer requests. This adds no runtime branch, no per-model special case, no flag, no dependency — it is the "solve it without new code at all" shape, and it documents a reject-with-400 policy, i.e. the charter-compliant side of "don't silently ignore API fields." pr_files confirms one file (docs/api.md, +17/−0), so "keep the runtime small" is untouched.

Novelty & status: genuinely additive — not superseded, not obsolete. No other PR/issue requests this enumeration, and nothing landed after the branch point touches docs/api.md. It implements the second branch of open issue #449 ("if the keyword set is meant to stay narrow, docs/api.md should list the accepted keywords"), matching yatesdr's "closed on purpose" position. The headline claim survives independent re-derivation: 42 code keywords (helios/src/grammar.rs:902-948) == 42 documented (29+13), and bounds 262_144/64/8_192 match grammar.rs:23-25. Caveat: #449 stays open — this is Refs, not Fixes; deprecated is still rejected.

Value vs cost: good value, near-zero upkeep — with two gaps.

Verdict: Worth it with changes. Require: (1) one sentence relating the output-constraint allowlist to the strict-tool subset and aligning $ref wording; (2) correct the commit reference; (3) optionally cross-reference invalid_grammar and add a cheap drift guard. Also rebase — the ~10-file rendered diff is stale-base drift, not scope.

No instruction-like content was found in the PR material reviewed.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, documentation, area:api

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +documentation, +area:api

Subtraction and simplicity

Subtraction & Simplicity audit — PR #704 (docs/api.md, +17/−0)

Verdict

The diff is lean: 17 lines of prose, no code, no knobs, no wrappers, nothing dead. There is nothing to delete wholesale — enumerating the allowlist is exactly the subtraction-favouring fix that issue #449's second branch asks for ("if the keyword set is meant to stay narrow, docs/api.md should list the accepted keywords"). Four concrete simplifications are worth making, one of which is high-signal and should gate merge.

Scope note: pr_files reports one file, +17/−0, which matches only the docs/api.md:927-942 paragraph. The second hunk the diff renders (docs/api.md:255-260, the error.code values on typed 400s) is base drift from already-merged #689, not this author's change — main at :256-258 still reads "…return 500. 5xx errors use server_error, or api_error on Messages. / Responses for requests…". Nothing to subtract there; it isn't part of the reviewable delta.

1. HIGH — the paragraph re-lists 26 of its 42 keywords that this same file already documents 200 lines above, under a different label, with the relation never stated

docs/api.md:722-725 (strict function tools, from the same author's merged #418) already enumerates:

"…and use supported bounded JSON-schema keywords (properties, required, additionalProperties, items, prefixItems, minItems, maxItems, enum, const, anyOf, local $ref to #, #/$defs/<name>, or #/definitions/<name>, numeric bounds, multipleOf, minLength, maxLength, and pattern)."

The new list at docs/api.md:930-939 repeats $ref, $defs, definitions, type, const, enum, anyOf, properties, additionalProperties, required, items, prefixItems, minItems, maxItems, minLength, maxLength, pattern, minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, $schema, title, description, default — 26 of the 42. Only 16 keywords (oneOf, allOf, patternProperties, minProperties, maxProperties, additionalItems, format, $anchor, $id, id, $comment, readOnly, writeOnly, examples, contentMediaType, contentEncoding) are actually new information.

I verified the containment against the code rather than by eye: SUPPORTED_KEYS (helios/src/grammar/strict.rs:147-174, applied at :214) is a strict 26-element subset of the 42 keys validate_schema_nodes accepts (helios/src/grammar.rs:901-948; 12 distinct keys across the recursion arms at :902, :913, :924, :935, :940 plus 30 pass-through keywords at :943-948 = 42). The counts in the PR body hold exactly: 29 + 13 = 42, zero missing, zero extra.

Why this is a subtraction problem, not just a style one: the document now has two independent hand-maintained keyword lists for one compiler, with no statement of how they relate, so a reader cannot tell that strict tool schemas reject readOnly, format, and oneOf while output constraints accept them, and any future keyword addition must be edited in two places or the file contradicts itself. Cheapest fix is one clause, and it replaces words rather than adding them — e.g. at docs/api.md:929-930 say the schemas "accept the strict function-tool keywords above plus oneOf, allOf, patternProperties, minProperties, maxProperties, additionalItems, format, and the metadata/annotation keywords …", which deletes the 26-way restatement and makes the subset relation explicit. ($ref also gets two different spellings for one code rule: docs/api.md:931 "same-document # references only" vs docs/api.md:723-724 "local $ref to #, #/$defs/<name>, or #/definitions/<name>" — the code checks only reference.starts_with('#'), helios/src/grammar.rs:903-911, so one phrasing is enough.)

2. MEDIUM — the 29/13 split is an editorial invention the code does not support; it costs the reader a two-list union to answer one question

docs/api.md:930-936 "Accepted structural and constraint keywords are …" and docs/api.md:936-939 "Accepted metadata and annotation keywords are …". Checked against helios/src/grammar.rs:943-948, the implementation's only distinction is recursed vs not recursed — and even that is not the doc's split. The 30 flat pass-through keywords are one block listing metadata and constraints interleaved:

"$anchor" | "$schema" | "$id" | "id" | "$comment" | "title" | "description" | "default" | "readOnly" | "writeOnly" | "examples" | "contentMediaType" | "contentEncoding" | "const" | "enum" | "type" | "minItems" | "maxItems" | "required" | "minProperties" | "maxProperties" | "minLength" | "maxLength" | "pattern" | "format" | "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf" => {}

So const/type/required/minItems are called "structural and constraint" while $schema/$id/$anchor — the keywords that change reference resolution, i.e. the most structural of all — are filed as "metadata". A caller asking "may I send X?" must scan both lists; the split answers no question the code asks. Either collapse to one list, or relabel by the real axis (recursed into vs accepted as a leaf), which is checkable against :902-948.

3. MEDIUM — the enumeration reads as a sufficient condition when the code treats it as necessary only, and every counter-example is already pinned by a test

docs/api.md:930 "Accepted structural and constraint keywords are …" plus docs/api.md:939-942 "Any other keyword (…), external $ref targets, and schemas exceeding 262,144 bytes, depth 64, or 8,192 nodes return HTTP 400" — a caller will read that as "allowlist-clean ⇒ compiles". It does not: helios/src/grammar.rs:1624-1631 rejects, after the allowlist walk, {"type":"string","format":"not-a-format"}, {"oneOf":[{"type":"integer"},{"type":"number"}]}, {"$ref":"#/$defs/missing"}, {"type":"integer","minimum":5,"maximum":1}, and json!(false) — all of which the new paragraph presents as accepted (format, oneOf, $ref, minimum/maximum). One clause ("meeting the allowlist is necessary, not sufficient: unknown format values, unresolved references, and contradictory bounds are rejected during compilation") prevents the predictable support load. Under the simplicity lens this is the unrepresentable-invalid-state point: the doc currently describes a single closed set where the code has two separate admission gates (helios/src/grammar.rs:209/:215 then enforcement inside compile_envelope).

4. LOW — two smaller trims inside the paragraph

Adjacent, outside this diff (not this PR's job, but the enumeration exposes it)

Full report

Gates and contracts

Contracts, Charter & Verification Gates Audit — PR #704 (docs/api: enumerate accepted response_format JSON Schema keywords)

Verdict: No contract or verification gate blockers. All four hard gates pass. The PR is a 17-line, single-file prose change whose central factual claim I re-derived independently against the code and confirmed.


Gate 1 — Signed core-format / wire / captured-graph / public contract boundaries: PASS

Gate 2 — Vendored upstream dependencies & cross-PR conflicts: PASS

Gate 3 — Mandatory verification evidence & failing tests: PASS

Gate 4 — Material scope / claim contradictions: PASS


Info / Nit (explicitly not blockers)

  1. docs/api.md:717-734 (strict function tools) and docs/api.md:927-942 (output constraints) are two differently-scoped "closed" keyword lists ~200 lines apart, and the new paragraph does not relate them. Both are accurate for their own paths — strict tool schemas validate through compile_strict_validators (helios/src/grammar/strict.rs:63), while the final-answer schema walks validate_schema_nodes (strict.rs:1516-1522), so the new text's "output constraints" scoping at :930 is correct and no conflict exists. Relating them would be a clarity improvement only.
  2. Bookkeeping: the body cites commit 3d1614cc while head is 77941c4; I re-ran the parity reasoning at head and it holds. The parity check is not committed as a drift guard; no gate requires one.
  3. The 262,144-byte bound is measured on the re-serialized schema (schema.to_string().len(), grammar.rs:209), not the request body, and is unstated as such. Not a contradiction with any normative doc, and unrelated to max_body_bytes/413.
  4. The enumeration is an admission floor, not a non-rejection guarantee — {"type":"string","format":"not-a-format"}, dangling #/$defs/missing refs, and boolean false roots still 400 after passing the allowlist. The text is scoped to "a closed keyword allowlist before grammar compilation" (:929-930), so this is not a contradiction.

No instruction-like or prompt-injection content was present in the PR material reviewed.

Full report

Code correctness

Deep Code Correctness, Invariants & Hot-Path Performance Audit — PR #704

Scope: docs/api.md (+17/−0), head 77941c4. This is a documentation-only change: the hunk adds one prose paragraph (docs/api.md:927-942) and extends the error-envelope paragraph (docs/api.md:257-261). There is no new or modified logic, no loop, no state machine, no numeric estimator, and no hot path. Per the partition rule (1 file, 17 lines) I audited directly without sub-agents.

Verdict: I found no Blocker, Major, or Minor code bug, invariant violation, or hot-path defect. Every factual claim in the diff traces 1:1 to code at the head commit, and I could not construct a counterexample in which the documented behavior differs from the implemented behavior.

Four-part protocol — where each check landed

1. Callee / enum-variant / design-invariant resolution (all claims opened, none assumed)

Doc claim Code verified Result
42-keyword allowlist (29 structural + 13 metadata) helios/src/grammar.rs:902 ($ref), :913 ($defs/definitions/properties/patternProperties), :924 (anyOf/oneOf/allOf/prefixItems), :935 (items array form), :940 (items/additionalItems/additionalProperties), :943-948 (30 leaf keywords) = 1+4+4+3+30 Exact: 42 unique, 1:1 with the two documented lists, zero missing, zero extra, zero duplicates. The PR's parity claim is correct.
$ref "same-document # references only" grammar.rs:902-912 Exact: reference.starts_with('#') else "must reference the same document".
262,144 bytes / depth 64 / 8,192 nodes grammar.rs:23-25 (MAX_GRAMMAR_BYTES=262_144, MAX_SCHEMA_NODES=8_192, MAX_SCHEMA_DEPTH=64); enforced at :209 and :884 Exact, including treating booleans as valid nodes (grammar.rs:890 precedes the as_object() cast, so true/false roots are not falsely rejected).
Four protocol surfaces helios/src/server/protocol/decode.rs:466-506 (Responses text.format), :560-579 (Messages output_config.format, Chat/Completions response_format) Exact; runtime/phase_tests.rs:8874-8903 proves HTTP 400 invalid_grammar on all four paths.
"HTTP 400 … keeping error.type as invalid_request_error", error.code ∈ the four names server.rs:733-741 (Error::Admission(_) → BAD_REQUEST except Capacity/Unavailable → 503), server.rs:743-755 (Grammar→invalid_grammar, Context→context_length_exceeded, Feature→unsupported_feature, Image→invalid_image), protocol/mod.rs:33-59 Exact. error.type is invalid_request_error on 400 (mod.rs:42); error.code is overwritten only for non-Messages (mod.rs:53-59), so the doc's deliberate exclusion of Messages from that sentence is correct rather than an omission.
deprecated, nullable, uniqueItems, x-guidance rejected grammar.rs:949-954 fallback arm; test grammar.rs:1619-1643 Exact.

2. Order-of-operations / state-transition tracing. The claim that these rejections "return HTTP 400" interacts with streaming, and that is where an ordering bug would live. Grammar admission runs inside spawn_blocking before any SSE headers are written (server/http.rs:209-285, with the early return at :288-292), so a streaming request with a bad schema also gets HTTP 400 — consistent with the doc's own separation at docs/api.md:264-267 ("admission failures after enqueue are terminal SSE errors"). Mid-generation parser poisoning (grammar.rs:868-874, fail() zeroing the mask) is the separate 500 output-validation path the doc already describes at line 256. No stale-flag read-before-write exists, because nothing in the diff reads or writes state.

3. Adversarial boundaries. Taking the guards literally (depth > MAX_SCHEMA_DEPTH || *nodes > MAX_SCHEMA_NODES, > MAX_GRAMMAR_BYTES): depth exactly 64 and 8,192 nodes pass, 65 and 8,193 fail; a schema of exactly 262,144 bytes passes, one byte more fails. The doc's phrasing "exceeding 262,144 bytes, depth 64, or 8,192 nodes" is therefore exact, not off by one. A pathological deep-but-narrow schema cannot reach the depth gate via stack overflow first either, because serde_json refuses to parse beyond its 128-level nesting limit, so schema.to_string() at grammar.rs:209 cannot blow the stack ahead of the recursive walk at :877.

4. Hot-path big-O. Untouched. The walk is one O(nodes) pass per request with nodes capped at 8,192, run on the blocking preparation pool, plus one linear re-serialization at :209. No per-iteration allocation was added and no scheduling, cache, or per-step path is involved.

Two precision caveats (judgment calls for the author, not defects)

  1. "Accepted" is slightly stronger than the code guarantees. Allowlisting a keyword does not mean a schema using it compiles. grammar.rs:1623-1630 shows {"type":"string","minLength":-1}, {"type":"string","format":"not-a-format"}, {"type":"integer","minimum":5,"maximum":1}, and the ambiguous {"oneOf":[{"type":"integer"},{"type":"number"}]} all still return 400 — and so does {"$ref":"#/$defs/missing"} despite satisfying the documented # rule. A caller reading "accepted … keywords are format, minLength, minimum, maximum, oneOf" could reasonably expect such schemas to be admitted. The adjacent sentence already says "Any other keyword … return HTTP 400", which is precise; the risk is only that the reader generalizes it to "these keywords are always fine".
  2. The 262,144-byte bound measures a re-serialization, not the wire bytes. grammar.rs:209 checks schema.to_string().len() — the compact re-encoding of the decoded value — so a schema sent with generous whitespace can exceed 262,144 bytes on the wire and still pass, while one padded inside string literals differs. Also note the byte check precedes validate_schema_nodes, so a >256 KiB schema fails with "exceeds … bytes" before depth/node limits are consulted.

One process observation, reported as a finding about the material rather than a code bug

pr_files reports a single changed file, but the full pr_diff also contains hunks in AGENTS.md (not opened), docs/TODO.txt, docs/cli-design.md (not opened), docs/core-design.md (not opened), docs/model-preparation.md (not opened), docs/scheduling-runtime-design.md (not opened), flare-cli/src/cli.rs (not opened), and flare-cli/src/orbit/agent.rs (not opened) — including a genuinely testable new test, debian_man_page_documents_every_visible_subcommand (flare-cli/src/cli.rs:2421-2454 (not opened)), which parses .SH COMMANDS from packaging/debian/flare.1. That fixture does exist and does contain .SH COMMANDS at line 12, and the sibling change in flare-cli/src/orbit/agent.rs (not opened) (systemd Description "a orbit's" → "an orbit's", plus a matching new assertion) is internally consistent. I did not audit these outside the declared scope, and I could not inspect the commit stack to see whether they belong to this PR: search_history fails with Could not read c513e46a79f3b6ac510235aaf09bcf055b841958 … Failed to traverse parents of commit ef38cb9395f6b2cb2a6598cb7b603177a93d0029f4, indicating a shallow clone. The doc content itself is accurate, so this affects review bookkeeping rather than correctness; flagging it so the diff you believe you are merging is the diff that gets merged.

Recommended action: merge as-is. Optionally soften "Accepted … keywords are" to make clear that a listed keyword can still be rejected by value (e.g. a negative minLength, an unknown format, contradictory bounds, a dangling #/$defs/... $ref), and say the 262,144-byte limit applies to the decoded schema as re-serialized.

Full report · Notes

Final review

Recommendation: Ready To Merge

This is a single 17-line prose addition (docs/api.md:927-942, pr_files = 1 file, +17/−0) that documents an existing closed-keyword policy. I re-derived the headline claim at head 77941c4 rather than trusting the description: validate_schema_nodes (helios/src/grammar.rs:877-958) accepts exactly 42 keywords (1 $ref + 4 object-map + 4 array + 3 schema-valued + 30 pass-through = 42), and the doc lists 29 + 13 = 42 with zero missing, zero extra, zero duplicates, so the parity claim holds even though the body cites commit 3d1614cc instead of head. Bounds (262_144/64/8_192, grammar.rs:23-25) and the strict-> enforcement (:209, :884) match the doc's "exceeding …" phrasing with no off-by-one, and HTTP 400 holds on all four routes (server.rs:733-741, :749; phase_tests.rs:8874-8926). I found no verified code bug, no contract/gate violation, and no evidence-backed reason to block; the remaining items are non-binding clarity nits.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

  1. docs/api.md:930-939 restates 26 of its 42 keywords that the same file already lists at :722-725. I verified containment against code rather than by eye: strict tools validate through SUPPORTED_KEYS (helios/src/grammar/strict.rs:147-174, applied at :214) = 26 keys, a strict subset of the 42 in validate_schema_nodes. Saying "the strict function-tool keywords above plus oneOf, allOf, patternProperties, minProperties, maxProperties, additionalItems, format, and the metadata/annotation keywords" would replace 26 restated keywords with an explicit subset relation and remove the need to edit two hand-maintained lists on any future keyword change. Non-blocking: both lists are individually accurate because the two paths genuinely differ.
  2. docs/api.md:936-939: the "metadata and annotation" label files $anchor, $id, id, $schema as metadata, though those change reference resolution. The code's only real axis is recursed-into vs. accepted-as-a-leaf (grammar.rs:902-948). Collapsing to one list, or relabeling by that axis, spares the reader a two-list union to answer "may I send X?".

Nits

Dropped on verification

Full report · Notes Decision to Test: no (95%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes