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$refto#,#/$defs/<name>, or#/definitions/<name>, numeric bounds,multipleOf,minLength,maxLength, andpattern)."
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
docs/api.md:941"or compiler extensions likex-guidance" —x-guidanceis a llguidance-internal key that appears in this repo only in tests (helios/src/grammar.rs:1626,:1640) and in the code doc comment as the generic phrase "compiler option extensions are rejected before compilation" (helios/src/grammar.rs:198-199). Naming a compiler-internal key in the public API reference buys nothing the three real keyword examples (deprecated,nullable,uniqueItems) don't already buy; keeping the generic phrase matches the code's own vocabulary and keeps the doc out of llguidance internals.docs/api.md:929-930"validate every schema node against a closed keyword allowlist before grammar compilation" then:939"Any other keyword … return HTTP 400" states closedness twice. The second statement is the useful one (it carries the examples that answer #449 verbatim); the first can drop to "…validate every schema node against a closed allowlist", letting the closing sentence do the work.- While touching the bounds, note the byte bound is measured on the re-serialized schema (
schema.to_string().len(),helios/src/grammar.rs:209), not the request body, and that it is the sameMAX_GRAMMAR_BYTES(helios/src/grammar.rs:23) that bounds Lark grammars (:618) and custom-tool regexes (:549). Naming the measurement costs three words and removes the 400-vs-413 ambiguity againstdocs/api.md:253(max_body_bytes→ 413request_too_large).
Adjacent, outside this diff (not this PR's job, but the enumeration exposes it)
- The list has no pin. Nothing in the tree ties
docs/api.mdtovalidate_schema_nodes— noinclude_str!ofdocs/, no doc-vs-code test. The repo already has the pattern for exactly this:flare-cli/src/cli.rs:2422debian_man_page_documents_every_visible_subcommandassertspackaging/debian/flare.1lists every visible subcommand. A 42-item hand list without such a check will drift, and finding #1 above doubles the drift surface. validate_schema_nodesitself has a duplicated arm.helios/src/grammar.rs:935-939("items" if value.is_array()) reproduces the array iteration of the"anyOf" | "oneOf" | "allOf" | "prefixItems"arm at:924-934, including anunwrap()that the adjacent arm avoids viaok_or_else— one arm with amatch value { Value::Array => …, _ => recurse }collapses both. Not requested by this PR; noted so the "structural" framing in the doc isn't mistaken for a faithful description of the code's shape.