Repository navigation
fix(release-cut): gate an explicit RC against its own series - #10525
Conversation
semver_gt compares through strip_pre(), so the explicit-version override only ever checked the stable line: 1.4.156-rc.0 read as 1.4.156, cleared a 1.4.155 stable, and republished an RC below what clients already run. Anchor a prerelease request on highest_rc_for_base -- the same rc history the kind path uses -- so the override can only advance the series. Two sibling gaps in the same block: - version_suffix was silently dropped when version was set, because the append lives in the kind branch the override skips. - the shape regex rejected X.Y.Z-rc.N.suffix, so a suffixed RC the rc path can produce could never be re-cut explicitly.
📝 WalkthroughWalkthroughThe release workflow adds shared alphanumeric validation for version suffixes, expands accepted explicit rc version formats, and documents rc numbering constraints. Explicit rc overrides now compare their rc number with the highest previously cut rc for the same base and reject non-increasing values. Suffix validation is also reused in the computed rc version path. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 96222b03-62c0-4adb-a4bd-4b10cd2f7bf2
📒 Files selected for processing (1)
.github/workflows/release-cut.yml
…pares The new explicit-rc gate compares with `[[ -le ]]`, i.e. bash machine-width integers, and the author closed only the low end. Past INTMAX bash saturates, so `version=1.4.156-rc.99999999999999999999` reads as "above the published rc.3" and the gate falls open — then the tag it cuts pins highest_rc_for_base at 1e20 for that base forever, and every later cut wraps to a lower rc the fleet never updates to. Bound the rc number to nine digits. Also reject leading zeros on an all-digit prerelease identifier. `npm version` renormalizes rc.4.01 to rc.4.1 while the tag step keeps the literal input, so the shipped package.json version and its own release tag name different releases. The explicit path's embedded identifier now goes through the same validator the kind path uses instead of only the shape regex.
CodeRabbit triageThree CodeRabbit items on this PR. Recording the disposition of each so none is silently dropped. 1. Bound RC numbers before Bash math ( Confirmed on bash 5.2 (the runner version): 2. Reject leading-zero numeric suffixes (
3. Pre-merge "Description check" warning — DECLINED. The check asks for the
The |
…ong series kind=rc derives its base from bump(latest_stable, patch), so the remedy the refusal suggested only works when the requested base *is* that next patch. A 1.5.0-rc.N series exists only because this override created it, so an operator resuming a stuck 1.5.0-rc.2 was told to dispatch kind=rc, which would have cut an unrelated 1.4.156-rc.4. Spell the condition out and give the fallback that does work for a non-patch base. Also correct the mechanism in the comment I added in 698c5be: bash wraps two's-complement, it does not saturate, which is why the hole is value-dependent (rc.10000000000000000000 wraps negative and failed closed, rc.99999999999999999999 wraps to 7766279631452241919 and sailed through). And name both inputs in the suffix error, which now serves version_suffix and the trailing identifier in version.
Review follow-up: three commits pushed on top of
|
| Commit | Defect |
|---|---|
698c5beeaa |
Gate fell open past INTMAX; leading-zero identifier caused a tag/package.json divergence |
5914f0a429 |
Refusal message pointed minor/major RC series at a remedy that cuts an unrelated release |
1. The -le gate closed only the low end of the range. The description credits the leading-zero fix for closing the octal fall-open, but the same [[ -le ]] falls open at the top of the range too. bash wraps two's-complement, so rc.99999999999999999999 wraps to 7766279631452241919, reads as "above the published rc.3", and passes. semver.valid() accepts it and npm version exits 0, so the tag really would be cut — after which rcNumberFromTag pins highest_rc_for_base at 1e20 permanently and every later cut wraps to an rc that sorts below it. That is the same fleet-stranding outcome this PR exists to prevent, reachable through the line the PR adds. Bounded to rc\.(0|[1-9][0-9]{0,8}).
2. npm version does not reject an invalid identifier, it silently renormalizes. 1.4.156-rc.4.01 → package.json at 1.4.156-rc.4.1, while :725 tags the literal $VERSION. The shipped version and its own release tag would name different releases. Closed in require_valid_version_suffix, with the explicit path's embedded identifier routed through that same helper.
3. The refusal's remedy was wrong for non-patch bases. kind=rc derives its base from bump(latest_stable, patch), so telling an operator resuming a stuck 1.5.0-rc.2 to "dispatch kind=rc instead" would have cut 1.4.156-rc.4 — an unrelated release. A 1.5.0-rc.N series exists only because this override created it. The message now states the condition and gives the fallback that works.
Two corrections to the description
- "A second harness … proves the shared-validator refactor changed nothing there — identical results before and after." That was true of
cf4100b661, but is no longer true of the branch:require_valid_version_suffixis now stricter, soversion_suffix=01and007are rejected on thekind=rcpath where they previously produced a version. That is intentional (they produced the tag/package.jsondivergence above), but the claim as written is now stale. - "Not verified: … the harness stubs
highest_rc_for_basewith a fixture rather than driving the actualrelease-rc-history.mjs." This gap is now closed. Driven against a real git repo with real tags, a really-deletedv1.4.156-rc.0, and the real unstubbedrelease-rc-history.mjs:
pre-PR HEAD
1.4.156-rc.0 (tag deleted, attack) OK(1.4.156-rc.0) REJECT
1.4.156-rc.3 OK(1.4.156-rc.3) REJECT
1.4.156-rc.4 (advances) OK(1.4.156-rc.4) OK(1.4.156-rc.4)
1.4.155 (leapfrog deleted stable) OK(1.4.155) OK(1.4.155) <- legit case intact
1.5.0-rc.0 / 1.5.0-rc.1 (minor RC) OK OK <- legit case intact
Known gap, deliberately not addressed here
Nothing pins this gate automatically. The repo's pattern for pinning this workflow is substring assertions in config/scripts/package-electron-runtime-contract.test.mjs, but that file sits at exactly its 600-line max-lines cap for **/*.mjs (the 800 override covers only .test.ts/.test.tsx), so extending it is not available without a disable or a cap bump — both banned by AGENTS.md. And a toContain on the regex text would pin text rather than behavior; it would not have caught either hole above. The version with real value is a behavioral extract-and-run harness for the bash block, which is new test infrastructure and should be its own PR rather than riding along on a release-safety fix.
…st its tag The new explicit-version gate only fails closed on a deleted tag because highest_rc_for_base also reads `release: v<base>-rc.N` subjects. That fallback did not parse the suffixed form: rcNumberFromTag accepts an optional .identifier, rcNumberFromReleaseSubject did not, so `4.perf` failed its `(\d+)(\s|$)` anchor and returned null. So deleting a v1.4.156-rc.4.perf tag dropped the series back to rc.3, and an explicit 1.4.156-rc.4 was waved through — below the rc.4.perf build perf-channel clients already run. Same under-count already made kind=rc recompute rc.4 over a deleted suffixed tag. Mirror the tag form's optional identifier. Covered by a unit assertion and a git-fixture test that both fail with this reverted.
Fourth defect: the deleted-tag fallback was blind to suffixed RCs (
|
…t path All four are wording or consistency, no behavior change (harness: 26/26 before and after, on bash 3.2 and bash 5.2). - The trailing-identifier comment justified itself as preserving a shape that "can never be re-cut through the override", but re-cutting a suffixed rc at or below the series head is exactly what the new gate refuses. State what it actually admits: a second spelling of version=X.Y.Z-rc.N + version_suffix. - version_suffix's input description still said "rc kind only" after this PR made it apply to an explicit bare X.Y.Z-rc.N. - The suffix guard's own rc pattern was unbounded while the shape check twelve lines up is bounded to nine digits; reuse the bounded one so a later edit to either cannot silently drift. - "which recovers the existing tag" was unconditional, but kind=rc recovery is also gated on tag_matches_current_ref, so a tag cut from a ref main has moved past advances to rc.N+1 instead.
Verification trap, for anyone re-checking the regexes in this PRIf you probe the shape regex from an interactive zsh prompt (macOS default) with the pattern written as an unquoted literal, you get a false pass on exactly the input this PR exists to reject. zsh strips backslashes from an unquoted On the real gate regex, every It needs both the stripped backslash and the optional trailing group, so a shortened probe will not reproduce it. Assigning the pattern to a variable first, or single-quoting it, also fixes it under zsh. Practical upshot: verify this file with Worth knowing generally: this workflow is |
…i#10525) * fix(release-cut): gate an explicit RC against its own series semver_gt compares through strip_pre(), so the explicit-version override only ever checked the stable line: 1.4.156-rc.0 read as 1.4.156, cleared a 1.4.155 stable, and republished an RC below what clients already run. Anchor a prerelease request on highest_rc_for_base -- the same rc history the kind path uses -- so the override can only advance the series. Two sibling gaps in the same block: - version_suffix was silently dropped when version was set, because the append lives in the kind branch the override skips. - the shape regex rejected X.Y.Z-rc.N.suffix, so a suffixed RC the rc path can produce could never be re-cut explicitly. * fix(release-cut): close both ends of the rc-number range the gate compares The new explicit-rc gate compares with `[[ -le ]]`, i.e. bash machine-width integers, and the author closed only the low end. Past INTMAX bash saturates, so `version=1.4.156-rc.99999999999999999999` reads as "above the published rc.3" and the gate falls open — then the tag it cuts pins highest_rc_for_base at 1e20 for that base forever, and every later cut wraps to a lower rc the fleet never updates to. Bound the rc number to nine digits. Also reject leading zeros on an all-digit prerelease identifier. `npm version` renormalizes rc.4.01 to rc.4.1 while the tag step keeps the literal input, so the shipped package.json version and its own release tag name different releases. The explicit path's embedded identifier now goes through the same validator the kind path uses instead of only the shape regex. * fix(release-cut): stop the refusal pointing minor/major RCs at the wrong series kind=rc derives its base from bump(latest_stable, patch), so the remedy the refusal suggested only works when the requested base *is* that next patch. A 1.5.0-rc.N series exists only because this override created it, so an operator resuming a stuck 1.5.0-rc.2 was told to dispatch kind=rc, which would have cut an unrelated 1.4.156-rc.4. Spell the condition out and give the fallback that does work for a non-patch base. Also correct the mechanism in the comment I added in 698c5be: bash wraps two's-complement, it does not saturate, which is why the hole is value-dependent (rc.10000000000000000000 wraps negative and failed closed, rc.99999999999999999999 wraps to 7766279631452241919 and sailed through). And name both inputs in the suffix error, which now serves version_suffix and the trailing identifier in version. * fix(release-cut): count a suffixed RC from its commit subject, not just its tag The new explicit-version gate only fails closed on a deleted tag because highest_rc_for_base also reads `release: v<base>-rc.N` subjects. That fallback did not parse the suffixed form: rcNumberFromTag accepts an optional .identifier, rcNumberFromReleaseSubject did not, so `4.perf` failed its `(\d+)(\s|$)` anchor and returned null. So deleting a v1.4.156-rc.4.perf tag dropped the series back to rc.3, and an explicit 1.4.156-rc.4 was waved through — below the rc.4.perf build perf-channel clients already run. Same under-count already made kind=rc recompute rc.4 over a deleted suffixed tag. Mirror the tag form's optional identifier. Covered by a unit assertion and a git-fixture test that both fail with this reverted. * docs(release-cut): correct four operator-facing claims in the explicit path All four are wording or consistency, no behavior change (harness: 26/26 before and after, on bash 3.2 and bash 5.2). - The trailing-identifier comment justified itself as preserving a shape that "can never be re-cut through the override", but re-cutting a suffixed rc at or below the series head is exactly what the new gate refuses. State what it actually admits: a second spelling of version=X.Y.Z-rc.N + version_suffix. - version_suffix's input description still said "rc kind only" after this PR made it apply to an explicit bare X.Y.Z-rc.N. - The suffix guard's own rc pattern was unbounded while the shape check twelve lines up is bounded to nine digits; reuse the bounded one so a later edit to either cannot silently drift. - "which recovers the existing tag" was unconditional, but kind=rc recovery is also gated on tag_matches_current_ref, so a tag cut from a ref main has moved past advances to rc.N+1 instead.
The hole
The
versionmanual-dispatch override is validated only against the stable line:semver_gtruns both operands throughstrip_pre(), which throws the prerelease identifier away. So1.4.156-rc.0is compared as1.4.156against stable1.4.155— and passes.Meanwhile the kind-based RC path anchors on
highest_rc_for_base "$base"and can therefore only ever move torc.N+1. The explicit path bypasses that anchor entirely.Concretely
Latest stable is v1.4.155. The 1.4.156 series is mid-bake: rc.0 … rc.3 are published and clients on the RC channel are running rc.3.
v1.4.156-rc.0tag/release to clean it up. (Deleting a bad tag is routine — the whole reason this override exists is that deletions regress the release list.)Cut Releasewithversion=1.4.156-rc.0, intending to "redo rc.0".strip_pre(1.4.156-rc.0)=1.4.156>1.4.155✅ — accepted. The tag no longer exists, so the collision check at the end of the step is also clear.main, hundreds of commits ahead of the original rc.0.Everyone on rc.3 now sees
1.4.156-rc.0as the newest release in the channel, which is lower semver than what they run, so they never update; anything that does land on it is a build whosePROTOCOL_VERSIONand daemon contract came from a version the fleet already moved past. This is the same regression class as the rc.4 incident that cut off an older branch, reverted ~100 commits, and orphaned the live v28 daemon with blank terminals.The fix
When the explicit version carries a prerelease, gate it against the RC history for its own base — reusing
highest_rc_for_base, not a second source of truth:That helper reads both
v<base>-rc.*tags andrelease: v<base>-rc.Ncommit subjects onHEAD/origin/main, so a deleted tag still counts — which is what makes the attack above fail closed.The existing stable-line gate is unchanged, and the legitimate use case survives: a human leapfrogging to an exact stable (
1.4.155,1.4.156) is untouched, and cutting1.4.156-rc.4after rc.3 works. I deliberately did not add an escape-hatch input: the only thing the strict gate takes away is resuming an unpublished RC tag by exact number, andkind=rcalready resumes that case throughrecover_unpublished_tag. The error message says so.Sibling gaps in the same block
version_suffixwas silently dropped. The suffix append lives inside theif [[ -z "$new" ]]kind branch that the explicit path skips, so passing both inputs quietly produced an unsuffixed version. It now applies on the explicit path too. Only a bareX.Y.Z-rc.Ncan take one —1.4.156.perfis not valid semver and re-suffixing an already-suffixed RC would yieldrc.4.perf.perf— and both are now loud errors rather than a silent drop. The alphanumeric check is extracted torequire_valid_version_suffixso the kind path and the explicit path share one definition (its "Why dot-appended" comment moved with it).^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$refusedX.Y.Z-rc.N.perf, a shape the rc path itself can produce — so a suffixed RC could never be re-cut through the override. Now accepted.[[ 08 -le 3 ]]is not false — it errors, and the failed test makes theiffalse, so1.4.156-rc.08would have slipped straight past the new gate. The regex now enforces semver's no-leading-zero rule on the RC number ((0|[1-9][0-9]*)), which is also what stops an invalid tag shape from being cut.Verification
There is no unit-test harness for bash-inside-YAML, so I wrote a scratch harness that extracts the real helper functions and the real explicit-version block out of
release-cut.ymlwith awk (dedent + stubhighest_rc_for_base), so the assertions run the shipped code rather than a paraphrase of it. Fixture: latest stable1.4.155, published1.4.156-rc.0 … rc.3.Same harness against the unmodified file at
f009500677— every new assertion fails there, so none of them pass vacuously:A second harness extracts the
kind=rcbranch to prove the shared-validator refactor changed nothing there — identical results before and after:rc advances to rc.4✅,rc + suffix appends→1.4.156-rc.4.perf✅,rc + non-alnum suffix→ rejected ✅.Also:
bash -non the full extracted "Compute next version" step passes, and the workflow still parses as YAML (all 10 jobs load).Not verified: nothing is exercised against a real GitHub Actions run or a real
gh releasestate — the harness stubshighest_rc_for_basewith a fixture rather than driving the actualrelease-rc-history.mjsagainst a live tag/log set.npx prettier --checkwarns on this file, but it warns identically on the unmodified file atf009500677(4 pre-existing''vs""lines, none of them mine); the repo formatter isoxfmt, which does not cover YAML, so I left those alone rather than reformat unrelated lines.Review addendum (added during review — 4 follow-up commits)
Two reviewers plus CodeRabbit went over this. Four defects were found in the original commit and fixed on the branch; the PR now touches 3 files and carries four concerns, named here so nobody meets them in a failed release cut instead.
698c5beeaarc.99999999999999999999→7766279631452241919> 3 and passed); leading-zero identifier caused a tag/package.jsondivergence becausenpm versionsilently renormalizesrc.4.01→rc.4.15914f0a429kind=rc, which anchors onbump(latest_stable, patch)and would cut an unrelated releasea44f406624rcNumberFromReleaseSubjectwas blind to suffixed RCs, so a deletedv…-rc.4.perftag dropped the series and an explicitrc.4was accepted below what perf-channel clients run — the deleted-tag fallback is the only thing making this gate non-vacuous0dbcf7597eThe four concerns in this PR
version_suffixnow applies on the explicit path. Previously it was silently dropped. Behavior change to flag:version=X.Y.Z+version_suffix=perfused to succeed (cuttingX.Y.Z, suffix discarded) and now hard-fails. That is a judgment call rather than a defect — it fails at the first step, beforenpm version/commit/tag/push, and silently discarding an explicitly-set input is the same failure shape this PR closes — but it is a real change and both reviewers thought this hunk was severable and could be its own PR. Your call whether to split it.X.Y.Z-rc.N.suffix. Redundant with (2) — it is a second spelling ofversion=X.Y.Z-rc.N+version_suffix. Kept and documented rather than removed, since removing it would delete a working spelling.require_valid_version_suffixis shared with thekind=rcpath, and is now stricter, soversion_suffix=01/007are rejected there too.Corrections to the original description
cf4100b661, no longer true of the branch: the kind path now differs from pre-PR in 3 of 35 combinations (01/007rejected, one message reworded). All intentional, but the claim is stale.highest_rc_for_base." Now closed — driven against a real git repo with real tags, a realgit tag -d, and the real unstubbedrelease-rc-history.mjs.0dbcf7597e, along withversion_suffix's "rc kind only" description, an unbounded rc pattern in the suffix guard, and an unconditional "recovers the existing tag" claim.Verified
Legitimate operations confirmed still working, on a real git fixture: leapfrogging a deleted/rolled-back stable, creating and advancing a minor/major RC series (which
kind=rcstructurally cannot produce), and suffixed side-branch cuts. Gate assertions pass 26/26 on both bash 3.2 and bash 5.2 — bash version is the real portability axis here, and the two genuinely disagree on the oversized-integer comparison behind the first fix. Parser round-trip 875/875 shapes; new tests revert-checked (2 fail with the source reverted,expected 5 to be 6andexpected null to be 6); 30/30 suites.Known gap, deliberately left: nothing pins the workflow's bash automatically.
config/scripts/package-electron-runtime-contract.test.mjsis at exactly its 600-linemax-linescap for**/*.mjs(the 800 override covers only.test.ts/.test.tsx), so it cannot be extended without a disable or cap bump — both banned by AGENTS.md — and atoContainon regex text would not have caught any of the four defects. A behavioral extract-and-run harness is the valuable version and belongs in its own PR.