Skip to content

ci(schemas): add oneOf discriminator audit + baseline (adcp#3917) - #3922

Merged
bokelley merged 2 commits into
mainfrom
bokelley/pr-3917
May 3, 2026
Merged

ci(schemas): add oneOf discriminator audit + baseline (adcp#3917)#3922
bokelley merged 2 commits into
mainfrom
bokelley/pr-3917

Conversation

@bokelley

@bokelley bokelley commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New scripts/audit-oneof.mjs walks every JSON schema under static/schemas/source/ and classifies every oneOf as 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.
  • New scripts/oneof-discriminators.baseline.json snapshots the current state (60 undiscriminated unions: 22 dangerous, 38 narrowable). Discriminated and scalar oneOfs are not stored.
  • Wired into npm run test:oneof-discriminators and the Build Check workflow. CI fails if a new undiscriminated oneOf appears 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.
  • Run node scripts/audit-oneof.mjs for a human report, --json for raw rows, --check for the gate, --update to 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 / model discriminators, fixing the genuine bugs in compliance/comply-test-controller-response.json etc., the AccountReference kind add) come in follow-up PRs.

Test plan

  • node scripts/audit-oneof.mjs prints 108 occurrences across 524 files, 22 ✗ / 38 ⚠ / 36 ✓ / 12 scalar
  • npm run test:oneof-discriminators passes against the committed baseline
  • Manual regression test: deleting a baseline entry causes --check to 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
  • --update regenerates the baseline deterministically (sorted keys)
  • CI green on this PR

🤖 Generated with Claude Code

bokelley and others added 2 commits May 2, 2026 21:27
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>
@bokelley
bokelley merged commit d55a406 into main May 3, 2026
20 checks passed
@bokelley
bokelley deleted the bokelley/pr-3917 branch May 3, 2026 02:12
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.

1 participant