From 8eff7a8a74ae50d4e41588302c9d1c1f85452700 Mon Sep 17 00:00:00 2001 From: Danathar Date: Wed, 28 Oct 2026 13:07:32 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(adoption):=20keep=20a=20fork?= =?UTF-8?q?=20PR=20the=20hive=20cannot=20push=20to=20with=20its=20author?= =?UTF-8?q?=20until=20the=20072=20dwell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A fork PR is never superseded or re-homed into the base repository (#14306), so adopting one the hive cannot push to only parked it at stage/085 on the next pass, 15 minutes after the author's relay went offline. Decline that adoption instead: the PR stays at 072 with its nudge and the relay's fix-pr task, and escalateUnadoptableFork parks it at 085 with the same maintainer ask once the head has waited the 072 dwell since the nudge. The stage engine reads the new pass fact ForkEscalationReason so enforce-mode derives the same stage. In-place fork adoption, same-repository adoption and explicit owner-delegated adoption are unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar --- .../fixed-fork-pr-not-adopted-without-push.md | 1 + src/docs/hive-merge.md | 12 ++- src/docs/labels-and-control-signals.md | 12 ++- src/docs/running-at-level-6.md | 2 +- .../automerge/automerge_contributor_adopt.go | 74 +++++++++++++- .../automerge_contributor_adopt_test.go | 96 +++++++++++++++++-- .../automerge/automerge_stage_labels.go | 15 +++ src/pkg/github/automerge/stage_facts_test.go | 26 +++++ src/pkg/stageengine/derive_pr.go | 5 + src/pkg/stageengine/facts.go | 3 + 10 files changed, 228 insertions(+), 18 deletions(-) create mode 100644 changelog.d/fixed-fork-pr-not-adopted-without-push.md diff --git a/changelog.d/fixed-fork-pr-not-adopted-without-push.md b/changelog.d/fixed-fork-pr-not-adopted-without-push.md new file mode 100644 index 0000000000..a1f6a66c58 --- /dev/null +++ b/changelog.d/fixed-fork-pr-not-adopted-without-push.md @@ -0,0 +1 @@ +- **Contributor PRs from forks the hive cannot push to are no longer adopted and parked within minutes.** The hive never moves a fork's commits into the base repository, so adopting a fork PR whose branch it cannot push to only parked it at `stage/085-needs-decision` on the next pass, 15 minutes after the author's relay went offline. Such a PR now stays at `stage/072-returned-to-contributor` with its nudge and the relay's queued `fix-pr` task, and is parked at 085 with the same maintainer ask only after the 072 dwell (24h) since the nudge on that head. In-place adoption on forks that allow maintainer edits, same-repository adoption, and explicit owner-delegated adoption are unchanged. diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index 1b7c6ad769..38d9edc85c 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -724,10 +724,14 @@ it on that branch (never a replacement PR), after which it follows the normal is never superseded or re-homed into `hive/adopt-`: a branch in the base repository makes a same-repository PR, which runs with the repository's secrets and write tokens and skips its fork-only guards, so unreviewed fork -code would run as trusted. The hive records the refusal and the next pass -parks the PR at `085` as `adoption-stalled:fork-rehome-refused` with a -maintainer ask; in-place adoption on the fork's own branch (when the -contributor allows maintainer edits) is unchanged. When adoption is in-place on the contributor PR's own +code would run as trusted. So a fork PR the hive cannot push to is not +adopted at all: it stays at `072` with its author's nudge and queued `fix-pr` +task, and only after the `072` dwell (24h) since the nudge on that head does +it park at `085` as `adoption-stalled:fork-rehome-refused` with a maintainer +ask. In-place adoption on the fork's own branch (when the contributor allows +maintainer edits) is unchanged; if such an adoption later needs a re-home, +the hive records the refusal and the next pass parks it at `085` with the +same ask. When adoption is in-place on the contributor PR's own branch, the hive owns the head it pushed: once that head is green, approved by the reviewer, DCO-clean and soaked, the contributor lane admits it under the hive's own authority (`contributor-lane:adopted-by-hive`, see the diff --git a/src/docs/labels-and-control-signals.md b/src/docs/labels-and-control-signals.md index fb2dcbc2ad..4fc70b4560 100644 --- a/src/docs/labels-and-control-signals.md +++ b/src/docs/labels-and-control-signals.md @@ -228,7 +228,7 @@ referenced it) a lone `stage/050-review-pending` | `stage/070-fixing` | PR | hive-owned repair: App/taken-over PR red, changes requested (by the swarm, or by a trusted human's **changes requested** review / `/hive decision ` on the current head — reason `human-changes-requested`, which also kicks the author agent with the text verbatim, [#13041](https://github.com/hivecommons/hive/issues/13041)) or needs-rebase, **or** a non-App PR whose red head was caused by a hive-pushed commit that must be removed/re-homed; a hive agent is reworking it | 2h | | `stage/071-needs-author` | PR | human-authored PR (`author/human`): CI red / changes requested / conflicting; the hive posted its diagnosis, the author must act. No nudge, no adoption — the person pushes or comments | 24h | | `stage/072-returned-to-contributor` | PR | clanker PR (`author/clanker`, relay or external hive): CI red / changes requested / conflicting; the hive posted its diagnosis, the ball is in the contributor hive's court. (Briefly spelled `stage/072-needs-author` by [#12713](https://github.com/hivecommons/hive/pull/12713); the engine renames that label back in place) | 24h | -| `stage/074-adopted-by-hive` | PR | the author (a clanker) was unavailable — relay offline, never registered, or silent past the grace (see below); the hive took the PR over: in place on the PR's own branch when it may push there (the scanner's red-PR fix kick rebases and fixes it), otherwise via `hive/adopt-` and a superseding App PR that keeps the author's commits (the original closes automatically when the superseder merges). Adoption is an **ownership** state, not a CI state: the PR reads 074 for as long as the hive owns it — through its fixes going pending, green, reviewed or red again (074 outranks 050/060/070/071/072) — and leaves 074 only at the merge gate (080/085/090/100), when the adoption is released, or to 085 `adoption-stalled:` when the head sat unchanged past the dwell with CI idle and a real blocker the hive cannot push past — a red optional check alone never counts, and the escalation releases back to 074 as soon as the reason clears (an in-place adoption with a blocking review finding re-homes to `hive/adopt-` first instead; one with a squash-unsafe hive commit elects a merge commit on a `role/trusted` PR — `merge-method/merge` label, lane continues — and otherwise immediately re-homes to an App-authored superseder (`signoff-rehome`), preserving commits and sign-offs while changing squash attribution; loss of push access re-homes immediately, and idle rebase work re-homes after the dwell). For in-place adoption, a changed head must be linked to the App bot by GitHub commit metadata (the stage store only remembers heads that already passed that check); otherwise the hive treats it as a contributor push and hands the PR back (072 if red, else the normal path). Forgeable git author/committer names and emails never keep 074. A PR whose author holds **admin** or **maintain** on the repository is never adopted or re-homed (one cached permission read per repo and author per 10 minutes; a failed read is not cached and defers: no adoption, and an existing adoption is neither released nor re-homed until the read succeeds), and an adoption of such an author is released on the next pass, closing a still-open hive superseder with a note first. A fork PR is never superseded or re-homed into the base repository (that would run unreviewed fork code with the repository's trusted CI); it parks at `085` as `adoption-stalled:fork-rehome-refused` instead. | 3h | +| `stage/074-adopted-by-hive` | PR | the author (a clanker) was unavailable — relay offline, never registered, or silent past the grace (see below); the hive took the PR over: in place on the PR's own branch when it may push there (the scanner's red-PR fix kick rebases and fixes it), otherwise via `hive/adopt-` and a superseding App PR that keeps the author's commits (the original closes automatically when the superseder merges). Adoption is an **ownership** state, not a CI state: the PR reads 074 for as long as the hive owns it — through its fixes going pending, green, reviewed or red again (074 outranks 050/060/070/071/072) — and leaves 074 only at the merge gate (080/085/090/100), when the adoption is released, or to 085 `adoption-stalled:` when the head sat unchanged past the dwell with CI idle and a real blocker the hive cannot push past — a red optional check alone never counts, and the escalation releases back to 074 as soon as the reason clears (an in-place adoption with a blocking review finding re-homes to `hive/adopt-` first instead; one with a squash-unsafe hive commit elects a merge commit on a `role/trusted` PR — `merge-method/merge` label, lane continues — and otherwise immediately re-homes to an App-authored superseder (`signoff-rehome`), preserving commits and sign-offs while changing squash attribution; loss of push access re-homes immediately, and idle rebase work re-homes after the dwell). For in-place adoption, a changed head must be linked to the App bot by GitHub commit metadata (the stage store only remembers heads that already passed that check); otherwise the hive treats it as a contributor push and hands the PR back (072 if red, else the normal path). Forgeable git author/committer names and emails never keep 074. A PR whose author holds **admin** or **maintain** on the repository is never adopted or re-homed (one cached permission read per repo and author per 10 minutes; a failed read is not cached and defers: no adoption, and an existing adoption is neither released nor re-homed until the read succeeds), and an adoption of such an author is released on the next pass, closing a still-open hive superseder with a note first. A fork PR is never superseded or re-homed into the base repository (that would run unreviewed fork code with the repository's trusted CI). So a fork PR is adopted only in place, when the hive can push to the fork's branch; one it cannot push to is not adopted at all. It stays at `072` with its author's nudge and queued `fix-pr` task, and parks at `085` as `adoption-stalled:fork-rehome-refused` only after the `072` dwell (24h) since the nudge on that head. An in-place fork adoption that can no longer be finished on the fork's branch parks there at once. | 3h | | `stage/080-awaiting-merge-admission` | PR | nothing left for the author: CI green (no red check on the head, required or not), verdict approve, no modifiers — and the automerge lane has not admitted it yet (prefilter not evaluated for this head, labels not synced, lane tripped). A stall here means a lane problem, so the hive also posts one `` comment with the lane's last skip reason | 30m | | `stage/085-needs-decision` | PR | **PR-only** since the owner decision of 2026-10-17 (issues park at `stage/045-needs-decision`; before that this stage carried both, [#12683](https://github.com/hivecommons/hive/issues/12683)). A person owes a **decision**, not a merge: a `requires_human` swarm verdict (reason `reviewer-verdict:requires_human`), `sentinel-alert`, `hold` / `do-not-merge*` / `needs-decision` modifier, no reviewer configured, GitHub workflow approval is required for a trusted same-repo bot/App/clanker PR (`workflow-approval-required:`); Hive has posted `/ok-to-test` and is waiting for the repo-local `hive-ok-to-test` workflow or a maintainer, or a human-only lane rule unrelated to trust (workflow-path edits, tests removed, human-merge path, reporter-trust hold), or an open issue the PR closes is held or parked (`linked-issue:hold:#N: