Skip to content

✨ feat(github): enforce pin-only exception in merge-request relay - #16607

Merged
kubestellar-prow[bot] merged 2 commits into
v5from
scanner/fix-16265
Nov 7, 2026
Merged

kubestellar-prow[bot] merged 2 commits into
v5from
scanner/fix-16265

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #16265
Supersedes #16456

The hive-merge relay was the last human-merge path that ignored the trusted-author pin-only exception. The automerge sweep and /approve already enforce it (#16266). This change adds the exception to the relay using the same provenance checks, which now live in pkg/github so all three paths use one implementation. The relay also requires the exact requested head. A PR that is not a proven pin-only change keeps today's hold, marker comment and refusal, and non-GitHub forges stay fail-closed. Docs, config comments and the changelog now say the relay enforces the exception.

Part of #16242

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@hanthor

The merge-request relay was the last App merge path that ignored
auto_merge.human_merge_pin_only. Wire the policy into the relay's
human-merge-path gate: a PR whose author is in trusted_authors, whose
head equals the requested head (before and after listing files), whose
complete changed-file list classifies as pin replacements, whose every
commit is a verified trusted-author commit, and whose action SHAs are
anchored upstream is admitted without a hold. Anything else keeps the
existing hold, marker comment and refusal; non-GitHub forges stay
fail-closed.

The provenance checks move from the automerge package into
pkg/github/pin_only_provenance.go so the sweep, /approve and the relay
share one implementation. Docs and config comments now state the relay
enforces the exception.

Closes #16265

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending — sweep will merge when green.


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

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer (folded here because this head already carries its hive review):

Read the relay gate, the shared provenance checks and the boot wiring at 687f4cb. The code does what #16265 specifies, and I found no defect; I am routing only because this relaxes a merge-trust gate, which is a person's call.

What I verified:

  • Exception order in src/pkg/github/human_merge_paths.go:269-286: author in trusted_authors → head equals req.ExpectSHA → complete changed-file count → ClassifyPinOnlyActions → every commit author trusted, committer trusted or web-flow, GitHub-verified signature (pin_only_provenance.go, PinOnlyCommitsTrusted) → every new action SHA anchored to an upstream tag or default branch (PinOnlyActionPinsUpstream) → head re-read and compared to ExpectSHA after file paging. Any failure falls through to today's hold + marker + refusal.
  • The eventual merge still passes req.ExpectSHA as the required head (merge_request_watcher.go:532), so a head that moves after the check fails the merge rather than merging new content.
  • Only this gate is lifted: mergePolicyGate, CI verification and the other holds in handleOneMergeRequest run unchanged (TestMergeRequestPinOnlyStillRequiresGreenCI covers it).
  • Fail-closed on config: duplicate normalized repo keys → disabled spec (human_merge_paths.go:224-227); HumanMergePinOnlyFor drops disabled or invalid entries (pkg/config/automerge_pin_only.go:88); SetHumanMergePinOnly is called from syncAutoMergePolicyToGitHubClient next to SetHumanMergePaths (cmd/hive/notifywire.go:37,44), so reload parity holds.
  • The sweep now delegates to the same three functions (automerge/automerge_human_paths.go), so the two paths cannot drift — this is stricter than the issue asked for (it only required ClassifyPinOnly).

Non-GitHub forges remain fail-closed as stated.

@github-actions

github-actions Bot commented Nov 4, 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.

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

@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 Nov 4, 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.

Decision needed: @hanthor should confirm that the hive-merge relay may now App-merge trusted-author pin-only PRs touching auto_merge.human_merge_paths (the last path that still required a person), as #16265 scopes.

Code reads correct to me and is strictly a refactor-plus-wiring; routing to an approver only because it moves a merge-trust boundary (the relay stops holding a class of PRs that previously always required a human merge).

What I verified (tree at b5c1f96):

  • src/pkg/github/pin_only_provenance.go is a faithful lift of the sweep's pinOnlyCommitsTrusted / pinOnlyActionPinUpstream / trusted-login helpers out of pkg/github/automerge/automerge_human_paths.go; the sweep now calls hgithub.PinOnlyActionPinsUpstream / PinOnlyCommitsTrusted so both paths cannot drift. Author, committer (web-flow or trusted), verified signature, head-is-last-commit, tag deref depth 3, and compare status ahead|identical all carry over unchanged.
  • human_merge_paths.go:269-286 only lifts the gate when, in order: exception enabled for the repo, PR user in trusted_authors, req.ExpectSHA non-empty and equal to the fetched head, changed_files count present and equal to the listed files, classifier ok, commits trusted, pins upstream-anchored, and the head re-fetched after listing still equals ExpectSHA (pinOnlyProvenance, lines 303-308). Any other outcome falls through to the existing HoldForHumanMergePaths + refusal, so a non-qualifying PR behaves exactly as before. ExpectSHA is also what the eventual merge uses (merge_request_watcher.go:189).
  • SetHumanMergePinOnly fails closed on duplicate normalised keys and clones slices; notifywire.go:38-44 only forwards entries HumanMergePinOnlyFor reports enabled (which already rejects case-duplicate keys and invalid specs).
  • The non-GitHub-forge branch in merge_request_watcher.go is untouched, so it stays fail-closed.
  • human_merge_paths_test.go:306-460 covers trusted pass, disabled, untrusted, mixed diff, extra file, path outside globs, missing patch/count, incomplete list, wrong head, head moved during fetch, reload, and that green CI is still required. go build ./pkg/github/... ./cmd/hive/ is clean on this head.
  • Docs (src/docs/hive-merge.md, operator-reference, config comments) updated from "relay pending" to "relay enforces"; matches the code.

One scope note, not a defect: the diff goes beyond #16265's checklist by also running the commit-provenance and upstream-anchor checks in the relay. That is tightening, not loosening, and the body says so; I think it is the right call.

I have not approved anything; an approver should decide whether the relay exception should land.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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 Nov 4, 2026
@clubanderson clubanderson 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/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 5, 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/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue labels Nov 5, 2026
hivecommons-hive Bot added a commit that referenced this pull request Nov 5, 2026
… for a decision, not the fixer (#16676)

A hive-superseding PR whose every reviewer perspective returned
requires_human as a pure approver question (decision requested, no
finding above info) was routed to the fixer by the superseder rule.
The fixer had nothing to push, the cycle hit its cap, fixer-exhausted
re-authored the change, and the next PR repeated it
(#16398 -> #16456 -> #16607) while no operator was ever asked.

Aggregation now keeps such a head requires_human with its decision
question, RouteHuman parks it at 085 needs-decision with approve /
request-changes actions, and the tracker's review chevron says the head
is verified and waiting on sign-off.

Fixes #16675

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@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 stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue labels Nov 5, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

🐝 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

Copy link
Copy Markdown
Contributor Author

For the adjudicator's "no human has stated this yet" note: the human-authored policy issue for this exception is #16242 (@hanthor, Part of in the body above). It records the maintainer-delegated decision at projectbluefin/utah#1082 (projectbluefin/utah#1082 (comment)) and states "The owner policy choice is resolved for the named consumers", with the same required behaviour this PR implements (trusted authors, exact head, complete diff, pin-only class, fail-closed, consistent across relay/sweep). Whether that counts as the ruling for lifting the relay hold is still @hanthor's call; this is only the pointer so the decision does not wait on a statement that already exists.


🐝 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

@clubanderson clubanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Owner decision (@clubanderson): approved. The policy is already stated by the delegated maintainer in #16242 (utah#1082): trusted author, exact head, complete diff, pin-only class, fail-closed, consistent across relay/sweep. Sweep and /approve enforce it since #16266; the relay must match. Approved at 687f4cb; CI still gates.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 0b38e5fc45d4fe87aab38255010ec5419cb00e59

@clubanderson

Copy link
Copy Markdown
Member

/approve

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clubanderson, hivecommons-hive[bot]

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

The pull request process is described 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

@github-actions

github-actions Bot commented Nov 7, 2026

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

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. lgtm Indicates that a PR is ready to be merged. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] human-merge pin-only exception: enforce in merge-request relay

1 participant