Skip to content

Add opt-in JSON Patch support - #18

Open
KastanDay wants to merge 6 commits into
cloudflare:mainfrom
KastanDay:kastan/schema-reasoning-patch
Open

Add opt-in JSON Patch support#18
KastanDay wants to merge 6 commits into
cloudflare:mainfrom
KastanDay:kastan/schema-reasoning-patch

Conversation

@KastanDay

@KastanDay KastanDay commented Aug 28, 2026

Copy link
Copy Markdown

Adds opt-in $patch support using JSON Patch (RFC 6902), so a shared schema can be narrowed or extended—for example, removing medium from a model's reasoning-effort enum.

Supports all six operations, JSON Pointer escaping, array edits, nested patches, and composition with $merge. Source references resolve before patching; operation values remain literal JSON until the resulting schema is prepared. Each $patch must produce an object schema.

Constructor and configuration updates prepare changes before committing them, preserve the root schema object's identity, and check required root writes before mutation. Unchanged schemas retain their existing branches. Literal defaults, enum members, annotations, and property names remain data. Composition validation counts successful branches and reports nested failures consistently.

Documents the API with a tested example and sets the package version to 0.3.0. Tests cover JSON Patch operations directly with inline Vitest cases, alongside schema integration and lifecycle coverage.

Validation

  • Local suite: 258 tests passed on Node 22.10.0, 24, and 26
  • npm run test-all: Cabidela suite passed; AJV comparison mode passed with 239 tests and 19 existing skips
  • Type checks, CJS/ESM/declaration builds, and package dry run passed
  • Local Workers runtime smoke test: 10 checks passed without nodejs_compat

@KastanDay
KastanDay requested a review from celso as a code owner August 28, 2026 23:47
@KastanDay
KastanDay force-pushed the kastan/schema-reasoning-patch branch from 2015a87 to 81d74a0 Compare September 9, 2026 00:40
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