Skip to content

πŸ› Adoption: re-adopt when the hive's superseding copy is closed unmerged - #15072

Merged
clubanderson merged 1 commit into
v5from
fix/adoption-orphan-recovery
Oct 28, 2026
Merged

clubanderson merged 1 commit into
v5from
fix/adoption-orphan-recovery

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #15052

What happened

On hive's hive, PR 14947 (thatguywob) was adopted in supersede mode at 15:40Z β†’ hive copy #14977. At 15:46Z the duplicate-fix sweep closed #14977 unmerged (sweep already fixed in #15011). The adoption was orphaned: 14947 sat OPEN at stage/085-needs-decision, the tracker said "Needs human decision", and Let hive decide answered "No change β€” hive already recorded this decision (rule contributor-offline)".

What this changes

Stage-label pass (pkg/github/automerge)

  • settleSuperseder: a superseder that is CLOSED and not merged is an orphaned adoption β†’ recoverOrphanedAdoption: log stage labels: adoption orphaned, re-adopting old=N new=M, open a fresh hive-authored copy from the same head, post a new hive:adopted … superseded_by=M marker.
  • Revert fallback: head moved / original merged / re-adoption failed β†’ ClearAdoption, PR returns to its pre-adoption stage, one <!-- hive:adoption-reverted head=… superseded_by=… why=head-moved|readopt-failed --> comment with plain words.
  • Loop guard: child closed again within an hour of the first orphan β†’ <!-- hive:adoption-child-closed-twice -->, park at 085 with reason adoption-child-closed-twice (held from stalled-adoption escalation).
  • Marker scan (restores state a rolled hive lost β€” the live 14947 record has no adoption fields): once per head, a PR at 085 with author/clanker and no adoption on record has its comments scanned for the last unsettled hive:adopted mode=supersede marker; merged copy β†’ standard "adopted β†’ merged" close of the original; closed copy β†’ recovery above; open copy β†’ restored to the record.
  • Merged superseder path unchanged (verified by test: fresh copy merges β†’ original closed).

Delegated decision (pkg/dashboard)

  • delegatedOrphanedAdoption detects a dead superseded_by (from markers + live PR state) and overrides the rule to adopt-supersede; the "already recorded" no-op no longer short-circuits when the orphan post-dates the prior decision. Outcome: "Re-adopting: hive's earlier copy πŸ› fix: reject auto-merge queues from untrusted merger identitiesΒ #14977 was closed by mistake; opening a fresh copy." Past the loop guard it recommends a person instead of opening a third copy.

Tracker

  • New adopted_by_state (closed | closed-twice); SPA stageTrackerAdoptedWord renders "Adopted β†’ #N (closed) Β· recovering" / "Adopted β†’ #N (closed twice) Β· needs a person", also on the 085 row; Go captions and the needs-human popover question say plainly why.

Docs: labels-and-control-signals.md (adoption section), dashboard-sections.md. Changelog fragment changelog.d/fixed-adoption-orphan-recovery.md.

Tests

  • automerge: re-adopt, closed-twice park, closed-again-after-window re-adopts, head-moved revert, re-adopt-failure revert, marker scan (closed / merged / closed-twice history / settled-or-absent), ScanAdoptionMarkers.
  • stagelabels: orphan record fields/AdoptionChildClosedTwice.
  • dashboard: delegated orphan re-adopt, live-copy no-op, looped recommendation, decision text, tracker adopted_by_state + captions; node fixture for stageTrackerAdoptedWord.
  • Coverage: dashboard 87.8% (floor 84), automerge 89.7% (88), github 88.9% (88), stagelabels 91.5% (90).

Acceptance

After roll, on hive's hive the first stage-label pass over 14947 (085, author/clanker, no adoption on record) runs the marker scan, finds superseded_by=14977 closed-unmerged, logs stage labels: adoption orphaned, re-adopting, opens a fresh copy and moves 14947 back to 074 ("Adopted β†’ #new").

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 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 hanthor 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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Both this PR and #15057 fix #15052. #15057 opened first but its checks are red while this PR is green, so the hive is asking the owner to pick rather than closing either.

@hivecommons-hive hivecommons-hive Bot added needs-human hive/supersession-pending stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue labels Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 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
#15057 πŸ› fix: recover orphaned supersede adoptions CONFLICT src/pkg/dashboard/api_repo_item_decide_delegated.go
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/static/index.html
src/pkg/github/automerge/automerge_adoption_orphan.go
src/pkg/github/automerge/automerge_adoption_orphan_test.go
src/pkg/github/automerge/automerge_contributor_adopt.go
src/pkg/github/automerge/automerge_contributor_adopt_test.go
src/pkg/github/automerge/automerge_stage_labels.go
src/pkg/stagelabels/adoption_orphan_test.go
src/pkg/stagelabels/store.go
#15067 πŸ› fix: enable bulk delegation for multi-PR parent selections same files src/pkg/dashboard/static/index.html
#15070 ✨ Activity Monitor: presence indicator (clanker online / offline / none) on the waiting-on pill same files src/docs/dashboard-sections.md
src/docs/labels-and-control-signals.md
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/static/index.html
#14807 ✨ dashboard: stream Job pod logs in the terminal pane for sandbox.runtime: job agents same files src/pkg/dashboard/static/index.html
#15020 πŸ› fix(stage): a contributor PR with no linked issue is not waiting on the hive same files src/pkg/github/automerge/automerge_stage_labels.go
#15074 πŸ› Activity Monitor: server-derived stage actor icons, one row per PR, Merged-today counter above the gate same files src/docs/dashboard-sections.md
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/static/index.html
#15069 πŸ› fix: record pending operator action before starting delegated job same files src/pkg/dashboard/api_repo_item_decide_delegated.go
#15087 πŸ› Activity Monitor: Ready for human merge offers Approve & merge / let hive merge; every needs-human state has its action same files src/docs/dashboard-sections.md
src/pkg/dashboard/api_repo_item_decision_test.go
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/stage_tracker_decision.go
src/pkg/dashboard/static/index.html
#15085 ✨ Activity Monitor: Adopt now and Reroute to another clanker for PRs waiting on a contributor's clanker same files src/docs/dashboard-sections.md
src/docs/labels-and-control-signals.md
src/pkg/dashboard/api_repo_item_decide_delegated.go
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/stage_tracker_decision.go
src/pkg/dashboard/static/index.html
src/pkg/github/automerge/automerge_contributor_adopt.go
src/pkg/github/automerge/automerge_stage_labels.go
src/pkg/stagelabels/store.go

