Repository navigation
chore: item done leaves an item stuck In Progress when its PR was merged externally before finalize ran (seen on #283 / PR #910) - #953
Merged
getappz merged 3 commits intoOct 22, 2026
Conversation
A human (or another instance's finalize) merged an item's PR while its job was still running, and the head branch went with it. `done` then tried to push a branch that no longer existed, and the item was left wedged in "started" with its PR record stripped -- a state nothing could recover from, because the sweep's self-heal reads the PR number out of that same record (item #283 / PR #910, item #173 / PR #666). `done` now asks GitHub whether the PR it tracked has already merged, and when it has, completes the item instead of pushing. Two conditions keep it honest: - it keys on `metadata.pr`, and `redispatch` clears that -- so an item handed back for more work carries no PR reference and can never be completed by someone else's merge; - the merge has to have covered the branch. A branch tip that moved on after the merge holds work the PR never carried, and that work is not completed away. The PR record survives the completion: it is what lets the review sweep find the PR again. Also adds `AgentflareMcp::github_client_override`, a GitHub-client test seam in the same shape as the repo-root and backend-db overrides, so a code path that has to ask GitHub about a PR can be driven end to end against a mock server instead of only at the helper level. Agentflare-Agent: opencode Agentflare-Branch: task/373-item-done-leaves-an-item-stuck-in-progre Agentflare-Item: 373
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 6 minutes. View limit details
Comment |
getappz
marked this pull request as ready for review
October 22, 2026 08:06
…-progre Agentflare-Agent: opencode Agentflare-Branch: HEAD
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.
A human (or another instance's finalize) merged an item's PR while its job was still running, and the head branch went with it.
donethen tried to push a branch that no longer existed, and the item was left wedged instartedwith its PR record stripped — a state nothing could recover from, because the sweep's self-heal reads the PR number out of that same record (item #283 / PR #910, item #173 / PR #666).donenow asks GitHub whether the PR it tracked has already merged, and when it has, completes the item instead of pushing.Two conditions keep it honest:
metadata.pr, andredispatchclears that (crates/agentflare-backend/src/item/claim.rs) — so an item handed back for more work carries no PR reference and can never be completed by someone else's merge;The PR record survives the completion: it is what lets the review sweep find the PR again.
Also adds
AgentflareMcp::github_client_override— a GitHub-client test seam in the same shape as the repo-root and backend-db overrides — so a code path that has to ask GitHub about a PR can be driven end to end against a mock server instead of only at the helper level. (item_check_merge's merge path had no such seam, which is why its behaviour was only ever unit-tested one layer down.)Test plan
Notes for reviewers
Risk areas
item_doneis the most-used path in the codebase. The new branch fires only when the item records a PR and GitHub reports that PR merged and the branch tip is exactly the PR's head — three conditions, all of which must hold.donecall on an item that has a PR. It runs before the push, so a merged PR short-circuits the push entirely.metadata.pris deliberately not cleared on this path: the sweep needs it to find the PR again.Edge cases covered by tests
metadata.pr.number, releases the claim, and removes the worktree;Backwards compatibility
Opened by
opencodeon i-flare-51bb8de6c33b (flared:51bb8de6c33b) for item #373 via agentflare.