Subtraction and simplicity report · NVIDIA/hyperflare-inference #704

Raw Markdown for agents: https://autobot.eidonix.com/p/1214b69e-85b6-4945-9d30-2cf82641ce05.md

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)