Repository navigation
Recover native merge after a lost GitHub reply - #1436
Conversation
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>
There was a problem hiding this comment.
loopzero primary review by claude on d82dd4afa3df822d0ccaae9215d3ccfa59fcafb1, 44.2s: approve (0 critical, 0 important, 3 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.
| raise MergeFailed(exc.command, exc.tail) from exc | ||
| except (GhError, ProcTimeout, OSError) as exc: | ||
| write_error = exc | ||
| sha = merged_sha(repo, number, expected_head=head_sha) |
There was a problem hiding this comment.
suggestion: The write error is lost when the follow-up read raises
write_error is only added to the message when all three reads finish without an error. If gh pr merge fails and merged_sha then raises, the caller sees only the read error and never the real reason the merge was rejected. This happens when the head has moved ("PR head changed before merge verification" hides gh's "head commit mismatch"), on invalid evidence, or on ClosedUnmerged. The same applies when merge_pending raises queue_error (line 1415). The run still fails closed and keeps the worktree, so this is not a correctness bug, but the diagnosis is harder. Smallest fix: wrap the reads after the write so that a GhError raised while write_error is set is re-raised as MergeFailed, with the write error added to its tail and chained with from.
| argv = ( | ||
| "pr", "merge", str(number), "--repo", repo, *method, "--match-head-commit", head_sha, | ||
| ) | ||
| if strategy == "queue" and merge_pending(repo, number, head_sha): |
There was a problem hiding this comment.
suggestion: The admission check before writing only runs for strategy == "queue"
merge_pending also returns True for an accepted auto-merge request. The squash, merge and rebase strategies reach that state on a queue-protected base, and test_merge_queued_returns_none covers that case. A retry after a lost reply under those strategies still sends a second gh pr merge. That second write is probably harmless, because gh rejects it or treats it as a no-op and the queue check afterwards returns None. Still, it falls short of the stated goal that a retry observes admission before writing. Consider either running the check for every strategy, or documenting that only queue is protected this way.
|
|
||
| def _queue_json(queued: bool) -> dict: | ||
| return {"data": {"repository": {"pullRequest": {"isInMergeQueue": queued}}}} | ||
| return {"data": {"repository": {"pullRequest": {"isInMergeQueue": queued, "headRefOid": HEAD}}}} |
There was a problem hiding this comment.
suggestion: No test for a missing or changed headRefOid in the queue check
The new head check in merge_pending (github.py:1376) is part of the acceptance criteria ('moved head or missing evidence ... reports failure'). Every updated fixture supplies a matching headRefOid, so no test fails if the check is removed. Add a test_github case where headRefOid is missing or different, for both the check before writing and the check after writing. It should assert that MergeFailed is raised and that no pr merge write is sent when the check before writing fails.
…erge-replacement # Conflicts: # src/loopzero/cli.py # tests/test_cli.py # tests/test_github.py
There was a problem hiding this comment.
loopzero delta review by claude on a82cb89ce9a299ade7f146d072f6a1237ea7bc6c, 18.4s: approve (0 critical, 0 important, 1 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.
| snapshots.append(merge_json(state="MERGED", sha="d" * 40)) | ||
| arm_merge(gh, accepted, *snapshots) | ||
| if strategy == "queue": | ||
| gh.respond("api graphql", _queue_json(False), accepted) |
There was a problem hiding this comment.
suggestion: The queue branch silently replaces the GraphQL responses that arm_merge sets
arm_merge already calls gh.respond("api graphql", accepted). FakeGh.respond replaces the responses for a key rather than adding to them, so for strategy == "queue" the extra gh.respond("api graphql", _queue_json(False), accepted) throws away what arm_merge set. The test is correct, but a reader has to know that replace behaviour to see why. Smallest fix: call arm_merge(gh, _queue_json(False) if strategy == "queue" else accepted, *snapshots) and use gh.append("api graphql", accepted) for the queue case, or add a short comment saying the call overrides the earlier one.
|
@Mergifyio queue |
❌ Left the queue ·
|
|
No description provided. |
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Recover native merge after a lost GitHub reply
Context and goal
Closes #1325
Acceptance
Notes
Replaces Recover native merge after a lost GitHub reply #1345. Mergify reported a conflict with main and Loop Zero declined a delta review of the resolved merge.
The CLI fake loses the reply after accepting the merge. Focused CLI and GitHub merge tests passed after the fix.
Base
Base: b9a018c
Validation
Recorded for
b669a890261cuv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review