fix: surface merge API errors and use a fresh sequence for merge/sync - #295
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Ruari-Phipps
force-pushed
the
ruari/fix/merge-sequence-mismatch
branch
from
August 27, 2026 17:24
b9084df to
98f7ec4
Compare
This comment has been minimized.
This comment has been minimized.
oeisenberg
approved these changes
Aug 27, 2026
A draft deployment finishing while a branch is being merged appends a deploymentCompleted event to the branch, so the merge is rejected with SEQUENCE_MISMATCH. Two things made that worse than a transient failure: - merge_branch/sync_branch sent the projection-cached sequence, so a plain retry resent the stale value. They now fetch the branch sequence fresh, matching delete_branch. - sync_client swallowed the SourcererAPIError and returned no errors, so callers (and CI) saw "Merge failed:" with no reason. The API error is now returned in `errors`, and `poly branch merge`/`sync` print a retry hint when it is a sequence mismatch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ruari-Phipps
force-pushed
the
ruari/fix/merge-sequence-mismatch
branch
from
August 28, 2026 09:37
98f7ec4 to
73974a7
Compare
Contributor
Coverage Report
Changed file coverage
|
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.
Summary
Make
merge_branch/sync_branchsend a freshly fetched branch sequence instead of the projection-cached one, and return the Sourcerer API error to callers instead of swallowing it.poly branch merge/syncprint a retry hint on a sequence mismatch.Motivation
A draft deployment finishing mid-merge appends a
deploymentCompletedevent to the branch, so Sourcerer rejects the merge withSEQUENCE_MISMATCH. Today that surfaces as a blankMerge failed:and a retry resends the same stale sequence.Changes
sdk.merge_branch/sdk.sync_branch: fetch the sequence viafetch_last_known_sequence_number()before the call (asdelete_branchalready does)sync_client.merge_branch/sync_branch: return theSourcererAPIErrormessage inerrors({"path": [], "message": ...}) instead of(False, [], [])poly branch merge/poly branch sync: print "The branch changed while merging… Re-run the merge." when an error is a sequence mismatchTest strategy
poly <command>)Checklist
ruff check .andruff format --check .passpytestpassespolyCLI interface (or migration path documented)