Skip to content

fix(schemas): make either/or union branches refuse the other branch's key - #9124

Open
KonstantinMirin wants to merge 10 commits into
adcontextprotocol:mainfrom
KonstantinMirin:schemas/constrain-unions-registries
Open

KonstantinMirin wants to merge 10 commits into
adcontextprotocol:mainfrom
KonstantinMirin:schemas/constrain-unions-registries

Conversation

@KonstantinMirin

@KonstantinMirin KonstantinMirin commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes two either/or unions accept only what their own descriptions already say. Each change is a tightening that no schema example, docs payload, storyboard sample, or example file in the repo depends on, and the delta manifest under .schema-deltas/ lists every difference with a witness payload. Both bounds come from the published text, so these are corrections under DR-0036, proposed for 3.3; see the DR-0036 comment.

Revised 2026-11-22: following @bokelley's review, the asset_requirements, mcp_resource_uri, and registry document changes moved to #9174 for separate rulings, and the adagents.json guards are gone, because #9170 resolves a file with both keys as the URL reference. Merged main, so the proof runs against 2db59bae43. Proposed for 3.3 as DR-0036 corrections, not held for 4.0.

Revised 2026-11-21: a section on merge order with #8536; merged main, so the proof runs against the new merge base, and one manifest line states max_weight_grams as minimum: 1, the form the check reports for the integer bound; the CI section explains the Python SDK job, which fails on main since #9049.

Refs #9051
Refs #8191

What changes

Either/or unions refuse the other branch's key (#9051). Each branch now carries not: {required: [<other key>]}, the idiom creative/validate-input-result.json already uses:

  • core/evaluator-spec.json: exemplars or agent_url.
  • registries/v1-canonical-mapping.json v1_pattern: "Carries either format_id_glob OR structural, not both."

A payload carrying both keys was already invalid when both forms were valid. It is now also invalid when the second form is malformed. No payload in the repo carries both keys of either union. media-buy/build-creative-response.json is left to the envelope stack (#9044), which renames that file.

For adagents.json, see #9170.

Proof

The schema equivalence check (proposed in #9119) compares every published root at the merge base and at the head:

Schema equivalence: origin/main (2db59bae43f0) -> schemas/constrain-unions-registries (e28ba3125aef)
Roots compared: 1113; roots that differ: 3; proof class: 3 (differences remain)
Rewrite rules fired: oneOf-to-anyOf x402, discriminator-to-anyOf x118
Differences: 6 entries at 4 sites
Manifest .schema-deltas/either-or-union-guards.yaml: matches the differences exactly
Corpus: 60/2669 bound instances checked, 50629 probe values against 4 changed sites
  docs: 16 checked, 16 valid at both, 0 invalid at both, 0 changed, 0 unpaired
  storyboard-request: 44 checked, 44 valid at both, 0 invalid at both, 0 changed, 0 unpaired
  Verdict changes: none
Witnesses: 4/4 manifest entries pass the witness check (an attributed witness per declared direction, none for "none")
Result: PASS

No unbound probe value hits a changed site.

Manifest summary (4 lines, all tighten):

Manifest Lines Sites Side
either-or-union-guards.yaml 4 not guards core/evaluator-spec.json#/oneOf/0,1 (also reached by build-creative-request.json), v1-canonical-mapping.json v1_pattern/oneOf/0,1 request, none

Witnesses, one per line. Each is valid at the base and invalid at the head, and invalid at the head only because of its own line:

Line Root and pointer Witness
core/evaluator-spec.json#/oneOf/0 / {"exemplars": {}, "agent_url": {}}
core/evaluator-spec.json#/oneOf/1 / {"agent_url": "https://example.com/x", "exemplars": null}
v1_pattern/oneOf/0 /mappings/0/v1_pattern {"format_id_glob": "a", "structural": null}
v1_pattern/oneOf/1 /mappings/0/v1_pattern {"structural": {}, "format_id_glob": {}}

Reproduce from a checkout of the tool branch:

node scripts/schema-equivalence/cli.cjs \
  --base "$(git merge-base origin/main schemas/constrain-unions-registries)" \
  --head schemas/constrain-unions-registries \
  --manifest auto --corpus --witness

CI

Generate Python SDK fails on main since #9049, and so on every branch that has merged main. #9049 adds a second postal_area property, so the generator numbers the postal union's classes PostalArea40 | PostalArea41 instead of PostalArea1 | PostalArea2, with the same structure. The SDK's fix_postal_union_arm_order matches the old names and raises "unexpected outer union shape". #9141, which doesn't contain this PR, fails the same way.

…quirements

offering-asset-constraint.json referenced asset-requirements.json, a
12-branch anyOf in which every branch accepts {}, so asset_requirements
accepted any object whatever its asset_type said. The union's own
description says the applicable schema is determined by the sibling
asset_type field.

Add one if/then rule per asset type that has a requirements schema,
following the pairing core/format.json already uses. The union stays
referenced, so the five asset types without a requirements schema keep
it and no URL changes.

Refs adcontextprotocol#8476
… key

Three oneOf unions pick a branch by which key is present, and each
document's prose says the forms exclude each other, but no branch said
so. A valid form plus a malformed copy of the other key matched one
branch and was accepted.

Add a not/required guard to each branch, the idiom the bundle already
uses (validate-input-result.json, get-creative-features-response.json):

- adagents.json: authoritative_location or authorized_agents. The spec
  already says the authoritative file carries no authoritative_location.
- core/evaluator-spec.json: exemplars or agent_url.
- registries/v1-canonical-mapping.json v1_pattern: format_id_glob or
  structural ("Carries either format_id_glob OR structural, not both").

The build-creative-response union is left for the envelope stack that
renames that file.

Refs adcontextprotocol#9051
The field carries an MCP resource URI such as ui://si/session-abc123.
format: uri accepts any scheme, as core/app-item.json deep_link_url
already relies on for custom app schemes, and refuses values with no
scheme. The description now says the value is not limited to http(s).

deep_link in si-ui-element.json stays a plain string: the SI chat
protocol's own app handoff example uses "flights/boston", a path with
no scheme, which format: uri would refuse.

Refs adcontextprotocol#8924
core/asset-group-vocabulary.json, core/format-shape-vocabulary.json,
creative/asset-types/index.json, and extensions/index.json declare
$schema but state no keyword, so each is the empty schema and admits
every JSON value.

Follow registries/v1-canonical-mapping.json, a registry that states
type and properties for its own data: each document now states
type: object and the shape of its entries, and validates against
itself. The build copies the schema keywords from the extensions
placeholder into the generated registry. No URL changes.

The roots require no property yet, because a new required name is not
additive in a minor release.

Closes adcontextprotocol#9104
The equivalence check merges a schema split across allOf members, so it
reports the first asset_type rule in offering-asset-constraint.json as
if and then keywords at allOf/0 rather than as an added allOf member.
Rewrite those manifest lines to match.

Refs adcontextprotocol#8476
@mintlify

mintlify Bot commented Nov 20, 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 e28ba31.

Approve preview

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated paths touched without required approval.

This PR modifies 10 files under static/schemas/source/**, which fall under the repo's hard, deterministic approval gate (gated_paths: true). The current review_decision is REVIEW_REQUIRED, not APPROVED, so the gate is not satisfied (decision table row 2). Human/CODEOWNERS review is required before this can merge.

No blocking findings exist. The reviewer found the change to be a clean schema-hardening PR: four patch-level tightenings (per-asset-type requirements pairing, not:{required} either/or guards with no undiscriminated oneOf, format:uri on mcp_resource_uri, and self-schemas for four registry documents). Four correct patch changesets present, no schema↔docs drift, and a formal equivalence proof (PASS, 50481 probes). No Critical/High/Medium findings.

Escalation reasons:

  • Gated files under static/schemas/source/** modified (adagents.json, core/asset-group-vocabulary.json, core/evaluator-spec.json, core/format-shape-vocabulary.json, core/requirements/asset-requirements.json, core/requirements/offering-asset-constraint.json, creative/asset-types/index.json, extensions/index.json, registries/v1-canonical-mapping.json, sponsored-intelligence/si-send-message-response.json) require human/CODEOWNERS approval; review_decision is REVIEW_REQUIRED.

Once a human/CODEOWNERS approval lands (review_decision: APPROVED), this clean diff with no findings would fall through to an approve.

Why human review

  • Modifies gated paths under static/schemas/source/** (10 files) while review_decision is REVIEW_REQUIRED — human/CODEOWNERS approval required before merge.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/adagents.json (modified) matches static/schemas/source/**; static/schemas/source/core/asset-group-vocabulary.json (modified) matches static/schemas/source/**; static/schemas/source/core/evaluator-spec.json (modified) matches static/schemas/source/**; static/schemas/source/core/format-shape-vocabulary.json (modified) matches static/schemas/source/**; static/schemas/source/core/requirements/asset-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/requirements/offering-asset-constraint.json (modified) matches static/schemas/source/**; static/schemas/source/creative/asset-types/index.json (modified) matches static/schemas/source/**; static/schemas/source/extensions/index.json (modified) matches static/schemas/source/**; static/schemas/source/registries/v1-canonical-mapping.json (modified) matches static/schemas/source/**; static/schemas/source/sponsored-intelligence/si-send-message-response.json (modified) matches static/schemas/source/**) and the current GitHub review decision is 'REVIEW_REQUIRED', not APPROVED. This is a hard gate enforced in code — Ladon cannot auto-approve until a human/CODEOWNERS approval is recorded, regardless of how clean the diff is.

@aao-secretariat aao-secretariat Bot added the ladon/needs-human-review Ladon has escalated this PR for human review. label Nov 20, 2026
@aao-secretariat
aao-secretariat Bot requested a review from bokelley November 20, 2026 03:09
Resolution ledger:
- Conflicts: none. Only package.json changed on both sides; it
  auto-merged as a key-wise union: this branch adds the registry
  self-schema test to 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: main adds no registry document, no extension, and no
  either/or union; its reporting changes add if/then rules only.
  The four registry documents, including the generated
  extensions/index.json, validate against themselves.
- Proof: schema equivalence against 576ebca finds the same 76
  entries at 33 sites, 12 roots, as against the old base, and no
  corpus verdict changes. One manifest line no longer matches the
  current equivalence check, which now folds integer bounds; the next
  commit updates it. That mismatch exists before this merge too.
…heck reports it

The equivalence check now folds an integer's exclusiveMinimum: 0 into
minimum: 1, so the image rule's then line in
asset-requirements-by-asset-type.yaml no longer matched the reported
difference. Both forms accept the same integers. With this line the
manifest matches all 76 entries at 33 sites, and 33 of 33 witnesses
pass.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated paths require human/CODEOWNERS approval.

This PR modifies 10 files under static/schemas/source/**, which are under a hard, non-overridable approval gate (gated_paths: true). The current review_decision is REVIEW_REQUIRED, not APPROVED, so the gate is not satisfied (decision row 2).

The reviewer found no blocking or Medium findings. The schema-hardening changes (union-branch not guards, registry self-schemas, per-asset-type asset_requirements enforcement, format: uri on mcp_resource_uri) each carry a correct patch changeset and were reviewed clean. The one new authored change — normalizing max_weight_grams from exclusiveMinimum: 0 to minimum: 1 (semantically identical for an integer) — is sound. The 6500+ delta files are a rebase pulling main's 3.1.34 snapshot; the artifacts are identical in base, so no immutability issue is attributable to this PR.

Despite the clean diff, Ladon cannot auto-approve until a human/CODEOWNERS approval is recorded on these gated schema-source files. Consistent with the prior escalate decision.

Escalation reasons

  • Modifies gated paths under static/schemas/source/** (10 files) while review_decision is REVIEW_REQUIRED — human/CODEOWNERS approval required before merge.

Why human review

  • Modifies gated paths under static/schemas/source/** (10 files: adagents.json, core/asset-group-vocabulary.json, core/evaluator-spec.json, core/format-shape-vocabulary.json, core/requirements/asset-requirements.json, core/requirements/offering-asset-constraint.json, creative/asset-types/index.json, extensions/index.json, registries/v1-canonical-mapping.json, sponsored-intelligence/si-send-message-response.json) while review_decision is REVIEW_REQUIRED — human/CODEOWNERS approval required before merge.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/adagents.json (modified) matches static/schemas/source/**; static/schemas/source/core/asset-group-vocabulary.json (modified) matches static/schemas/source/**; static/schemas/source/core/evaluator-spec.json (modified) matches static/schemas/source/**; static/schemas/source/core/format-shape-vocabulary.json (modified) matches static/schemas/source/**; static/schemas/source/core/requirements/asset-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/requirements/offering-asset-constraint.json (modified) matches static/schemas/source/**; static/schemas/source/creative/asset-types/index.json (modified) matches static/schemas/source/**; static/schemas/source/extensions/index.json (modified) matches static/schemas/source/**; static/schemas/source/registries/v1-canonical-mapping.json (modified) matches static/schemas/source/**; static/schemas/source/sponsored-intelligence/si-send-message-response.json (modified) matches static/schemas/source/**) and the current GitHub review decision is 'REVIEW_REQUIRED', not APPROVED. This is a hard gate enforced in code — Ladon cannot auto-approve until a human/CODEOWNERS approval is recorded, regardless of how clean the diff is.

@bokelley

Copy link
Copy Markdown
Contributor

Thanks for this, Konstantin, and for the #9051 census behind it. There's an overlap with #9170, which fixes part of #9051 for 3.3 rc.3, so I'm flagging it.

For the 3.3 RCs we're only taking union guards that accept payloads that were rejected before. So the symmetric either/or guards here (core/evaluator-spec.json, v1-canonical-mapping.json v1_pattern, and the adagents.json both-keys rejection) are held for 4.0 and #8191's literal discriminators. As the PR notes, each one also rejects a payload when its second form is malformed, which is a tightening.

On adagents.json we went the other way for 3.3. In #9170, a file carrying both a valid authoritative_location and inline authorized_agents is the URL reference: the inline variant refuses a valid reference with not: { "$ref": "#/oneOf/0" }. Two things in docs/governance/property/adagents.mdx led us there:

  • Validation Behavior step 2, "Detect Reference: Check for authoritative_location field", followed by fetching it. A file that has one is treated as a reference.
  • "Body does not contain an authoritative_location field (nested references are rejected)" is a rule for the target file. Validators still reject a target that is itself a reference.

Would you be open to splitting #9124 so its non-union parts can be judged on their own? Those are asset_requirements following asset_type (#8476), mcp_resource_uri as format: uri (#8924), and the registry documents describing their own data (#9104). Brian will rule on those. I'm not suggesting any change to them.

@KonstantinMirin

Copy link
Copy Markdown
Collaborator Author

@bokelley Yes, I'll split it. The parts that aren't union guards move to a new PR: asset_requirements following asset_type (#8476), mcp_resource_uri as format: uri (#8924), and the registry documents describing their own data (#9104). #9124 keeps the symmetric guards for 4.0 and goes back to draft until #8191's literal discriminators land.

On adagents.json, your reading of the validation steps works for me. #9170 replaces our both-keys rejection, so I'll drop it from #9124.

@KonstantinMirin
KonstantinMirin marked this pull request as draft November 22, 2026 14:24
The asset_requirements pairing (adcontextprotocol#8476), format: uri on
mcp_resource_uri (adcontextprotocol#8924), and the registry document schemas (adcontextprotocol#9104)
move to schemas/asset-requirements-uri-registries, so each can be
ruled on apart from the either/or union guards. This branch keeps
only the union guards, which wait for 4.0 and adcontextprotocol#8191.

This reverts 65c0ce5, b179816, 4d062c4, a6a5d12, and
80ffa23.
adcontextprotocol#9170 resolves a file that carries both a valid authoritative_location
and inline authorized_agents as the URL reference, following validation
step 2 in docs/governance/property/adagents.mdx. The guards here
rejected that file, so they come out, with their manifest lines.

The core/evaluator-spec.json and v1-canonical-mapping.json v1_pattern
guards stay.

Refs adcontextprotocol#9051
@KonstantinMirin KonstantinMirin changed the title fix(schemas): constrain asset requirements, either/or unions, mcp_resource_uri, and registry documents fix(schemas): make either/or union branches refuse the other branch's key Nov 22, 2026
@KonstantinMirin

Copy link
Copy Markdown
Collaborator Author

@bokelley Upon better analysis, I think the two guards left in this PR are corrections under DR-0036, so they can ship in 3.3. Each union's own text sets the bound:

  • core/evaluator-spec.json: "Provide exactly one of two source forms (inline exemplars or an external agent_url)".
  • v1_pattern: "Carries either format_id_glob OR structural, not both."

No conforming sender puts both keys in one payload, so the guards reject nothing a conforming peer sends.

Without the guards, these unions don't determine which form a payload uses. A payload with both keys passes whenever the second form is malformed, and that form is never validated. A reader then has to pick a form. For v1_pattern, resolution steps 3 and 4 give different answers.

Does that change the decision for these two? adagents.json stays with #9170.

@KonstantinMirin
KonstantinMirin marked this pull request as ready for review November 22, 2026 18:55

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated schema paths require human/CODEOWNERS approval.

This PR adds minimal mutual-exclusion not: {required:[...]} guards to two two-branch either/or oneOfs in core/evaluator-spec.json and registries/v1-canonical-mapping.json. The reviewer found the change correct, fail-closed (only new rejection is valid-first-key + malformed-second-key that previously slipped through fail-open), with no schema↔docs drift, an honest patch changeset, and a .schema-deltas record carrying Ajv witness verification. No critical/high/medium findings.

The diff is clean, but it modifies files under static/schemas/source/**, which are under a hard, non-overridable approval gate (gated_paths: true), and the current review_decision is REVIEW_REQUIRED, not APPROVED. Per decision row 2, Ladon cannot auto-approve a gated-path change until a human/CODEOWNERS approval is recorded. This also matches the prior decision, which escalated for the same gate reason.

Escalation reasons

  • Modifies gated paths static/schemas/source/core/evaluator-spec.json and static/schemas/source/registries/v1-canonical-mapping.json while review_decision is REVIEW_REQUIRED — human/CODEOWNERS approval required before merge.

No blocking code findings; the escalation is purely the gated-path/review-status gate. Once a human/CODEOWNERS approval is recorded, this clean diff can fall through to approval.

Why human review

  • Modifies gated paths under static/schemas/source/** (core/evaluator-spec.json, registries/v1-canonical-mapping.json) while review_decision is REVIEW_REQUIRED — human/CODEOWNERS approval required before merge.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/evaluator-spec.json (modified) matches static/schemas/source/**; static/schemas/source/registries/v1-canonical-mapping.json (modified) matches static/schemas/source/**) and the current GitHub review decision is 'REVIEW_REQUIRED', not APPROVED. This is a hard gate enforced in code — Ladon cannot auto-approve until a human/CODEOWNERS approval is recorded, regardless of how clean the diff is.

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

ladon/needs-human-review Ladon has escalated this PR for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants