From 334023f720190ea0243edd066d6d95f66d2c9483 Mon Sep 17 00:00:00 2001 From: Danathar Date: Sun, 25 Oct 2026 16:50:00 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(stage):=20park=20maintainer-?= =?UTF-8?q?only=20blockers=20at=20085,=20not=20072?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two kinds of PR were returned to their contributor (071/072) and nudged to fix something only a maintainer can clear: - Hive-caused sign-off attribution. The hive pushed its own App-signed fix commit onto a contributor PR (projectbluefin/testsuite#991), and the stage pass sent it back under hive-signoff-attribution, asking the contributor to re-sign a commit they never made. A head the hive caused (mixed authorship, or a head it pushed) now parks at 085 with one maintainer note per head; a trusted merger's approval of the current head lets the lane elect a merge commit, as it already did for role/trusted. The refusal names squash-only before role so the note never asks for an impossible --merge. A head of only App-signed commits the hive never pushed (hivecommons/pluk#315) still goes back to its author. - Fork-publication guards. Forward-port of v5 #14282 (88fa705): a fork PR whose only red checks refuse forks parks at 085 with the check named. Adapted to v6, where DecisionComment renders the 085 actions. Adds the two real utah-packages guard wordings to the matcher tests. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar --- .../fixed-fork-publication-guard-stage.md | 1 + ...xed-hive-caused-signoff-attribution-085.md | 1 + src/cmd/hive/merge_eligibility.go | 1 + src/cmd/hive/stage_shared_ci.go | 18 +- src/docs/labels-and-control-signals.md | 29 ++- src/docs/operator-reference.md | 2 +- src/pkg/dashboard/stage_tracker.go | 3 + src/pkg/dashboard/stage_tracker_test.go | 1 + .../automerge/automerge_contributor_adopt.go | 25 ++- .../automerge/automerge_merge_commit.go | 88 +++++++- .../automerge/automerge_merge_commit_test.go | 29 ++- .../automerge_signoff_attribution_085_test.go | 206 ++++++++++++++++++ .../github/automerge/automerge_stage_human.go | 6 + .../automerge/automerge_stage_labels.go | 61 +++++- .../automerge/automerge_stage_sharedci.go | 16 ++ src/pkg/github/fork_guard.go | 68 ++++++ src/pkg/github/fork_guard_test.go | 48 ++++ src/pkg/stageengine/derive_pr.go | 7 + src/pkg/stageengine/derive_pr_classify.go | 38 ++++ .../stageengine/derive_pr_fork_guard_test.go | 66 ++++++ src/pkg/stageengine/facts.go | 11 +- src/pkg/stageengine/prstage/reasons.go | 1 + src/pkg/stageengine/prstage/types.go | 4 + src/pkg/stageengine/stage_goldens_test.go | 8 + .../testdata/stage_goldens/dco.json | 117 +++++++--- src/pkg/stagelabels/human.go | 27 ++- src/pkg/stagelabels/human_test.go | 33 +++ src/pkg/stagelabels/store.go | 23 ++ 28 files changed, 845 insertions(+), 93 deletions(-) create mode 100644 changelog.d/fixed-fork-publication-guard-stage.md create mode 100644 changelog.d/fixed-hive-caused-signoff-attribution-085.md create mode 100644 src/pkg/github/automerge/automerge_signoff_attribution_085_test.go create mode 100644 src/pkg/github/fork_guard.go create mode 100644 src/pkg/github/fork_guard_test.go create mode 100644 src/pkg/stageengine/derive_pr_fork_guard_test.go diff --git a/changelog.d/fixed-fork-publication-guard-stage.md b/changelog.d/fixed-fork-publication-guard-stage.md new file mode 100644 index 0000000000..0f91a815c2 --- /dev/null +++ b/changelog.d/fixed-fork-publication-guard-stage.md @@ -0,0 +1 @@ +- A fork pull request whose only failing checks refuse forks (for example "a fork pull request cannot publish…; a maintainer must push this branch to the repository") is now parked at `stage/085-needs-decision` with the check named, instead of being returned to its contributor or adopted, since only a maintainer can clear it ([#14273](https://github.com/hivecommons/hive/issues/14273)). diff --git a/changelog.d/fixed-hive-caused-signoff-attribution-085.md b/changelog.d/fixed-hive-caused-signoff-attribution-085.md new file mode 100644 index 0000000000..1f381102db --- /dev/null +++ b/changelog.d/fixed-hive-caused-signoff-attribution-085.md @@ -0,0 +1 @@ +- A PR whose sign-off attribution problem comes from the hive's own commits (the contributor's self-signed commits beside the hive's App-signed fix commit, or a head the hive pushed) is no longer returned to the contributor at 071/072 with instructions to re-sign commits they never made. It parks at `stage/085-needs-decision` with one maintainer note per head naming what clears it, and when a trusted merger approves the current head the lane elects a merge commit (`merge-method/merge`) as it already did for `role/trusted` PRs. A head made only of the author's own App-signed commits still goes back to its author. diff --git a/src/cmd/hive/merge_eligibility.go b/src/cmd/hive/merge_eligibility.go index 315ddb0f7c..ae92389d74 100644 --- a/src/cmd/hive/merge_eligibility.go +++ b/src/cmd/hive/merge_eligibility.go @@ -136,6 +136,7 @@ func stageLabelPolicyFunc(cfg *config.Config) func() automerge.StageLabelPolicy RelayKnown: contributorRelayKnown, SharedCIIncident: stageSharedCIIncident, BaseBranchRed: stageBaseBranchRed, + ForkGuard: stageForkGuard, DCORequired: stage.DCO.RequiredFor, SquashOnly: cfg.AutoMerge.SquashOnlyFor, } diff --git a/src/cmd/hive/stage_shared_ci.go b/src/cmd/hive/stage_shared_ci.go index cd375a3434..31f25d89a4 100644 --- a/src/cmd/hive/stage_shared_ci.go +++ b/src/cmd/hive/stage_shared_ci.go @@ -16,6 +16,10 @@ type stageSharedCIEntry struct { // baseRed names the failing checks that are also red on the base branch // tip; set only when every failing check is (PullRequest.AllFailuresBaseRed). baseRed []string + // forkGuard names the failing checks that refuse the PR only because it + // is from a fork; set only when every failing check does + // (PullRequest.ForkGuardChecks). + forkGuard []string } // stageSharedCIIndex holds, per "repo#number", the open [shared-ci] incident @@ -41,7 +45,8 @@ func publishStageSharedCIIncidents(actionable *github.ActionableResult) { if pr.AllFailuresBaseRed() { e.baseRed = append([]string(nil), pr.BaseRedChecks...) } - if e.incident > 0 || len(e.baseRed) > 0 { + e.forkGuard = pr.ForkGuardChecks() + if e.incident > 0 || len(e.baseRed) > 0 || len(e.forkGuard) > 0 { idx[stageSharedCIKey(pr.Repo, pr.Number)] = e } } @@ -73,6 +78,17 @@ func stageBaseBranchRed(repo string, number int, head string) []string { return append([]string(nil), e.baseRed...) } +// stageForkGuard answers StageLabelPolicy.ForkGuard with the same repo/head +// matching as stageSharedCIIncident: the failing checks that refuse the PR +// only because it is from a fork, when every failing check does. +func stageForkGuard(repo string, number int, head string) []string { + e, ok := stageSharedCILookup(repo, number, head) + if !ok || len(e.forkGuard) == 0 { + return nil + } + return append([]string(nil), e.forkGuard...) +} + func stageSharedCILookup(repo string, number int, head string) (stageSharedCIEntry, bool) { idx := stageSharedCIIndex.Load() if idx == nil { diff --git a/src/docs/labels-and-control-signals.md b/src/docs/labels-and-control-signals.md index 64cfd3efd4..8fcfa564f3 100644 --- a/src/docs/labels-and-control-signals.md +++ b/src/docs/labels-and-control-signals.md @@ -422,6 +422,7 @@ used to admit the PR: | `head-changed-since-eval`, `merge-failed`, `merge-queue-required` (the base branch's ruleset only accepts merges through GitHub's merge queue, so the direct REST merge is refused; logged as a skip rather than a merge error, [#14018](https://github.com/hivecommons/hive/issues/14018); the self-authored sweep then skips the direct merge on that base for 30 minutes and logs the skip once per PR head, [#14068](https://github.com/hivecommons/hive/issues/14068); the trusted-author, queued and contributor-lane sweeps skip it the same way, sharing one memory of such bases; while a base is remembered the dashboard shows its otherwise-green PRs as a person's to merge, not Merge-eligible), `required-checks-expected`, `behind`, `updated-branch`, `behind-update-budget-exhausted` (a behind self-authored PR the sweep did not update only because this tick's branch-update budget was spent; retried next tick, waits on the hive, [#12607](https://github.com/hivecommons/hive/issues/12607)), `release-hold*` — and no red check on the head | `100-merge-queue` | | CI red (required or optional check) while the PR is deferred to an open `[shared-ci]` incident (``, the governor's `deferred_incident`) for the same head | `050-review-pending` / `060-reviewed`, reason `shared-ci-incident:`: the base or a shared check is what is red, so the PR is never sent to 070/071/072, never nudged and never stalled; once the incident closes a still-red head is handed back as usual. Conflicts and requested changes stay author-facing ([#12606](https://github.com/hivecommons/hive/issues/12606)) | | CI red (required or optional) while **every** failing check on the head is also red on the base branch's tip — the governor's `base_red_checks` / `base_red`, set during CI enrichment when a same-named latest check run on the base ref (meta checks excluded) concluded failure / timed_out / cancelled / action_required / startup_failure / stale **and** the PR's changed files include none of `.github/workflows/*`, `Dockerfile` / `Dockerfile.*` / `*.Dockerfile`, `go.mod` / `go.sum` (a PR touching those plausibly owns the check and stays author-facing; a lookup error or a diff beyond the file-list page budget also stays author-facing) | `050-review-pending` / `060-reviewed`, reason `base-branch-red:,` ("waiting for the base branch's CI to recover (…) — not this PR's fault"): never 070/071/072, never nudged, never stalled, still not merged (the lane's skip reason is the same token). The fix loop counts no attempt, kicks no fixer, and posts one `` hold comment per head; an escalation the hive itself raised (ledger `label_applied`) over such a head has its `needs-human` removed with the hold wording. The next evaluation after the base goes green re-evaluates the head: a still-red PR is handed back as usual. Conflicts and requested changes stay author-facing (seen on [#13270](https://github.com/hivecommons/hive/pull/13270) and [#13258](https://github.com/hivecommons/hive/pull/13258), 2026-10-20) | +| CI red (required or optional) on a **fork** PR while **every** failing check's annotation says the check refuses forks (case-insensitive `fork pull request(s) cannot`, `maintainer must push this branch`, or `cannot publish` together with `fork` — a fork-publication / fork-secrets guard) | `085-needs-decision`, reason `fork-guard:,`: never 070/071/072, never nudged, never adopted (074) — neither the author nor the hive can turn the check green by pushing to the fork. The entry comment names the check and says a maintainer must push the branch to the repository (or approve the run as the repository requires). A same-repo PR with the same message, or a fork PR with any other red check, is handed back as usual ([#14273](https://github.com/hivecommons/hive/issues/14273)) | | any **non-required** check on the current head is red, whatever the lane's reason (the lane gates on required checks only, so it still soaks and merges; a reader of the rollup sees ✗). Parking modifiers (`hold`, `needs-human`, admission reasons) still win | `070-fixing` / `071-needs-author` / `072-returned-to-contributor` (by author kind), reason `optional-check-failing:` (the nudge lists every red check); never 080 or 100. A red *required* check is the lane's own `required-check-failing:*` → 070/071/072 ([#12538](https://github.com/hivecommons/hive/issues/12538), seen on [#12457](https://github.com/hivecommons/hive/pull/12457)) | | `label:hold`, `held`, `label:needs-human`, `exempt-label`, `excluded-label:*`, `sentinel`, `human-merge-path*`, `intent-*`, `contributor-lane:workflow-path` / `tests-removed` / `no-reviewer` / `reporter-trust-hold`, `workflow-permission` (GitHub refused update-branch or the merge-forward with a 403 because the base changed `.github/workflows/` and the App lacks the workflows permission; no token the hive holds can push that update, so it is not sent to 070), `linked-issue:hold:#N: