Skip to content

πŸ› fix: re-adoption after a closed hive copy is not replayed by the mutation journal - #15209

Merged
hivecommons-hive[bot] merged 1 commit into
v5from
scanner/fix-15204
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v5from
scanner/fix-15204

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

When hive closed its own copy of an adopted PR (#14947 β†’ #14977), the orphan recovery re-ran supersedeAdoptedPR with the same branch_push / pull_request_create claim 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, created stayed nil, the engine logged adoption failed to open App PR error=None, and ClearAdoption reverted the adoption. Every retry looped into the same replay.

Changes (automerge_contributor_adopt.go):

  • A re-adoption after an orphaned copy adds 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.
  • When a pull_request_create replay 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

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15219 πŸ› fix: preserve human and owner PRs during delegated decisions same files src/pkg/github/automerge/automerge_contributor_adopt.go
#15206 πŸ› Activity Monitor: delegated adopt-supersede reports executing β†’ adopted/could-not-adopt, routes workflow-path to the workflows blocker, re-adoption survives the mutation journal same files src/pkg/github/automerge/automerge_contributor_adopt.go
#15085 ✨ Activity Monitor: Adopt now and Reroute to another clanker for PRs waiting on a contributor's clanker same files src/pkg/github/automerge/automerge_contributor_adopt.go

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 29, 2026
@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 29, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 29, 2026
…tation journal

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 29, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed β€” no findings from this perspective.

β€” hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against the journal boundary and the orphan-recovery caller; the mechanism holds and this looks correct to me.

Verified

  • Claim Inputs do feed the journal identity: src/pkg/convergence/mutation/boundary.go:279-289 copies them into the Effect, and journal.go:189 folds them into LogicalID(). Adding prior_copy therefore yields a distinct logical effect, as the body says.
  • A replay returns op.Result as Provenance with a nil error (boundary.go:112-126), so adoptionReplayedPRNumber(provenance) sees the earlier …/pull/N URL and created == nil β€” exactly the pre-fix failure signature (adoption failed to open App PR error=None).
  • priorCopy is populated on the path that matters: automerge_adoption_orphan.go:200 calls NoteAdoptionOrphaned(key, dead) before supersedeAdoptedPR while AdoptedBy is still dead, so stored.AdoptOrphanedBy == stored.AdoptedBy is true and both claims carry prior_copy=<dead>. The loop-window second orphan gets prior_copy=<dead2>, also distinct.
  • Fallback branch (automerge_contributor_adopt.go:852-869): open replayed PR is adopted; closed-unmerged pushes again with prior=replayed and re-claims. Branch re-push is safe because the 422β†’UpdateRef(force) path already handles the existing adopt/N ref.
  • Tests use a fake boundary keyed on repo|kind|target|inputs (automerge_adoption_readopt_journal_test.go:31-42), so TestAdoptionReadoptAfterClosedCopyIsNotJournalReplayed genuinely fails without the prior_copy input.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed (style/maintainability) β€” no blocking findings; two advisory notes, read at head ef740d1.

  1. Merged-copy replay falls through silently to the opaque failure log β€” src/pkg/github/automerge/automerge_contributor_adopt.go:856-872. The replay switch handles getErr, open, and !GetMerged(), but a replayed copy that is merged matches no case: created stays nil, err stays nil, and the code lands on adoption failed to open App PR error=None (line 872) β€” the same uninformative line #15204 quotes. An explicit default: (or case pr.GetMerged():) with its own c.info/c.warn naming the merged copy would keep that path readable and make the next log triage trivial.

  2. supersedeAdoptedPR keeps 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, and store.Get(key) is read twice in the same function (:745 and :767). Behavior is fine; lifting the closures to (c *Engine) methods taking prior int and reusing one stored lookup 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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):

  1. automerge_contributor_adopt.go:866-870 β€” on a closed-unmerged replay, pushBranch(replayed) re-runs CreateRef/UpdateRef to obs.HeadSHA, which discards the base merge replaySupersedeOntoBase performed at :816-826 when supersedeHeadConflicts(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.
  2. automerge_contributor_adopt.go:856-871 β€” the switch handles open and closed-unmerged, but a replayed PR that is closed and merged falls through with created == nil, err == nil into the generic "failed to open App PR" β†’ ClearAdoption revert at :872-874. Rare (the orphan path is only entered for unmerged copies), but a pr.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

@hivecommons-hive
hivecommons-hive Bot merged commit cf1fe3a into v5 Oct 29, 2026
75 of 77 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15204 branch October 29, 2026 01:37
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#15209ef740d1` sha256:d39547dd78eb04ec881ffb7e6d839358d516c295be9ab3d00659998c11502a6f β€” download from the dashboard or `hivectl review evidence #15209`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 29, 2026
@clubanderson

Copy link
Copy Markdown
Member

#15206 (same parent #15188, rebased on v5 after #15201) already covers this and the two improvements here have been folded into it: prior_copy is added to the branch_push / pull_request_create claims only when a prior copy exists (first adoptions keep their existing keys), and a replayed provenance is resolved β€” an open copy is reused, a closed-unmerged one triggers a fresh push + create keyed on the dead number in the same pass. #15206 also adds the βœ“ hover / ledger states (executing β†’ adopted as #N / could not adopt) that this fix was sequenced behind, with a journaling-boundary test for each replay case. Suggest landing #15206 and closing this as superseded.

clubanderson added a commit that referenced this pull request Oct 29, 2026
…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>
clubanderson added a commit that referenced this pull request Oct 29, 2026
…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>
clubanderson added a commit that referenced this pull request Oct 29, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] Re-adoption after a closed hive copy is defeated by mutation-journal replay

1 participant