Skip to content

fix: lease the major tag on the state the release checks ran against - #165

Merged
agoldis merged 2 commits into
mainfrom
agoldis/release-lease-snapshot
Nov 15, 2026
Merged

agoldis merged 2 commits into
mainfrom
agoldis/release-lease-snapshot

Conversation

@agoldis

@agoldis agoldis commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Owner: @agoldis
Linear: P-ENG-132

script/release could move v2 backward over a release that landed after its checks. It read the lease from the remote after the fetch and the version checks. A release published in between became the lease, the checks never saw it, and the push succeeded. This is the same problem a review found in cancel-run-gh-action#21, which copied this script.

The lease now comes from what the remote had before the fetch:

  • git ls-remote --tags runs before git fetch. The major tag's object from that snapshot is the lease. It is empty when the remote has no major tag yet, which means "must not exist".
  • After the fetch, if the local major tag differs from the snapshot, a release landed during the fetch: the script stops before the checks describe the wrong state.
  • After the prompt, the script reads the remote again and stops before tagging anything if the major tag moved.
  • The push keeps --atomic --force-with-lease=refs/tags/v2:<snapshot> with no +.

The snapshot comes from the remote, not from the local tag. A run whose atomic push failed for a new major leaves a local v2 that the remote never had. Leasing on that tag would make every retry fail.

How it was tested

bash -n and shellcheck -S warning pass. A harness ran the whole script against throwaway local bare repositories, with gh replaced by a stub. A second clone plays another operator, and a git wrapper lets it publish a release just before a chosen git call:

# Case Result
1 Update an existing major vX.Y.Z published, major tag at the release
2 Create a new major Major tag created at the release
3 Answer n Nothing published
4 Another release lands between the snapshot and the fetch Stops; the other release keeps the major tag
5 Another release lands while the prompt waits Stops before tagging; the other release keeps it
6 Another release lands right before the push Lease refuses the atomic push; neither tag published
7 Someone creates the new major while the prompt waits Stops; theirs is kept
8 Resume a new major whose push failed (local major tag left over, remote has none) Completes
9 Another release lands at the first ls-remote Stops: package.json is behind the release that landed

Case 9 against the script before this change: it moves the major tag back over the other release. That is the review's reproduction. All 9 cases pass with this change. The harness is not committed.

🤖 Generated with Claude Code

https://claude.ai/code/session_011baD3hG81A9qbFYrSn1ysE


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The lease came from an ls-remote after the fetch and the checks. A release
that landed in between became the lease, and the push moved the major tag
back from it. The script now reads the remote tags before the fetch, stops
when the fetch brings a different major tag, checks the remote again after
the prompt, and leases the major tag on the snapshot. The snapshot comes
from the remote, not the local tag, because a failed push of a new major
leaves a local tag the remote never had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011baD3hG81A9qbFYrSn1ysE
@baz-reviewer

baz-reviewer Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Review this PR on Baz

Baz Summary

Harden script/release so major-tag updates are leased against the remote state captured before fetching and validated throughout the release flow. Prevent the script from overwriting releases that land during fetch, prompting, or pushing while preserving retries after failed new-major pushes.

Latest Contributors(2)
UserCommitDate
agoldis@gmail.comfix: read only the exa...November 15, 2026
dj@currents.devchore: harden the rele...October 28, 2026

Merger   ✅ Ready to Merge

MERGE: the release lease fix is present, CI ran, and there are no unresolved discussions.



Skills  Activate Skill Maintainer to keep your skills up to date

Planner  This PR would have been improved with Baz Planner - Try it now

The check after the prompt took every line ls-remote printed for the major
tag. A git that also lists the peeled commit of an annotated tag
(refs/tags/vN^{}) would give two IDs, and the check would stop every
release of an existing major. It now keeps only the refs/tags/vN line, as
the snapshot before the fetch already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011baD3hG81A9qbFYrSn1ysE
@agoldis
agoldis merged commit d9c7fe3 into main Nov 15, 2026
27 checks passed
@agoldis
agoldis deleted the agoldis/release-lease-snapshot branch November 15, 2026 22:45
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