Skip to content

feat(docs): render docs payload blocks from schema examples - #9194

Open
KonstantinMirin wants to merge 9 commits into
adcontextprotocol:mainfrom
KonstantinMirin:docs/examples-from-schemas
Open

KonstantinMirin wants to merge 9 commits into
adcontextprotocol:mainfrom
KonstantinMirin:docs/examples-from-schemas

Conversation

@KonstantinMirin

@KonstantinMirin KonstantinMirin commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #9120.

Revised 2026-11-23: Merged main at 52b11c1. The bundle and MCP projection sizes are re-measured against it, the training agent's discovery tools/list drops examples, the gates were rerun, and the Python SDK note is gone because that job passes on main again.

Docs payload examples now render from the schema examples, so a docs block can't drift from its schema.

Inventory

A script classified the 1,860 JSON blocks in docs/** at #9120's head:

Class Blocks
Identical to a schema example 32
Valid instance, not a schema example 744
Invalid against its schema (drift) 146
Not schema-backed 938

Of the 744 valid instances, 372 name their $schema; 81 more match their page's task schema, and 291 only match a schema by field overlap. All 146 drifted blocks lack $schema, so test:json-schema never saw them.

Mechanism

{/* schema-example: #/examples/2 */}
```json Request
{
  "$schema": "https://adcontextprotocol.org/schemas/v3/media-buy/get-products-request.json",
  ...
}
```

scripts/docs-schema-examples.cjs writes the body as $schema plus the root example the marker names. I kept the JSON inline rather than in imported snippets as the conservative option: an MDX comment renders nothing and needs no Mintlify feature, and tools that read the MDX source (test:json-schema, the field audit, the docs index) still see the JSON.

Applied

560 blocks render from schema examples:

  • 381 blocks with $schema, all valid: each moved into, or matched, the schema's examples.
  • 24 blocks equal to a schema example: they gained $schema.
  • 155 blocks on task reference pages that are instances of the page's request or response schema: they gained $schema and moved into its examples. 71 of them lacked one required field with an evident value: status: "completed" on 55 synchronous responses, and an idempotency_key on 16 mutating requests.

519 instances are new in the examples of 168 schemas, where test:schemas validates them. Shared definitions carry their examples into every bundle that inlines them: the bundled tree grows 1.6%, from 87.1 to 88.4 MB, mostly from core/error.json, core/provenance.json, and the format declaration, display tag, proposal, and targeting definitions. Those blocks show the component, so binding them to a task schema would change them. The MCP projection grows from 24.0 to 24.6 MB, and its sanity cap moves to 24 MiB. Its validation profiles keep examples, while its model-context views drop them. The training agent's product discovery tools/list now drops them at every depth too, so the four-tool surface stays at main's 161,453 bytes.

Remaining drift

159 blocks still fail a schema that doesn't determine the fix:

  • 46 task-page blocks: 20 requests lack account, 6 get_adcp_capabilities excerpts lack adcp, 7 verify_brand_claim responses match no branch, and 13 others lack required fields.
  • 4 illustrative blocks with $schema and ... in build_creative and preview_creative.
  • 109 blocks whose schema is only inferred. They and 288 valid inferred blocks need their schema confirmed before binding.

The full list, with errors: Docs blocks that fail their schema.

The check

npm run build:docs-examples writes the bound blocks. npm run test:docs-examples, in npm test, fails on a stale bound block, a broken marker or pointer, an AdCP $schema without a marker, and an unbound copy of a schema example.

Its tests drive the CLI against fixtures, one rule per case. The field audit now sees the blocks that gained $schema. Stale fields in si_terminate_session, validate_content_delivery, and the intro's brand.json now use the fields their schemas declare. Its baseline goes from 15 keys to 9, each with a reason: the comply_test_controller account reference beside sandbox, the open generation_context signals, and two governance capability fields the page documents but the schema doesn't declare.

Gates

On the merge with main, every npm test stage passes, as do CI's build-worker steps and the field audit with --check, apart from two timeouts on a loaded test box that main shows identically: one spawned script in test:release-workflow, and the docs-indexer heading search in test:server-unit, which passes locally. The 125 changed pages parse as MDX, with the same JSON fences as on #9120 except three illustrative ones that si_terminate_session replaces with a table. test:snippets fails the same 22 Python snippets on #9120's head.

…ata} wrappers

Draft-07 `examples` holds instances of the schema. 81 schemas wrapped
each example in a `{description, data}` object, which is not an
instance, so 75 of them failed validation against their own schema and
6 passed only because the schema is open enough to accept the wrapper.

Replace each of the 224 wrappers with its `data` payload. The payloads
are unchanged. The labels are dropped: draft-07 has no place for a
per-example label, and the 51 schemas that already wrote bare instances
carry none.

Update the four tests that read `example.data`.

Refs adcontextprotocol#8343
The schema validation suite validated `example.data || example`, so a
`{description, data}` wrapper passed whenever its payload did, and the
pagination lint unwrapped `data` the same way. Now that every example
is an instance, check them as written.

Test 13 now validates every `examples` value, at the root and at every
nested schema position, against the published composition, and fails
on a `{description, data}` wrapper in a schema that declares neither
property. It reports every failing example instead of stopping at the
first, and no longer skips sync-creatives-request and
list-creatives-response, whose examples validate.

The pagination lint reads each example as written.

