Skip to content

πŸ”’ fix(adoption): never move a fork PR's code into a base-repo branch (re-home ran fork code as trusted) - #14306

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/no-fork-rehome-into-base-repo
Oct 25, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/no-fork-rehome-into-base-repo

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary (security)

When the hive supersedes an adopted PR, it pushes the PR's head to hive/adopt-<n> inside the base repository and opens a same-repository PR from it. This applies to every path: grace, offline, dco-rehome and in-place-stalled. For a fork PR, that move runs the fork's unreviewed code with the repository's trusted CI: secrets, write tokens, and none of its fork-only guards. The hive should never raise a change's trust level by moving it.

Evidence

All times are 2026-10-25 UTC.

Change

  • Refuse to move fork code. supersedeAdoptedPR, the single path every supersede and re-home goes through, refuses when the head repository is not the base repository. An unknown head repository, such as a deleted fork, counts as a fork. It records the refusal for that head (ForkRehomeRefusedHead in the stage store), pushes nothing and opens nothing.
  • Park for a maintainer. On the next pass, the existing stalled-adoption escape parks the PR at stage/085-needs-decision as adoption-stalled:fork-rehome-refused. Its one note names the fork, explains why the hive did not move it, and asks a maintainer to review the change and bring it in themselves (or follow the repository's fork process), or to close it.
  • Unchanged:
    • In-place adoption on the fork's own branch, when the contributor allows maintainer edits: the code stays on the fork, so CI still treats it as a fork run.
    • A PR from a branch of the base repository: its code already runs with the repository's trust, so supersede and re-home work as before.
  • Docs and changelog: hive-merge.md (adoption section), the stage/074 row in labels-and-control-signals.md, and a security- changelog fragment.

Testing

go test ./pkg/github/automerge/... ./pkg/stagelabels/... ./pkg/stageengine/... ./pkg/github/ ./pkg/dashboard/... ./cmd/hive/... -count=1 (run from src/): all ok: pkg/github/automerge 1.9s, pkg/stagelabels, pkg/stageengine (+prstage, stageenginetest), pkg/github 50.2s, pkg/dashboard 106.9s (+collect, theme, webstatic), cmd/hive 12.2s.

The adoption test fixture (adoptPR) previously defaulted to a fork head, so every supersede test was a fork supersede. It now defaults to a branch of the base repository, so the supersede and re-home mechanics stay covered on the shape still allowed; forkPR builds the fork case. 18 existing tests failed on the new rule before this switch; afterwards, 15 pass unchanged and three were fork scenarios:

Test What changed
TestAlreadyAdoptedInPlaceForkDCOFailureIsNotRehomed (was …AppAuthoredDCOFailureWithoutPushRehomes) The projectbluefin/utah-packages#609 β†’ projectbluefin/utah-packages#626 shape: in-place adoption on a fork, DCO re-home due. Nothing is pushed or shut, the refusal is recorded, and the next pass parks at 085 with the note naming mallory/widget, trusted CI and the maintainer ask.
TestAdoptionForkWithoutPushIsNotSuperseded (was …InPlaceFallsBackToSupersede) A fork without maintainer edits used to fall back to a base-repo supersede. Now there is no branch and no PR, and it parks at 085.
TestAdoptionOnlineGraceThenAdopt No longer expects the fork's name in the superseding body, because the PR is in-repo.

New tests:

  • TestAlreadyAdoptedInPlaceInRepoDCOFailureWithoutPushRehomes: the in-repo DCO re-home still happens and the original is shut.
  • TestAdoptionForkWithPushStaysInPlace: a fork with maintainer edits is still adopted in place.
  • TestAdoptionFromFork: in-repo (any case), fork, and unknown head.

Guards and checks: BASE_REF=v6 bash src/scripts/check-changelog-fragment.sh is OK, go vet is clean, and gofmt is clean.

Not in this PR

  • Repos without in-place adoption: where governor.labels.stage.adoption.in_place is off (default on), or a contributor disallows maintainer edits, an adopted fork PR now always parks at 085 instead of being re-homed. That is the intended trade.
  • No approval exception: a "move it once a trusted maintainer approves the exact head" path is possible but not added. A maintainer who has reviewed the change can bring it in directly.
  • Already published: existing hive/adopt-* branches and images published from re-homed fork PRs, such as canary-pr626, are for the repository's maintainers to review; this PR doesn't touch them.

Contributor checklist

  • Changelog: changelog.d/security-no-fork-rehome-into-base-repo.md.
  • Targets v6.
  • The title uses the emoji convention.
  • Commits include DCO sign-off.
  • Docs updated.
  • No secrets, credentials or local runtime state are committed.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 25, 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 kellyaa 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 25, 2026
@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login 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 25, 2026
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

This PR conflicts with v6 itself. Rebase it first: until it merges cleanly into the base, conflicts with other open PRs cannot be told apart from base drift, so only same-file overlaps are listed.

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

No conflicting open PRs or same-file overlaps were found.

@hivecommons-hive hivecommons-hive Bot added stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 25, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the branch conflicts with the base and needs a rebase

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Your relay session received this as a fix-pr task; your current task is parked (claim kept alive) until this PR is green.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the branch conflicts with the base and needs a rebase

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (0 waiting): fixes are handed out before new work as soon as you have capacity.

@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.

Decision needed: @clubanderson should confirm the policy change this encodes: fork PRs the hive cannot push to are no longer re-homed to hive/adopt-N under any supersede reason and instead park at 085 for a maintainer.

Conclusion: the code does what the body says and the mechanism it closes is real; I found no defect. It is a merge/trust policy change (fork code never gets promoted to a base-repo branch), so a maintainer other than the author should sign off on the policy itself. It also needs a rebase: v6 has moved past this head in the same file.

Read the PR head 6c9d09b against its v6 merge-base, plus canPushToPRBranch, settleAdoption, adoptionStalledReason, the stage-label observer and the store.

What I verified

  • supersedeAdoptedPR is the single sink for every re-home path β€” callers at automerge_contributor_adopt.go:610 (grace/offline), :730 (dco-rehome) and :1094 (in-place-stalled) β€” so the guard at :614-619 covers all of them.
  • adoptionFromFork (:777-779) treats an empty HeadRepo as a fork. HeadRepo is only empty when GitHub's head.repo is null (automerge_stage_labels.go:391-393, a deleted fork), and canPushToPRBranch:785 already treats that as not-pushable, so the two agree and a base-repo PR cannot be misclassified.
  • The refusal is keyed per head (ForkRehomeRefusedHead, store.go), so a new push re-evaluates; adoptionStalledReason picks it up before the supersede-failed case (:1045-1047) and the existing 085 escape carries the maintainer ask from adoptionBlockerText:467-469.
  • Nothing is pushed or opened on the refused path; in-place adoption on the fork's own branch (with maintainer_can_modify) is untouched, as the body states.

Needs before merge

  • Rebase. mergeable=CONFLICTING: 647dbeaa8 (#14303) landed on v6 and changed automerge_contributor_adopt.go and labels-and-control-signals.md. The intent looks complementary (#14303 parks maintainer-only blockers at 085, which is exactly where this relies on landing), but I could not confirm the merged text β€” please resolve and re-run the adoption tests.
  • #14305 (same author) also inserts a guard at the top of supersedeAdoptedPR; whichever lands second will conflict there too.

Consequence worth stating plainly for the decider

After this, a fork PR whose author did not tick "allow edits by maintainers" can never be finished by the hive β€” every supersede reason, including a failing DCO, ends at 085 with a note. That is the intended trade (the utah-packages#609 β†’ #626 canary publish shows why), but it is a visible behaviour change for every repo the hive serves, which is why I am routing it rather than calling it fine.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar the hive has adopted this PR (stage/074-adopted-by-hive): CI stayed red for 2h after the nudge and the relay nudge went unanswered. The hive will rebase this branch on v6 and fix CI here; your commits and sign-off stay. Push a new head yourself at any time and the hive yields it back to you.

@hivecommons-hive hivecommons-hive Bot added stage/074-adopted-by-hive Contributor PR adopted: author unavailable after red CI; the hive is finishing it (takeover path) and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Oct 25, 2026
Superseding an adopted PR (grace, offline, dco-rehome, in-place-stalled)
pushes its head to hive/adopt-<n> inside the base repository and opens a
same-repository PR from it. For a fork PR that runs the fork's unreviewed
code with the repository's trusted CI: secrets, write tokens, and none of
its fork-only guards. projectbluefin/utah-packages#609 was re-homed as
projectbluefin/utah-packages#626, whose Canary run published and Sigstore-signed
ghcr.io/projectbluefin/utah-packages:canary-pr626 from that code.

supersedeAdoptedPR now refuses when the head repository is not the base
repository (or is unknown), records the refusal per head, and the
stalled-adoption escape parks the PR at 085 as
adoption-stalled:fork-rehome-refused with a maintainer ask. In-place
adoption on the fork's own branch is unchanged; in-repo PRs are re-homed
as before. The adoption test fixture now defaults to an in-repo branch so
the supersede mechanics stay covered, with forkPR for the fork cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Danathar <Danathar@users.noreply.github.com>
@hivecommons-hive
hivecommons-hive Bot force-pushed the fix/no-fork-rehome-into-base-repo branch from 6c9d09b to b99dd02 Compare October 25, 2026 23:13
@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/awaiting-ci: rebased onto v6 (resolved additive conflicts with the maintainer-permission adoption guard in automerge_contributor_adopt.go, stagelabels/store.go and labels-and-control-signals.md; author and sign-off preserved). 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 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.

Decision needed: @clubanderson should decide whether the hive must refuse every fork→base-repo re-home (parking such PRs at 085) rather than keep a maintainer-approval exception; this is a merge/trust-policy change authored by a fellow approver.

Read the code at head b99dd02 against v6; the change does what the body says and I found no defect. Routing to an approver because it changes adoption/trust policy, not because anything is wrong.

What I verified in the tree:

  • supersedeAdoptedPR really is the single funnel: all three call sites β€” automerge_contributor_adopt.go:616 (grace/offline), :735 (dco-rehome), :1135 (in-place-stalled) β€” go through it, so the new adoptionFromFork guard covers every re-home path.
  • The 085 park actually happens. Each caller runs store.MarkAdopted(key, head, 0, now) first, and MarkAdopted sets AdoptMode = AdoptModeSupersede (stagelabels/store.go:990). On the next pass inPlaceRehomeReason returns "" (AdoptedInPlace() is false, :1072), so escapeStalledAdoption falls through to adoptionStalledReason, where the new ForkRehomeRefused check sits ahead of AdoptionAttemptedNothingOpened (:1116). The in-place-adopted fork can't loop back into another supersede.
  • Fail-closed on unknown head repo is consistent with existing code: obs.HeadRepo has one population point (automerge_stage_labels.go:400) and canPushToPRBranch already returns false when it is empty (:822).
  • Fixture flip (adoptPR β†’ in-repo, new forkPR) is the right move; it means the surviving supersede tests exercise the shape that is still allowed.

Not a defect, just for the approver's awareness: with this change a fork PR whose author disallows maintainer edits can never be finished by the hive β€” it always parks at 085. The body states that trade explicitly ("Not in this PR"), so it is a policy choice, not an oversight. CI on this head was still running when I read it.

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

@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/074-adopted-by-hive Contributor PR adopted: author unavailable after red CI; the hive is finishing it (takeover path) labels Oct 25, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

  • the reviewer swarm returned requires_human @b99dd02
  • reviewer question: @clubanderson should decide whether the hive must refuse every forkβ†’base-repo re-home (parking such PRs at 085) rather than keep a maintainer-approval exception; this is a merge/trust-policy change authored by a fellow approver.
  • the automerge lane will not merge this unattended

Head: verdict requires_human @b99dd02, 47/47 checks green, DCO yes, soak 0s of 30m0s.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@hivecommons-hive
hivecommons-hive Bot merged commit 23a0ef8 into hivecommons:v6 Oct 25, 2026
57 of 59 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#14306b99dd02` sha256:0a49d9279287285264eefd4ef8dbbc4dcfe67a40ed981af5777abe4a955e91cd β€” download from the dashboard or `hivectl review evidence #14306`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at b99dd02.

@hivecommons-hive hivecommons-hive Bot removed the role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) label Oct 25, 2026
@hivecommons-hive hivecommons-hive Bot removed the stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue label Oct 25, 2026
hivecommons-hive Bot pushed a commit that referenced this pull request Oct 26, 2026
#14354)

A PR the hive opens to supersede an adopted contributor PR starts at the
contributor's head, unchanged, but Sentinel judged it by its author, the
App: a blocking alert on the contributor's PR became an "author is trusted
(hive agent)" notice on the App's copy of the same commit, and no merge
lane was stopped. Since #14306 forks are no longer re-homed, but every
supersede path still runs for a same-repo branch of a non-maintainer.

The sweep now reads the adopted PR and its author from the supersede line
AdoptionPRBody writes and decides trust by that author. A maintainer's
clearance of the same head on the adopted PR carries over; later heads
are judged afresh.


Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

Signed-off-by: Danathar <Danathar@users.noreply.github.com>
Co-authored-by: Danathar <Danathar@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
hivecommons-hive Bot pushed a commit that referenced this pull request Oct 28, 2026
…or until the 072 dwell (#15018)

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.


Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

Signed-off-by: Danathar <Danathar@users.noreply.github.com>
Co-authored-by: Danathar <Danathar@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/clanker A contributor's own hive authored this PR under their login 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.

1 participant