From 2644582c89ca12dcff91b835cef62224ab4aac0d Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 19:53:53 -0500 Subject: [PATCH 1/3] fix(automerge): clear adopt-supersede label once a forced adoption is consumed The 072 adoption call site never removed the request label after an attempt, unlike the 085 one. A consumed Adopt now left the label, so later sweeps re-read it as a plain request and re-logged the refusal. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16489.md | 1 + .../automerge/automerge_adopt_now_test.go | 26 +++++++++++++++++++ .../automerge/automerge_stage_labels.go | 8 ++++++ 3 files changed, 35 insertions(+) create mode 100644 changelog.d/fixed-16489.md diff --git a/changelog.d/fixed-16489.md b/changelog.d/fixed-16489.md new file mode 100644 index 0000000000..f21a8286ed --- /dev/null +++ b/changelog.d/fixed-16489.md @@ -0,0 +1 @@ +- Consuming an operator's "Adopt now" now also removes the `adoption/supersede` label, so the sweep no longer logs a person-authored refusal for that PR every pass ([#16489](https://github.com/hivecommons/hive/issues/16489)). diff --git a/src/pkg/github/automerge/automerge_adopt_now_test.go b/src/pkg/github/automerge/automerge_adopt_now_test.go index c99e676b92..0739d3edc3 100644 --- a/src/pkg/github/automerge/automerge_adopt_now_test.go +++ b/src/pkg/github/automerge/automerge_adopt_now_test.go @@ -159,3 +159,29 @@ func TestAdoptNowTakesOverOwnerAuthoredPR(t *testing.T) { t.Fatalf("forced mark or person block survived the adoption: %+v", rec) } } + +// hivecommons/hive#16489: the adoption/supersede label queued with Adopt now +// is consumed with the forced mark, so later sweeps do not re-read it as a +// plain request and refuse an owner's PR every pass. +func TestAdoptNowConsumesSupersedeLabelOn072(t *testing.T) { + policy := adoptPolicy() + policy.OwnerAuthor = func(login string) bool { return login == "mallory" } + h, done := newAdoptHarness(t, ContributorNudgeOutcome{Mode: "comment"}, policy) + defer done() + h.sink.presence = &ContributorPresence{Registered: true, Online: false} + h.observe(adoptPR(7, "aaa"), "check-failing:unit") + key := stageKey("acme", "widget", 7) + store := h.e.stageStoreOrShared() + labels := []string{"stage/072-returned-to-contributor", "role/contributor", "author/clanker"} + + store.NoteAdoptionForced(key, "clubanderson", h.clock.now()) + h.api.reset() + h.clock.advance(time.Minute) + h.observe(adoptPR(7, "aaa", append(labels, "adoption/supersede")...), "check-failing:unit") + if len(h.adopt.pulls) != 1 { + t.Fatalf("Adopt now did not supersede: pulls=%v", h.adopt.pulls) + } + if !containsLabel(h.api.removed, "adoption/supersede") { + t.Fatalf("request label kept after the forced adoption was consumed: removed=%v", h.api.removed) + } +} diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index a453aebf98..9cb08c3dc9 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -1362,11 +1362,19 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error) } } if policy.Adoption { + before, _ := store.Get(key) n, err := c.adoptContributorPR(ctx, store, key, obs, policy, presence, hasPresence, now) result.Comments += n if err != nil && firstErr == nil { firstErr = err } + // A consumed request (a forced adoption included) must not + // leave its label behind to re-refuse every sweep. + if after, ok := store.Get(key); ok && hasLabel(obs.Labels, delegatedecision.LabelAdoptSupersede) && (after.AdoptedBy > 0 || delegatedAdoptionAttempted(before, after) || after.AdoptionRequestConsumed(obs.HeadSHA)) { + if err := c.removeNonStageLabel(ctx, obs.Owner, obs.Repo, obs.Number, delegatedecision.LabelAdoptSupersede); err != nil && firstErr == nil { + firstErr = err + } + } if err := c.restageAfterAdoption(ctx, reconciler, store, p); err != nil && firstErr == nil { firstErr = err } From 777b57df4e9cc1eaa95da8682ba7a4f0258f5c9e Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 20:26:36 -0500 Subject: [PATCH 2/3] fix(automerge): drop unreachable supersede-label removal; keep regression test Review of the previous commit showed the new removal block could never run: the enclosing 072 branch requires the adoption/supersede label to be absent, while the block required it present. A labelled PR, whatever its stage, is handled by the delegated-request block earlier in ApplyStageLabels, which already removes the label once the attempt is recorded (MarkAdopted also clears the forced mark), so the base tree already has the behaviour #16489 asks for. Revert the dead hunk and the changelog fragment (no behaviour change); keep TestAdoptNowConsumesSupersedeLabelOn072 as a regression guard for that path, with its comment pointing at the block it exercises. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16489.md | 1 - src/pkg/github/automerge/automerge_adopt_now_test.go | 9 ++++++--- src/pkg/github/automerge/automerge_stage_labels.go | 8 -------- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 changelog.d/fixed-16489.md diff --git a/changelog.d/fixed-16489.md b/changelog.d/fixed-16489.md deleted file mode 100644 index f21a8286ed..0000000000 --- a/changelog.d/fixed-16489.md +++ /dev/null @@ -1 +0,0 @@ -- Consuming an operator's "Adopt now" now also removes the `adoption/supersede` label, so the sweep no longer logs a person-authored refusal for that PR every pass ([#16489](https://github.com/hivecommons/hive/issues/16489)). diff --git a/src/pkg/github/automerge/automerge_adopt_now_test.go b/src/pkg/github/automerge/automerge_adopt_now_test.go index 0739d3edc3..aa61d5ae9e 100644 --- a/src/pkg/github/automerge/automerge_adopt_now_test.go +++ b/src/pkg/github/automerge/automerge_adopt_now_test.go @@ -160,9 +160,12 @@ func TestAdoptNowTakesOverOwnerAuthoredPR(t *testing.T) { } } -// hivecommons/hive#16489: the adoption/supersede label queued with Adopt now -// is consumed with the forced mark, so later sweeps do not re-read it as a -// plain request and refuse an owner's PR every pass. +// hivecommons/hive#16489: Adopt now queues the adoption/supersede label along +// with the forced mark. A labelled PR, whatever its stage, is handled by the +// delegated-request block in ApplyStageLabels, which removes the label once +// the attempt is recorded — so later sweeps do not re-read it as a plain +// request and refuse an owner's PR every pass. Regression guard for a PR +// parked at 072 when the forced adoption lands. func TestAdoptNowConsumesSupersedeLabelOn072(t *testing.T) { policy := adoptPolicy() policy.OwnerAuthor = func(login string) bool { return login == "mallory" } diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index 9cb08c3dc9..a453aebf98 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -1362,19 +1362,11 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error) } } if policy.Adoption { - before, _ := store.Get(key) n, err := c.adoptContributorPR(ctx, store, key, obs, policy, presence, hasPresence, now) result.Comments += n if err != nil && firstErr == nil { firstErr = err } - // A consumed request (a forced adoption included) must not - // leave its label behind to re-refuse every sweep. - if after, ok := store.Get(key); ok && hasLabel(obs.Labels, delegatedecision.LabelAdoptSupersede) && (after.AdoptedBy > 0 || delegatedAdoptionAttempted(before, after) || after.AdoptionRequestConsumed(obs.HeadSHA)) { - if err := c.removeNonStageLabel(ctx, obs.Owner, obs.Repo, obs.Number, delegatedecision.LabelAdoptSupersede); err != nil && firstErr == nil { - firstErr = err - } - } if err := c.restageAfterAdoption(ctx, reconciler, store, p); err != nil && firstErr == nil { firstErr = err } From 66de21cdff037f52a6a5bd65939f282cebebf588 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 22:35:23 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8C=B1=20test(automerge):=20retitle?= =?UTF-8?q?=20=E2=80=94=20this=20PR=20is=20test-only,=20not=20a=20behaviou?= =?UTF-8?q?r=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review of #16495 noted the 🐛 fix(automerge) title and the first commit message describe a label-removal hunk as landed. That hunk was reverted in 777b57d because the base tree already removes adoption/supersede in the delegated-request block of ApplyStageLabels; the only change that remains is the regression test TestAdoptNowConsumesSupersedeLabelOn072. The PR title now carries the 🌱 test prefix so the squash-merge history reads as a test addition for #16489 rather than a code fix. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>