Refs adcontextprotocol#8343
Resolution ledger:
- Conflicts: none. Two files changed on both sides and auto-merged in
  separate hunks:
  - core/reporting-subscription.json: this branch unwraps the root
    example; main adds selector.dimension_systems and two allOf rules.
    The unwrapped example names no dimension_systems, so it stays an
    instance of the merged schema.
  - tests/reporting-subscriptions.test.cjs: this branch validates the
    examples as written; main adds the metro and postal dimension
    systems test, which builds its payloads from allAccounts, not from
    examples.
- Mechanical: package-lock.json is main's (this branch does not
  change it); node_modules reinstalled with npm ci.
- Invariants: main adds no schema examples and no readers of
  example.data. At the merged tree, 132 schemas carry 377 root
  examples, none wrapped, and test 13 validates every example as
  written.
- Proof: schema equivalence against 576ebca: 1113 roots, 0 differ,
  class 1, no informational entries; --corpus-all: 611 schema
  examples valid at both refs, no verdict changes. The built bundles
  differ from main's only in examples.
Add scripts/docs-schema-examples.cjs. A docs JSON block that names its
`$schema` carries a `{/* schema-example: #/examples/<index> */}` marker
above the fence; the script writes the block body as that `$schema`
followed by the schema's root example at the index, and `--check`
reports, without writing:

- a marker that is not directly above a json fence;
- a bound block whose `$schema` names no schema file;
- a pointer that names no root example;
- a bound block that differs from the rendered example;
- a block with an AdCP `$schema` and no marker;
- an unbound block equal to a root example of some schema.

A block that contains "..." is illustrative and is skipped, as in
test:json-schema. The MDX comment renders nothing, so the page looks
the same and every tool that reads the fence keeps working.

tests/docs-schema-examples.test.cjs drives the CLI against a fixture
docs tree and schema tree, one rule per vector.

Refs adcontextprotocol#9120
Bind every docs JSON block that is a schema instance to the schema's
root `examples`, and gate it in npm test:

- 381 blocks with a `$schema` field: each validates, so its instance
  moves into that schema's `examples`, or binds to an equal example.
- 24 blocks without `$schema` that equal a schema example: they gain
  the `$schema` and bind to it.
- 155 blocks without `$schema` on a task reference page that are
  instances of that task's request or response schema: they gain the
  `$schema` and move into its `examples`. 71 of them lacked a required
  field with an evident value, which the schema example now carries:
  `status: "completed"` on 55 synchronous responses and an
  `idempotency_key` on 16 mutating requests.

519 instances are new to the `examples` of 168 schemas, appended after
the examples they had. A `$schema` value that a block named stays as
written; one added here uses the v3 alias when the latest 3.x release
has the schema, and latest otherwise.

The docs JSON field audit now sees the blocks that gained a `$schema`.
Where a block showed a field its schema doesn't declare because the
docs were stale, the example now uses the declared field:

- si_terminate_session: `termination_context.intent` becomes
  `transaction_intent`; the user-exit and timeout details become
  `summary`; `follow_up.suggested_action` becomes `action`, with
  `remind_later` as `set_reminder`, and the undeclared `message` goes.
  The page's field tables follow the schema.
- validate_content_delivery: a feature result drops `value`, which the
  schema's oracle pattern excludes, and `message` becomes `explanation`.
- intro: the brand's `identity_agent` becomes an `agents` entry with
  `type: "brand"`.

The baseline keeps 9 keys, each with a reason: the comply_test_controller
account reference beside `sandbox`, the open `generation_context`
signals, and two governance capability fields that the page documents
and the schema doesn't declare. It drops 6 keys that no longer match any
finding. It had 15 keys allowing 18 findings; it has 9 allowing 20.

Examples in shared definitions travel into every MCP tool that bundles
them, so the MCP projection's `examples` grow from 448,527 to 1,057,793
bytes and the projection to 24,514,057 bytes. Its sanity cap moves from
23 to 24 MiB; model-context views strip `examples`.

Refs adcontextprotocol#9120
@mintlify

mintlify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 9ce2a44.

Approve preview

@aao-secretariat

Copy link
Copy Markdown
Contributor

Ladon cannot review this PR until merge conflicts are resolved.

Resolution ledger:
- semantic: package.json -> union. The `test` script keeps this branch's
  `test:docs-examples` (after `test:json-schema`) and main's
  `test:build-schemas-exit-status`. Every other script, including main's
  `oneof-overlap-resolution` test in `test:schemas` and the 3.3.0-rc.3
  version, comes from main.
- auto-merged, reviewed: 3 docs pages and 15 schema sources that both
  sides changed. The renderer check still renders all 560 bound blocks.
- package-lock.json: main's, unchanged by this branch.


Main now projects 24,021,083 bytes; with the schema examples the
projection measures 24,552,662 bytes, still under the 24 MiB cap.
The tools/list bundler already dropped `example` and `examples` from
every referenced definition, but kept them on the root request schema.
The request schemas now carry root examples, which put 6,004 bytes of
example payloads into the four-tool discovery surface and over its
162 KiB budget. The root document now drops them by the same rule.
Example payloads document a schema; they are not contract, and
validation still reads the source schemas.

The four-tool surface measures 161,453 bytes, the same as on main. A
new test asserts that no product discovery tool's tools/list schema
carries `example` or `examples` at any depth.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant