Skip to content

ci(changesets): refuse breaking work until a minor is scheduled - #6889

Merged
cixzhang merged 1 commit into
mainfrom
enforce-release-target
Oct 2, 2026
Merged

cixzhang merged 1 commit into
mainfrom
enforce-release-target

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Rewritten and rebased. An earlier revision enforced a frozen .changeset/minor-plan.json with cleanup and lifecycle ids. That file and its module are deleted. This revision is two states and one tiny file. Base retargeted to main now that #6887 has merged (ebd939b).

Implements #6888. Land that first; this is its mechanism.

Maintainer impact

The publishable packages are a fixed group, so one [breaking] Changeset moves every package to a new minor. Nothing checked that at merge time, so a release could change shape without the owner deciding it — the release owner found out at cut time, with the work already on main.

Intended invariant

spec:AST-017 FR46–FR50 (#6888):

main targets a PATCH by default   ->  incompatible work is refused
an owner SCHEDULES a minor first  ->  incompatible work may land

Nothing about the authoring vocabulary changes: the [category] set, the category↔bump coupling, and every existing check behave exactly as before.

Change

One pure module plus a call site in the existing pnpm check:changesets, which already runs inside check:repo and lint:strict. No new workflow, no new CI job.

The schedule is .release/target.json with exactly two fields:

{
  "version": "0.7.0",
  "scheduledFor": "2026-12-01"
}

Why .release/: it is already this repository's release-intent namespace — scripts/release/active-release.mjs keeps active.json and plan.json there on a release branch. But nothing resident on main said what main is heading for (.release/ is untracked on main), so this adds the one small file that does. It cannot collide: active-release.mjs guards only on those two file names. The file is tracked, so scheduling a minor is a reviewable one-file commit.

Order is enforced. Pending Changesets never set the mode — the entry being judged cannot be its own authorization. That is the circularity that would let a release retarget itself.

Scope is one question. No per-change record, no cleanup or lifecycle ids, no second approval path, no manifest. FR28's deprecation lifecycle, FR31's cleanup mapping, FR37's release planning, and ordinary review continue on their own terms and are not enforced here. The base version is read only when a schedule exists or incompatible work is pending, so the gate stays quiet about state that is not its business.

Generic by construction. No version, package, surface, or contributor appears in the source; a test asserts the refusal text contains none either, and the fixtures use arbitrary versions (1.2.3).

Evidence

End to end against the merged main tree:

tree result
no schedule ✅ main targets a patch (published at 0.6.4)
+ a [breaking] Changeset ❌ refused, with the FR50 remediation text
+ schedule 0.7.0 for a future day ✅ main targets 0.7.0, a minor scheduled for 2026-12-01
schedule expired ❌ fail closed
schedule names 0.8.0 ❌ fail closed — next minor is 0.7.0
schedule carries an extra field ❌ fail closed

The refusal:

cli-remove-layout-command.md: this entry is incompatible, and main is targeting 0.6.5 — a patch.
      The published packages release together, so admitting it would move all of
      them to 0.7.0.
      Either keep the release patch-compatible: leave the released surface working
      and deprecate it instead (AST-017 FR28) — ship the replacement, keep old usage
      equivalent, and take the patch bump; the removal lands once a minor is
      scheduled.
      Or schedule that minor first (AST-017 FR47): a release owner adds
      .release/target.json with the target version and the day it is scheduled for.
  • Failure before the change: node scripts/check-changesets.mjs reported changesets valid and said nothing about the release silently becoming a minor.
  • Success after: the same command prints the mode on success and refuses incompatible work under the patch default.
  • Product/runtime behavior verified unchanged: no published package is touched; all existing check-changesets tests pass untouched.

Narrow test cases (21)

Denied: [breaking] under the patch default · a minor bump with a non-breaking category · schedule with an extra field · malformed version · malformed day · an impossible day (2026-02-30, which Date.parse silently rolls forward — caught by a round-trip check) · a version that is not the minor successor · an expired day · disagreeing published versions · a canary identifier read as the published version.

Allowed: compatible work under the default · no Changesets at all · a scheduled minor admitting one or several breaking entries with no per-change record · the scheduled day itself.

Also covered: returning to the patch default when the schedule is removed; the gate staying silent about the published version when nothing asks.

Two real bugs were found by these tests during development and fixed: the impossible-date rollover above, and (in the superseded revision) a plan that went unvalidated when nothing incompatible was pending.

Scope

Testing

npx vitest run --root . scripts/    # 1512 passed, 83 files (21 new cases)
pnpm check:repo                     # passes

CONTRIBUTING.md gains the same rule where version bumps are already explained, including that contributors never author the schedule or decide it — they state intent and a maintainer handles it.

@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 2, 2026 4:23pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 2, 2026
@astracat-bot

astracat-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 2, 2026, 4:46 PM UTC

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for closing the silent-retarget gap — deriving the target from the tree and refusing with both remedies spelled out is the right shape, and the one-to-one cleanup mapping in both directions is well tested.

Approval needs a maintainer decision first. Current spec requires a frozen, owner-approved plan before a removal ships, but it does not yet establish the derived-target admission rule or .changeset/minor-plan.json as that plan's record, and the proposed spec update for the rule has not landed. A maintainer needs to settle both: approve or land the governing spec for the gate, and confirm the plan file and its schema as the frozen-plan record (or name the record that governs instead). No rewrite is being asked for on that point — the mechanism can stand as proposed once the authority is settled.

Independent of that decision, three gate bypasses need fixes before this can merge:

  • A lone breaking Changeset declared with no bump currently passes both validators instead of being refused.
  • A plan file that is present is skipped entirely on trees with no pending bump, so an invalid plan can sit unchecked — the case the change sets out to prevent.
  • A major bump is admitted by the new gate without any plan; only the separate 0.x check catches it today.

The refusal message should also name which signal fired (the breaking category or the declared bump) so contributors know which field to fix.

[Automated review]

Implements `spec:AST-017` FR46-FR50 inside the existing authoritative gate,
`pnpm check:changesets`, which already runs in `check:repo` and
`lint:strict`. No new workflow and no new CI job.

The publishable packages are a `fixed` group, so one `[breaking]` Changeset
moves every package to a new minor. Nothing checked that at merge time, so
a release could change shape without the owner deciding it.

The rule is two states:

  main targets a PATCH by default   -> incompatible work is refused
  an owner SCHEDULES a minor first  -> incompatible work may land

The schedule is `.release/target.json`, carrying exactly `version` and
`scheduledFor` and nothing else. `.release/` is already this repository's
release-intent namespace — `active-release.mjs` keeps `active.json` and
`plan.json` there on a release branch — but nothing resident on main said
what main is heading for, so this adds the one small file that does. It
cannot collide: `active-release.mjs` guards only on those two file names.

Order matters and is enforced: pending Changesets never set the mode. The
entry being judged cannot be its own authorization, which is the
circularity that would let a release retarget itself.

Fail-closed. The schedule is refused, and main stays on its patch default,
when it is malformed, carries any field beyond the two, names a version
that is not the minor successor of the published version, has a day that
has passed, or cannot be checked because the published packages disagree. A
prerelease or canary identifier is never read as the published version.
Returning to the default is just deleting the file.

Scope is one question. No per-change record, no cleanup or lifecycle ids,
no second approval path, no manifest. FR28's deprecation lifecycle, FR31's
cleanup mapping, FR37's release planning, and ordinary review continue on
their own terms and are not enforced here. The base version is read only
when a schedule exists or incompatible work is pending, so this gate stays
quiet about state that is not its business.

Generic: no version, package, surface, or contributor is named in the
source, and a test asserts the refusal text contains none either.

Replaces the earlier derived-target implementation, which computed the
target from pending bumps and enforced a frozen `.changeset/minor-plan.json`
with cleanup-id mapping. That file and its module are gone.

Test plan:
- `npx vitest run --root . scripts/` — 1512 passed, 83 files, including 21
  cases in scripts/release-admission.test.mjs
- `pnpm check:repo` — passes
- end to end against the merged main tree:
  - no schedule                      -> pass, "main targets a patch (published at 0.6.4)"
  - + a [breaking] Changeset         -> fail, with the FR50 remediation text
  - + schedule 0.7.0 for a future day -> pass, "main targets 0.7.0, a minor scheduled for ..."
  - schedule expired                 -> fail closed
  - schedule names 0.8.0             -> fail closed (next minor is 0.7.0)
  - schedule carries an extra field  -> fail closed
@cixzhang
cixzhang force-pushed the enforce-release-target branch from f874e22 to 291da70 Compare October 2, 2026 16:14
@cixzhang
cixzhang changed the base branch from restore-layout-command to main October 2, 2026 16:14
@cixzhang cixzhang changed the title ci(changesets): refuse incompatible work while the release targets a patch ci(changesets): refuse breaking work until a minor is scheduled Oct 2, 2026
@cixzhang cixzhang closed this Oct 2, 2026
@cixzhang cixzhang reopened this Oct 2, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rewriting this down to two states and one tiny file — and for fixing the two bypasses from the earlier revision: a [breaking] entry with no bump is now refused by its category, and a schedule that is present is now validated even when nothing incompatible is pending. The refusal naming the target version and both ways forward is exactly what a contributor who has never read the spec needs.

Approval needs a maintainer decision first. The current spec requires a frozen, owner-approved plan before a removal ships, but it does not yet establish the patch-default admission rule, and the proposed spec update for that rule has not landed. A maintainer needs to settle both parts: land or approve the governing spec for the gate, and confirm .release/target.json with exactly version and scheduledFor as the schedule statement that spec governs (distinct from the fuller minor plan the current spec describes). No rewrite is being asked for on that point — the mechanism can stand as proposed once the authority is settled.

Independent of that decision, a few fail-closed edges need fixes before this can merge:

  • The admission check itself lets a major bump through (it reads [breaking] or minor only); the separate 0.x ban catches that shape today, but the gate should not depend on it, especially past 1.0.
  • A member of the fixed publishing group with no version in the map is silently skipped when deriving the shared base, so a schedule can be checked against a partial group.
  • A schedule file containing JSON null is treated as if the file were absent and passes silently, while other unreadable schedules are correctly reported.

Adding tests for those three shapes (and one locking in the breaking-with-no-bump refusal) would close them out.

[Automated review]

@cixzhang
cixzhang merged commit 5e0f026 into main Oct 2, 2026
46 checks passed
@github-actions
github-actions Bot deleted the enforce-release-target branch October 3, 2026 06:24

This branch was successfully deployed

1 active deployment
Preview — 291da70d Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant