Expand description
Core schema-merging logic - a faithful Rust port of the definitions-
combining half of the former schema/build_combined_schema.py (see git
history for the original). Reused by both regen (the real merge) and
bisect (building opaqued-out candidate schemas from the same merge).
Structs§
- Methods
Manifest - Notification
Entry - One
server_notifications/client_notificationsmanifest entry - noresponse_typefield at all (not evennull), matching the Python original’s dict literal for notifications. - Params
Type - The resolved params type for one method’s
oneOfbranch: the referenced type name (if any) and whether the params were nullable (2-way anyOf). - Request
Entry - One
client_requests/server_requestsmanifest entry (includes a resolved response type). Field order is JSON serialization order - must staymethod, variant_name, fn_name, params_type, params_optional, response_typeto byte-match the Python original’s output.
Constants§
- EXPECTED_
DIVERGENT_ 🔒COLLISIONS - Definition names known to legitimately differ between the master and v2
bundles - v2’s copy is the deliberately-pruned/authoritative one and is
expected to differ from master’s (ref-rewritten) copy. Any other
name-collision with differing content is treated as a hard failure (see
check_collision_compatibility) rather than silently letting v2 shadow a master definition that might carry different meaning.
Functions§
- build_
combined - Merges the master bundle’s flat top-level definitions (ref-rewritten)
with the v2 bundle’s definitions (v2 wins name collisions), applies the
McpServerElicitationRequestParamsflatten workaround, and wraps the result in the same schema envelopebuild_combined_schema.pyproduced. - build_
methods_ manifest - Builds the full
methods.jsonmanifest from a merged, flatdefinitionsmap (as produced bybuild_combined). - check_
collision_ 🔒compatibility - For every definition name present in both
master_flat_rewrittenandv2_defs, verifies they’re either identical or on the explicit known-divergent allowlist.build_combinedalways prefers v2’s copy on a collision; this only exists to catch collisions where that’s not safe - a future codex schema change that makes some other same-named type genuinely diverge between the two bundles would otherwise have v2 silently substitute the wrong shape into a master-derived envelope type (several of which transitively$refinto collision names likeAbsolutePathBufandRequestId), with no build failure and no warning. - flatten_
base_ plus_ oneof - The
McpServerElicitationRequestParamstypify-0.7.0 workaround: merges a schema’s top-level objectproperties/requiredinto each siblingoneOfbranch, producing a pure oneOf-of-self-contained-objects. Returns the schema unchanged unless it actually has this exact shape (top-leveloneOfandpropertiesboth present). - get_def 🔒
- methods_
of - Extracts the
methodstring of everyoneOfbranch of a discriminated union definition (e.g.ClientRequest), in schema order. - params_
type_ for - STRICT: only a plain
$ref, a 2-way nullable-refanyOf, an explicit{"type": "null"}, or a missing"params"key are recognized. Any other shape is a hard failure, matching the Python original’sparams_type_fordocstring: raising here (rather than silently falling back to “no params”) is load-bearing - the wrapper codegen inbuild.rswould otherwise silently emitparams: ()for a method that actually requires typed params. - ref_
name 🔒 - rewrite_
v2_ refs - Recursively rewrites
"$ref": "#/definitions/v2/X"to"#/definitions/X"so refs resolve against a single flatdefinitionsnamespace. - wrap_
definitions - Wraps a flat
definitionsmap in the schema envelope the crate’sbuild.rsexpects ($schema/title/description/type/definitions, in that field order).