fix: preserve __origin__ sequences in alias-expanded schemas#3
Merged
reuvenharrison merged 2 commits intov3from Mar 31, 2026
Merged
fix: preserve __origin__ sequences in alias-expanded schemas#3reuvenharrison merged 2 commits intov3from
reuvenharrison merged 2 commits intov3from
Conversation
Previously, __origin__ entries were skipped entirely during alias expansion to prevent inflating aliasCount. This stripped origin data (including sequences.required tracking) from alias-expanded schemas, causing Origin.Sequences to be nil and breaking source navigation for changes like response-property-became-optional. Instead, decode __origin__ entries with aliasDepth temporarily zeroed so they don't count toward aliasCount — the ratio check stays safe and origin data is preserved. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
When origin tracking is enabled and a YAML anchor is referenced via an alias,
the
__origin__metadata injected into the anchor's mapping was being skippedentirely during alias expansion. This prevented any consumer of the decoded
data from knowing where the anchor's fields and sequences were defined.
Root cause
PR #2 introduced a guard to skip
__origin__entries during alias expansion,because re-decoding them through the normal path increments
aliasCount—which can spuriously trigger the excessive-aliasing ratio check on large
documents with many aliases.
The guard was correct in intent but too blunt: it silently dropped all origin
metadata from every alias-expanded mapping.
Fix
Instead of skipping
__origin__entries, decode them withaliasDepthtemporarily set to 0 so they don't count toward
aliasCount. Theratio check stays safe, and the origin data (keys, field locations, and
sequence-item locations) is preserved in the decoded output.
Test plan
TestOrigin_ManyAliasesNoExcessiveAliasingstill passes — 5000 aliasesof a 20-property anchor no longer trigger "document contains excessive
aliasing" (aliasCount stays below the threshold because
__origin__decodesare excluded from the count)
TestOrigin_AliasPreservesSequences(new) — verifies that after aliasexpansion the decoded map contains
__origin__with a populatedsequencessub-map, confirming that sequence-item location data is preserved
🤖 Generated with Claude Code