ci(schemas): add oneOf discriminator audit + baseline (adcp#3917) - #3922
Merged
Conversation
scripts/audit-oneof.mjs walks static/schemas/source/ and classifies every oneOf as discriminated, structurally narrowable, dangerous, or scalar. CI runs the script in --check mode against scripts/oneof-discriminators.baseline.json and fails on any new undiscriminated union or any regression in an existing one. Run --update to ratchet the baseline after fixes land. No spec changes; this only freezes current state so the unfixed unions listed on adcp#3917 cannot grow while we work through them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Containment guard in resolveRef: refuse refs that escape static/schemas/source - --file <path> flag for iterating on one schema locally - --update refuses new undiscriminated entries unless --accept-new is also passed, to prevent silently ratcheting in regressions - Sharper --check failure message: names two discriminator patterns + example schemas, plus pointers to npm scripts - audit:oneof npm alias for the human report mode - Header notes the one-hop ref-resolution and allOf-wrapping limitations Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
18 tasks
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
scripts/audit-oneof.mjswalks every JSON schema understatic/schemas/source/and classifies everyoneOfas discriminated / structurally narrowable / dangerous / scalar — same walker that produced the audit on spec(adcp): discriminator audit — every oneOf needs a discriminator key + CI assertion #3917.scripts/oneof-discriminators.baseline.jsonsnapshots the current state (60 undiscriminated unions: 22 dangerous, 38 narrowable). Discriminated and scalar oneOfs are not stored.npm run test:oneof-discriminatorsand the Build Check workflow. CI fails if a new undiscriminatedoneOfappears or an existing one regresses to a worse status. Improvements are accepted silently and surface in the diff so they get ratcheted on the next--update.node scripts/audit-oneof.mjsfor a human report,--jsonfor raw rows,--checkfor the gate,--updateto refresh the baseline.This is the first step in the plan from #3917: lock current state so the unfixed unions can't grow while we work through them. Spec fixes (hoisting
asset_type/modeldiscriminators, fixing the genuine bugs incompliance/comply-test-controller-response.jsonetc., theAccountReferencekindadd) come in follow-up PRs.Test plan
node scripts/audit-oneof.mjsprints 108 occurrences across 524 files, 22 ✗ / 38 ⚠ / 36 ✓ / 12 scalarnpm run test:oneof-discriminatorspasses against the committed baseline--checkto fail with a clear error pointing at the ✗ entry and linking back to spec(adcp): discriminator audit — every oneOf needs a discriminator key + CI assertion #3917--updateregenerates the baseline deterministically (sorted keys)🤖 Generated with Claude Code