An open source design system that's fully customizable and agent ready
TypeScript
fix(release): allow pending merge-back equality
Cindy Zhang5256f1cc8fed
diff --git a/docs/specs/AST-017/spec.md b/docs/specs/AST-017/spec.mdindex e19058396c..3c58230b52 100644--- a/docs/specs/AST-017/spec.md+++ b/docs/specs/AST-017/spec.md@@ -587,10 +587,13 @@ one removal merged ahead of the decision to allow it.branch remains bound to its cut declaration. While that cut is active and its stabletag does not yet exist, the active cut version is an additional floor: main'sdeclaration may stay equal to it or rise, but MUST NOT be lowered below it. Once the- tag exists, the ordinary strict-above-stable rule applies except to FR50's trusted- merge-back path. The declaration MUST otherwise remain a plain- version strictly greater than the newest stable `vX.Y.Z` tag except for the trusted- release-return equality described by FR50–FR51. For example, after `v0.6.7`, changing+ tag exists, the ordinary strict-above-stable rule applies except while that exact+ published branch's merge-back is still pending: the tag and active branch MUST name+ the same commit and every frozen Changeset MUST remain byte-identical on main. That+ narrow equality window closes when merge-back consumes those Changesets. The+ declaration MUST otherwise remain a plain version strictly greater than the newest+ stable `vX.Y.Z` tag except for the trusted release-return equality described by+ FR50–FR51. For example, after `v0.6.7`, changing`0.7.0` to `0.6.8` is valid only when no pending `[breaking]` Changeset would becomeinadmissible; the lowering pull request itself MUST be refused otherwise. Changing theplan to `0.6.7` or lower is not valid. When main has not advanced before merge-back,@@ -598,12 +601,12 @@ one removal merged ahead of the decision to allow it.FR50 until FR51's required next-plan change. Main publishes only canaries, versioned`<declared version>-canary.<commit>`, and MUST NOT publish a canary from that equalitystate. Pull-request checks on main compare the declaration with the newest stable tag,- refuse a version at or below that tag or a split fixed group except for the trusted- release-return path, refuse a pending `[breaking]` Changeset while the declaration is- a patch, admit that category while the declaration is the minor successor, validate- merge-back under FR50 and the next-plan change under FR51, and validate every other- Changeset's format, category, bump, and coverage. Pending Changesets do not derive or- promote the release version.+ admit equality only during that exact frozen merge-back window, refuse every other+ version at or below the tag or a split fixed group, refuse a pending `[breaking]`+ Changeset while the declaration is a patch, admit that category while the declaration is+ the minor successor, validate merge-back under FR50 and the next-plan change under FR51,+ and validate every other Changeset's format, category, bump, and coverage. Pending+ Changesets do not derive or promote the release version.- **FR47 — A release branch releases the declared version.** A release branch'sversion is the fixed-group version declared at its cut commit. Admission, therelease plan, Changeset consumption, changelog generation, and stablediff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.mdindex be28bfab4f..a192dc253a 100644--- a/docs/specs/AST-030/spec.md+++ b/docs/specs/AST-030/spec.md@@ -116,7 +116,9 @@ they are separately named.and `lint` MUST continue to report on every pull request through their existingjobs or join jobs. A specialized lane skips owned steps inside those jobs; itdoes not remove historical required contexts. Any owned lane failure MUST fail- its join.+ its join. The required lint context MAY admit main's published-version equality+ only when trusted release authority proves the exact frozen merge-back is still+ pending; the context still runs and fails closed outside that window.- **FR8 — Initial tooling admissions.** `node-tooling` covers`scripts/score-ledger.mjs`, `scripts/score-ledger.test.mjs`,`internal/scripts/`, and `.github/workflows/crowdin-upload.yml`. It runs thediff --git a/scripts/release/active-release.mjs b/scripts/release/active-release.mjsindex 9ff0bab912..66e7f40799 100644--- a/scripts/release/active-release.mjs+++ b/scripts/release/active-release.mjs@@ -843,6 +843,36 @@ function validateReleaseMergeBack({return errors;}+/**+ * The published-equality window exists only while the immutable release still+ * has one exact active branch and every frozen Changeset remains on main for+ * the pending merge-back to consume.+ */+function pendingMergeBackVersion({+ releasedVersion,+ activeBranches,+ marker,+ plan,+ releaseHead,+ branchHead,+ baseChangesets,+}) {+ if (+ !VERSION_RE.test(releasedVersion ?? '') ||+ activeBranches.length !== 1 ||+ marker?.state !== 'active' ||+ marker.version !== releasedVersion ||+ marker.branch !== activeBranches[0] ||+ releaseHead !== branchHead ||+ validateIdentity(marker, plan).length > 0 ||+ plan.changesets.some(+ entry => baseChangesets.get(entry.path) !== entry.sha256,+ )+ )+ return null;+ return releasedVersion;+}+/*** FR46/FR51 — main's fixed-group version on a pull request into main.*@@ -855,6 +885,7 @@ function validateReleaseMergeBack({* @param {string[]} input.fixed trusted fixed-group package names* @param {string} input.releasedVersion newest stable vX.Y.Z tag, without v* @param {string|null} [input.activeCutVersion] single active untagged/ongoing cut+ * @param {string|null} [input.pendingMergeBackVersion] exact published version whose frozen Changesets remain on main* @param {Map<string, object|null>} input.baseManifests name -> manifest at base* @param {Map<string, object|null>} input.headManifests name -> manifest at head* @returns {string[]}@@ -863,6 +894,7 @@ function validateMainVersions({fixed,releasedVersion,activeCutVersion = null,+ pendingMergeBackVersion = null,baseManifests = new Map(),headManifests,}) {@@ -897,7 +929,13 @@ function validateMainVersions({const order = VERSION_RE.test(releasedVersion ?? '')? compareVersions(declaredVersion, releasedVersion): null;- if (order === null || order <= 0)+ const publishedEqualityIsPending =+ order === 0 && pendingMergeBackVersion === releasedVersion;+ if (+ order === null ||+ order < 0 ||+ (order === 0 && !publishedEqualityIsPending)+ )errors.push(`main declares ${declaredVersion}; it must stay strictly above newest stable v${releasedVersion}`,);@@ -1224,6 +1262,28 @@ async function main() {activeBranches.length === 1? markerAtRef(root, `origin/${activeBranches[0]}`).version: null;+ let pendingMergeBack = null;+ if (+ releasedVersion &&+ activeBranches.length === 1 &&+ activeCutVersion === releasedVersion+ ) {+ const releaseTag = `v${releasedVersion}`;+ const branch = activeBranches[0];+ const marker = markerAtRef(root, releaseTag);+ const plan = JSON.parse(+ git(root, ['show', `${releaseTag}:${RELEASE_DIR}/${PLAN_FILE}`]),+ );+ pendingMergeBack = pendingMergeBackVersion({+ releasedVersion,+ activeBranches,+ marker,+ plan,+ releaseHead: git(root, ['rev-parse', releaseTag]),+ branchHead: git(root, ['rev-parse', `origin/${branch}`]),+ baseChangesets: changesetMapAtRef(root, base),+ });+ }const errors = [];if (activeBranches.length > 1)errors.push(@@ -1234,6 +1294,7 @@ async function main() {fixed: (config.fixed ?? []).flat(),releasedVersion,activeCutVersion,+ pendingMergeBackVersion: pendingMergeBack,baseManifests: packageManifestsByName(file => jsonAtRef(root, base, file),root,@@ -1246,7 +1307,13 @@ async function main() {);if (errors.length) throw new Error(errors.join('\n'));console.log(- JSON.stringify({base, releasedVersion, activeCutVersion, valid: true}),+ JSON.stringify({+ base,+ releasedVersion,+ activeCutVersion,+ pendingMergeBackVersion: pendingMergeBack,+ valid: true,+ }),);return;}@@ -1419,6 +1486,7 @@ export {computePlanDigest,declaredVersionAtRef,nextPlannedVersion,+ pendingMergeBackVersion,isStableReleasePackage,latestStableVersion,listActiveBranches,diff --git a/scripts/release/active-release.test.mjs b/scripts/release/active-release.test.mjsindex cc63c54e1b..0df9d0c2d5 100644--- a/scripts/release/active-release.test.mjs+++ b/scripts/release/active-release.test.mjs@@ -20,6 +20,7 @@ import {declaredVersionAtRef,latestStableVersion,nextPlannedVersion,+ pendingMergeBackVersion,validateMainVersions,validateReleaseDiff,validateReleaseMergeBack,@@ -783,11 +784,13 @@ describe('main pull requests keep the declared version above newest stable (FR46head,releasedVersion = '0.6.7',activeCutVersion = null,+ pendingMergeBack = null,) =>validateMainVersions({fixed,releasedVersion,activeCutVersion,+ pendingMergeBackVersion: pendingMergeBack,baseManifests: base,headManifests: head,});@@ -808,6 +811,57 @@ describe('main pull requests keep the declared version above newest stable (FR46);});+ it('allows published equality only while the exact frozen merge-back is pending', () => {+ expect(check(at('0.6.8'), at('0.6.8'), '0.6.8', '0.6.8', '0.6.8')).toEqual(+ [],+ );+ expect(check(at('0.6.8'), at('0.6.8'), '0.6.8', '0.6.8')).toContain(+ 'main declares 0.6.8; it must stay strictly above newest stable v0.6.8',+ );+ expect(+ check(at('0.6.8'), at('0.6.8'), '0.6.8', '0.6.8', '0.6.7'),+ ).toContain(+ 'main declares 0.6.8; it must stay strictly above newest stable v0.6.8',+ );+ });++ it('proves the pending window from exact authority and every frozen Changeset', () => {+ const plan = {+ schemaVersion: 2,+ version: '0.6.8',+ branch: 'release/v0.6.8',+ cutSha: 'a'.repeat(40),+ changesets: [+ {+ path: '.changeset/frozen.md',+ sha256: 'b'.repeat(64),+ packages: [{name: '@astryxdesign/core', bump: 'patch'}],+ category: 'fix',+ headline: 'Fix it',+ contributors: ['person'],+ body: '',+ },+ ],+ };+ const marker = buildMarker(plan);+ const input = {+ releasedVersion: '0.6.8',+ activeBranches: ['release/v0.6.8'],+ marker,+ plan,+ releaseHead: 'c'.repeat(40),+ branchHead: 'c'.repeat(40),+ baseChangesets: new Map([['.changeset/frozen.md', 'b'.repeat(64)]]),+ };+ expect(pendingMergeBackVersion(input)).toBe('0.6.8');+ expect(+ pendingMergeBackVersion({...input, baseChangesets: new Map()}),+ ).toBeNull();+ expect(+ pendingMergeBackVersion({...input, branchHead: 'd'.repeat(40)}),+ ).toBeNull();+ });+it('admits only patch or minor successor as the first plan after merge-back', () => {expect(check(at('0.6.7'), at('0.6.8'))).toEqual([]);expect(check(at('0.6.7'), at('0.7.0'))).toEqual([]);