Pre-validate before mutation; atomic push prevents orphan tags#49
Merged
Conversation
Splits main() into gather, validate, and execute. Validate runs read-only checks (file would change, identity available, remote tag absent, local HEAD is FF-able, forge reachable with push permission) and prints + exits before any mutation if any fail. Execute uses `git push --atomic` so a partial push (branch rejected, tag accepted) can no longer leave an orphan tag on the remote. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR restructures the versions CLI workflow to pre-validate all read-only constraints before performing any mutations, and to eliminate partial remote state (notably orphan remote tags) by switching to an atomic git push.
Changes:
- Split execution into Gather → Validate → Execute phases, ensuring validation failures exit cleanly before any file/git mutations.
- Replace non-atomic remote updates with
git push --atomic <remote> <branch> <tag>to prevent orphan tags on rejected branch pushes. - Add a regression test ensuring validation aborts when the remote branch has advanced beyond the local HEAD.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
index.ts |
Adds gather/validate/execute phasing, remote probing + forge ping validation, and atomic push to prevent partial remote updates. |
index.test.ts |
Adds a regression test for the “remote advanced → abort before mutation” scenario and updates expectations for --remote + --release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fires every independent probe up front (resolveBaseVersion, pushBranch, identity check, getRepoInfo + tokens + pingForge, later probeRemote + merge-base ancestor check). validate collects everything in one Promise.all instead of awaiting each git/HTTPS call sequentially. The critical path drops from ~450ms to whichever single network call is slowest. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Reviewer feedback: throwing a plain Error from the push-permission check short-circuits withTokens, which only retries on AuthRetryable. A user with two tokens where the first lacks push would have validate fail even though the second token would succeed. Switch to AuthRetryable so withTokens falls through. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
* Use raw `files` count for the no-op check so a run that only specified unhandled lockfiles aborts instead of failing later at "nothing to commit". Gated on !args.gitless to preserve the existing "lockfile silently skipped" behavior in gitless mode. * pingForge treats 404 as auth-retryable: GitHub returns 404 (not 403) for private repos when the token lacks read access, so withTokens needs to fall through to the next token. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
silverwind
added a commit
that referenced
this pull request
May 28, 2026
* update deps (silverwind) * Pre-validate before mutation; atomic push prevents orphan tags (#49) (silverwind) * simplify: share TOML walker, extract commit/tag/push, derive push gates (silverwind) * make update a combination target, split out update-js (silverwind) * add update-actions make target (silverwind) * remove authorship attribution rule from AGENTS.md (silverwind) * simplify: dedup forge helpers, pyproject section loop, changelog parser (silverwind) * fix: tighten lock-file regex, preserve CRLF in changelog updates (silverwind)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
git push <remote> <branch> <tag>is not atomic. If the branch push is rejected (non-FF) but the tag push succeeds, the rollback hooks — registered afterawait execreturns — never run, so the orphan tag stays on the remote.Architecture
main()is now gather → validate → execute:--release: forge reachable, token accepted,permissions.pushis true-c→ commit → tag →git push --atomic→ forge release. The local rollback chain runs only on failure before the atomic push lands; once it lands, the commit/tag are shared and we leave them.Pre-validation removes the predictable post-push failure modes.
--atomicremoves the partial-push class. Post-push forge failure prints a recovery hint instead of force-pushing remote history.Behavior changes
--baseis wrong) now errors instead of silently exiting 0.ls-remotefailure aborts — previously a warning + best-effort push; now refuses to mutate if the remote state can't be read.Performance
All independent I/O probes fire in parallel at the top of
main()andvalidateawaits them once. Critical path drops from ~450ms (sequential) to ~210–300ms (slowest single chain).Tests
All 105 existing tests pass; added
validate - aborts when remote branch has advanced beyond localregressing the exact orphan-tag trigger.This PR was written with the help of Claude Opus 4.7