Skip to content

fix(build): keep call-site annotations on hoisted enums, and hoist inside definitions - #9167

Merged
bokelley merged 2 commits into
adcontextprotocol:mainfrom
KonstantinMirin:build/hoist-inside-definitions
Nov 24, 2026
Merged

bokelley merged 2 commits into
adcontextprotocol:mainfrom
KonstantinMirin:build/hoist-inside-definitions

Conversation

@KonstantinMirin

@KonstantinMirin KonstantinMirin commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

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 $defs and definitions blocks, 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

resolveRefs merges keys written beside a $ref into the inlined enum, so an enum's occurrences differ in description, default, deprecated or x-*. hoistDuplicateInlineEnums collapses them into one entry. @bokelley's 64eacbc kept deprecated, x-deprecated-in and x-removed-in beside the $ref; every other annotation still moves. On main, 1,721 sites in 50 bundles carry an annotation their source does not give them: another field's description, and three leaked default or x-status values.

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.cjs builds a fixture tree with --root and 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 definitions that hoistNestedDefsToRoot moves to the bundle root, though only the entry is named; its contents are ordinary schema. #9121 hit this: with the manifest's fields under creative-manifest.json#/definitions/creative-manifest-base, seven creative bundles grew by about 4 MB each, so #9121 moved them to core/creative-manifest-base.json. On main merged with the open schema PRs, that definitions layout bundles to 118.4 MB without this commit and 83.5 MB with it (measured without commit 1).

Both passes now look inside each $defs and definitions entry; the entry itself is still neither counted nor replaced. tests/build-schemas-hoist-inside-definitions.test.cjs checks 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:

  • Annotations. Walked site by site through local $refs against bundles built with neither hoist, all 462,708 sites match at both commits for description, default, deprecated, enumDescriptions, x-*, title and examples.
  • verify-build (build(schemas): prove what a schema change does to valid payloads #9119): proof class 1, no differences, over 1,237 root pairs at both commits. Its informational channel loses the default and x-status leaks.
  • Ajv. Each bundle that differs from 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

Build Bundled total Bundles changed vs. previous row
main 87.0 MB
Commit 1 87.4 MB (+0.4%) 50 of 124
Commit 2 83.3 MB (−4.7%) 29 of 124

creative/list-creatives-response.json, which inlined AssetVariant twice under definitions/resolvedAssets, goes from 4.14 to 1.65 MB and creative/sync-creatives-response.json from 2.95 to 1.40 MB. Commit 1 grows media-buy/get-media-buy-delivery-response.json most, 4.20 to 4.43 MB, with the field descriptions it keeps. The MCP projection is byte-identical (56.8 MB), and npm run test:mcp-schema-projection passes.

CI

#9174's build reads extensions/index.json from the source tree. #9174 adds that file to the exit-status test's fixture, which this PR moves to tests/helpers/build-schemas-fixture.cjs; whichever of the two merges second adds it there.

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.
@mintlify

mintlify Bot commented Nov 22, 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 e5be393.

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: 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_risk is true but the only reason is scripts/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.

@bokelley
bokelley merged commit dd72a50 into adcontextprotocol:main Nov 24, 2026
65 checks passed
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 25, 2026
…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.
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 25, 2026
…, 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.
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.

2 participants