Skip to content

fix(release-cut): gate an explicit RC against its own series - #10525

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/p2-release-cut-explicit-version
Jul 25, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/p2-release-cut-explicit-version

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

The hole

The version manual-dispatch override is validated only against the stable line:

if ! semver_gt "$explicit" "$latest_stable"; then   # refuse

semver_gt runs both operands through strip_pre(), which throws the prerelease identifier away. So 1.4.156-rc.0 is compared as 1.4.156 against stable 1.4.155 — and passes.

Meanwhile the kind-based RC path anchors on highest_rc_for_base "$base" and can therefore only ever move to rc.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.

  1. rc.0 turned out to be broken, so someone deletes the v1.4.156-rc.0 tag/release to clean it up. (Deleting a bad tag is routine — the whole reason this override exists is that deletions regress the release list.)
  2. An operator dispatches Cut Release with version=1.4.156-rc.0, intending to "redo rc.0".
  3. Today's gate: 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.
  4. CI cuts and publishes v1.4.156-rc.0 off current main, hundreds of commits ahead of the original rc.0.

Everyone on rc.3 now sees 1.4.156-rc.0 as 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 whose PROTOCOL_VERSION and 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:

if [[ "$explicit" == *-rc.* ]]; then
  explicit_base="${explicit%%-*}"
  explicit_rc="${explicit#*-rc.}"; explicit_rc="${explicit_rc%%.*}"
  highest_explicit_rc="$(highest_rc_for_base "$explicit_base")"
  if [[ -n "$highest_explicit_rc" && "$explicit_rc" -le "$highest_explicit_rc" ]]; then
    # refuse

That helper reads both v<base>-rc.* tags and release: v<base>-rc.N commit subjects on HEAD/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 cutting 1.4.156-rc.4 after 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, and kind=rc already resumes that case through recover_unpublished_tag. The error message says so.

