Skip to content

Recover native merge after a lost GitHub reply - #1345

Closed
eowca wants to merge 3 commits into
mainfrom
lean178/1325-native-merge-recovery
Closed

eowca wants to merge 3 commits into
mainfrom
lean178/1325-native-merge-recovery

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Recover native merge after a lost GitHub reply

Context and goal

  • Goal: Verify and follow the original merge request when GitHub accepted it before losing the reply.
  • Problem: A lost native merge reply can report failure after landing, or cause a retry to send another queue request.
  • Context: GitHub provides a landed SHA and queue admission tied to the PR head.

Closes #1325

Acceptance

  • An accepted squash merge with a lost reply verifies the landed SHA and cleans up in the same invocation.
  • An accepted queue request with a lost reply follows the normal queue path, and a retry observes admission before writing.
  • A moved head or missing evidence preserves the worktree and reports failure.

Notes

  • The CLI fake loses the reply after accepting the merge. Focused CLI and GitHub merge tests passed after the fix.

Base

Base: b69efec

Validation

(no loopzero check run recorded)


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

Review

  • primary, claude, 4c65947, approve

Architecture-Review: unchanged; native merge admission and cleanup still require GitHub evidence for the reviewed head.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on 4c65947394ce950d08ee03060f6e006ee54c6251, 48.3s: approve (0 critical, 0 important, 2 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/github.py
argv = (
"pr", "merge", str(number), "--repo", repo, *method, "--match-head-commit", head_sha,
)
if strategy == "queue" and merge_pending(repo, number, head_sha):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Only the queue strategy checks for admission before writing; squash/merge/rebase retries still send a second write

The check before the write (if strategy == "queue" and merge_pending(...)) only runs for strategy == "queue". merge() also treats a squash/merge/rebase request as accepted when GitHub queues it or turns it into an auto-merge request (test_merge_queued_returns_none with strategy=squash, auto=True). Example: a squash request is accepted as auto-merge, the reply is lost, and the run fails or is interrupted before the second read. The retry then sends another gh pr merge --squash. This retry case is the one the acceptance criterion "a retry observes admission before writing" describes. The second write is usually harmless because the read after it still finds the PR pending, but it is the same defect. Smallest fix: run the admission check for every strategy, which costs one GraphQL read, or explain in a comment why non-queue strategies are excluded. Then add the squash+auto case to the retry assertion in test_merge_queued_returns_none.

Comment thread src/loopzero/github.py
_gh(*argv, timeout=300)
except GhError as exc:
raise MergeFailed(exc.command, exc.tail) from exc
except (GhError, ProcTimeout, OSError) as exc:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The write error is dropped when a later verification step raises

write_error only appears in the final "neither merged nor queued" message. In two cases the write failure never reaches the user:

  • merged_sha(..., expected_head=...) raises "PR head changed before merge verification". This is the usual result of a --match-head-commit rejection.
  • queue_error is re-raised, for example when gh pr merge was rejected for a failing required check and the queue lookup then had a transient error.

Before this change, the user always saw gh's rejection text. Smallest fix: attach write_error to the verification error. Either chain it (raise queue_error from write_error) or add its text to the message, and wrap the merged_sha calls the same way.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Owner queue route: the full sandboxed check passed on 50b1ccd9 after a clean merge from main, and both required hosted checks are green. The slot receipt is missing the settings fingerprint, so the local receipt guard rejects it. Mergify will verify the integration candidate.

@eowca
eowca marked this pull request as ready for review November 26, 2026 02:47
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🚫 Left the queue · conflict with base branch

6 min in the queue, with no time running CI.

So far

Reason

The pull request conflicts with main

Conflicting file: tests/test_cli.py

Before this, the pull request was held in the queue behind 3 pull requests ahead of it.

To get back in the queue

  • You should update or rebase your pull request. A pull request in a stack is updated by rebasing the stack onto the branch it conflicts with. A pull request queued by a rule comes back to the queue once updated, as long as the rule still matches.
  • If it was queued with a command, update it, then comment @mergifyio queue to queue it again.

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify mergify Bot added dequeued and removed queued labels Nov 26, 2026
Architecture-Review: unchanged; merge recovery keeps the reviewed head checks and the conflict resolution only changes a test reference.
Co-Authored-By: Codex <noreply@openai.com>
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1436. Mergify reported a conflict with main, and Loop Zero declined a delta review of the resolved merge. The replacement retains the hosted eligibility test imports and carries the same native-merge recovery.

@eowca eowca closed this Nov 26, 2026
@mergify mergify Bot removed the dequeued label Nov 26, 2026
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.

Verify a native GitHub merge when its response is lost

1 participant