Skip to content

refactor(mix_protocol): export breakpoint bounds as oneOf - #1059

Merged
leoafarias merged 1 commit into
mainfrom
refactor/breakpoint-bounds-oneof
Sep 22, 2026
Merged

leoafarias merged 1 commit into
mainfrom
refactor/breakpoint-bounds-oneof

Conversation

@leoafarias

Copy link
Copy Markdown
Collaborator

Description

_BreakpointBoundsConstraint.toJsonSchema() spelled its either/or as if/then/else wrapped around a not. This replaces it with oneOf:

'oneOf': [
  {'required': ['token']},
  hasBounds,
]

Identical truth table — token alone matches one branch, a width bound alone matches one branch, both match two, neither matches zero — which is exactly what isValid enforces.

Why

The if/then/else form needed a nested negation and a second copy of the hasBounds block per site. The oneOf form needs neither. Net effect on the checked-in goldens:

before after
if / then / else / not 23 each (style), 53 each (chart) 0
oneOf 0 23 / 53
anyOf (style) 302 279

The anyOf drop is exactly the 23 duplicated hasBounds blocks. Baseline had zero oneOf, so nothing was clobbered by the new key.

Verification

  • Every accepted and rejected document is unchanged. tool/schema-check validates all 284 fixtures across the four suites with Ajv: 284/284, same verdicts as before.
  • mix_protocol 404 tests, mix_chart_protocol 15, mix_winds 824 — green. dart analyze clean on all three, dart format clean.
  • Goldens regenerate to exactly what is checked in (melos run schema:fixtures produces no further diff).

mix_chart_protocol is regenerated too, since it shares the codec and its checked-in schema had 53 stale if sites.

One thing that did not change

Ajv still needs strictRequired: false. Its lint does not resolve required against the parent's properties through any applicator branch, so oneOf trips it exactly as if did — I tested enabling it and all three suites still fail to compile. The option stays; its comment now describes the current spelling rather than the old one.

_BreakpointBoundsConstraint spelled its either/or as if/then/else with a
nested not. `oneOf: [{required: [token]}, hasBounds]` has the identical
truth table -- token alone matches one branch, a width bound alone
matches one branch, both match two, neither matches zero -- and drops
the nested negation along with the duplicated anyOf block at each of the
23 style and 53 chart breakpoint sites.

Every accepted and rejected document is unchanged: all 284 checked-in
fixtures across the four suites still validate identically under Ajv.

Ajv still needs strictRequired disabled. Its lint does not resolve
`required` through an applicator branch, so oneOf trips it exactly as if
did; the comment now describes the current spelling instead of the old
one.
@leoafarias
leoafarias merged commit 2281c58 into main Sep 22, 2026
7 checks passed
@leoafarias
leoafarias deleted the refactor/breakpoint-bounds-oneof branch September 22, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant