Skip to content

fix(unstable-v2): enforce two schema limits in the Rust types - #2921

Merged
benbrandt merged 1 commit into
mainfrom
fix/v2-enforce-schema-limits
Nov 19, 2026
Merged

benbrandt merged 1 commit into
mainfrom
fix/v2-enforce-schema-limits

Conversation

@benbrandt

Copy link
Copy Markdown
Member

Summary

The JSON Schema states several limits that the Rust types did not check, so a Rust receiver accepted values that a schema-validating receiver rejects.

This enforces the two where a wrong value does harm, and leaves the rest tolerant on purpose.

Changes

  • Terminal size. TerminalSize.cols and rows are NonZeroU16. A terminal cannot have zero columns or rows. size is a tolerant patch field, so a zero size is not applied. A tool call location's line already works this way. TerminalSize::new takes the non-zero types.
  • Permission options. A session/request_permission request with an empty options list fails to deserialize, so the Agent gets an error. A Client cannot answer a request that offers nothing to select.

Left unchecked

  • Display data and hints: a notice title, annotation priority, the option lists of elicitation forms and config options, and diff changes.
  • Empty prompt and systemPrompt content: the spec says an Agent MAY reject these, so the type does not decide for it.

Checks

  • Clippy, the tests, rustdoc and cargo fmt pass. Tests that read a permission request with no options now offer one.
  • The regenerated schema changes in two descriptions only ("At least 1").

The JSON Schema states several limits that the Rust types did not check.
Enforce the two where a wrong value does harm:

- `TerminalSize.cols` and `rows` are `NonZeroU16`. A terminal cannot have
  zero columns or rows. `size` is a tolerant patch field, so a zero size
  is not applied, as with a location's `line`.
- A `session/request_permission` request with an empty `options` list
  fails to deserialize. A Client cannot answer a request that offers
  nothing to select.

The other schema-only limits stay unchecked on purpose. They are on
display data and hints, or the spec lets the receiver choose whether to
reject (an empty `prompt`).

The generated schema changes in two descriptions only.
@benbrandt
benbrandt requested a review from a team as a code owner November 19, 2026 22:18
@benbrandt
benbrandt enabled auto-merge (squash) November 19, 2026 22:21
@benbrandt
benbrandt merged commit 7939fec into main Nov 19, 2026
13 checks passed
@benbrandt
benbrandt deleted the fix/v2-enforce-schema-limits branch November 19, 2026 22:23
@acp-release-bot acp-release-bot Bot mentioned this pull request Nov 19, 2026
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