fix(normalize): keep portable schema IDs stable across unrelated root edits - #131
Merged
Merged
Conversation
The primary schema resource label was derived from a digest of the whole root document, and referenced resource labels are seeded from their parent label, so any unrelated root edit (info.version, a description) rotated every schema ID in generated output. Label the primary resource "root". Generated schema IDs are scoped to one module's Spec, and the "external-" and "resource-" prefixes cannot collide with the constant label. An external resource label still depends on the first reference site that reaches it in sort order, so adding a reference to it at an earlier-sorting location can relabel it. Fixes #117
tanmaykm
marked this pull request as ready for review
October 1, 2026 06:03
nkottary
approved these changes
Oct 1, 2026
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.
Fixes #117.
The primary schema resource label was
"root-" * <digest of the whole root document>. In a single-file spec, every component schema lives under that resource. External labels are seeded from their parent's label, so any unrelated root edit, such asinfo.versionor a description, rotated every ID in_SCHEMA_RESOURCE_DATA. That produced very large diffs in committed generated code.The primary resource is now labelled
"root". The schema IDs are scoped to each generated module'sSpec, and theexternal-andresource-prefixes cannot collide with the constant label. Determinism and uniqueness are unchanged. Already-generated modules keep working, and regenerating changes their IDs once.Tests
test/references.jl. For single-file and multi-file specs, it editsinfoand checks that the schema IDs and the emitted source are unchanged, except for the header and the embedded root document. This test fails onmain.OPENAPI_CORPUS_TESTS=all) passes 32/32 on 1.12.Known limitation (reviewer note, not addressed here)
An
external-label is still seeded from the parent label, the reference-site pointer and the keyword. Renaming the location that references an external file, or adding an earlier-sorting reference to it, still relabels that file and anything reachable below it. Changes to the external schema's own content do not. The issue offers seeding on the target's content digest as an alternative, which would need collision suffixes. That can be a follow-up if needed.