@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue labels Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Style/readability (read at head 2952dd3)

Loop-guard note from the marker scan renders #0 as the first copy. recoverOrphanedAdoptionFromMarker calls AdoptionChildClosedTwiceComment(obs, 0, dead) (src/pkg/github/automerge/automerge_adoption_orphan.go:287), and the template unconditionally prints both numbers (:168-170), so the PR gets a public comment saying "closed without merging twice within an hour (#0, then #89)" plus a first=0 marker attribute. ScanAdoptionMarkers already walks every marker (:128-145) β€” it just drops the previous one. TestAdoptionMarkersClosedTwiceParksFromHistory only counts the note, so the text is unasserted.

Suggested fix β€” keep the previous copy's number on the scan and pass it through:

 type AdoptionMarkerScan struct {
 	Live   bool
 	Marker AdoptionMarker
+	// Previous is the copy named by the marker before Marker (0 when
+	// Marker is the first): the loop guard's "first" number.
+	Previous int
 	Count  int
 }
@@ func ScanAdoptionMarkers(comments []*gh.IssueComment) AdoptionMarkerScan {
 		if m, ok := ParseAdoptionMarker(body); ok {
 			m.At = c.GetCreatedAt().Time
+			out.Previous = out.Marker.SupersededBy
 			out.Marker, out.Live = m, true
 			out.Count++
 			continue
 		}
@@ func (c *Engine) recoverOrphanedAdoptionFromMarker(
-			if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(AdoptionChildClosedTwiceComment(obs, 0, dead))}); err != nil {
+			if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(AdoptionChildClosedTwiceComment(obs, scan.Previous, dead))}); err != nil {

and assert #88, then #89 on the note body in TestAdoptionMarkersClosedTwiceParksFromHistory.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security perspective (read at head 2952dd3)

Forged hive:adopted comments drive PR close / re-adoption β€” marker scan does not check who posted the comment.

ScanAdoptionMarkers (src/pkg/github/automerge/automerge_adoption_orphan.go:131-148) accepts a <!-- hive:adopted … mode=supersede superseded_by=N head=… --> marker from any comment on the PR; neither it nor its callers look at c.GetUser(). Both new consumers act on the result with write operations:

  • recoverOrphanedAdoptionFromMarker (automerge_adoption_orphan.go:258-297) runs on every clanker-authored PR parked at 085 (adoptionMarkerScanDue, :239-249). It calls store.MarkAdopted(key, adoptedHead, dead, now) with adoptedHead taken from the marker (:271-272), then:
    • sup.GetMerged() β†’ closeSupersededOriginal (automerge_contributor_adopt.go:1034-1056). Because rec.AdoptedHead now equals the forged head=, supersederCarriesHead (:1018-1022) returns true and the hive closes the open PR. Anyone who can comment on a public repo can point superseded_by= at any merged PR and have the hive close another agent's PR.
    • copy closed β†’ recoverOrphanedAdoption β†’ supersedeAdoptedPR (automerge_adoption_orphan.go:201-205): the hive opens a hive-authored copy of a PR a reviewer parked as requires_human, bypassing the 085 gate on the strength of an unauthenticated comment.
  • delegatedOrphanedAdoption (src/pkg/dashboard/api_repo_item_decide_orphan.go:49-61) reads the same unfiltered scan and overrides the recorded policy decision to VerdictAdoptSupersede (:81-86); lower exposure since a user must click Let hive decide, but the forged marker still decides the verdict.

The repo already has the right precedent: the claim-marker reader in automerge_contributor_lane.go:1010 skips comments not authored by c.transport.AppBotLogin(). Please do the same here (the real hive:adopted marker is posted with the App token, so it matches).

--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
+++ b/src/pkg/github/automerge/automerge_adoption_orphan.go
-// ScanAdoptionMarkers reads the comments in posting order.
-func ScanAdoptionMarkers(comments []*gh.IssueComment) AdoptionMarkerScan {
+// ScanAdoptionMarkers reads the comments in posting order. Only comments
+// written by appLogin count: the marker closes PRs and opens hive-authored
+// copies, so it must not be forgeable by anyone who can comment.
+func ScanAdoptionMarkers(comments []*gh.IssueComment, appLogin string) AdoptionMarkerScan {
 	var out AdoptionMarkerScan
+	appLogin = strings.TrimSpace(appLogin)
+	if appLogin == "" {
+		return out
+	}
 	for _, c := range comments {
-		if c == nil {
+		if c == nil || !strings.EqualFold(hgithub.SafeGetLogin(c.GetUser()), appLogin) {
 			continue
 		}
@@ func (c *Engine) recoverOrphanedAdoptionFromMarker(
-	scan := ScanAdoptionMarkers(comments)
+	scan := ScanAdoptionMarkers(comments, c.transport.AppBotLogin())
--- a/src/pkg/dashboard/api_repo_item_decide_orphan.go
+++ b/src/pkg/dashboard/api_repo_item_decide_orphan.go
-	scan := automerge.ScanAdoptionMarkers(comments)
+	scan := automerge.ScanAdoptionMarkers(comments, s.deps.GHClient.AppBotLogin())

(adjust the dashboard accessor to however the server exposes the App login; the tests in automerge_adoption_orphan_test.go / api_repo_item_decide_orphan_test.go need User: &gh.User{Login: …} on their fixture comments plus one case asserting a marker from another login is ignored).

β€” 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

Choose a reason for hiding this comment

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

Correctness review (read at head 2952dd3, plus the mutation boundary the re-adopt path runs through).

1. Re-adoption from the same head is deduped by the mutation journal β†’ always reverts as readopt-failed (in-scope, high)

recoverOrphanedAdoption re-runs supersedeAdoptedPR from the same head (automerge_adoption_orphan.go:205). That function wraps the PR open in effects.Execute with claim inputs {base, supersedes, head_sha} (automerge_contributor_adopt.go:749) β€” identical to the claim journaled by the original adoption at 15:40Z. Under the default shadow mode (pkg/config/convergence.go:97, RecordingEnabled = shadow|enforce) the journal is durable (cmd/hive/main.go:2059 ↔ journal.json), and mutation.Boundary.Execute treats ErrAlreadyApplied as idempotent success without running the effect (pkg/convergence/mutation/boundary.go:118-130; executor.go:105-113). So created stays nil with err == nil, supersedeAdoptedPR returns 0, nil at :763, the store still has AdoptedBy == dead, and recoverOrphanedAdoption falls through to revertOrphanedAdoption(... adoptionRevertReadoptFail) (automerge_adoption_orphan.go:214-216). Net effect on hive's hive: #14947 gets an "adoption is undone" note instead of a fresh copy β€” the acceptance in #15052 ("re-adopts 14947 … within one stage-label pass") is not met. The tests don't see this because the harness runs with a nil boundary (NoopBoundary). The same applies to the dashboard ActionAdoptSupersede path, which ends in the same function.

Fix: make the re-adopt claims distinct from the first adoption's, and let supersedeAdoptedPR see the orphan count (it is bumped on the store at :200 but rec passed at :205 is the pre-bump copy).

--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
+++ b/src/pkg/github/automerge/automerge_adoption_orphan.go
@@ -199,6 +199,7 @@
 	store.NoteAdoptionOrphaned(key, dead, now)
+	rec, _ = store.Get(key) // carry AdoptOrphanCount into the claim inputs
 	c.info("stage labels: adoption orphaned, re-adopting", logArgs("old", dead, "attempt", rec.AdoptOrphanCount+1)...)
--- a/src/pkg/github/automerge/automerge_contributor_adopt.go
+++ b/src/pkg/github/automerge/automerge_contributor_adopt.go
@@ -711,7 +711,11 @@
+	claimInputs := func(m map[string]string) map[string]string {
+		if rec.AdoptOrphanCount > 0 { m["readopt"] = strconv.Itoa(rec.AdoptOrphanCount) }
+		return m
+	}
 	_, err = effects.Execute(ctx, c.mutation, effects.Claim{
 		Repo: fullRepo, Kind: effects.KindBranchPush, Target: branch, Actor: "stage_labels",
-		Inputs: map[string]string{"pr": strconv.Itoa(number), "head_sha": obs.HeadSHA, "adopt": "true"},
+		Inputs: claimInputs(map[string]string{"pr": strconv.Itoa(number), "head_sha": obs.HeadSHA, "adopt": "true"}),
@@ -747,7 +751,7 @@
 		Repo: fullRepo, Kind: effects.KindPullRequestCreate, Target: branch, Actor: "stage_labels",
-		Inputs: map[string]string{"base": obs.BaseRef, "supersedes": strconv.Itoa(number), "head_sha": obs.HeadSHA},
+		Inputs: claimInputs(map[string]string{"base": obs.BaseRef, "supersedes": strconv.Itoa(number), "head_sha": obs.HeadSHA}),

(The log line's attempt then also needs to drop the +1.) A test that wires a journaling mutation.Boundary into the adopt harness and asserts a second POST /pulls would pin this.

2. Marker-path loop guard counts settled markers (in-scope, low)

ScanAdoptionMarkers increments Count for every supersede marker, including ones later settled by a revert/close note (automerge_adoption_orphan.go:134), and AdoptionLoopFromMarkers only checks Count > 1 + the latest marker's age (:147-149). A PR adopted once long ago (settled) and re-adopted within the last hour whose copy was closed once will be parked as adoption-child-closed-twice instead of recovered, and the note reads "(#0, then #N)" since the marker path has no first number (:287). Suggest counting only markers posted after the last settling note (reset Count when AdoptionSettledMarker flips Live false) and keeping the previous marker's SupersededBy for the comment.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Intent alignment vs #15052 (read at head 2952dd3)

1. Re-adoption from the same head is deduped by the mutation journal β†’ always reverts as readopt-failed (high, in-scope)

recoverOrphanedAdoption (src/pkg/github/automerge/automerge_adoption_orphan.go:196) calls supersedeAdoptedPR with the same obs.HeadSHA, so both effects.Claims in automerge_contributor_adopt.go:714-717 (branch_push, target hive/adopt-N, inputs pr/head_sha/adopt) and :747-749 (pull_request_create, inputs base/supersedes/head_sha) are byte-identical to the first adoption's. With the default convergence mode shadow (pkg/config/convergence.go:97, journaling on per mutation/executor.go:19), Journal.Begin returns ErrAlreadyApplied (mutation/journal.go:386-387) and the boundary treats it as idempotent success without running the effect (mutation/boundary.go:113-125). created stays nil, supersedeAdoptedPR returns (0, nil) at :768-771, after.AdoptedBy == dead, and recoverOrphanedAdoption falls through to revertOrphanedAdoption(... adoptionRevertReadoptFail) (automerge_adoption_orphan.go:205-211). On hive's hive the acceptance in #15052 ("re-adopts 14947 ... within one stage-label pass") would instead post "the hive could not open a fresh copy just now" and clear the adoption. The tests pass because the harness has no journaling boundary.

Fix: make the re-adoption claims distinct. E.g. re-read the record after NoteAdoptionOrphaned and thread the attempt into both claims:

--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
@@ func (c *Engine) recoverOrphanedAdoption(
 	store.NoteAdoptionOrphaned(key, dead, now)
+	rec, _ = store.Get(key) // carries AdoptOrphanCount for the claim inputs
 	c.info("stage labels: adoption orphaned, re-adopting", logArgs("old", dead, "attempt", rec.AdoptOrphanCount)...)
--- a/src/pkg/github/automerge/automerge_contributor_adopt.go
@@ func (c *Engine) supersedeAdoptedPR(
+	pushInputs := map[string]string{"pr": strconv.Itoa(number), "head_sha": obs.HeadSHA, "adopt": "true"}
+	createInputs := map[string]string{"base": obs.BaseRef, "supersedes": strconv.Itoa(number), "head_sha": obs.HeadSHA}
+	if rec.AdoptOrphanCount > 0 {
+		// A re-adoption after an orphaned copy (hivecommons/hive#15052) is a
+		// new logical effect; the journal must not replay the first copy.
+		a := strconv.Itoa(rec.AdoptOrphanCount)
+		pushInputs["readopt"], createInputs["readopt"] = a, a
+	}
 	_, err = effects.Execute(ctx, c.mutation, effects.Claim{
-		Repo: fullRepo, Kind: effects.KindBranchPush, Target: branch, Actor: "stage_labels",
-		Inputs: map[string]string{"pr": strconv.Itoa(number), "head_sha": obs.HeadSHA, "adopt": "true"},
+		Repo: fullRepo, Kind: effects.KindBranchPush, Target: branch, Actor: "stage_labels", Inputs: pushInputs,
 	}, ...
 	_, err = effects.Execute(ctx, c.mutation, effects.Claim{
-		Repo: fullRepo, Kind: effects.KindPullRequestCreate, Target: branch, Actor: "stage_labels",
-		Inputs: map[string]string{"base": obs.BaseRef, "supersedes": strconv.Itoa(number), "head_sha": obs.HeadSHA},
+		Repo: fullRepo, Kind: effects.KindPullRequestCreate, Target: branch, Actor: "stage_labels", Inputs: createInputs,
 	}, ...

Please add a test that runs the re-adopt through a journaling mutation.Boundary (mode shadow) after a first adoption at the same head and asserts a second POST /pulls.

2. Marker-path loop-guard note names #0 (low, in-scope)

automerge_adoption_orphan.go:285 calls AdoptionChildClosedTwiceComment(obs, 0, dead), rendering first=0 and "(#0, then #N)" (:172-176). ScanAdoptionMarkers only keeps the last marker; keep the previous marker's SupersededBy (e.g. a Prev AdoptionMarker field) and pass it here, or word the note without the first number when unknown.

Advisory: the marker-scan path does not call restageAfterAdoption, so 14947 moves to 074 on the next sweep after the re-adopt, not the same pass as the PR body says β€” fine per #15052's acceptance, just noting the body overstates it.

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

@clubanderson
clubanderson force-pushed the fix/adoption-orphan-recovery branch from 2952dd3 to d772475 Compare October 28, 2026 19:46
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Intent-alignment β€” delta re-review at d772475 (previous head 2952dd3). The delta is a rebase onto v5 (six upstream commits) plus one mechanical conflict resolution moving the orphan hook from runDelegatedDecision into decideDelegatedOne; the PR's own hunks are otherwise byte-identical. Every previous in-scope finding is therefore still present:

  1. Re-adoption from the same head is deduped by the mutation journal, so the "re-adopt" path always ends in why=readopt-failed (still present). recoverOrphanedAdoption (src/pkg/github/automerge/automerge_adoption_orphan.go:205) calls supersedeAdoptedPR, whose branch-push claim (automerge_contributor_adopt.go:712-714: Target hive/adopt-N, Inputs pr/head_sha/adopt) and PR-create claim (:747-750: Target hive/adopt-N, Inputs base/supersedes/head_sha) are identical to the first adoption's β€” nothing in either claim distinguishes attempt 1 from attempt 2. In production c.mutation is the journaling boundary (automerge_sweep.go:360-362), which replays an exact-ID applied claim as idempotent success without running the effect (src/crux/effects/effects.go:155-160), so created stays nil, supersedeAdoptedPR returns 0, nil, and recoverOrphanedAdoption falls through to revertOrphanedAdoption(..., adoptionRevertReadoptFail). The issue's acceptance ("re-adopts 14947 … within one stage-label pass") is not met on a real hive; the tests pass only because the harness uses the nil/Noop boundary. Fix β€” salt both claims with the orphan attempt:
--- a/src/pkg/github/automerge/automerge_contributor_adopt.go
+++ b/src/pkg/github/automerge/automerge_contributor_adopt.go
@@ func (c *Engine) supersedeAdoptedPR(
+	attempt := strconv.Itoa(rec.AdoptOrphanCount)
 	_, err = effects.Execute(ctx, c.mutation, effects.Claim{
 		Repo: fullRepo, Kind: effects.KindBranchPush, Target: branch, Actor: "stage_labels",
-		Inputs: map[string]string{"pr": strconv.Itoa(number), "head_sha": obs.HeadSHA, "adopt": "true"},
+		Inputs: map[string]string{"pr": strconv.Itoa(number), "head_sha": obs.HeadSHA, "adopt": "true", "attempt": attempt},
 	}, func(ctx context.Context) (effects.Result, error) {
@@
 	_, err = effects.Execute(ctx, c.mutation, effects.Claim{
 		Repo: fullRepo, Kind: effects.KindPullRequestCreate, Target: branch, Actor: "stage_labels",
-		Inputs: map[string]string{"base": obs.BaseRef, "supersedes": strconv.Itoa(number), "head_sha": obs.HeadSHA},
+		Inputs: map[string]string{"base": obs.BaseRef, "supersedes": strconv.Itoa(number), "head_sha": obs.HeadSHA, "attempt": attempt},
 	}, func(ctx context.Context) (effects.Result, error) {

(store.NoteAdoptionOrphaned at automerge_adoption_orphan.go:203 increments AdoptOrphanCount before the call, so the first re-adopt uses attempt=1; the original adoption keeps attempt=0.) Add a test with a journaling fake boundary that records applied claims so this path is covered.

  1. Marker-path loop guard posts first=0 / "(#0, then #N)" (still present). automerge_adoption_orphan.go:287 calls AdoptionChildClosedTwiceComment(obs, 0, dead); the comment template (:179-183) renders the literal #0. ScanAdoptionMarkers already walks every marker (:124-141) β€” keep the previous one:
--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
+++ b/src/pkg/github/automerge/automerge_adoption_orphan.go
@@ type AdoptionMarkerScan struct {
 	Live   bool
 	Marker AdoptionMarker
+	Prev   AdoptionMarker // the supersede marker before Marker, when Count > 1
 	Count  int
 }
@@ func ScanAdoptionMarkers(
 		if m, ok := ParseAdoptionMarker(body); ok {
 			m.At = c.GetCreatedAt().Time
+			out.Prev = out.Marker
 			out.Marker, out.Live = m, true
@@ func (c *Engine) recoverOrphanedAdoptionFromMarker(
-			if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(AdoptionChildClosedTwiceComment(obs, 0, dead))}); err != nil {
+			if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(AdoptionChildClosedTwiceComment(obs, scan.Prev.SupersededBy, dead))}); err != nil {
  1. PR body: "moves 14947 back to 074" in the first pass (still present, minor). The marker scan at automerge_stage_labels.go:1197-1200 runs inside the post-transition loop (:1068-1070 reads transitions[i].Outcome, already written), so MarkAdopted lands after this pass's labels; 074 is applied on the next sweep. The issue's acceptance only requires the re-adopt itself within one pass, so either reword the body/changelog or move the scan ahead of the transition batch.

Verdict unchanged: changes_requested.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Delta re-review (2952dd3 β†’ 306e3f2, intent-alignment). The delta is a rebase onto v5; the PR's own interdiff is limited to adapting the dedup guard to delegatedPriorDecisionState (api_repo_item_decide_delegated.go, prior.At.After(orphan.MarkerAt)), one docs sentence, and test fixtures. That adaptation is correct at head (delegated_decision_effect.go:46-47, api_repo_item_decide_orphan.go:36,61). No new intent gaps versus #15052.

Still present (low, in-scope): the marker-scan loop guard posts AdoptionChildClosedTwiceComment(obs, 0, dead) at src/pkg/github/automerge/automerge_adoption_orphan.go:287, so the human-facing note reads "(#0, then #14977)". #15052 asks the loop guard be "shown plainly"; #0 is not a PR. ScanAdoptionMarkers (:124-141) already walks every marker in order, so the previous copy is one field away:

--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
+++ b/src/pkg/github/automerge/automerge_adoption_orphan.go
@@ type AdoptionMarkerScan struct {
 	Live   bool
 	Marker AdoptionMarker
+	Prev   int // superseded_by of the marker before Marker, 0 when none
 	Count  int
 }
@@ func ScanAdoptionMarkers(comments []*gh.IssueComment) AdoptionMarkerScan {
 		if m, ok := ParseAdoptionMarker(body); ok {
 			m.At = c.GetCreatedAt().Time
+			if out.Count > 0 {
+				out.Prev = out.Marker.SupersededBy
+			}
 			out.Marker, out.Live = m, true
 			out.Count++
 			continue
 		}
@@ func (c *Engine) ... marker scan
-			if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(AdoptionChildClosedTwiceComment(obs, 0, dead))}); err != nil {
+			if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(AdoptionChildClosedTwiceComment(obs, scan.Prev, dead))}); err != nil {

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

@hivecommons-hive hivecommons-hive Bot added stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security (delta re-review at 306e3f2) β€” the PR's own patch is unchanged since 2952dd3 apart from rebase adaptations; the 84-file delta is v5 catching up. One new in-scope finding on the marker scan this PR introduces, plus the prior style note still stands.

1. Medium β€” the adoption marker scan trusts any commenter's hive:adopted marker (src/pkg/github/automerge/automerge_adoption_orphan.go:124-141, consumed at :252-274).
ScanAdoptionMarkers parses every IssueComment body with no check on comment.User. recoverOrphanedAdoptionFromMarker then does store.MarkAdopted(key, adoptedHead, dead, now) (:273) from whatever the marker says and, when superseded_by names a closed-unmerged PR, calls recoverOrphanedAdoption β†’ supersedeAdoptedPR (:199-203), which opens a hive-authored copy of the PR's head. When it names a merged PR it runs closeSupersededOriginal (:278-279). So anyone who can comment on a clanker-authored PR parked at 085 can post <!-- hive:adopted mode=supersede superseded_by=<any closed PR> head=<current head> --> and make the hive adopt that head β€” bypassing the delegated decision / maintainer_policy gate that 085 exists to enforce β€” or close the PR as "merged as #N". The precondition adoptionMarkerScanDue (:235-246) only requires policy.Adoption, stage 085 and AuthorKind == Clanker; it is not an authorship check on the comment.

The codebase already has the pattern for hive notices: hasSelfAuthorizationNotice in src/pkg/github/pr_level_hold.go:248-253 skips comments whose login is not appBotLogin. The engine has the login at hand (c.transport.AppBotLogin(), used at automerge_contributor_adopt.go:622). Suggested fix β€” filter before scanning:

--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
+++ b/src/pkg/github/automerge/automerge_adoption_orphan.go
@@ func (c *Engine) recoverOrphanedAdoptionFromMarker(
 	comments, err := c.listIssueComments(ctx, obs.Owner, obs.Repo, obs.Number)
 	if err != nil {
 		c.warn("stage labels: adoption marker scan failed", "repo", obs.Display, "pr", obs.Number, "error", err)
 		return 0, err
 	}
-	scan := ScanAdoptionMarkers(comments)
+	// Only the hive's own markers restore an adoption: a marker anyone
+	// else posted must not make the hive adopt (or close) a PR.
+	if app := strings.TrimSpace(c.transport.AppBotLogin()); app != "" {
+		own := comments[:0:0]
+		for _, cm := range comments {
+			if cm != nil && normalizeBotLogin(cm.GetUser().GetLogin()) == normalizeBotLogin(app) {
+				own = append(own, cm)
+			}
+		}
+		comments = own
+	}
+	scan := ScanAdoptionMarkers(comments)

(If AppBotLogin() can be empty in some deployments, skipping the scan entirely in that case is the safer default than scanning unfiltered.) Add a test with a marker posted by a non-app login asserting no MarkAdopted/no copy opened.

2. Still present (style, from previous review) β€” automerge_adoption_orphan.go:288 calls AdoptionChildClosedTwiceComment(obs, 0, dead), so the marker-path loop-guard note renders "(#0, then #N)" (:168-170). The scan has the history: pass the previous marker's SupersededBy instead of 0, or render "an earlier copy" when first == 0.

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

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 28, 2026
A PR adopted in supersede mode whose hive copy was closed without merging
was left parked at 085 with "Let hive decide" answering "no change"
(hivecommons/hive PR 14947 / copy 14977).

- stage-label pass: detect the orphan (settle path and, once per head, a
  marker scan for PRs at 085 with no adoption on record), re-adopt from
  the same head with a new hive:adopted marker, revert with
  hive:adoption-reverted when the head moved or re-adoption fails, and
  park as adoption-child-closed-twice if copies are closed twice within
  an hour
- merged copy still closes the original the standard way
- delegated decision re-adopts instead of no-op
- tracker: adopted_by_state closed / closed-twice with plain captions
- docs, changelog fragment, tests

Fixes #15052

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the fix/adoption-orphan-recovery branch from 306e3f2 to d46c60c Compare October 28, 2026 21:15
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security perspective β€” delta re-review at d46c60c (previous head 2952dd3; the 129-file delta is a v5 rebase, the PR's own patch changed only in the decideDelegatedOne/delegatedPriorDecisionState/req.Force adaptation and test fixtures).

1. Marker scan trusts any commenter's hive:adopted marker (medium, in-scope)

ScanAdoptionMarkers (src/pkg/github/automerge/automerge_adoption_orphan.go:124-142) parses every comment body and never looks at c.GetUser(). recoverOrphanedAdoptionFromMarker (:252-296) then promotes the parsed marker straight into the store β€” store.MarkAdopted(key, adoptedHead, dead, now) at :274 with adoptedHead/dead taken from the comment β€” and acts on it. The gate adoptionMarkerScanDue (:235-246) only requires: PR at 085, author/clanker, no adoption on record.

So anyone who can comment on a clanker PR can post <!-- hive:adopted mode=supersede superseded_by=N --> and:

  • N = any merged PR β†’ closeSupersededOriginal (automerge_contributor_adopt.go:1034): supersederCarriesHead (:1018-1023) passes because rec.AdoptedHead was just set from the marker (or obs.HeadSHA when omitted), and the hive posts "Closing: #N (the hive's adoption of this PR…) has merged" and closes the PR.
  • N = any closed PR β†’ recoverOrphanedAdoption β†’ supersedeAdoptedPR opens a hive-authored copy of the head, skipping adoptionDue (grace/nudge/presence), adoptionBlocked(obs.Labels) and maintainerHoldsAdoption (automerge_contributor_adopt.go:582-604). The diff/workflow fence and maintainer release inside supersedeAdoptedPR (:682-704) still apply, so this is a policy bypass, not a code-publishing bypass β€” but it hands untrusted input the same power as the triage-only LabelAdoptSupersede label.

Before this PR, orphan handling keyed only on store state the hive wrote itself; the marker path is the new trust boundary. The same unfiltered scan feeds the operator-facing delegatedOrphanedAdoption (src/pkg/dashboard/api_repo_item_decide_orphan.go:49-53), where a forged marker overrides the policy's decision with adopt-supersede (api_repo_item_decide_delegated.go:481-485).

The package already has the precedent (commitByApp(commit, app) at automerge_contributor_adopt.go:1338); apply it to comments:

--- a/src/pkg/github/automerge/automerge_adoption_orphan.go
+++ b/src/pkg/github/automerge/automerge_adoption_orphan.go
-// ScanAdoptionMarkers reads the comments in posting order.
-func ScanAdoptionMarkers(comments []*gh.IssueComment) AdoptionMarkerScan {
+// ScanAdoptionMarkers reads the comments in posting order. Only comments
+// authored by the hive's App login count: a marker anyone else posts is
+// text, not an adoption.
+func ScanAdoptionMarkers(comments []*gh.IssueComment, appLogin string) AdoptionMarkerScan {
 	var out AdoptionMarkerScan
+	want := normalizeBotLogin(appLogin)
 	for _, c := range comments {
-		if c == nil {
+		if c == nil || want == "" || normalizeBotLogin(c.GetUser().GetLogin()) != want {
 			continue
 		}
@@ func (c *Engine) recoverOrphanedAdoptionFromMarker(
-	scan := ScanAdoptionMarkers(comments)
+	scan := ScanAdoptionMarkers(comments, c.transport.AppBotLogin())

and in the dashboard pass a login the GHClient already knows how to judge (IsHiveAuthorLogin, src/pkg/github/question_thread.go:117) or filter comments with it before calling ScanAdoptionMarkers. A cheap second belt: in recoverOrphanedAdoptionFromMarker after PullRequests.Get, require strings.HasPrefix(sup.GetHead().GetRef(), adoptBranchPrefix) ("hive/adopt-", automerge_contributor_adopt.go:48) so an arbitrary merged/closed PR number can never be named as "the hive's copy".

Add a test with a marker comment whose User.Login is not the App and assert scan.Live == false.

2. Previous finding (style) β€” still present

automerge_adoption_orphan.go:287 still passes 0 as first to AdoptionChildClosedTwiceComment, so the loop-guard note from the marker path reads "(#0, then #N)". Unchanged since 2952dd3. The scan already knows the earlier marker exists (Count > 1); keep the previous supersede marker's SupersededBy in AdoptionMarkerScan and pass it here.

β€” 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

Choose a reason for hiding this comment

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

Correctness (delta re-review, head d46c60c). The rebase onto #15063 is sound: api_repo_item_decide_delegated.go:492 keeps the orphan override (orphan.Dead == 0 || prior.At.After(orphan.MarkerAt)) around the new delegatedPriorDecisionState/req.Force dedup, and api_repo_item_decide_orphan_test.go:58-85 accepts rowActionNoEffect for a standing adoption while asserting no re-adoption. Two items remain in the (unchanged) marker-scan path:

  1. Still present β€” #0 in the closed-twice comment. automerge_adoption_orphan.go:287 calls AdoptionChildClosedTwiceComment(obs, 0, dead), which renders "closed without merging twice within an hour (#0, then #N)" (:168-170) on a real PR.

  2. Loop guard counts markers across settled adoptions. ScanAdoptionMarkers (automerge_adoption_orphan.go:131-139) increments Count for every hive:adopted marker and never resets it when AdoptionSettledMarker flips Live off. AdoptionLoopFromMarkers (:147-149) only checks Count > 1 plus the latest marker's age, so a history of adopted β†’ reverted (hive:adoption-reverted) β†’ later adopted β†’ copy closed trips the "closed twice" guard on the first orphan of the new adoption, parking at 085 with a comment claiming two closures. The dashboard Looped flag (api_repo_item_decide_orphan.go:61) shares the same function, so Let hive decide would recommend a person instead of re-adopting. Failure is conservative but contradicts the contract's "closed again within the hour" semantics.

One fix covers both β€” track the previous unsettled copy and reset on settle:

 type AdoptionMarkerScan struct {
 	Live   bool
 	Marker AdoptionMarker
-	Count  int
+	Prev   int // superseded_by of the prior unsettled supersede marker, 0 if none
+	Count  int // supersede markers since the last settled marker
 }
@@ func ScanAdoptionMarkers
 		if m, ok := ParseAdoptionMarker(body); ok {
 			m.At = c.GetCreatedAt().Time
+			if out.Live {
+				out.Prev = out.Marker.SupersededBy
+			}
 			out.Marker, out.Live = m, true
 			out.Count++
 			continue
 		}
 		if out.Live && AdoptionSettledMarker(body) {
 			out.Live = false
+			out.Count, out.Prev = 0, 0
 		}
@@ func (c *Engine) recoverFromAdoptionMarkers (line 287)
-			... gh.Ptr(AdoptionChildClosedTwiceComment(obs, 0, dead)) ...
+			... gh.Ptr(AdoptionChildClosedTwiceComment(obs, scan.Prev, dead)) ...

TestScanAdoptionMarkers (automerge_adoption_orphan_test.go:332) may need its Count expectation adjusted if a fixture has a settled marker between adoptions; TestAdoptionMarkersClosedTwiceParksFromHistory (:289) should additionally assert the comment names the first copy.

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

@clubanderson
clubanderson merged commit 070ab85 into v5 Oct 28, 2026
80 of 82 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/adoption-orphan-recovery branch October 28, 2026 21:30
@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 added stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read the recovery path against the tree at merge-base 3e9edae; the mechanism looks correct to me, with two low ordering/wording items worth a follow-up push.

Verified:

  • MarkAdopted (stagelabels/store.go:1087-1099) does not touch AdoptOrphanedBy/At/Count, so when supersedeAdoptedPR records the fresh copy the loop guard at automerge_adoption_orphan.go:184 still sees the first orphan on a second closure. Only ClearAdoption (store.go:1312) resets them. Good.
  • settleSuperseder (automerge_contributor_adopt.go:995) stops polling once AdoptionChildClosedTwice() holds, and escapeStalledAdoption (:1576) keeps the park, so no third copy opens.
  • The marker scan is gated once per head and only for 085 + clanker + no adoption on record (adoptionMarkerScanDue), and listIssueComments paginates fully (automerge_contributor_lane.go:1097-1109), so the live #14947 case (6 comments) is reached.

Findings (low):

  1. Loop guard runs before the head-moved check β€” automerge_adoption_orphan.go:184 vs :196. If the contributor pushed between the two closures (within the hour), the guard calls MarkAdoptionEscalated(key, rec.AdoptedHead, …) with the old head. AdoptionChildClosedTwice() is then true (escalated head == adopted head), so settleSuperseder stops polling forever, but escapeStalledAdoption checks rec.AdoptionEscalated(obs.HeadSHA) (store.go:950) against the new head and never honours the park. The record keeps pointing at a dead copy and the tracker says "closed twice Β· needs a person" while the lane derives its ordinary stage. It self-heals only when a fresh adoption at the new head overwrites the record (automerge_contributor_adopt.go:583). Swapping the two if blocks (head moved β†’ revert wins) avoids it. Same ordering applies in the marker path (:281-290 parks at adoptedHead from the marker, which may differ from obs.HeadSHA).

  2. #0 in the operator-facing loop note from the marker path β€” automerge_adoption_orphan.go:287 calls AdoptionChildClosedTwiceComment(obs, 0, dead), which renders "closed without merging twice within an hour (#0, then #89)". ScanAdoptionMarkers only keeps the last marker; TestAdoptionMarkersClosedTwiceParksFromHistory (_test.go:289-306) has #88 then #89 available but does not assert the text. Keeping the previous marker's number in the scan (or dropping the "first" clause when it is 0) fixes it.

Info: the dashboard delegate reads a single page of 100 comments (api_repo_item_decide_orphan.go:50, delegatedDecisionGatherLimit) where the reconciler paginates; on a PR with >100 comments before the marker the delegate falls back to the ordinary path. Not a defect today, just a divergence to know about.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read head d46c60c against v5: automerge_adoption_orphan.go, the settleSuperseder / ApplyStageLabels call sites, stagelabels/store.go, and the delegated-decision path. The store side is sound β€” MarkAdopted (store.go:1087-1099) leaves the orphan fields alone and only ClearAdoption (store.go:1312) resets them, so the closed-twice guard in recoverOrphanedAdoption genuinely sees the first orphan on the second close; the marker writes the full head SHA (automerge_contributor_adopt.go:522-525), so the marker path's head comparison can match and re-adopt. One medium finding on the marker path, one low on its comment text.

Medium β€” the marker scan is marked done before any read succeeds, so one transient API error disables the recovery for that head.

  • recoverOrphanedAdoptionFromMarker calls store.MarkAdoptMarkerScanned(key, obs.HeadSHA) at automerge_adoption_orphan.go:253, then listIssueComments (:254) and PullRequests.Get(dead) (:265). Either read failing returns the error with the store still carrying no adoption.
  • adoptionMarkerScanDue (:235-245) gates on rec.AdoptMarkerScanHead != obs.HeadSHA, so the next pass is not due; ApplyStageLabels (automerge_stage_labels.go:1224) never calls the scan again until the head moves.
  • Consequence: the acceptance case in the body β€” #14947 at 085, head static, store without adoption fields β€” is precisely a head that will not move. A single 5xx/secondary-rate-limit on the comment list during the first pass after roll leaves it parked exactly as it is today, with no log beyond one adoption marker scan failed warning. Suggest moving MarkAdoptMarkerScanned after the PullRequests.Get succeeds (or into the !scan.Live / open-copy exits), so a failed read is retried on the next pass; the store write is cheap and the scan is already once-per-head on success.

Low β€” the marker-path loop guard posts #0 as the first copy. :287 calls AdoptionChildClosedTwiceComment(obs, 0, dead), which renders "closed without merging twice within an hour (#0, then #N)" on a public PR. ScanAdoptionMarkers (:124-141) already walks every marker; keeping the previous marker's SupersededBy (a Prev int on AdoptionMarkerScan) gives the real first number. TestAdoptionMarkersClosedTwiceParksFromHistory asserts the marker prefix only, so this is not pinned either way.

Verified and fine: Target: o.Dead on the dashboard's ActionAdoptSupersede is unused by the executor (api_repo_item_decide_delegated.go:751-765 only adds the request label), and the delegated prior-decision bypass is correctly bounded by prior.At.After(orphan.MarkerAt) (:492).

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/human A person pushed this PR themselves conflicts-with-open-pr Open PR has a merge conflict with another open PR dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. needs-human size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adoption orphaned when the hive's superseding copy is closed unmerged: original sits at 085 forever, Let hive decide says no change

1 participant