Repository navigation
build(schemas): prove what a schema change does to valid payloads - #9119
Open
KonstantinMirin wants to merge 31 commits into
Open
KonstantinMirin wants to merge 31 commits into
KonstantinMirin wants to merge 31 commits into
Conversation
Add scripts/schema-equivalence, a CLI that proves what a schema change does to the set of valid payloads. It compares every published root at two refs in a canonical form (one graph node per schema location, equality by bisimulation, so recursive schemas compare soundly), applies guarded rewrite rules for meaning-preserving rewrites, matches the differences against a per-PR delta manifest in .schema-deltas/, runs a corpus differential over schema examples, docs blocks, storyboard samples, and compliance vectors, and searches one witness payload per declared difference. verify-build compares static/schemas/source with dist/schemas/latest and its bundled schemas, so the comparison reflects what the build publishes. A pull_request workflow runs the check on schema-touching PRs, and the fixture tests run through the CLI as part of test:schemas.
Ajv reads type when it applies nullable, so the canonical form no longer drops a type that const or enum makes redundant on a node with nullable.
…rotocol#8536 - Read the propertyNames subgraph in a string-instance context that passes through allOf, anyOf, oneOf, not, if, then, else, and $ref, with context copies of shared targets. A string type reached through anyOf/$ref under propertyNames no longer reports a false site. - Give each manifest line its own witness: a payload whose verdict changes because of that line, checked on a hybrid head with only that line reverted at its site. Add the "none" direction for a line that another line at the same node masks. Keep the unattributed per-site search for undeclared directions. - Keep annotations written beside $ref or allOf on the referencing location in the informational channel, so a default that stays beside a new $ref is no longer reported as removed. - Bind unbound probe values by (parent property, property), leave out values inside bound samples, and label probe hits as a heuristic. Each fix has a CLI fixture that fails on the previous commit and passes now.
…ifests from the head ref - The witness regex sampler treats lookaheads and lookbehinds as zero-width and adds a variant that takes one optional part at a time, so a duration pattern yields "PT" and "P0D". The real RegExp still filters every sample, and Ajv confirms every witness. - --manifest auto reads the .schema-deltas files from the head ref's git objects, so the head does not have to be checked out. --repo selects the repository, which the test uses for a scratch repository. - One reverted head and one lazily compiling Ajv serve all of a manifest line's roots, and the undeclared direction is searched on the first root only. The witness stage on adcontextprotocol#8536 drops from 68 s to 13 s. - Restore the README sections that a string replacement duplicated.
The witness search found no payload for added if/then rules, not guards on either/or unions, or documents that gained a schema. It now also builds candidates from the constraint itself and merges them into the valid instance at the location: - an added not: an instance of the negated schema, and for a guard on an either/or pair, the guarded key with a value of each JSON type; - an added if/then: an instance that satisfies if and violates then, with wrong-typed values and values another branch of the property's own schema accepts; - a schema gaining constraints where it had none: a value of each JSON type. Every candidate is still confirmed with Ajv and attributed to its line by reverting it. Reverts now follow a conjunction member written behind the location's $ref or allOf, revert a whole-schema change, and drop an allOf that the revert empties (an empty allOf does not compile, which hid the search). A reverted head that does not compile is reported. In directory mode, --corpus reads the repository's non-schema corpus at HEAD.
Conjunction members (allOf members, or a $ref target and its siblings) merge into one schema object where the merge keeps the meaning, so moving a root's keywords into a definition referenced next to the oneOf compares equal. Keywords on different names merge, required is the union, the same property becomes the conjunction of both schemas, the same bound takes the tighter value, and type is the intersection. Members stay separate when additionalProperties or patternProperties would see the other member's properties (or additionalItems the other's items), when either has discriminator or nullable, and when they share another keyword with different values. A merged node reports each keyword at the source object that writes it, which witness reverts also use. not-branch-subtraction also applies to a merged object that holds both the not and the union.
The canonical pattern spelling read a literal "-" next to another "-" as
two literals, so [--/] (U+002D..U+002F) and [\-/] got the same spelling,
as did [!--] and [!\-]. It also read the escape pair 😀 as two
lone surrogates, so [😀] matched [\u{D83D}\u{DE00}]. Both made
the check report "equivalent" for patterns that Ajv evaluates
differently. A literal "-" is now a range endpoint where the u-mode
grammar allows it, and a lead and trail \u escape form one code point.
The construct catalog (tp-bzw.11) found both. Each has a fixture that
fails on 09f80b4.
In the string-instance context of propertyNames, a oneOf whose object branches admit no string became false, also under discriminator. Ajv checks a discriminator only on objects and then skips the oneOf, so such a node passes every property name. The check reported propertyNames with a discriminator as equal to propertyNames: false. The context copy now drops the discriminator and its oneOf, and an alias to true counts as true, so the result equals no propertyNames. The construct catalog (tp-bzw.11) found this. The fixtures fail on 09f80b4.
The CLI ended with process.exit(), which drops the part of a large "--json -" report that a pipe has not yet read. A report over 64 KB on a failing check reached the reader cut at 65,536 bytes and did not parse. The CLI now sets process.exitCode and lets Node drain stdout. Found while running the check on the refutational-normalization datasets. The c3-large-report fixture fails on 09f80b4.
The catalog holds 832 schema pairs that enumerate the constructs the AdCP bundle uses: each normalization and rewrite rule (including the allOf-member merge) in every context the bundle uses, with near misses; branch separation by const, discriminator, type, required plus not required, and none; $ref with siblings, to another file, recursive, extracted, and inlined; the combinator nestings by bundle frequency; a minimal tighten and loosen for every assertion keyword; and the constructs the tool compares exactly. The tool plays no part in the verdicts. The refutational-normalization prototype (commit 8064ad83, run offline as an external process) decided inclusion in both directions for 795 pairs, and 37 pairs that use format, uniqueItems, ".", lookahead, or astral characters carry hand verdicts. The repo's Ajv configuration confirmed every witness. The prototype's GPLv3 code and datasets stay out of the repository. tests/schema-equivalence-catalog.test.cjs runs the CLI in directory mode on each pair. A pair that is not equivalent must get a difference, and an equivalent pair must get none unless false-alarms.json lists it with its cause (53 pairs). CI runs it with the fixture tests.
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
This was referenced Nov 20, 2026
Open
…cts, and context
The disjointness prover behind the guarded oneOf-to-anyOf and
not-branch-subtraction rewrites read only top-level type, const, and
enum, so it left 48 of the 223 reachable oneOf on main undecided. It
now lives in lib/disjoint.cjs with these rules:
- a not over a schema that accepts every value of a type removes that
type, so not {required: [k]} leaves only objects;
- a required property whose two schemas are disjoint;
- a closed object (additionalProperties: false, read one schema object
at a time with its own properties and patternProperties) that forbids
a key the other branch requires;
- one branch implies a schema the other negates: required keys, a
pinned value on a required key, or the same referenced schema;
- each alternative of an anyOf implies the other branch's not operand;
- a finite value set that an Ajv-faithful evaluator rejects in full;
- non-empty arrays with disjoint item schemas.
lib/context.cjs computes what every instance reaching a node satisfies,
from conjunction members, union and not/if/then/else parents, and
sibling properties/<name> schemas of the parent instance, joined over
every path from the roots, so a rewrite made under it holds at every
use.
The differ now compares a oneOf that a rule rewrote on one side only
with the other side's oneOf branches, and reports and renders rewritten
unions under the source keyword, so a not guard that makes branches
disjoint is still reported where it was written.
The construct catalog gains 96 oracle-decided pairs, an equivalent pair
and a near miss for each rule in six contexts. The 12 false alarms for
branches separated by required and not required are gone.
…le oneOf `cli.cjs oneof --ref REF` (or `--dir DIR`) walks every oneOf that the published roots reach, through any number of $ref hops, and reports each one as: - P: every branch pair proved disjoint under the context where the oneOf is evaluated, with the rules used; a one-branch oneOf; or an Ajv discriminator that compiles; - W: a payload built from the branch schemas that matches two or more branches, rejected by Ajv (repo options, every schema registered) with a single oneOf error, and accepted by each named branch on its own; - U: undecided. It exits 1 on any W or U and has no baseline or allowlist; --report-only prints the same Markdown table and exits 0. On main it reports P 207, W 16, U 0. The README describes it as a proof-based replacement for scripts/audit-oneof.mjs, which stays as it is. The schema-equivalence workflow runs it report-only on the PR head and appends the table to the job summary. It stays report-only until the 16 overlaps on main are fixed in a separate PR. Tests run the command through the CLI on one fixture per result, with and without --report-only.
…it in The oneof report escaped `|` in every table cell but not `\`, so plain text with a backslash before a pipe lost the backslash, and CodeQL flagged the escape as incomplete. Cells now escape for their context: - Plain text (an undecided reason, the rules) escapes backslashes first, then pipes. - A code span (the location, the witness) escapes only pipes, because backslashes in a code span are literal and GitHub's table parser reads every `\|` as a pipe. Its fence is one backtick longer than any run inside, so a backtick in a name no longer ends the span. The witness was also escaped twice, once alone and again with the whole detail cell, so a pipe in it rendered as `\|`. Each part is now escaped once. A new oneof fixture has names with a backslash before a pipe and a backtick, and the test reads every row of each fixture's Markdown table back the way GitHub splits cells, checking the location and witness. On HEAD the report is unchanged: P 207, W 16, U 0.
…e the prototype verdicts The construct catalog gets a second oracle that anyone can rerun: subsumes (georg-wolflein/subsumes, MIT) at 9a9d00af, through its `harness run` binary. catalog-oracle-subsumes.cjs bundles each pair as the prototype's input is bundled, translates it to draft 2020-12, and records a `subsumes` verdict per direction in the pair's record. A `no` needs a counterexample that the repo's Ajv configuration confirms; a `yes` is unproven on pairs with `format` date-time, uuid or uri, or a pattern that names a surrogate code point. A decided direction must agree with the pair's label, or the script writes nothing. The prototype's verdicts stay as they are, marked frozen as of 2026-11-20. Labels, witnesses and the catalog test are unchanged. CI does not run subsumes. Run: 1,856 directions, 1,833 decided. 1,782 agree with the prototype, 0 disagree; 51 of the 74 hand-decided directions agree with the hand verdict. All 313 counterexamples are confirmed by Ajv. 8 are unproven, 15 unknown.
generate.cjs no longer calls the prototype. It checks every pair in both directions with subsumes (catalog-generator/subsumes.cjs, moved from catalog-oracle-subsumes.cjs) and labels each pair from a hand verdict, from the frozen prototype verdict while the pair's files are unchanged, or else from subsumes, which must settle both directions with `yes` or an Ajv-confirmed `no`. A pair subsumes can't settle stops the generator until it gets a hand verdict. A subsumes `yes` or `no` that contradicts a hand or frozen verdict also stops it, and nothing is written. The generator writes `oracle_commit`, `oracle_frozen` and `subsumes_commit` in every file. With no change to pairs.cjs it rewrites the catalog byte for byte; the catalog data is unchanged by this commit.
…oubles
Ajv checks multipleOf as x / m !== parseInt(x / m) on doubles, and
parseInt(1e21) is 1. Two frozen prototype verdicts assumed exact numbers:
- opaque/numeric-bounds/integer-as-multipleof-one: {type: integer} accepts
1e21 and {type: number, multipleOf: 1} rejects it, so only head_in_base
holds. It is no longer equivalent and leaves false-alarms.json (41 to 40);
the tool's difference there is correct.
- opaque/numeric-bounds/multipleof-tightened: 2e21 passes multipleOf 4 and
fails multipleOf 2, so head_in_base is false too.
Both get hand verdicts with Ajv-confirmed witnesses. A probe of all 253
pairs with numeric content, with double edge values, finds no other wrong
label.
subsumes reasons over exact numbers, so its yes is now unproven on a pair
with multipleOf, type integer beside a numeric bound, or a number above
2^53 in magnitude. That turns 29 subsumes yes records into unproven.
…ouble negation
Three normalizations join the canonical form, each with a fixture that
must compare equal and a near miss that must not:
- With type integer, exclusiveMinimum n is minimum floor(n) + 1 and
exclusiveMaximum n is maximum ceil(n) - 1. Ajv compares numbers as
doubles, so the fold fires only when n and the result are safe
integers; above 2^53, exclusiveMaximum 9007199254740996 stays apart from
maximum 9007199254740995, which Ajv reads as 9007199254740996.
- With both maximum and exclusiveMaximum (or minimum and
exclusiveMinimum), only the tighter bound counts.
- not: {not: X} is X, also when either operand is reached through $ref.
They remove three catalog false alarms (40 to 37):
opaque/numeric-bounds/integer-minimum-vs-exclusive,
opaque/numeric-bounds/redundant-exclusive-maximum and
opaque/not/double-negation. The catalog has no misses, the tool reports a
difference on all 1,399 external not-included pairs, and its reports on
adcp#8536 and on main against itself are unchanged.
Resolution ledger: - Conflicts: none. Only package.json changed on both sides; it auto-merged as a key-wise union: this branch adds test:schema-equivalence, check:schema-equivalence and the two equivalence tests in test:schemas; main changes version, test, test:release-workflow, precommit, verify:local and @adcp/sdk. No key changed on both sides. - Mechanical: package-lock.json is main's (this branch does not change it); node_modules reinstalled with npm ci. - Invariants: no change needed. Main adds no oneOf. The oneof check at the merged tree reports 223 reachable oneOfs, P 207, W 16, U 0, the same as main at 576ebca. The construct catalog still reports its 37 known false alarms and no misses. - Proof: schema equivalence of the merged tree against 576ebca: 1113 roots, 0 differ, class 1, no informational entries.
This was referenced Nov 22, 2026
Brings in 6 commits from main: adcontextprotocol#9123 (deprecates the single-value form of the scalar-or-list unions), adcontextprotocol#9169 (training agent inventory floors), adcontextprotocol#9171 (PROPOSAL_TERMS_CHANGED), adcontextprotocol#9170 (not-guards that resolve 11 overlapping oneOf unions, with tests/oneof-overlap-resolution.test.cjs), adcontextprotocol#9141 (3.3.0-rc.3 version packages) and adcontextprotocol#9176 (rc.3 docs snapshot). Resolution ledger: - package.json (conflicted): test:schemas keeps both sides' entries, the two equivalence tests from this branch and tests/oneof-overlap-resolution.test.cjs from main, at main's position. Main's test:build-schemas-exit-status auto-merged. Every test file it names exists. The version (3.3.0-rc.3) is main's. - package-lock.json: main's (version field only). - Invariants: no code change needed. The oneof check at the merged tree reports 223 reachable oneOfs, P 219, W 4, U 0, the same as main at 14651cc; adcontextprotocol#9170 resolves 12 of the 16 witnessed overlaps (main at 2db59ba, after adcontextprotocol#9123, still has 16). The 4 left are the either/or unions adcontextprotocol#9170 leaves for adcontextprotocol#8191. The construct catalog still reports its 37 known false alarms and no misses, and tests/oneof-overlap-resolution.test.cjs passes (38 of 38). - Proof: schema equivalence of the merged tree against 14651cc: 1113 roots, 0 differ, class 1, no informational entries.
…h $ref
A manifest line whose constraint reaches its site through a $ref (a site
that wrote a schema inline now names a definition that carries the
constraint) found no witness. Three causes, all in the witness search:
- The revert read the entry's last pointer segment as a property name, so
a properties map added or removed as a whole (pointer .../$ref) could not
be reverted, and anyOf or oneOf added or removed as a whole had no revert.
Every keyword whose value holds subschemas now comes back as the base
wrote it.
- The revert edited the shared definition in place, with the base value of
the inline site, so the definition's other users changed too. It now
edits a private copy of the definition's document, and only the
referencing site's $ref (and each $ref of a chain that leads there)
names the copy. A base value keeps naming what it named in the base: its
$refs become absolute, to a copy of the base document when the head no
longer has the target. Roots that reach the site from another
referencing site get their own reverted head.
- The synthesized instance gave a property that one allOf member requires
the schema only its own member declares, so a member that required a
property declared behind a sibling's $ref got {}. A property any member
declares, also behind its $ref, now gives its schema to every member.
Five fixtures, each failing before this change for its one reason: a site
that now names a definition with an anyOf, a properties map through a
chain of two $refs, a loosening whose base value names a moved local
definition, a required property declared behind a member's $ref, and a
shared definition whose other user must keep its required list.
On the one-definition-per-object series, the lines with an attributed
witness go from 85 to 118 of 138 (delivery and reporting 12 to 37 of 37);
no line that had a witness lost it. adcp#8536 against main keeps 41 of 41.
The catalog still has no misses and the same 37 false alarms.
Twelve manifest lines in the one-definition-per-object series found no witness, for reasons unrelated to $ref. Each was a gap in instance synthesis or in the candidates: - The synthesized instance ignored an if/then/else elsewhere in the root. An optional `unchanged: true` selected a `then` that forbids the property on the path, so no seed was valid. - An allOf member that pins nested properties (a subject's type and resource_type) lost to the other member's oneOf, whose first branch the synthesis took, and an item with minProperties came out empty. - A lowered maxLength on an email address had only repetitions of the address as long strings, and they break the format. - There was no candidate for uniqueItems (a repeated item), for a removed additionalProperties: false (one more property), for maxProperties (more properties), or for a union of required-only branches added beside a required property (the object without the branches' properties). Each synthesized instance is now also conformed to the whole root: a raw draft-07 evaluator (lib/raw-eval.cjs) checks the schema, and the instance gets the pinned values, the required properties, the union branch it fits (the pointer's branch first, then by fewest contradicted pins) and the then or else its if selects, flipping the condition when that branch cannot hold. The instance path is never dropped, and Ajv still confirms every witness. Objects get properties up to minProperties, and length candidates at a location with a format or pattern keep it. Eight fixtures, each failing before this change for its one reason: a root if/then/else, minProperties in a closed oneOf, maxProperties, two properties an allOf member pins to different oneOf branches, an email maxLength, uniqueItems, a removed additionalProperties: false, and an anyOf of required-only branches added with a required property. On the series, the lines with an attributed witness go from 118 to 131 of 138: the twelve lines above, and a loosening of brand-localized-scalar.json that a neighbouring line was thought to mask. No line that had a witness lost it. adcp#8536 against main keeps 41 of 41. The catalog still has no misses and the same 37 false alarms.
The canonical form merged the plain members of a conjunction first fit: each member joined the first earlier member it could combine with. When two members could not combine (each with its own `not`), the result depended on member order and on how allOf nested them. A submitted body that wrote envelope fields inline beside its own `not` compared different from the same body composing a shared definition that declares those fields, although both accept the same payloads. Three async submitted documents (get_products, get_signals, get_creative_features) hit this, so their rewrite had no zero-difference proof. Each plain member is now taken apart into its value keywords, its `properties`, and its other subschema keywords, kept in the groups that read each other (`if`/`then`/`else`; `additionalProperties` and `patternProperties` with the same object's `properties`; `items` with `additionalItems`). Value keywords and properties combine across all members. A subschema group joins the merged object only when the conjunction has one of it, and a closed object only when no other member declares properties, so every decision reads the whole conjunction. A member with `discriminator` or `nullable` stays whole, as before. Two fixtures fail before this change: the submitted body in its inline and composed forms, and three allOf members in another order. A near miss, where the composed definition narrows `context`, must still report the difference. The catalog still has no misses and the same 37 false alarms. adcp#8536 against main reports the same 40 sites, keeps its manifest, and keeps 41 of 41 witnesses. On the one-definition-per-object series, two manifests were written against the first-fit grouping and need new lines: in properties-identifiers, `core/identifier.json` has two if/then members, and neither joins the object now, so the domain rule shows as an `allOf` member at each referencing site instead of `if` and `then` lines; in delivery-reporting, 18 `properties` values render a merged node with one more member. With those lines regenerated, both commits keep every witness (14 of 14 and 37 of 37).
…atch A oneOf that replaces an object schema tightens when an object that the old schema accepts also matches the new second branch: both branches accept it, so the oneOf rejects it. The witness search had no candidate for that, so the content-standards calibration exemplar lines (an artifact object that became a oneOf of a URL reference and the artifact) had only a payload checked by hand. For an entry on `oneOf`, the search now merges each pair of the synthesized branch instances into the valid instance at the location. A fixture fails before this change for that reason only: an artifact object replaced by a oneOf of a URL reference and itself.
KonstantinMirin
added a commit
to KonstantinMirin/adcp
that referenced
this pull request
Nov 23, 2026
…ent conjunction merge The schema equivalence check (adcontextprotocol#9119) now merges the members of a conjunction the same way however allOf groups or orders them. Before, the first member that could combine took the next one, so the result depended on member order. Two manifests were written against that grouping: - properties-identifiers: core/identifier.json's allOf has two if/then members, for domain and subdomain values. The old merge took the domain one into the object and left the subdomain one separate. Now neither joins the object, so the domain rule shows as an allOf member at each referencing site, like the subdomain rule already did. Its if and then lines become six allOf lines, one per site. - delivery-reporting: 18 properties lines render a viewability or identifier node whose allOf has two if/then members. Neither joins the object now, so each node renders one more member. The values change; the lines, directions, and notes don't. No schema changes, and no other manifest changes. Each commit's differences still match its manifest exactly.
…ommits CI compares a PR's merge commit with its first parent, so it sees the whole PR. A series that gives each commit its own manifest failed there although every commit matched its manifest: a later commit can change a site an earlier line describes, and a merge can change a value inside one. On adcontextprotocol#9180, the adcontextprotocol#9170 guard that a merge ported into core/calibration-exemplars.json left four content-standards lines unmatched, and brand line 31 showed the wrong side. With --manifest auto, when the lines do not match the range as a whole and the range has more than one commit, the check now composes them in commit order. It compares each commit of base..head with its first parent: a commit that adds or changes a manifest file must show exactly that file's lines, any other commit must show no difference, and a merge's net effect is part of the chain. When the head is a merge into the base, as on CI, the merge itself is left out. If every commit passes, the range's differences are the composition of declared changes. The composition is checked on commits, not on rendered values. A render names a shared node by the first location it met it at, so the same schema renders differently once an earlier commit extracts a definition, and a merge's change can sit inside a value another line declares. A line's side is the side its own commit reaches. A later commit that makes the site reachable from the other side is checked against its own lines, so the report notes the widening instead of failing it. Each line's witness comes from its own commit, with validators that compile only the roots a line reaches. The workflow fetches the PR's history, and its timeout goes from 10 to 20 minutes: adcontextprotocol#9180 as one range takes about 5 minutes on a 16-vCPU box. Four CLI tests on scratch repositories, each failing before this change: two commits at one site, an undeclared change in the second commit, a merge whose resolution adds a rule, and a site a later commit makes reachable from requests.
…lOf members A failed response that composes core/task-error-response.json and narrows its errors items to a definition that builds on core/error.json compared different from the inline form, and the move of the items constraint showed as a loosening with no witness. The canonical form kept two items in one conjunction as two separate conjuncts, while the inline form had one items. sync_catalogs' error branch and get_reporting_status's unavailable lookup kept their own error list because of it. In a conjunction, `items: A` and `items: B` are `items: allOf[A, B]`. The merge now conjoins `items` (a single schema, no additionalItems), `propertyNames`, and an `additionalProperties` that no properties or patternProperties sits beside, as it already did for each property. A conjunction keeps each schema once, so when B already composes A, its members are B's and it compares equal to B; nothing reduces on a weaker argument. `contains` stays as it was: two items can each satisfy one of two `contains`. Two fixtures: an item definition that builds on error.json, which fails before this change and now compares equal, and one that does not, which must still report that each item now also needs error.json's fields.
…check Checking a range commit by commit built both full trees for every commit and compared all 1,500 roots twice (once more for the informational channel), then searched every line's witness in its own commit with its own validators. adcontextprotocol#9202 as one range (93 commits) took 59 minutes on a box: 25 for the commit walk and 32 for witnesses. Each commit now compares only the roots that reach a changed document through $refs in its parent or in itself, without the informational channel. Every other root reaches byte-identical documents, so its canonical form is the same. A commit that changes no schema file has no difference and shares its parent's tree. A changed released schema compares every root, because releases reference each other and only source documents are indexed. A line that matches the range's differences on its own now gets its witness from the range, with one pair of validators for all such lines. The others, and any line the range search does not confirm, still get theirs from the commit that declares it; the report says which (`from`). Both are the same evidence: a payload one side accepts and the other rejects, whose verdict comes back when that line alone is reverted. adcontextprotocol#9180 as one range goes from 363 to 202 seconds and adcontextprotocol#9202 from about 59 to 17 minutes, with the same differences; adcontextprotocol#8536, a single-manifest range, is unchanged. adcontextprotocol#9202 still needs more than the workflow's 20 minutes with the rest of the job, so the timeout goes to 30 with the measurements in a comment. Two tests: a change two $refs from a root is still found in its commit while a commit without schema changes compares nothing, and lines that match the range take their witness from it while the others take it from their commits.
Checking a range commit by commit required every commit with a difference to carry its own manifest. A PR that adds one manifest after its schema commits, as adcontextprotocol#8536 does, failed as soon as it sat inside a stacked range (adcontextprotocol#9202 from main's merge base), and so would on CI. The range check now composes in steps: - A segment: the commits since the previous segment, along first parents, up to a commit that adds or changes a manifest file. Its differences, from the parent of its first commit to that commit, must equal the lines of the manifests its commits add. A commit with its own manifest is a segment of one, as before. - A merged branch: when a merge's other parent heads a range from the base whose differences equal the manifests that range adds, that range is one step. adcontextprotocol#8536 merges main several times before its manifest, so no segment along its first parents isolates its changes; as a range from the base, it matches its manifest exactly. - A merge's net effect, as before. Commits after the last manifest form an open segment that must show no difference, as must a segment a merge cuts short. Every difference still arises in a step whose differences are declared. Two CLI tests on scratch repositories, failing before this change: a segment of two commits closed by a manifest, and a stacked branch that merges the base before its manifest and is merged into a series. The open-segment and per-commit tests keep passing; the notes-only commit in the transitive-$ref test now joins the next segment.
KonstantinMirin
added a commit
to KonstantinMirin/adcp
that referenced
this pull request
Nov 24, 2026
…ction The schema equivalence check (adcontextprotocol#9119) now treats `items: A` beside `items: B` in one conjunction as `items: allOf[A, B]`. Three manifests declared lines for differences that only came from the old handling: - account-agents alignment: the four masked items and allOf lines for the registry event's agents_added and agents_removed are gone. The check now shows the restated items equal to the composed ones. - signals alignment: the two masked items and allOf lines for the signal listing's categories are gone, for the same reason. - content standards alignment: the four lines for the evaluator exemplars become one `oneOf` line at core/calibration-exemplar.json#, declared `none`. The evaluator's exemplars compose the calibration exemplars and keep their own artifact items, so the URL-or-artifact union is masked: an artifact fails the URL branch and passes the artifact branch. Ajv at 3ca3c4e^ and 3ca3c4e gives the same verdicts for a URL-reference exemplar (invalid), an artifact, and an artifact with type and value (both valid), and the witness search finds no payload in either direction. Two of the old lines declared this as a loosening, which no payload showed; the check now reports what the change is. No schema changes and no other manifest changes. Each commit's differences match its manifest exactly, and no corpus instance changes verdict.
Some lines change validation in a way the witness search cannot build a payload for, and their manifests carried a payload checked by hand in a note. A note is not evidence the check can confirm, so those lines failed the witness check (19 in adcontextprotocol#9202). A manifest line may now carry `witness: {root, instance}`, or a list of them. When the search finds no witness for a declared direction, the tool verifies the recorded one: with the repo's Ajv configuration it must be valid at the base and invalid at the head for `tighten` (the reverse for `loosen`), and with only this line reverted at its site, the same attribution the search uses, it must get the base verdict again. A recorded witness that does not verify fails the line and says why; one that verifies is reported with `from: recorded`. A `none` line takes no witness. When the line's keyword cannot be reverted alone (it comes from a normalization, or a discriminator needs the union), the recorded witness is attributed to the line's site: the head with the whole schema there reverted. The report says which (`attribution`). A `none` line no longer trips the direction inference. Context can mask a change that is monotone on its own (an enum added beside a const, a minItems that the response's other rules make unreachable), and the witness search checks the claim that no payload changes verdict. Fixtures on a root whose token pattern needs two lookaheads, so the search builds no instance: a recorded witness that verifies, one that shows a loosening for a line declared as a tightening, one whose verdict changes because of another line (the last two fail), and one for a oneOf that a discriminator reads, verified at its site. One more for an enum added beside a const, declared none.
A merged node records which source object writes each of its keywords, so a difference is reported where its keyword is written. The guarded rewrites (oneOf to anyOf, not-branch subtraction) and the union simplification copy a node without that record, so the copy reported every keyword at the node's first member. On adcontextprotocol#9202, a `not` that list_creatives' fourth allOf member adds was reported at the first member, where its keyword cannot be reverted, so the line could not get a witness. Each copy now keeps the record. A fixture: a not added by a new allOf member of an object whose oneOf the rewrite turns into an anyOf is reported at that member; it fails before this change.
…alone does not restore it A recorded witness was attributed to its line only: with the line's keyword reverted, the payload had to get the base verdict again. Where another conjunct at the same site states the same rule, reverting one of them restores nothing, although the site's change is what the payload shows. On adcontextprotocol#9202, a delivery provider domain with a 64-character label is rejected at the head by two conjuncts that each limit labels. When the line's revert does not restore the base verdict, the recorded witness is checked against the head with the whole schema at the line's site reverted, as it already was when the line's keyword cannot be reverted alone; the report says `attribution: site`. A payload whose verdict changes because of another site still fails, as the other-reason fixture shows.
KonstantinMirin
added a commit
to KonstantinMirin/adcp
that referenced
this pull request
Nov 24, 2026
The schema equivalence check (adcontextprotocol#9119) now verifies a payload a manifest line records (`witness: {root, instance}`): Ajv at both commits must give it the line's direction, and reverting the line, or the whole schema at its site, must give it the base verdict again. A payload in a note does not count. 19 lines here had only a note. - 15 lines get a recorded witness, each a full root payload built from the value their note gives: the validate-input target, the reporting destination and delivery provider domains, the reporting schedule durations, the legacy available action's review_sla, the compact pricing option's four cpa and revenue_share rules, the reporting subscription ID ".", and the three bounds with no published text. - 3 lines become `none`: the get_products suggestions minItems and the catalog error's recovery enum, whose notes already said no payload changes verdict because of them, and the delivery provider domain's label pattern, which stays in effect as its own conjunct beside the dotted rule (its note now says so). - 1 line, list_creatives' capability guard, names the allOf member that writes its `not` (allOf/3, not allOf/0); with that, the search finds its witness. No schema changes. Each commit's differences match its manifest, no corpus instance changes verdict, and every line passes the witness check.
The site attribution for a recorded witness whose own line's revert does not restore the verdict had no fixture; only adcontextprotocol#9202's delivery provider domain exercised it. This fixture gives a label two allOf conjuncts that both cap its length at 10. An 11-letter label is valid at the base and invalid at the head, but reverting either conjunct alone leaves it invalid, so the witness verifies at the site. It fails before 6931d3e, which reported that the verdict changes for another reason, and passes after. The other-reason fixture still fails as it should.
This was referenced Nov 24, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revised 2026-11-21: the disjointness proof reads
not, closed objects, and the enclosing context; adds aoneofcheck that proves or refutes everyoneOf; the catalog has 928 pairs and 37 known false alarms;subsumesreruns the catalog and the prototype's verdicts are frozen; the canonical form folds integer bounds, redundant bounds, and double negation; the CI section explains the redcode_reviewjob; counts after mergingmain(1,113 roots).Revised 2026-11-22: merged with
mainat14651cc07c; #9170 resolves 12 of the overlaps, so theoneofcheck finds 4.Revised 2026-11-23: the witness search handles a constraint that reaches its site through a
$ref: the line is reverted for that referencing site only, apropertiesmap or a union added or removed as a whole can be reverted, and a property declared behind anallOfmember's$refgets a valid value. Synthesized instances are also conformed to the whole root (anifelsewhere in it, the union branch that pinned values select,minProperties), and new candidates coveruniqueItems, a removedadditionalProperties: false,maxProperties, a union of required-only branches,maxLengthon a formatted string, and an object two branches of an addedoneOfboth accept. The canonical form now merges a conjunction the same way howeverallOfgroups or orders its members, so a body that composes a shared definition beside its ownnotproves equal to the inline form, and it conjoinsitemsacross members, so a failed response that narrows a shared error list's items to a definition building oncore/error.jsonproves equal too. A range whose commits carry their own manifests is checked commit by commit when its lines don't match the range as a whole, so CI's merge-commit check passes a series whose per-commit manifests are right; a manifest also covers the commits before it, and a merged stacked PR that matches its manifest from the base counts as one step. A manifest line may record a witness payload for a change the search can't build one for; the tool verifies it with Ajv at both refs and attributes it by reverting the line (or, where the line can't be reverted alone, its site), and a prose note no longer counts. On a series that replaces inline copies with shared definitions (#9180), the lines with a witness go from 85 to 134 of 142, the other 8 are declarednone, and the whole PR passes as one range; #8536 keeps 41 of 41.This PR adds a check that reports exactly which payloads a schema change newly accepts or rejects, and fails a PR whose changes don't match what it declares. Restructuring PRs, such as extracting a shared definition or adding a title, prove they change nothing, and constraint fixes prove they change only the sites they list.
What it checks
scripts/schema-equivalence/cli.cjsreadsstatic/schemas/sourceat two git refs and compares every published root:$ref, strips annotations (title,description,examples,$comment), and normalizes spellings that accept the same payloads:type: "x"and["x"],required: []and norequired, a one-valueenumandconst,\dand[0-9], and so on. Roots are compared as graphs, so recursive schemas work. Conjunctions merge the same way howeverallOfgroups or orders their members, anditems: Abesideitems: Bisitems: allOf[A, B]. The README lists every normalization; each one has a fixture.oneOfbecomesanyOf, andallOf[union, {not: branch}]becomes the remaining branches, only when the branches provably can't overlap: disjoint types or values, a required tag with disjoint values, or anotor closed object that rules out the other branch, read in the context where the union is evaluated..schema-deltas/<name>.yamllisting each intended difference: site, keyword, old and new value, and direction (tighten, loosen, or none). The check passes only when the differences match the manifest exactly. When each commit of a series carries its own manifest, the lines compose in commit order: each manifest covers the commits since the previous one, a stacked PR merged in that matches its own manifest from the base counts as one step, and a merge counts with its net effect.$schema-tagged doc blocks, storyboard sample requests and responses, and the example directories are validated against both refs with the repo's Ajv options. A real payload that changes verdict is reported.witness:), which the tool verifies the same way. When the constraint reaches the site through a$ref, the line is reverted for that referencing site only.Anything the canonical form doesn't model, such as
formatnames, numeric reasoning beyond integer bounds, ornotsimplification beyond double negation, is compared literally. That can produce a false difference, never a false "equivalent". The tool also stops if Ajv evaluates a keyword the canonical form doesn't know.How it was validated
origin/mainagainst itself: no differences over 1,113 roots.title).sla-durationacceptedPT, andmaxLengthwas stated twice. schemas: give every repeated constraint one definition, and fail CI on any repeat (#8525) #8536 now fixes all three and carries its manifest.core/signal-definition.jsonat both refs.Construct catalog
scripts/schema-equivalence/test/catalog/holds 928 schema pairs with verdicts the tool didn't produce: 617 equivalent, 311 different. They enumerate the constructs the bundle uses rather than sampling them:allOf, undernot, behind$ref, in a cycle, underdiscriminator), plus near misses;const,discriminator,type,requiredplusnotrequired, and none;$refforms, and the constructs the tool compares literally.889 verdicts come from the refutational-normalization prototype above, run in both directions, and are kept as a frozen record. 39 involve
format,uniqueItems,., lookahead, astral characters, ormultipleOfon doubles, which the prototype doesn't model like Ajv, so they were decided by hand with a written reason. The prototype is GPLv3, so only the pairs, verdicts, and witnesses are committed.The generator reruns
subsumes(MIT, pinned to9a9d00af), another implementation of the same method, on every pair. Where it decides a direction, it must agree with the stored verdict, or generation stops and names the pair. A new pair takes its verdict fromsubsumesor from a hand verdict. Asubsumes"no" counts only with a counterexample that Ajv confirms. A "yes" doesn't count on pairs that usedate-time,uuid,uri,multipleOf,type: integerbeside a numeric bound, a number above 2^53, or a pattern that can match a lone surrogate. CI doesn't run it. Ajv confirms every witness on each run.The catalog found 8 pairs the tool wrongly called equivalent: bracket classes with a literal
-as a range endpoint, astral characters counted as two, anddiscriminatorinsidepropertyNames. This PR fixes all three. Two prototype labels were wrong for Ajv, which checksmultipleOfon doubles:1e21is an integer but not a multiple of 1, and2e21is a multiple of 4 but not of 2. They are now hand verdicts. The tool now has no misses on the catalog, and 37 known false alarms (equivalent pairs it reports as different). Each false alarm is listed with its cause infalse-alarms.json, and the test fails if one silently stops being reported. Offline, it also reports a difference on all 1,399 pairs that the prototype's own datasets label as not included. The catalog test takes about 6 s.Proving every oneOf
node scripts/schema-equivalence/cli.cjs oneof --ref <ref>checks everyoneOfthe published roots reach, through any number of$refs. It either proves the branches disjoint and names the rule, or finds a payload that matches two branches and that Ajv rejects at theoneOf. It exits 1 on an overlap or an undecided case, and it has no baseline.On
mainat14651cc07cit proves 219 and finds 4 overlaps; none is undecided. All 4 overlaps are inoneOfs thatscripts/audit-oneof.mjsclassifies as narrowable and its baseline accepts. For example, aprice-breakdown.jsonadjustment that states bothrateandamountmatches both branches. The check is meant to replace the audit, which this PR leaves in place.CI
.github/workflows/schema-equivalence.ymlruns on PRs that touchstatic/schemas/source/**or.schema-deltas/**, and skips drafts. It compares the merge commit with its first parent, and fetches the PR's history for a series checked commit by commit. A change with no differences takes about 1.5 s; #8536 with its corpus and 41 witnesses takes about 13 s on a laptop; each commit of a series compares only the roots that reach a changed document, and a line that matches the whole range takes its witness from the range. On a 16-vCPU box, #9180 (22 commits, 142 witnesses) takes about 3.5 minutes and #9202 (93 commits) about 17, so the job timeout is 30 minutes. The job summary shows the report, and the JSON report is uploaded. The job also runs theoneofcheck in report-only mode and adds its table to the summary; it becomes blocking once the 4 overlaps onmainare fixed.The
code_reviewjob is red on this PR. Ladon's run ends with "No complete review record after one finalization retry … This is not a code rejection; the arbiter is skipped and the run fails closed." It did that on both heads, so it reports that the review bot didn't finish, not a finding.Reproduce
No protocol changeset: this is build tooling, and
check-changeset-protocol-scope.cjspasses.