Sibling gaps in the same block

  • version_suffix was silently dropped. The suffix append lives inside the if [[ -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 bare X.Y.Z-rc.N can take one — 1.4.156.perf is not valid semver and re-suffixing an already-suffixed RC would yield rc.4.perf.perf — and both are now loud errors rather than a silent drop. The alphanumeric check is extracted to require_valid_version_suffix so the kind path and the explicit path share one definition (its "Why dot-appended" comment moved with it).
  • The shape regex rejected suffixed RCs. ^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ refused X.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.
  • Leading-zero octal trap (found while testing). [[ 08 -le 3 ]] is not false — it errors, and the failed test makes the if false, so 1.4.156-rc.08 would 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.yml with awk (dedent + stub highest_rc_for_base), so the assertions run the shipped code rather than a paraphrase of it. Fixture: latest stable 1.4.155, published 1.4.156-rc.0 … rc.3.

PASS  explicit 1.4.156-rc.0 (below published rc.3)               -> REJECT
PASS  explicit 1.4.156-rc.3 (equals published rc.3)              -> REJECT
PASS  explicit 1.4.156-rc.4 (advances series)                    -> OK (1.4.156-rc.4)
PASS  explicit 1.4.156 (stable promotion)                        -> OK (1.4.156)
PASS  explicit 1.4.155 (equals latest stable)                    -> REJECT
PASS  explicit 1.4.154 (below latest stable)                     -> REJECT
PASS  explicit 1.4.157-rc.0 (fresh base, no history)             -> OK (1.4.157-rc.0)
PASS  explicit rc + version_suffix lands                         -> OK (1.4.156-rc.4.perf)
PASS  explicit 1.4.156-rc.4.perf (suffixed shape)                -> OK (1.4.156-rc.4.perf)
PASS  explicit 1.4.156-rc.3.perf (suffixed, below)               -> REJECT
PASS  explicit stable + suffix (loud, not silent)                -> REJECT
PASS  explicit suffixed rc + suffix (no rc.N.a.b)                -> REJECT
PASS  explicit rc + non-alnum suffix                             -> REJECT
PASS  explicit v-prefixed 1.4.156-rc.4                           -> OK (1.4.156-rc.4)
PASS  explicit 1.4.156-rc.08 (octal trap)                        -> REJECT
PASS  explicit 1.4.156-rc.010 (octal trap, >rc.3)                -> REJECT
PASS  explicit garbage 1.4                                       -> REJECT
PASS  no explicit version (kind path)                            -> OK
passed=18 failed=0

Same harness against the unmodified file at f009500677 — every new assertion fails there, so none of them pass vacuously:

FAIL  explicit 1.4.156-rc.0 (below published rc.3)   -> OK (1.4.156-rc.0)      <-- the bug
FAIL  explicit 1.4.156-rc.3 (equals published rc.3)  -> OK (1.4.156-rc.3)
FAIL  explicit rc + version_suffix lands             -> OK (1.4.156-rc.4)      <-- suffix dropped
FAIL  explicit 1.4.156-rc.4.perf (suffixed shape)    -> REJECT (regex)
FAIL  explicit stable + suffix (loud, not silent)    -> OK (1.4.156)
FAIL  explicit rc + non-alnum suffix                 -> OK (1.4.156-rc.4)
FAIL  explicit 1.4.156-rc.08 (octal trap)            -> OK (1.4.156-rc.08)
FAIL  explicit 1.4.156-rc.010 (octal trap, >rc.3)    -> OK (1.4.156-rc.010)
passed=10 failed=8

A second harness extracts the kind=rc branch 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 -n on 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 release state — the harness stubs highest_rc_for_base with a fixture rather than driving the actual release-rc-history.mjs against a live tag/log set. npx prettier --check warns on this file, but it warns identically on the unmodified file at f009500677 (4 pre-existing '' vs "" lines, none of them mine); the repo formatter is oxfmt, 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.

Commit What it fixes
698c5beeaa Gate fell open past INTMAX (bash wraps two's-complement, so rc.99999999999999999999 → 7766279631452241919 > 3 and passed); leading-zero identifier caused a tag/package.json divergence because npm version silently renormalizes rc.4.01 → rc.4.1
5914f0a429 Refusal message pointed minor/major RC series at kind=rc, which anchors on bump(latest_stable, patch) and would cut an unrelated release
a44f406624 rcNumberFromReleaseSubject was blind to suffixed RCs, so a deleted v…-rc.4.perf tag dropped the series and an explicit rc.4 was accepted below what perf-channel clients run — the deleted-tag fallback is the only thing making this gate non-vacuous
0dbcf7597e Four operator-facing corrections (see below)

The four concerns in this PR

  1. The RC gate — the stated fix.
  2. version_suffix now applies on the explicit path. Previously it was silently dropped. Behavior change to flag: version=X.Y.Z + version_suffix=perf used to succeed (cutting X.Y.Z, suffix discarded) and now hard-fails. That is a judgment call rather than a defect — it fails at the first step, before npm 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.
  3. The shape regex accepts X.Y.Z-rc.N.suffix. Redundant with (2) — it is a second spelling of version=X.Y.Z-rc.N + version_suffix. Kept and documented rather than removed, since removing it would delete a working spelling.
  4. require_valid_version_suffix is shared with the kind=rc path, and is now stricter, so version_suffix=01/007 are rejected there too.

Corrections to the original description

  • "A second harness … proves the shared-validator refactor changed nothing there — identical results before and after." True of cf4100b661, no longer true of the branch: the kind path now differs from pre-PR in 3 of 35 combinations (01/007 rejected, one message reworded). All intentional, but the claim is stale.
  • "Not verified: … the harness stubs highest_rc_for_base." Now closed — driven against a real git repo with real tags, a real git tag -d, and the real unstubbed release-rc-history.mjs.
  • The trailing-identifier comment justified itself as preserving a shape that "can never be re-cut through the override" — falsified by the gate this PR adds. Reworded in 0dbcf7597e, along with version_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=rc structurally 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 6 and expected 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.mjs is at exactly its 600-line max-lines cap 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 a toContain on 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.

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.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely summarizes the main change: explicit RC cuts are gated against their own release series.
Description check ✅ Passed The description is detailed and mostly complete, but it does not follow the template sections for screenshots, testing checklist, security audit, or cross-platform review.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e1eca7f and cf4100b.

📒 Files selected for processing (1)
  • .github/workflows/release-cut.yml

Comment thread .github/workflows/release-cut.yml Resolved
Comment thread .github/workflows/release-cut.yml Resolved
…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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

CodeRabbit triage

Three CodeRabbit items on this PR. Recording the disposition of each so none is silently dropped.

1. Bound RC numbers before Bash math (potential_issue, Major) — ACTIONED in 698c5be. Reply: #10525 (comment)

Confirmed on bash 5.2 (the runner version): [[ 99999999999999999999 -le 3 ]] saturates and returns false, so the new gate falls open on exactly the input class it was added to catch. Worse than a bad tag — rcNumberFromTag then pins highest_rc_for_base at 1e20 for that base permanently, and every later kind=rc cut wraps to a lower rc the fleet never updates to. Bounded to rc\.(0|[1-9][0-9]{0,8}).

2. Reject leading-zero numeric suffixes (potential_issue, Minor) — ACTIONED in 698c5be. Reply: #10525 (comment)

npm version does not reject 1.4.156-rc.4.01; it silently renormalizes to 1.4.156-rc.4.1 while the tag step keeps the literal input, so package.json and the release tag would name different releases. Closed in require_valid_version_suffix and routed the explicit path's embedded identifier through that same helper rather than duplicating the rule in the regex.

3. Pre-merge "Description check" warning — DECLINED.

The check asks for the Screenshots, AI Review Report, Security Audit, and Notes sections from .github/pull_request_template.md. Declining because:

  • Screenshots — this PR changes only .github/workflows/release-cut.yml. There is no UI surface and no runnable artifact to capture; a placeholder image would be noise.
  • AI Review Report with macOS/Linux/Windows coverage — the changed code is a bash block in a GitHub Actions job that runs exclusively on ubuntu-latest. Per-OS coverage is not a meaningful axis here. What is the meaningful axis is bash version, and that is covered: every assertion was run on both bash 3.2.57 and bash 5.2 (5.2.15 / 5.2.37), which was load-bearing — the two disagree on integer saturation, and item 1 above only reproduces on 5.x.
  • Security Audit — the whole PR is the audit finding; the description states the threat model, the reachable path, and the blast radius in full.
  • Notes / checklist-style Testing — the description already carries the verification matrix and an explicit "Not verified" section. Reformatting it into checkboxes would not add information.

The Title check, Docstring Coverage, Linked Issues, and Out of Scope Changes pre-merge checks all pass. Happy to add the headings if a human reviewer wants the template shape enforced regardless.

…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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review follow-up: three commits pushed on top of cf4100b661

I reviewed this as a release-safety change and pushed fixes for three defects. Recording them here because two of them invalidate claims in the PR description above, and a reviewer reads that first.

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_suffix is now stricter, so version_suffix=01 and 007 are rejected on the kind=rc path where they previously produced a version. That is intentional (they produced the tag/package.json divergence above), but the claim as written is now stale.
  • "Not verified: … the harness stubs highest_rc_for_base with a fixture rather than driving the actual release-rc-history.mjs." This gap is now closed. Driven against a real git repo with real tags, a really-deleted v1.4.156-rc.0, and the real unstubbed release-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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Fourth defect: the deleted-tag fallback was blind to suffixed RCs (a44f406624)

This one goes at the heart of the PR's central claim. The description says:

That helper reads both v<base>-rc.* tags and release: v<base>-rc.N commit subjects on HEAD/origin/main, so a deleted tag still counts — which is what makes the attack above fail closed.

That is only true for unsuffixed RCs. The two parsers in config/scripts/release-rc-history.mjs disagreed:

shape                    rcNumberFromTag   rcNumberFromReleaseSubject
1.4.156-rc.4                   4                    4
1.4.156-rc.4.perf              4                    null   <-- tag counted, subject NOT
1.4.156-rc.4.0                 4                    null
1.4.156-rc.4.5                 4                    null

rcNumberFromTag has an optional .identifier (added deliberately — its comment says suffixed side-branch RCs "must advance the shared rc counter"). rcNumberFromReleaseSubject did not: /^(\d+)(?:\s|$)/ sees 4.perf, hits . where it wants whitespace-or-end, and returns null.

So the fallback that makes this gate fail closed does not fire for the suffixed form. On a real git fixture — real tags, a real git tag -d, the real unstubbed module:

highest_rc_for_base(1.4.156) with the v1.4.156-rc.4.perf tag present = 4
highest_rc_for_base(1.4.156) after DELETING that tag                 = 3   <-- under-counts

explicit 1.4.156-rc.4  ->  ACCEPTED as 1.4.156-rc.4
semver.compare('1.4.156-rc.4', '1.4.156-rc.4.perf') = -1

1.4.156-rc.4 sorts below the rc.4.perf build that perf-channel clients are already running. Same downgrade class the PR exists to prevent, through the gate's own deleted-tag mechanism.

The same under-count is also a pre-existing bug on the kind=rc path: after a suffixed RC tag is deleted, kind=rc recomputes rc.4 and tries to re-cut it.

Fix — mirror the tag form's optional identifier:

-  const match = /^(\d+)(?:\s|$)/.exec(subject.slice(prefix.length))
+  const match = /^(\d+)(?:\.[0-9A-Za-z]+)?(?:\s|$)/.exec(subject.slice(prefix.length))

After it the fixture returns 4 and the cut is refused.

This one is covered by real tests, and I checked they are not vacuous

config/scripts/release-rc-history.test.mjs has ample max-lines headroom (78 lines), so unlike the workflow this is genuinely testable. Added a unit assertion and a git-fixture test. Revert-check — source reverted, tests kept:

 FAIL  release RC history > keeps a suffixed RC counted once its tag is deleted
 AssertionError: expected 5 to be 6

 Test Files  1 failed (1)
      Tests  2 failed | 4 passed (6)

Restored: Tests 6 passed (6), and 30 passed (30) across this suite plus package-electron-runtime-contract.

Scope note — this takes the PR to two source files

Flagging it rather than burying it, since one-concern-per-PR is the rule here. My reasoning for keeping it: it is the helper this gate anchors on, and without it the PR's stated fail-closed guarantee is false for a shape the rc path itself can cut. The counter-argument is fair — it is a pre-existing bug in a different file that also affects kind=rc, so it could stand alone. If you would rather keep this PR to the workflow, say so and I will revert a44f406624 and file it separately; the gate still fixes the reported bug without it, just with this gap left open.

…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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Verification trap, for anyone re-checking the regexes in this PR

If 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 =~ right-hand side; bash preserves them:

$ [[ "1x4" =~ ^[0-9]+\.[0-9]+$ ]]          # zsh  -> MATCH   (\. degraded to "any char")
$ [[ "1x4" =~ ^[0-9]+\.[0-9]+$ ]]          # bash -> no match (correct)

On the real gate regex, every \. becomes a wildcard and the trailing (\.[0-9A-Za-z]+)? then swallows the overflow digits — [1-9][0-9]{0,8} takes the first nine, . eats one more, [0-9A-Za-z]+ eats the rest:

v=1.4.156-rc.99999999999999999999
zsh,  literal unquoted RHS  -> ACCEPT   <-- false pass
zsh,  same regex via $R     -> reject   (correct)
bash, literal unquoted RHS  -> reject   (correct)

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 bash -c '...', a #!/usr/bin/env bash script, or docker run --rm bash:5.2. All verification reported on this PR was done that way, so none of it is affected — but a reviewer spot-checking rc.99999999999999999999 at a macOS prompt would conclude the bound does not work when it does.

Worth knowing generally: this workflow is runs-on: ubuntu-latest, so bash version is the real portability axis here, not OS. macOS bash 3.2 and runner bash 5.2 genuinely disagree on the oversized-integer comparisons at the heart of the first fix — 9223372036854775808 -le 3 is true on both, but the 20-digit case only falls open on 5.x. Every result reported here was checked on both.

@brennanb2025
brennanb2025 merged commit fc51323 into main Jul 25, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
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