Repository navigation
fix(build): keep call-site annotations on hoisted enums, and hoist inside definitions - #9167
Conversation
resolveRefs merges the keys written beside a `$ref` into the inlined enum, so occurrences of one enum differ in `description`, `default`, `deprecated` or `x-*`. hoistDuplicateInlineEnums gave every occurrence the annotations of one of them: 64eacbc kept `deprecated`, `x-deprecated-in` and `x-removed-in` beside the `$ref`, but every other annotation still moved. On main, 1,721 sites in 50 bundles show another field's description, and two gain a `default` and one an `x-status` their source does not give them. This generalizes 64eacbc to every annotation key: title, description, default, examples, deprecated, readOnly, writeOnly, enumDescriptions, $comment and x-*. The hoisted entry keeps only what every occurrence shares, and each occurrence keeps its own annotations beside its `$ref`. Occurrences share an entry only when every key that is not an annotation matches, so the entry never changes what a site accepts. Every site of every bundle now has the annotations of the unhoisted bundle, verify-build gives proof class 1, and the bundles grow 0.4%. The fixture helpers of the exit-status test move to tests/helpers/build-schemas-fixture.cjs for the new test, which builds a fixture tree through `--root`.
hoistDuplicateInlineEnums and hoistMarkedSchemas skipped every `$defs` and `definitions` block. hoistNestedDefsToRoot moves an inlined document's `definitions` to the bundle root, so a marked schema or a repeated enum inside such an entry stayed inline at every site: the creative bundles keep the asset union inline under `definitions/resolvedAssets`, and adcontextprotocol#9121's first layout grew seven creative bundles by about 4 MB each. Both passes now walk into each entry of a `$defs` or `definitions` block. The entry itself is still neither counted as an occurrence nor replaced. Bundles go from 87.4 MB to 83.3 MB and 29 of 124 change. Validation and each site's annotations are unchanged: verify-build gives proof class 1, no Ajv verdict or error set differs over the schema-equivalence corpus, and every site matches the unhoisted bundle. The new test builds a fixture tree through `--root`. The hoist-marked test that pinned the skip now checks a marker on an entry itself, which is stripped, not hoisted.
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — build-tooling only, no blocking or medium findings.
This PR modifies scripts/build-schemas.cjs (enum hoisting) plus two scoped patch changesets and a set of new/updated tests. The reviewer verified the transform is strictly more conservative: the fingerprint now includes all non-annotation keys (closing a latent bug where enums differing only in minLength/format/const could collapse), canonicalEnumBody never deletes a validation key, and pointerFor only writes annotation keys beside a $ref (draft-07 ignores $ref siblings for validation). Per-site annotation fidelity holds across drop/keep/absent cases, and new Ajv-backed tests cover both commits.
Decision-table walk:
- Rows 1 (no critical/high), 4 (no medium), 6 (no prior decision): no match.
- Row 2 (gated_paths): false — N/A despite
review_decision: REVIEW_REQUIRED. - Rows 3/5:
high_riskis true but the only reason isscripts/build-schemas.cjs (modified); row 5 requires a medium finding, and there are none. Row 3 requires a deletion. No match. - Row 7: no no-auto-approve team match.
- Row 8: zero medium findings (<3).
- Row 9: approve.
No source schemas or dist/** semver artifacts touched; changesets correctly scoped as patch. high_risk flag is a look-closer signal only, and the reviewer found nothing actionable on the modified file.
…tries Resolution: - tests/build-schemas-exit-status.test.cjs: main's version, which builds its fixture with tests/helpers/build-schemas-fixture.cjs (adcontextprotocol#9167). - tests/helpers/build-schemas-fixture.cjs: the shared fixture gets this branch's extension registry placeholder (d42f0db), because the build here reads extensions/index.json from source. The two hoist tests that share the helper need it too.
…, certification retry (adcontextprotocol#9196), release-audit changesets (adcontextprotocol#8879), reporting subscriber suspend and resume (adcontextprotocol#9199), inventory goal forecast refusal (adcontextprotocol#9206), enum hoisting annotations (adcontextprotocol#9167), format_option_ref (adcontextprotocol#8876), claim-priority indexes (adcontextprotocol#9219) Two conflicts. Resolution ledger: - semantic: package.json `test` -> union: this branch's chain (the suites it added and the build-cache and git-env steps) plus main's test:build-schemas-hoist-enum-annotations and test:build-schemas-hoist-inside-definitions, after test:build-schemas-exit-status. Every script main's chain runs is in the merged chain. Dependencies auto-merged to main's versions. - semantic: server/src/training-agent/gcs-reporting.ts imports -> union: this branch's narrow `@adcp/sdk/utils` import of canonicalize; main's randomUUID import and its added `@adcp/sdk/server` names. The rest of the file auto-merged. - mechanical: package-lock.json -> main's (auto-merged; this branch does not change it). Checks: npm ci on main's lockfile (SDK 17.0.0-beta.40), npm run typecheck, and the pre-commit hook's full run.
Revised 2026-11-23: The Python SDK job passes again, so its CI note is gone; the fixture note names #9174, which carries the registry change split from #9124.
The bundler's enum hoist gives every occurrence of an enum the annotations of one of them, and both content-based hoists skip
$defsanddefinitionsblocks, so large schemas there stay inline. One commit fixes each; commit 2 only reuses commit 1's test fixture helper.Commit 1: keep call-site annotations beside hoisted enums
resolveRefsmerges keys written beside a$refinto the inlined enum, so an enum's occurrences differ indescription,default,deprecatedorx-*.hoistDuplicateInlineEnumscollapses them into one entry. @bokelley's 64eacbc keptdeprecated,x-deprecated-inandx-removed-inbeside the$ref; every other annotation still moves. Onmain, 1,721 sites in 50 bundles carry an annotation their source does not give them: another field's description, and three leakeddefaultorx-statusvalues.This commit generalizes 64eacbc to every annotation key (
title,description,default,examples,deprecated,enumDescriptions,x-*and the rest). The entry keeps what all occurrences share; each keeps its own annotations beside its$ref. Occurrences share an entry only when all keys that are not annotations match.tests/build-schemas-hoist-enum-annotations.test.cjsbuilds a fixture tree with--rootand checks each site's annotations; one unit expectation changes, since a field's own description now stays beside its$ref.Commit 2: hoist marked schemas and duplicate enums inside definitions
Both hoists skipped the
definitionsthathoistNestedDefsToRootmoves to the bundle root, though only the entry is named; its contents are ordinary schema. #9121 hit this: with the manifest's fields undercreative-manifest.json#/definitions/creative-manifest-base, seven creative bundles grew by about 4 MB each, so #9121 moved them tocore/creative-manifest-base.json. Onmainmerged with the open schema PRs, thatdefinitionslayout bundles to 118.4 MB without this commit and 83.5 MB with it (measured without commit 1).Both passes now look inside each
$defsanddefinitionsentry; the entry itself is still neither counted nor replaced.tests/build-schemas-hoist-inside-definitions.test.cjschecks this through--root; the hoist-marked test that pinned the skip now checks a marker on an entry itself, which is stripped, not hoisted.Proof
Builds at
main(fe24de8b62) and both commits:$refs against bundles built with neither hoist, all 462,708 sites match at both commits fordescription,default,deprecated,enumDescriptions,x-*,titleandexamples.defaultandx-statusleaks.main(50, then 51) was compiled with the repo's configuration (draft-07,allErrors,strict: false,discriminator, ajv-formats) and validated against the 53,081 values of the tool's corpus. No verdict and no error set differs.Measurements
maincreative/list-creatives-response.json, which inlinedAssetVarianttwice underdefinitions/resolvedAssets, goes from 4.14 to 1.65 MB andcreative/sync-creatives-response.jsonfrom 2.95 to 1.40 MB. Commit 1 growsmedia-buy/get-media-buy-delivery-response.jsonmost, 4.20 to 4.43 MB, with the field descriptions it keeps. The MCP projection is byte-identical (56.8 MB), andnpm run test:mcp-schema-projectionpasses.CI
#9174's build reads
extensions/index.jsonfrom the source tree. #9174 adds that file to the exit-status test's fixture, which this PR moves totests/helpers/build-schemas-fixture.cjs; whichever of the two merges second adds it there.