fix(schema): include async response refs in release bundles#5166
Merged
Conversation
Contributor
There was a problem hiding this comment.
LGTM. Forward-only fix with the right shape: SDK loader cooperation moves upstream into the published bundle instead of living only in stage-sdk-schema-bundle.sh.
Things I checked
copyAsyncResponseRefsToCoreatscripts/build-schemas.cjs:1021-1057— walk is contained totargetDir, skip predicates forbundled/and the destinationcore/async-response-refs/exit recursion cleanly, thecore/file-prefix skip is belt-and-suspenders (basename regex already filters), idempotent via pre-delete +ensureDir. No path-traversal surface.- No double-bundling.
generateBundledSchemasreads fromSOURCE_DIR(see callers atscripts/build-schemas.cjs:1899,:1922,:1983), so duplicated files intargetDir/core/async-response-refs/are never seen by the bundler. - Call sites: release branch (
:1921), latest-after-release (:1955), dev/latest (:2009). All three call aftercopyAndTransformSchemasand beforegenerateBundledSchemas. Correct ordering. npm testwiring: defined once atpackage.json:71, included once in the aggregate chain at:88, placed next to the otherbuild-schemas-*tests.- Changeset is
patch. Consistent with.changeset/prepare-3-1-rc-mode.mdprecedent for release-process changes. Perdocs/reference/versioning.mdx, this adds no new$ids, fields, tools, or enum values — patch is the right tier. 3.1.0-rc.1immutability preserved. Forward-only to3.1.0-rc.2.audit-oneof.mjsonly walksstatic/schemas/source/and inspectsoneOfstructure — unaffected. In-repo validators (tests/json-schema-validation.test.cjs:116,tests/canonical-fixture-validation.test.cjs:73) already tolerate duplicate$idregistration.- Test at
tests/build-schemas-async-response-refs.test.cjsfaithfully simulates the @adcp/client 8.1.0-beta.12 loader pattern —isOriginalAsyncResponsemirrors the skip list, refs are registered undercore/async-response-refs/, target compiles. Tmp cleanup viafinally+rmSync(..., { recursive: true, force: true }).
Follow-ups (non-blocking — file as issues)
- Third-party validator duplicate-
$idexposure. The mitigation co-locates dupes under a path the SDK loader treats as fragments — it's a soft contract that relies on consumer cooperation, not on the bundle being self-consistent. Naive validators (Pythonjsonschema, Gogojsonschema,ajv-cliin strict mode) that walk the published bundle and unconditionally register every.jsonwill throw on the second$idregistration. Worth a one-line aside indocs/reference/release-notes.mdxfor3.1.0-rc.2clarifying thatcore/async-response-refs/is a redundant SDK-compat directory, not a new schema namespace — the registry isn't auto-enumerated from disk so the new dir won't appear inindex.json, and that asymmetry is the exact thing implementers will need explained. - Test exercises a synthetic fixture, not the real pipeline. Current test hand-rolls schemas under a tmp dir; it doesn't run
copyAndTransformSchemas→copyAsyncResponseRefsToCoreend-to-end. If anyone adds a post-copy transform between those two steps later, copies could silently diverge from originals. A follow-up assertion that walks the actualdist/schemas/{version}/output and confirmsJSON.parse(original) deepEqual JSON.parse(copy)for each duplicated file would close that gap. - Sunset tracking. Carrying a permanent shadow directory of every async-response schema is a smell. File a tracking issue to rip this out when the SDK loader stops skipping response-tool files, or when
core/async-response-data.jsonis restructured to not$reftool response schemas directly. Pin it to a 4.0 milestone.
Minor nits (non-blocking)
- Inconsistent success logging across call sites. Release branch logs the count (
scripts/build-schemas.cjs:1922-1923), dev/latest branch logs the count (:2009-2010), but the latest-after-release branch at:1955calls silently. Cosmetic, but a future reader will wonder why the middle call site is quieter than its siblings. - Walks into
core/unnecessarily. The directory walk descends intocore/and relies on the basename regex + file-prefix skip to drop everything inside. A directory-skip oncore/would be marginally tidier. Trivial.
Approving. Forward-only RC cut is the right path; once 3.1.0-rc.2 ships, the staging shell script becomes belt-and-suspenders rather than load-bearing.
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.
Summary
Fixes the schema release build so generated bundles include
core/async-response-refs/copies of async response schemas. This lets SDK/compliance validators pre-register async response refs before compilingcore/async-response-data.json, even when original*-async-response-*tool response files are skipped during core pre-registration.This is forward-only: existing exact-version bundles such as
3.1.0-rc.1remain immutable. The patch changeset should cause the next Version Packages cut to publish3.1.0-rc.2with the corrected bundle.Changes
copyAsyncResponseRefsToCore()toscripts/build-schemas.cjsand run it for release and latest schema builds.core/async-response-refs/.npm test.Validation
npm run test:build-schemas-async-response-refsnpm run build:schemasnpm run test:schemastest:unit,test:test-dynamic-imports,test:callapi-state-change,typecheckRefs #5161