Repository navigation
π fix: re-adoption after a closed hive copy is not replayed by the mutation journal - #15209
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
β¦tation journal Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
d570be7 to
ef740d1
Compare
There was a problem hiding this comment.
Reviewed (correctness) β approve with one advisory; read at ef740d1.
Both halves of #15204 are implemented: prior_copy is set from the store only when AdoptOrphanedBy == AdoptedBy (automerge_contributor_adopt.go:767-768), which recoverOrphanedAdoption guarantees via NoteAdoptionOrphaned(key, dead, now) just before the call (automerge_adoption_orphan.go:200-205); Inputs feed the journal's LogicalID (convergence/mutation/boundary.go:279-281, journal.go:189), and the real boundary does return op.Result as provenance on ErrAlreadyApplied (boundary.go:120), so the replay-resolution branch gets the URL it parses.
Advisory (low, in-scope): closed-replay fallthrough discards the conflict replay. First pass is pushBranch(priorCopy) β replaySupersedeOntoBase when supersedeHeadConflicts(obs) β openCopy (automerge_contributor_adopt.go:816-827). The closed-replay path then calls pushBranch(replayed) (:864), whose UpdateRef(..., force=true) re-points hive/adopt-N at the raw tip (:795-798), dropping the base merge commit, and goes straight to openCopy(replayed) (:867) without re-running the conflict replay β so for a conflicting head the fresh copy opens unmergeable, which the first pass explicitly avoids. Fix: re-run the supersedeHeadConflicts block after the second push (or skip the second push when the branch already exists). Not exercised by the new tests (adoptPR(7, "aaa", β¦) has no conflict reason).
Out of scope (pre-existing, for backlog): replaySupersedeOntoBase's claim inputs (:950-951) carry no prior_copy, so on a re-adoption the base merge is itself journal-replayed and silently skipped.
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Read the diff against the journal boundary and the orphan-recovery caller; the mechanism holds and this looks correct to me.
Verified
- Claim
Inputsdo feed the journal identity:src/pkg/convergence/mutation/boundary.go:279-289copies them into theEffect, andjournal.go:189folds them intoLogicalID(). Addingprior_copytherefore yields a distinct logical effect, as the body says. - A replay returns
op.ResultasProvenancewith a nil error (boundary.go:112-126), soadoptionReplayedPRNumber(provenance)sees the earlierβ¦/pull/NURL andcreated == nilβ exactly the pre-fix failure signature (adoption failed to open App PR error=None). priorCopyis populated on the path that matters:automerge_adoption_orphan.go:200callsNoteAdoptionOrphaned(key, dead)beforesupersedeAdoptedPRwhileAdoptedByis stilldead, sostored.AdoptOrphanedBy == stored.AdoptedByis true and both claims carryprior_copy=<dead>. The loop-window second orphan getsprior_copy=<dead2>, also distinct.- Fallback branch (
automerge_contributor_adopt.go:852-869): open replayed PR is adopted; closed-unmerged pushes again withprior=replayedand re-claims. Branch re-push is safe because the 422βUpdateRef(force)path already handles the existingadopt/Nref. - Tests use a fake boundary keyed on
repo|kind|target|inputs(automerge_adoption_readopt_journal_test.go:31-42), soTestAdoptionReadoptAfterClosedCopyIsNotJournalReplayedgenuinely fails without theprior_copyinput.
Note (not a defect): when the replayed PR is closed and merged, the switch has no arm, so it falls through to return 0, nil with the "failed to open App PR" warning β same as before this PR. Fine for #15204's scope; just flagging that the log line is slightly misleading in that one case.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (style/maintainability) β no blocking findings; two advisory notes, read at head ef740d1.
-
Merged-copy replay falls through silently to the opaque failure log β
src/pkg/github/automerge/automerge_contributor_adopt.go:856-872. The replayswitchhandlesgetErr,open, and!GetMerged(), but a replayed copy that is merged matches no case:createdstays nil,errstays nil, and the code lands onadoption failed to open App PR error=None(line 872) β the same uninformative line #15204 quotes. An explicitdefault:(orcase pr.GetMerged():) with its ownc.info/c.warnnaming the merged copy would keep that path readable and make the next log triage trivial. -
supersedeAdoptedPRkeeps growing by nested closures βautomerge_contributor_adopt.go:772-813(pushBranch) and:829-847(openCopy) are now two ~40-line closures inside an already ~170-line method, andstore.Get(key)is read twice in the same function (:745and:767). Behavior is fine; lifting the closures to(c *Engine)methods takingprior intand reusing onestoredlookup would make the replay branch easier to follow. Non-blocking.
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (intent-alignment) β judged against #15204 (the PR's closing keyword; #14947 is the example PR, not an issue). Diff at ef740d1b implements both items of the issue's Fix section and stays inside its stated scope (automerge_contributor_adopt*.go + tests; no dashboard/ledger files). Verified the mechanism end-to-end: recoverOrphanedAdoption calls NoteAdoptionOrphaned(key, dead) right before supersedeAdoptedPR with rec.AdoptedBy == dead (automerge_adoption_orphan.go:200-205), so the AdoptOrphanedBy == AdoptedBy check (automerge_contributor_adopt.go:767) fires on both the direct-poll and marker-scan paths; and the journal's LogicalID hashes claim.Inputs (convergence/mutation/journal.go:189, boundary.go:279-281), so prior_copy genuinely yields a distinct key.
Two low-severity advisories in the new replay-resolution branch (non-blocking):
automerge_contributor_adopt.go:866-870β on a closed-unmerged replay,pushBranch(replayed)re-runsCreateRef/UpdateReftoobs.HeadSHA, which discards the base mergereplaySupersedeOntoBaseperformed at:816-826whensupersedeHeadConflicts(obs)was true;openCopy(replayed)then opens the fresh copy without re-replaying the base. Only hit when a replay and a conflicting head coincide; consider skipping the second push (the branch already exists at the right tip) or re-running the replay.automerge_contributor_adopt.go:856-871β theswitchhandles open and closed-unmerged, but a replayed PR that is closed and merged falls through withcreated == nil, err == nilinto the generic "failed to open App PR" βClearAdoptionrevert at:872-874. Rare (the orphan path is only entered for unmerged copies), but apr.GetMerged()case routing to the merged-copy close path would make the resolution total.
Not run locally: tests type-check by inspection only (fake journalBoundary keys on repo|kind|target|inputs, matching the real boundary's inputs).
β hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
|
#15206 (same parent #15188, rebased on v5 after #15201) already covers this and the two improvements here have been folded into it: |
β¦dopted or could-not-adopt, routes workflow-path PRs to the workflows capability blocker
Let hive decide β adopt-supersede settled the operator-action ledger as
applied ("done") as soon as the adoption/supersede request label landed,
and the β hover kept saying so while nothing happened.
- #14822 edits .github/workflows: the adoption engine's
fence refused the supersession (adoption-stalled:contributor-lane:
workflow-path) and the row fell back to a bare Needs human decision.
The policy now decides such PRs as capability-gap (recommend-only),
the ledger records blocked, and the badge names the
capability:workflows-permission blocker with what a person can do.
- #14947: the re-adoption after the copy #14977 was
closed was replayed by the mutation journal; that fix landed in
#15209 (prior_copy claim input, replayed provenance
resolved). This PR layers the ledger / hover states over it.
- settledDelegatedOutcome: adopt-supersede β executing, dedup β no-effect,
capability-gap β blocked. The tracker derives the β state from the
stage record (adopted as #N / could not adopt / still executing / stuck)
and exposes progress, blocker and human to the SPA hover.
Fixes #15188
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦dopted or could-not-adopt, routes workflow-path PRs to the workflows capability blocker
Let hive decide β adopt-supersede settled the operator-action ledger as
applied ("done") as soon as the adoption/supersede request label landed,
and the β hover kept saying so while nothing happened.
- #14822 edits .github/workflows: the adoption engine's
fence refused the supersession (adoption-stalled:contributor-lane:
workflow-path) and the row fell back to a bare Needs human decision.
The policy now decides such PRs as capability-gap (recommend-only),
the ledger records blocked, and the badge names the
capability:workflows-permission blocker with what a person can do.
- #14947: the re-adoption after the copy #14977 was
closed was replayed by the mutation journal; that fix landed in
#15209 (prior_copy claim input, replayed provenance
resolved). This PR layers the ledger / hover states over it.
- settledDelegatedOutcome: adopt-supersede β executing, dedup β no-effect,
capability-gap β blocked. The tracker derives the β state from the
stage record (adopted as #N / could not adopt / still executing / stuck)
and exposes progress, blocker and human to the SPA hover.
Fixes #15188
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦dopted or could-not-adopt, routes workflow-path PRs to the workflows capability blocker (#15206) Let hive decide β adopt-supersede settled the operator-action ledger as applied ("done") as soon as the adoption/supersede request label landed, and the β hover kept saying so while nothing happened. - #14822 edits .github/workflows: the adoption engine's fence refused the supersession (adoption-stalled:contributor-lane: workflow-path) and the row fell back to a bare Needs human decision. The policy now decides such PRs as capability-gap (recommend-only), the ledger records blocked, and the badge names the capability:workflows-permission blocker with what a person can do. - #14947: the re-adoption after the copy #14977 was closed was replayed by the mutation journal; that fix landed in #15209 (prior_copy claim input, replayed provenance resolved). This PR layers the ledger / hover states over it. - settledDelegatedOutcome: adopt-supersede β executing, dedup β no-effect, capability-gap β blocked. The tracker derives the β state from the stage record (adopted as #N / could not adopt / still executing / stuck) and exposes progress, blocker and human to the SPA hover. Fixes #15188 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
When hive closed its own copy of an adopted PR (#14947 β #14977), the orphan recovery re-ran
supersedeAdoptedPRwith the samebranch_push/pull_request_createclaim inputs as the original adoption. The mutation journal therefore matched the first claim's logical effect key and answered "already applied": the effect closure never ran,createdstayed nil, the engine loggedadoption failed to open App PR error=None, andClearAdoptionreverted the adoption. Every retry looped into the same replay.Changes (
automerge_contributor_adopt.go):prior_copy=<dead #>to both claim inputs, so it is a distinct logical effect and the journal does not replay the first claim. Claims without a prior copy keep their existing keys.pull_request_createreplay hands back provenance (β¦/pull/N), it is resolved: an open PR becomes the adoption's copy; a closed-unmerged one triggers a fresh claim (prior_copy=N) instead of being read as a failure.Tests (
automerge_adoption_readopt_journal_test.go) use a journaling fake boundary: re-adopt after a closed copy opens #91 without a replay; a replay naming a closed PR opens a fresh copy and does not revert; a replay naming an open PR adopts it.Closes #15204
Part of #15188 (child (c); (b) is #15203 and (a)+(d) is #15205, sequenced after #15134)
β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@thatguywob