From 978e89e70ab632e64b2e460049b3806de90614cd Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 11:24:46 -0400 Subject: [PATCH 1/5] fix: require verified signature for email-only hive commit identity match Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15182.md | 1 + src/docs/operator-reference.md | 2 +- src/pkg/github/pr_merge_state.go | 19 ++++-- .../pr_merge_state_commit_by_hive_test.go | 60 +++++++++++++++++++ 4 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 changelog.d/changed-15182.md create mode 100644 src/pkg/github/pr_merge_state_commit_by_hive_test.go diff --git a/changelog.d/changed-15182.md b/changelog.d/changed-15182.md new file mode 100644 index 0000000000..a864ca028d --- /dev/null +++ b/changelog.d/changed-15182.md @@ -0,0 +1 @@ +- The rebase-then-merge follow-through now counts a head as the hive's own by its email domain alone (no GitHub login resolved) only when GitHub reports the commit as verified; a commit whose login resolves to the App bot counts as before ([#15182](https://github.com/hivecommons/hive/issues/15182)). diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 4bef77f96b..429639087b 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -472,7 +472,7 @@ verified owner or an authorized user with the `merger` role: | Decision | What it does | Audit / ledger | |---|---|---| | `merge-now` — *Approve & merge as maintainer* | Comments on the PR that @you merged it from the dashboard, then merges it at once through the hive's GitHub App (`MergePRVia`, audit path `dashboard`). Refused when the PR is merged or closed, or when you are its author. | `repo_item_decision_merge`; `last_operator_action.action: merge-now`; toast *merged*. | -| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App); a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | +| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; an identity matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified); a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | | `queue-merge` — *Approve — let hive merge* | Leaves an `APPROVED` review in your name with a note, adds the automerge label, and leaves the merge to the App self-merge sweep, which merges on its next pass once CI is green and the head has soaked. Refused on your own PR. | `repo_item_decision_queue_merge`; `last_operator_action.action: queue-merge`; toast *queued for merge*. | **Approve is the trust override for that head diff --git a/src/pkg/github/pr_merge_state.go b/src/pkg/github/pr_merge_state.go index 1c465e49e9..cfc477dc73 100644 --- a/src/pkg/github/pr_merge_state.go +++ b/src/pkg/github/pr_merge_state.go @@ -91,9 +91,12 @@ func (c *Client) GetPRMergeState(ctx context.Context, repo string, number int) ( // CommitByHive reports whether the commit at sha is the hive's own work: // its author or committer resolves to the App bot (by login or noreply // address) or to an address in the pane identity domain — the fixer's -// rebase or GitHub's update-branch under the App. A head a person pushed -// after a rebase-then-merge approval is new content the approval never -// covered, so the follow-through fails closed on it (hivecommons/hive#15104). +// rebase or GitHub's update-branch under the App. When GitHub resolves no +// login for that identity, the email-only match also requires the commit's +// signature to be verified by GitHub (hivecommons/hive#15182). A head a +// person pushed after a rebase-then-merge approval is new content the +// approval never covered, so the follow-through fails closed on it +// (hivecommons/hive#15104). func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) { if c == nil || c.client == nil { return false, ErrNoGitHubClient @@ -107,10 +110,16 @@ func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, erro if err != nil { return false, fmt.Errorf("reading %s/%s@%s: %w", owner, repoName, shortSHA(sha), err) } - if c.hiveCommitIdentity(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) { + verified := rc.GetCommit().GetVerification().GetVerified() + byHive := func(login, email string) bool { + // An email-only match (no login resolved) counts only on a commit + // GitHub verified; a login resolved to the App bot counts as is. + return c.hiveCommitIdentity(login, email) && (login != "" || verified) + } + if byHive(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) { return true, nil } - return c.hiveCommitIdentity(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil + return byHive(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil } // PRConflictCandidates names the files a PR changed that its base also diff --git a/src/pkg/github/pr_merge_state_commit_by_hive_test.go b/src/pkg/github/pr_merge_state_commit_by_hive_test.go new file mode 100644 index 0000000000..a706c38c5b --- /dev/null +++ b/src/pkg/github/pr_merge_state_commit_by_hive_test.go @@ -0,0 +1,60 @@ +package github + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" +) + +// An email-only hive identity (no login resolved) counts as the hive's own +// only on a commit GitHub verified; a login resolved to the App bot counts +// whatever the verification (hivecommons/hive#15182). +func TestCommitByHive(t *testing.T) { + t.Setenv(signedTrailerDomainEnv, "") + cases := []struct { + name string + login, email string + verification map[string]any + want bool + }{ + {"email only, verified", "", "quality@hive.kubestellar.io", map[string]any{"verified": true}, true}, + {"email only, unverified", "", "quality@hive.kubestellar.io", map[string]any{"verified": false}, false}, + {"email only, no verification", "", "quality@hive.kubestellar.io", nil, false}, + {"bot noreply email only, unverified", "", "1+hive-app[bot]@users.noreply.github.com", map[string]any{"verified": false}, false}, + {"bot login, unverified", reconcileBot, "anything@example.com", map[string]any{"verified": false}, true}, + {"bot login, no verification", reconcileBot, "anything@example.com", nil, true}, + {"person login, verified", "alice", "quality@hive.kubestellar.io", map[string]any{"verified": true}, false}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/repos/acme/widget/commits/abc123" { + t.Fatalf("unexpected request: %s %s", r.Method, r.URL.String()) + } + ident := map[string]any{"name": "n", "email": tc.email} + commit := map[string]any{"author": ident, "committer": ident, "message": "m"} + if tc.verification != nil { + commit["verification"] = tc.verification + } + body := map[string]any{"sha": "abc123", "commit": commit} + if tc.login != "" { + body["author"] = map[string]any{"login": tc.login} + body["committer"] = map[string]any{"login": tc.login} + } + json.NewEncoder(w).Encode(body) + })) + defer server.Close() + c := NewClientForTest(server.URL, "acme", []string{"widget"}, nil) + c.SetAppBotLogin(reconcileBot) + got, err := c.CommitByHive(context.Background(), "acme/widget", "abc123") + if err != nil { + t.Fatalf("CommitByHive: %v", err) + } + if got != tc.want { + t.Errorf("CommitByHive = %v, want %v", got, tc.want) + } + }) + } +} From bd947edb46b2bef5f42abedc98d6edceea180912 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 11:44:29 -0400 Subject: [PATCH 2/5] fix: count the author only by App-bot login in CommitByHive GitHub's signature verification binds the signing key to the committer address alone, so a verified commit says nothing about the author field. Keep the verified-email fallback for the committer and require the author to resolve by login to the App bot; cover author/committer split identities in the table test. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15182.md | 2 +- src/docs/operator-reference.md | 2 +- src/pkg/github/pr_merge_state.go | 35 +++++++----- .../pr_merge_state_commit_by_hive_test.go | 56 ++++++++++++------- 4 files changed, 59 insertions(+), 36 deletions(-) diff --git a/changelog.d/changed-15182.md b/changelog.d/changed-15182.md index a864ca028d..e4ced4a1a6 100644 --- a/changelog.d/changed-15182.md +++ b/changelog.d/changed-15182.md @@ -1 +1 @@ -- The rebase-then-merge follow-through now counts a head as the hive's own by its email domain alone (no GitHub login resolved) only when GitHub reports the commit as verified; a commit whose login resolves to the App bot counts as before ([#15182](https://github.com/hivecommons/hive/issues/15182)). +- The rebase-then-merge follow-through now counts a head as the hive's own by its committer: an email-domain-only match (no GitHub login resolved) needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot, since a signature never vouches for the author address ([#15182](https://github.com/hivecommons/hive/issues/15182)). diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 429639087b..58900558a1 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -472,7 +472,7 @@ verified owner or an authorized user with the `merger` role: | Decision | What it does | Audit / ledger | |---|---|---| | `merge-now` — *Approve & merge as maintainer* | Comments on the PR that @you merged it from the dashboard, then merges it at once through the hive's GitHub App (`MergePRVia`, audit path `dashboard`). Refused when the PR is merged or closed, or when you are its author. | `repo_item_decision_merge`; `last_operator_action.action: merge-now`; toast *merged*. | -| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; an identity matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified); a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | +| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot); a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | | `queue-merge` — *Approve — let hive merge* | Leaves an `APPROVED` review in your name with a note, adds the automerge label, and leaves the merge to the App self-merge sweep, which merges on its next pass once CI is green and the head has soaked. Refused on your own PR. | `repo_item_decision_queue_merge`; `last_operator_action.action: queue-merge`; toast *queued for merge*. | **Approve is the trust override for that head diff --git a/src/pkg/github/pr_merge_state.go b/src/pkg/github/pr_merge_state.go index cfc477dc73..3b46ae5510 100644 --- a/src/pkg/github/pr_merge_state.go +++ b/src/pkg/github/pr_merge_state.go @@ -89,14 +89,16 @@ func (c *Client) GetPRMergeState(ctx context.Context, repo string, number int) ( } // CommitByHive reports whether the commit at sha is the hive's own work: -// its author or committer resolves to the App bot (by login or noreply -// address) or to an address in the pane identity domain — the fixer's -// rebase or GitHub's update-branch under the App. When GitHub resolves no -// login for that identity, the email-only match also requires the commit's -// signature to be verified by GitHub (hivecommons/hive#15182). A head a -// person pushed after a rebase-then-merge approval is new content the -// approval never covered, so the follow-through fails closed on it -// (hivecommons/hive#15104). +// its committer resolves to the App bot (by login or noreply address) or to +// an address in the pane identity domain — the fixer's rebase — or its +// author resolves by login to the App bot, as on GitHub's update-branch +// under the App. When GitHub resolves no login for the committer, the +// email-only match also requires the commit's signature to be verified by +// GitHub, which binds the signing key to the committer address only +// (hivecommons/hive#15182); the author is free text GitHub never vouches +// for, so no email-only author match counts. A head a person pushed after a +// rebase-then-merge approval is new content the approval never covered, so +// the follow-through fails closed on it (hivecommons/hive#15104). func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) { if c == nil || c.client == nil { return false, ErrNoGitHubClient @@ -110,16 +112,19 @@ func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, erro if err != nil { return false, fmt.Errorf("reading %s/%s@%s: %w", owner, repoName, shortSHA(sha), err) } - verified := rc.GetCommit().GetVerification().GetVerified() - byHive := func(login, email string) bool { + committerLogin := safeGetLogin(rc.GetCommitter()) + if c.hiveCommitIdentity(committerLogin, rc.GetCommit().GetCommitter().GetEmail()) { // An email-only match (no login resolved) counts only on a commit // GitHub verified; a login resolved to the App bot counts as is. - return c.hiveCommitIdentity(login, email) && (login != "" || verified) - } - if byHive(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) { - return true, nil + if committerLogin != "" || rc.GetCommit().GetVerification().GetVerified() { + return true, nil + } } - return byHive(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil + // The author counts only by a login resolved to the App bot: a signature + // never covers the author address, so a verified commit proves nothing + // about an email-only author match. + authorLogin := safeGetLogin(rc.GetAuthor()) + return authorLogin != "" && c.hiveCommitIdentity(authorLogin, rc.GetCommit().GetAuthor().GetEmail()), nil } // PRConflictCandidates names the files a PR changed that its base also diff --git a/src/pkg/github/pr_merge_state_commit_by_hive_test.go b/src/pkg/github/pr_merge_state_commit_by_hive_test.go index a706c38c5b..56a6ccc31b 100644 --- a/src/pkg/github/pr_merge_state_commit_by_hive_test.go +++ b/src/pkg/github/pr_merge_state_commit_by_hive_test.go @@ -8,24 +8,37 @@ import ( "testing" ) -// An email-only hive identity (no login resolved) counts as the hive's own -// only on a commit GitHub verified; a login resolved to the App bot counts -// whatever the verification (hivecommons/hive#15182). +// An email-only hive committer identity (no login resolved) counts as the +// hive's own only on a commit GitHub verified; a login resolved to the App +// bot counts whatever the verification. GitHub's verification binds the +// signing key to the committer address only, so an email-only author match +// never counts, verified or not (hivecommons/hive#15182). func TestCommitByHive(t *testing.T) { t.Setenv(signedTrailerDomainEnv, "") + type identity struct{ login, email string } cases := []struct { - name string - login, email string - verification map[string]any - want bool + name string + author, committer identity + verification map[string]any + want bool }{ - {"email only, verified", "", "quality@hive.kubestellar.io", map[string]any{"verified": true}, true}, - {"email only, unverified", "", "quality@hive.kubestellar.io", map[string]any{"verified": false}, false}, - {"email only, no verification", "", "quality@hive.kubestellar.io", nil, false}, - {"bot noreply email only, unverified", "", "1+hive-app[bot]@users.noreply.github.com", map[string]any{"verified": false}, false}, - {"bot login, unverified", reconcileBot, "anything@example.com", map[string]any{"verified": false}, true}, - {"bot login, no verification", reconcileBot, "anything@example.com", nil, true}, - {"person login, verified", "alice", "quality@hive.kubestellar.io", map[string]any{"verified": true}, false}, + {"email only, verified", identity{"", "quality@hive.kubestellar.io"}, identity{"", "quality@hive.kubestellar.io"}, map[string]any{"verified": true}, true}, + {"email only, unverified", identity{"", "quality@hive.kubestellar.io"}, identity{"", "quality@hive.kubestellar.io"}, map[string]any{"verified": false}, false}, + {"email only, no verification", identity{"", "quality@hive.kubestellar.io"}, identity{"", "quality@hive.kubestellar.io"}, nil, false}, + {"bot noreply email only, unverified", identity{"", "1+hive-app[bot]@users.noreply.github.com"}, identity{"", "1+hive-app[bot]@users.noreply.github.com"}, map[string]any{"verified": false}, false}, + {"bot login, unverified", identity{reconcileBot, "anything@example.com"}, identity{reconcileBot, "anything@example.com"}, map[string]any{"verified": false}, true}, + {"bot login, no verification", identity{reconcileBot, "anything@example.com"}, identity{reconcileBot, "anything@example.com"}, nil, true}, + {"person login, verified", identity{"alice", "quality@hive.kubestellar.io"}, identity{"alice", "quality@hive.kubestellar.io"}, map[string]any{"verified": true}, false}, + // A signer forging --author into the pane domain: the signature vouches + // for alice as committer, never for the author address. + {"person committer, email-only pane author, verified", identity{"", "quality@hive.kubestellar.io"}, identity{"alice", "alice@example.com"}, map[string]any{"verified": true}, false}, + {"person committer, email-only bot noreply author, verified", identity{"", "1+hive-app[bot]@users.noreply.github.com"}, identity{"alice", "alice@example.com"}, map[string]any{"verified": true}, false}, + // update-branch under the App: author resolves to the bot, GitHub commits. + {"bot login author, web-flow committer", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"web-flow", "noreply@github.com"}, map[string]any{"verified": true}, true}, + {"bot login author, web-flow committer, unverified", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"web-flow", "noreply@github.com"}, nil, true}, + // The fixer's rebase keeps the person as author; the hive commits. + {"person author, email-only pane committer, verified", identity{"alice", "alice@example.com"}, identity{"", "fixer@hive.kubestellar.io"}, map[string]any{"verified": true}, true}, + {"person author, email-only pane committer, unverified", identity{"alice", "alice@example.com"}, identity{"", "fixer@hive.kubestellar.io"}, map[string]any{"verified": false}, false}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -33,15 +46,20 @@ func TestCommitByHive(t *testing.T) { if r.URL.Path != "/repos/acme/widget/commits/abc123" { t.Fatalf("unexpected request: %s %s", r.Method, r.URL.String()) } - ident := map[string]any{"name": "n", "email": tc.email} - commit := map[string]any{"author": ident, "committer": ident, "message": "m"} + commit := map[string]any{ + "author": map[string]any{"name": "n", "email": tc.author.email}, + "committer": map[string]any{"name": "n", "email": tc.committer.email}, + "message": "m", + } if tc.verification != nil { commit["verification"] = tc.verification } body := map[string]any{"sha": "abc123", "commit": commit} - if tc.login != "" { - body["author"] = map[string]any{"login": tc.login} - body["committer"] = map[string]any{"login": tc.login} + if tc.author.login != "" { + body["author"] = map[string]any{"login": tc.author.login} + } + if tc.committer.login != "" { + body["committer"] = map[string]any{"login": tc.committer.login} } json.NewEncoder(w).Encode(body) })) From d394f328c2bf64af61a462a50fd0c7720accb064 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:04:40 -0400 Subject: [PATCH 3/5] fix: sign the fixer's rebase of a contributor PR before the merge follow-through reads it Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15182.md | 2 +- src/docs/operator-reference.md | 2 +- .../dashboard/rebase_merge_followthrough.go | 27 +++ .../rebase_merge_followthrough_test.go | 61 +++++ src/pkg/github/pr_fixer_rebase_signed.go | 212 ++++++++++++++++++ src/pkg/github/pr_fixer_rebase_signed_test.go | 176 +++++++++++++++ src/pkg/github/pr_merge_state.go | 8 +- 7 files changed, 483 insertions(+), 5 deletions(-) create mode 100644 src/pkg/github/pr_fixer_rebase_signed.go create mode 100644 src/pkg/github/pr_fixer_rebase_signed_test.go diff --git a/changelog.d/changed-15182.md b/changelog.d/changed-15182.md index e4ced4a1a6..8da1ef459b 100644 --- a/changelog.d/changed-15182.md +++ b/changelog.d/changed-15182.md @@ -1 +1 @@ -- The rebase-then-merge follow-through now counts a head as the hive's own by its committer: an email-domain-only match (no GitHub login resolved) needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot, since a signature never vouches for the author address ([#15182](https://github.com/hivecommons/hive/issues/15182)). +- The rebase-then-merge follow-through now counts a head as the hive's own by its committer: an email-domain-only match (no GitHub login resolved) needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot, since a signature never vouches for the author address; the fixer's plain-git rebase of a contributor PR is first sealed as one GitHub-signed merge commit authored by the App on top of the approved head, so the contributor's commits stay theirs and the rebase still counts ([#15182](https://github.com/hivecommons/hive/issues/15182)). diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 58900558a1..857e962a63 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -472,7 +472,7 @@ verified owner or an authorized user with the `merger` role: | Decision | What it does | Audit / ledger | |---|---|---| | `merge-now` — *Approve & merge as maintainer* | Comments on the PR that @you merged it from the dashboard, then merges it at once through the hive's GitHub App (`MergePRVia`, audit path `dashboard`). Refused when the PR is merged or closed, or when you are its author. | `repo_item_decision_merge`; `last_operator_action.action: merge-now`; toast *merged*. | -| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot); a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | +| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot). Because the fixer rebases with plain git, its unsigned head is signed first: when GitHub's timeline shows the App force-pushing that head over the approved one, the hive replaces it with one GitHub-signed merge commit authored by the App (first parent the approved head, so the contributor's commits stay theirs; second parent the base commit the fixer rebased onto; the fixer's resolved tree) and the next tick reads that head. A head the hive cannot sign (pushed by anyone else, or on a fork the App cannot write) stays unsigned and does not count: a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | | `queue-merge` — *Approve — let hive merge* | Leaves an `APPROVED` review in your name with a note, adds the automerge label, and leaves the merge to the App self-merge sweep, which merges on its next pass once CI is green and the head has soaked. Refused on your own PR. | `repo_item_decision_queue_merge`; `last_operator_action.action: queue-merge`; toast *queued for merge*. | **Approve is the trust override for that head diff --git a/src/pkg/dashboard/rebase_merge_followthrough.go b/src/pkg/dashboard/rebase_merge_followthrough.go index 9048d32c0c..1a534269c0 100644 --- a/src/pkg/dashboard/rebase_merge_followthrough.go +++ b/src/pkg/dashboard/rebase_merge_followthrough.go @@ -45,6 +45,12 @@ var rebaseAttemptsStore = func() *rebasemerge.Attempts { return rebasemerge.Shar // rebaseMergeNow is the clock (swapped in tests). var rebaseMergeNow = time.Now +// rebaseMergeSignFixerRebase seals the fixer's plain-git rebase of a +// contributor PR as a GitHub-signed commit (swapped in tests). +var rebaseMergeSignFixerRebase = func(ctx context.Context, gh *ghpkg.Client, repo string, number int, prevHead, head string) (string, error) { + return gh.SignFixerRebase(ctx, repo, number, prevHead, head) +} + // rebaseMergeFollowThroughLabel / Consequence are the option text the // decision menu shows instead of "Approve & merge as maintainer" when the // PR needs a rebase first. @@ -222,6 +228,27 @@ func (s *Server) driveRebaseMerge(ctx context.Context, store *rebasemerge.Store, now := rebaseMergeNow() obs := rebasemerge.Observation{Now: now, Head: st.HeadSHA, State: st.State, Merged: st.Merged, MergeableState: st.MergeableState, CIRed: st.CIRed} if head := strings.TrimSpace(st.HeadSHA); head != "" && head != f.ApprovedHead && head != f.RebasedHead && !f.HiveAuthored && !st.Merged { + // The fixer rebases with plain git, so its head is unsigned and + // CommitByHive would not count it (hivecommons/hive#15182). Seal it + // as a GitHub-signed commit first; the next tick reads the signed + // head. A head the hive cannot sign falls through to the verdict + // below and fails closed. + prev := nonEmptyString(f.RebasedHead, f.ApprovedHead) + signed, err := rebaseMergeSignFixerRebase(ctx, gh, f.Repo, f.Number, prev, head) + switch { + case err == nil && signed != "": + if s.logger != nil { + s.logger.Info("rebase-then-merge: signed the fixer's rebase", "repo", f.Repo, "number", f.Number, "rebased_head", head, "signed_head", signed, "parent", prev) + } + return + case ghpkg.IsSignedHeadMoved(err): + if s.logger != nil { + s.logger.Info("rebase-then-merge: head moved while signing the fixer's rebase; waiting", "repo", f.Repo, "number", f.Number, "head", head, "error", err) + } + return + case err != nil && s.logger != nil: + s.logger.Warn("rebase-then-merge: cannot sign the fixer's rebase; the head counts only if GitHub says the hive committed it", "repo", f.Repo, "number", f.Number, "head", head, "from_fork", st.FromFork, "error", err) + } // The approval was bound to ApprovedHead. Before the new head can // count as "the rebase", make sure the hive produced it; a read // error leaves the decision to the next tick rather than guessing. diff --git a/src/pkg/dashboard/rebase_merge_followthrough_test.go b/src/pkg/dashboard/rebase_merge_followthrough_test.go index f4acbcfdd7..83237fd5a0 100644 --- a/src/pkg/dashboard/rebase_merge_followthrough_test.go +++ b/src/pkg/dashboard/rebase_merge_followthrough_test.go @@ -3,8 +3,10 @@ package dashboard import ( "context" "encoding/json" + "errors" "net/http" "path/filepath" + "strconv" "strings" "testing" "time" @@ -367,3 +369,62 @@ func TestDriveRebaseMergeForeignHeadFailsClosed(t *testing.T) { t.Fatalf("failed result = %+v", res) } } + +// The signing step (hivecommons/hive#15182): the fixer's plain-git rebase +// of a contributor PR is sealed as a GitHub-signed head before the +// follow-through judges it, so it does not settle as foreign-head; the next +// tick reads the signed head. A head the hive cannot sign still fails +// closed on CommitByHive's verdict. +func TestDriveRebaseMergeSignsFixerRebaseFirst(t *testing.T) { + const ( + approved = "feedfacefeedfacefeedfacefeedfacefeedface" + rebased = "0123456789abcdef0123456789abcdef01234567" + signed = "5190ed5190ed5190ed5190ed5190ed5190ed5190" + ) + cases := []struct { + name string + signErr error + signed string + wantState string + wantFail string + }{ + {name: "signed", signed: signed, wantState: rebasemerge.StateRebasing}, + {name: "cannot sign", signErr: errors.New("creating the signed commit in alice/r: 403"), wantState: rebasemerge.StateFailed, wantFail: rebasemerge.FailForeignHead}, + {name: "not a fixer rebase", wantState: rebasemerge.StateFailed, wantFail: rebasemerge.FailForeignHead}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + store := useRebaseMergeStore(t) + mock := &repoItemDecisionMock{prForeign: true} + srv := newRepoItemDecisionServer(t, mock) + srv.operatorActionStore = newOperatorActionStore(filepath.Join(t.TempDir(), "ops.json")) + now := time.Date(2026, 10, 29, 9, 0, 0, 0, time.UTC) + prevNow := rebaseMergeNow + rebaseMergeNow = func() time.Time { return now } + t.Cleanup(func() { rebaseMergeNow = prevNow }) + var calls []string + prevSign := rebaseMergeSignFixerRebase + rebaseMergeSignFixerRebase = func(_ context.Context, _ *ghpkg.Client, repo string, number int, prev, head string) (string, error) { + calls = append(calls, repo+"#"+strconv.Itoa(number)+" "+prev+"->"+head) + return tc.signed, tc.signErr + } + t.Cleanup(func() { rebaseMergeSignFixerRebase = prevSign }) + + f := rebasemerge.Arm("testorg/testrepo", 8, "writer", "main", approved, false, now) + f.Kicked(now, "fixer") + _ = store.Put(f) + now = now.Add(5 * time.Minute) + srv.driveRebaseMerge(context.Background(), store, f, ghpkg.PRMergeState{State: "open", HeadSHA: rebased, BaseRef: "main", MergeableState: "clean", FromFork: true, MaintainerCanModify: true}) + f, _ = store.Get("testorg/testrepo", 8) + if len(calls) != 1 || calls[0] != "testorg/testrepo#8 "+approved+"->"+rebased { + t.Fatalf("sign calls = %q", calls) + } + if f.State != tc.wantState || f.FailReason != tc.wantFail { + t.Fatalf("follow-through = %+v", f) + } + if len(mock.merges) != 0 { + t.Fatalf("nothing merges on the unsigned head: %v", mock.merges) + } + }) + } +} diff --git a/src/pkg/github/pr_fixer_rebase_signed.go b/src/pkg/github/pr_fixer_rebase_signed.go new file mode 100644 index 0000000000..766fe2c054 --- /dev/null +++ b/src/pkg/github/pr_fixer_rebase_signed.go @@ -0,0 +1,212 @@ +package github + +import ( + "context" + "errors" + "fmt" + "strings" + + gh "github.com/google/go-github/v72/github" +) + +// The signing step for the fixer's rebase of a contributor PR +// (hivecommons/hive#15182, follow-through of #15104). +// +// The rebase-then-merge follow-through counts a contributor PR's new head as +// the rebase only when CommitByHive says the hive committed it, and since +// #15182 an email-only pane-identity committer needs a GitHub-verified +// signature. The fixer rebases with plain git, so its head is unsigned by +// construction and would settle every such follow-through as foreign-head. +// +// SignFixerRebase seals that rebase as a GitHub-signed commit without +// re-authoring anybody. GitHub signs a commit the App creates through the +// REST API only when the request carries no custom author or committer, so +// the signed commit is the App's own: a merge commit whose first parent is +// the head the operator approved (the contributor's commits, byte for byte, +// with their own authorship and sign-offs) and whose second parent is the +// base commit the fixer rebased onto, carrying the fixer's resolved tree. +// The squash-attribution DCO check skips merge commits, and the PR diff +// (base...head) is the same as the fixer's rebase. +// +// Provenance comes from GitHub, never from the commit's own fields: the PR +// timeline must show the App bot force-pushing exactly this head over the +// approved one. A head a person pushed with the pane identity's address is +// refused, so the signing step cannot launder a forged committer into a +// verified one. + +// fixerRebaseForcePushWindow is how many recent force-push events are read. +const fixerRebaseForcePushWindow = 20 + +// errFixerRebaseNotSigned marks a candidate head the hive refused to sign +// (wrong pusher, unexpected history). It wraps errSignedCommitSkip. +var errFixerRebaseNotSigned = fmt.Errorf("%w: fixer rebase not signed", errSignedCommitSkip) + +// IsSignedHeadMoved reports whether err is the transient "head moved while +// the signed commit was being built" refusal; the caller retries next tick. +func IsSignedHeadMoved(err error) bool { + var moved signedHeadMovedError + return errors.As(err, &moved) +} + +type fixerRebaseForcePush struct { + Actor struct { + Typename string `json:"__typename"` + Login string `json:"login"` + } `json:"actor"` + BeforeCommit struct { + OID string `json:"oid"` + } `json:"beforeCommit"` + AfterCommit struct { + OID string `json:"oid"` + } `json:"afterCommit"` +} + +type fixerRebasePullRequest struct { + HeadRefName string `json:"headRefName"` + BaseRefName string `json:"baseRefName"` + HeadRepository struct { + NameWithOwner string `json:"nameWithOwner"` + } `json:"headRepository"` + TimelineItems struct { + Nodes []fixerRebaseForcePush `json:"nodes"` + } `json:"timelineItems"` +} + +type fixerRebasePR struct { + Repository struct { + PullRequest fixerRebasePullRequest `json:"pullRequest"` + } `json:"repository"` +} + +const fixerRebasePRQuery = `query($owner: String!, $name: String!, $number: Int!, $last: Int!) { + repository(owner: $owner, name: $name) { + pullRequest(number: $number) { + headRefName + baseRefName + headRepository { nameWithOwner } + timelineItems(last: $last, itemTypes: [HEAD_REF_FORCE_PUSHED_EVENT]) { + nodes { + ... on HeadRefForcePushedEvent { + actor { __typename login } + beforeCommit { oid } + afterCommit { oid } + } + } + } + } + } +}` + +// SignFixerRebase seals head — the fixer's plain-git rebase of PR number, +// replacing prevHead (the approved head, or the last head the follow-through +// accepted) — as one GitHub-signed merge commit on the PR's head branch and +// returns its sha. ("", nil) means head is not a fixer rebase (its committer +// is not an unverified, email-only pane identity): nothing was written and +// CommitByHive decides as before. An error means a candidate the hive could +// not sign — a push it cannot attribute to the App, or a head repository +// (a contributor's fork) the App cannot write — and nothing was written; the +// follow-through then fails closed on CommitByHive's verdict. +func (c *Client) SignFixerRebase(ctx context.Context, repo string, number int, prevHead, head string) (string, error) { + if c == nil || c.client == nil { + return "", ErrNoGitHubClient + } + prevHead, head = strings.TrimSpace(prevHead), strings.TrimSpace(head) + if head == "" || prevHead == "" || head == prevHead { + return "", nil + } + owner, repoName := c.splitRepo(repo) + ctx = WithRESTCaller(ctx, "hive:rebase_merge_sign") + rc, _, err := c.client.Repositories.GetCommit(ctx, owner, repoName, head, nil) + if err != nil { + return "", fmt.Errorf("reading %s/%s@%s: %w", owner, repoName, shortSHA(head), err) + } + committerLogin := safeGetLogin(rc.GetCommitter()) + if committerLogin != "" || rc.GetCommit().GetVerification().GetVerified() || !c.hiveCommitIdentity("", rc.GetCommit().GetCommitter().GetEmail()) { + return "", nil + } + tree := rc.GetCommit().GetTree().GetSHA() + if tree == "" { + return "", fmt.Errorf("reading %s/%s@%s: no tree", owner, repoName, shortSHA(head)) + } + + var pr fixerRebasePR + if err := c.graphQL(ctx, fixerRebasePRQuery, map[string]any{"owner": owner, "name": repoName, "number": number, "last": fixerRebaseForcePushWindow}, &pr); err != nil { + return "", fmt.Errorf("reading %s/%s#%d force-pushes: %w", owner, repoName, number, err) + } + p := pr.Repository.PullRequest + if !c.fixerRebasePushedByHive(p, prevHead, head) { + return "", fmt.Errorf("%w: GitHub shows no force-push of %s over %s by the App on %s/%s#%d", errFixerRebaseNotSigned, shortSHA(head), shortSHA(prevHead), owner, repoName, number) + } + headRef := strings.TrimSpace(p.HeadRefName) + headOwner, headName, ok := strings.Cut(strings.TrimSpace(p.HeadRepository.NameWithOwner), "/") + if headRef == "" || !ok || headOwner == "" || headName == "" { + return "", fmt.Errorf("%w: %s/%s#%d has no readable head branch", errFixerRebaseNotSigned, owner, repoName, number) + } + + cmp, _, err := c.client.Repositories.CompareCommits(ctx, owner, repoName, p.BaseRefName, head, &gh.ListOptions{PerPage: 1}) + if err != nil { + return "", fmt.Errorf("comparing %s...%s: %w", p.BaseRefName, shortSHA(head), err) + } + onto := cmp.GetMergeBaseCommit().GetSHA() + if onto == "" || onto == prevHead { + return "", fmt.Errorf("%w: no base commit under %s to merge", errFixerRebaseNotSigned, shortSHA(head)) + } + + ref, _, err := c.client.Git.GetRef(ctx, headOwner, headName, "heads/"+headRef) + if err != nil { + return "", fmt.Errorf("reading %s:%s: %w", headOwner+"/"+headName, headRef, err) + } + if got := ref.GetObject().GetSHA(); got != head { + return "", signedHeadMovedError{fmt.Errorf("%w: %s moved from %s to %s before the fixer's rebase was signed", errSignedCommitSkip, headRef, shortSHA(head), shortSHA(got))} + } + // No Author / Committer: GitHub signs only an App commit without them. + signed, _, err := c.client.Git.CreateCommit(ctx, headOwner, headName, &gh.Commit{ + Message: gh.Ptr(fixerRebaseSignedMessage(p.BaseRefName, headRef, number, prevHead, head, c.appBotLogin)), + Tree: &gh.Tree{SHA: gh.Ptr(tree)}, + Parents: []*gh.Commit{{SHA: gh.Ptr(prevHead)}, {SHA: gh.Ptr(onto)}}, + }, nil) + if err != nil { + return "", fmt.Errorf("creating the signed commit in %s: %w", headOwner+"/"+headName, err) + } + if signed.GetSHA() == "" { + return "", fmt.Errorf("creating the signed commit in %s: no sha returned", headOwner+"/"+headName) + } + if _, _, err := c.client.Git.UpdateRef(ctx, headOwner, headName, &gh.Reference{ + Ref: gh.Ptr("refs/heads/" + headRef), + Object: &gh.GitObject{SHA: gh.Ptr(signed.GetSHA())}, + }, true); err != nil { + return "", fmt.Errorf("updating %s:%s to signed commit %s: %w", headOwner+"/"+headName, headRef, shortSHA(signed.GetSHA()), err) + } + return signed.GetSHA(), nil +} + +// fixerRebasePushedByHive: the newest force-push to head replaced prevHead +// and was made by the App bot. GraphQL reports a Bot's login without the +// "[bot]" suffix REST uses, so both spellings match. +func (c *Client) fixerRebasePushedByHive(p fixerRebasePullRequest, prevHead, head string) bool { + bot := strings.TrimSpace(c.appBotLogin) + if bot == "" { + return false + } + nodes := p.TimelineItems.Nodes + for i := len(nodes) - 1; i >= 0; i-- { + n := nodes[i] + if n.AfterCommit.OID != head { + continue + } + login := strings.TrimSpace(n.Actor.Login) + byBot := strings.EqualFold(login, bot) || (n.Actor.Typename == "Bot" && strings.EqualFold(login+"[bot]", bot)) + return byBot && n.BeforeCommit.OID == prevHead + } + return false +} + +func fixerRebaseSignedMessage(base, headRef string, number int, prevHead, head, bot string) string { + var b strings.Builder + fmt.Fprintf(&b, "Merge %s into %s\n\n", base, headRef) + fmt.Fprintf(&b, "The hive's rebase of #%d onto %s (%s), signed by GitHub as a merge on top of the approved head %s so the contributor's commits stay theirs.", number, base, shortSHA(head), shortSHA(prevHead)) + if bot = strings.TrimSpace(bot); bot != "" { + b.WriteString("\n\n" + BotSignedOffByTrailer(bot)) + } + return b.String() +} diff --git a/src/pkg/github/pr_fixer_rebase_signed_test.go b/src/pkg/github/pr_fixer_rebase_signed_test.go new file mode 100644 index 0000000000..718997fa91 --- /dev/null +++ b/src/pkg/github/pr_fixer_rebase_signed_test.go @@ -0,0 +1,176 @@ +package github + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "strings" + "sync" + "testing" +) + +// The signing step for the fixer's rebase of a contributor PR +// (hivecommons/hive#15182): an unverified, email-only pane-identity head the +// App force-pushed over the approved head is sealed as one GitHub-signed +// merge commit (approved head + the base it was rebased onto, the fixer's +// tree, no custom author or committer so GitHub signs it); anything else is +// left alone or refused without a write. +func TestSignFixerRebase(t *testing.T) { + t.Setenv(signedTrailerDomainEnv, "") + const ( + approved = "aaaa000000000000000000000000000000000001" + rebased = "bbbb000000000000000000000000000000000002" + onto = "cccc000000000000000000000000000000000003" + tree = "dddd000000000000000000000000000000000004" + signed = "eeee000000000000000000000000000000000005" + other = "ffff000000000000000000000000000000000006" + ) + type push struct{ typename, login, before, after string } + appPush := push{"Bot", "hive-app", approved, rebased} + cases := []struct { + name string + committerLogin string + committerEmail string + verified bool + headRepo string + pushes []push + refSHA string + createStatus int + want string + wantErr bool + wantMoved bool + wantGraphQL bool + wantWrites bool + }{ + {name: "fixer rebase, App force-push over the approved head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{appPush}, want: signed, wantGraphQL: true, wantWrites: true}, + {name: "REST bot login spelling", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"Bot", reconcileBot, approved, rebased}}, want: signed, wantGraphQL: true, wantWrites: true}, + {name: "fork head the App can write", committerEmail: "fixer@hive.kubestellar.io", headRepo: "alice/r", pushes: []push{appPush}, want: signed, wantGraphQL: true, wantWrites: true}, + {name: "fork head the App cannot write", committerEmail: "fixer@hive.kubestellar.io", headRepo: "alice/r", pushes: []push{appPush}, createStatus: http.StatusForbidden, wantErr: true, wantGraphQL: true}, + {name: "committer resolves to a login", committerLogin: "alice", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{appPush}}, + {name: "already verified", committerEmail: "fixer@hive.kubestellar.io", verified: true, headRepo: "o/r", pushes: []push{appPush}}, + {name: "committer outside the pane domain", committerEmail: "alice@example.com", headRepo: "o/r", pushes: []push{appPush}}, + {name: "a person force-pushed the pane-identity head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"User", "alice", approved, rebased}}, wantErr: true, wantGraphQL: true}, + {name: "App force-push over another head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"Bot", "hive-app", other, rebased}}, wantErr: true, wantGraphQL: true}, + {name: "no force-push of this head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"Bot", "hive-app", approved, other}}, wantErr: true, wantGraphQL: true}, + {name: "head moved before signing", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{appPush}, refSHA: other, wantErr: true, wantMoved: true, wantGraphQL: true}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + var ( + mu sync.Mutex + graphQLs int + created map[string]any + updated map[string]any + writePath []string + ) + headPrefix := "/repos/" + tc.headRepo + "/git/" + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mu.Lock() + defer mu.Unlock() + w.Header().Set("Content-Type", "application/json") + switch { + case r.Method == http.MethodGet && r.URL.Path == "/repos/o/r/commits/"+rebased: + commit := map[string]any{ + "author": map[string]any{"name": "alice", "email": "alice@example.com"}, + "committer": map[string]any{"name": "fixer", "email": tc.committerEmail}, + "message": "feat: alice's change", + "tree": map[string]any{"sha": tree}, + "verification": map[string]any{"verified": tc.verified}, + } + body := map[string]any{"sha": rebased, "commit": commit, "author": map[string]any{"login": "alice"}} + if tc.committerLogin != "" { + body["committer"] = map[string]any{"login": tc.committerLogin} + } + _ = json.NewEncoder(w).Encode(body) + case r.Method == http.MethodPost && r.URL.Path == "/graphql": + graphQLs++ + nodes := make([]map[string]any, 0, len(tc.pushes)) + for _, p := range tc.pushes { + nodes = append(nodes, map[string]any{"actor": map[string]any{"__typename": p.typename, "login": p.login}, "beforeCommit": map[string]any{"oid": p.before}, "afterCommit": map[string]any{"oid": p.after}}) + } + _ = json.NewEncoder(w).Encode(map[string]any{"data": map[string]any{"repository": map[string]any{"pullRequest": map[string]any{ + "headRefName": "feature", "baseRefName": "main", + "headRepository": map[string]any{"nameWithOwner": tc.headRepo}, + "timelineItems": map[string]any{"nodes": nodes}, + }}}}) + case r.Method == http.MethodGet && r.URL.Path == "/repos/o/r/compare/main..."+rebased: + _ = json.NewEncoder(w).Encode(map[string]any{"merge_base_commit": map[string]any{"sha": onto}}) + case r.Method == http.MethodGet && r.URL.Path == headPrefix+"ref/heads/feature": + sha := rebased + if tc.refSHA != "" { + sha = tc.refSHA + } + _ = json.NewEncoder(w).Encode(map[string]any{"ref": "refs/heads/feature", "object": map[string]any{"sha": sha}}) + case r.Method == http.MethodPost && r.URL.Path == headPrefix+"commits": + writePath = append(writePath, r.URL.Path) + if tc.createStatus != 0 { + w.WriteHeader(tc.createStatus) + _, _ = w.Write([]byte(`{"message":"Resource not accessible by integration"}`)) + return + } + _ = json.NewDecoder(r.Body).Decode(&created) + _ = json.NewEncoder(w).Encode(map[string]any{"sha": signed}) + case r.Method == http.MethodPatch && r.URL.Path == headPrefix+"refs/heads/feature": + writePath = append(writePath, r.URL.Path) + _ = json.NewDecoder(r.Body).Decode(&updated) + _ = json.NewEncoder(w).Encode(map[string]any{"ref": "refs/heads/feature", "object": map[string]any{"sha": signed}}) + default: + t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path) + http.NotFound(w, r) + } + })) + defer server.Close() + c := NewClientForTest(server.URL, "o", []string{"r"}, nil) + c.SetAppBotLogin(reconcileBot) + + got, err := c.SignFixerRebase(context.Background(), "o/r", 8, approved, rebased) + if (err != nil) != tc.wantErr { + t.Fatalf("SignFixerRebase err = %v, wantErr %v", err, tc.wantErr) + } + if IsSignedHeadMoved(err) != tc.wantMoved { + t.Fatalf("IsSignedHeadMoved(%v) = %v, want %v", err, !tc.wantMoved, tc.wantMoved) + } + if got != tc.want { + t.Fatalf("SignFixerRebase = %q, want %q", got, tc.want) + } + mu.Lock() + defer mu.Unlock() + if (graphQLs > 0) != tc.wantGraphQL { + t.Fatalf("graphql calls = %d, want any: %v", graphQLs, tc.wantGraphQL) + } + if !tc.wantWrites { + if updated != nil { + t.Fatalf("a refused head must not move the branch: %v", updated) + } + if tc.createStatus == 0 && len(writePath) != 0 { + t.Fatalf("a refused head must not write: %v", writePath) + } + return + } + if created == nil || updated == nil { + t.Fatalf("writes: created=%v updated=%v", created, updated) + } + if _, ok := created["author"]; ok { + t.Fatalf("a custom author stops GitHub signing the commit: %v", created) + } + if _, ok := created["committer"]; ok { + t.Fatalf("a custom committer stops GitHub signing the commit: %v", created) + } + parents, _ := created["parents"].([]any) + if len(parents) != 2 || parents[0] != approved || parents[1] != onto { + t.Fatalf("parents = %v, want [approved head, rebase base]", created["parents"]) + } + if created["tree"] != tree { + t.Fatalf("tree = %v, want the fixer's tree %s", created["tree"], tree) + } + msg, _ := created["message"].(string) + if !strings.HasPrefix(msg, "Merge main into feature\n") || !strings.Contains(msg, BotSignedOffByTrailer(reconcileBot)) { + t.Fatalf("message = %q", msg) + } + if updated["sha"] != signed || updated["force"] != true { + t.Fatalf("ref update = %v", updated) + } + }) + } +} diff --git a/src/pkg/github/pr_merge_state.go b/src/pkg/github/pr_merge_state.go index 3b46ae5510..3f780f38e2 100644 --- a/src/pkg/github/pr_merge_state.go +++ b/src/pkg/github/pr_merge_state.go @@ -96,9 +96,11 @@ func (c *Client) GetPRMergeState(ctx context.Context, repo string, number int) ( // email-only match also requires the commit's signature to be verified by // GitHub, which binds the signing key to the committer address only // (hivecommons/hive#15182); the author is free text GitHub never vouches -// for, so no email-only author match counts. A head a person pushed after a -// rebase-then-merge approval is new content the approval never covered, so -// the follow-through fails closed on it (hivecommons/hive#15104). +// for, so no email-only author match counts. The fixer's plain-git rebase of +// a contributor PR is therefore sealed by SignFixerRebase first, as an App +// commit GitHub signs, before this verdict reads it. A head a person pushed +// after a rebase-then-merge approval is new content the approval never +// covered, so the follow-through fails closed on it (hivecommons/hive#15104). func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) { if c == nil || c.client == nil { return false, ErrNoGitHubClient From cba6d4b1189b6c16302d66d96fe61ba90c7a34e8 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:48:58 -0400 Subject: [PATCH 4/5] drop fixer-rebase sealing; keep CommitByHive verified-signature tightening only Per maintainer review on #15405: the hive must not force-update a contributor's head branch, even to an App-signed merge commit. Remove SignFixerRebase and the follow-through hook that called it, and trim the changelog and operator-reference to the CommitByHive change that stays. Hive-Fix-Attempt: 3/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15182.md | 2 +- src/docs/operator-reference.md | 2 +- .../dashboard/rebase_merge_followthrough.go | 27 --- .../rebase_merge_followthrough_test.go | 61 ----- src/pkg/github/pr_fixer_rebase_signed.go | 212 ------------------ src/pkg/github/pr_fixer_rebase_signed_test.go | 176 --------------- src/pkg/github/pr_merge_state.go | 4 +- 7 files changed, 3 insertions(+), 481 deletions(-) delete mode 100644 src/pkg/github/pr_fixer_rebase_signed.go delete mode 100644 src/pkg/github/pr_fixer_rebase_signed_test.go diff --git a/changelog.d/changed-15182.md b/changelog.d/changed-15182.md index 8da1ef459b..e4ced4a1a6 100644 --- a/changelog.d/changed-15182.md +++ b/changelog.d/changed-15182.md @@ -1 +1 @@ -- The rebase-then-merge follow-through now counts a head as the hive's own by its committer: an email-domain-only match (no GitHub login resolved) needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot, since a signature never vouches for the author address; the fixer's plain-git rebase of a contributor PR is first sealed as one GitHub-signed merge commit authored by the App on top of the approved head, so the contributor's commits stay theirs and the rebase still counts ([#15182](https://github.com/hivecommons/hive/issues/15182)). +- The rebase-then-merge follow-through now counts a head as the hive's own by its committer: an email-domain-only match (no GitHub login resolved) needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot, since a signature never vouches for the author address ([#15182](https://github.com/hivecommons/hive/issues/15182)). diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 6e723bda2f..0065f99854 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -479,7 +479,7 @@ verified owner or an authorized user with the `merger` role: | Decision | What it does | Audit / ledger | |---|---|---| | `merge-now` — *Approve & merge as maintainer* | Comments on the PR that @you merged it from the dashboard, then merges it at once through the hive's GitHub App (`MergePRVia`, audit path `dashboard`). Refused when the PR is merged or closed, or when you are its author. | `repo_item_decision_merge`; `last_operator_action.action: merge-now`; toast *merged*. | -| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot). Because the fixer rebases with plain git, its unsigned head is signed first: when GitHub's timeline shows the App force-pushing that head over the approved one, the hive replaces it with one GitHub-signed merge commit authored by the App (first parent the approved head, so the contributor's commits stay theirs; second parent the base commit the fixer rebased onto; the fixer's resolved tree) and the next tick reads that head. A head the hive cannot sign (pushed by anyone else, or on a fork the App cannot write) stays unsigned and does not count: a head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | +| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot). A head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | | `queue-merge` — *Approve — let hive merge* | Leaves an `APPROVED` review in your name with a note, adds the automerge label, and leaves the merge to the App self-merge sweep, which merges on its next pass once CI is green and the head has soaked. Refused on your own PR. | `repo_item_decision_queue_merge`; `last_operator_action.action: queue-merge`; toast *queued for merge*. | **Approve is the trust override for that head diff --git a/src/pkg/dashboard/rebase_merge_followthrough.go b/src/pkg/dashboard/rebase_merge_followthrough.go index d68a7e2612..6ab4b4ce31 100644 --- a/src/pkg/dashboard/rebase_merge_followthrough.go +++ b/src/pkg/dashboard/rebase_merge_followthrough.go @@ -45,12 +45,6 @@ var rebaseAttemptsStore = func() *rebasemerge.Attempts { return rebasemerge.Shar // rebaseMergeNow is the clock (swapped in tests). var rebaseMergeNow = time.Now -// rebaseMergeSignFixerRebase seals the fixer's plain-git rebase of a -// contributor PR as a GitHub-signed commit (swapped in tests). -var rebaseMergeSignFixerRebase = func(ctx context.Context, gh *ghpkg.Client, repo string, number int, prevHead, head string) (string, error) { - return gh.SignFixerRebase(ctx, repo, number, prevHead, head) -} - // rebaseMergeFollowThroughLabel / Consequence are the option text the // decision menu shows instead of "Approve & merge as maintainer" when the // PR needs a rebase first. @@ -255,27 +249,6 @@ func (s *Server) driveRebaseMerge(ctx context.Context, store *rebasemerge.Store, } obs := rebasemerge.Observation{Now: now, Head: st.HeadSHA, State: st.State, Merged: st.Merged, MergeableState: st.MergeableState, CIRed: st.CIRed} if head := strings.TrimSpace(st.HeadSHA); head != "" && head != f.ApprovedHead && head != f.RebasedHead && !f.HiveAuthored && !st.Merged { - // The fixer rebases with plain git, so its head is unsigned and - // CommitByHive would not count it (hivecommons/hive#15182). Seal it - // as a GitHub-signed commit first; the next tick reads the signed - // head. A head the hive cannot sign falls through to the verdict - // below and fails closed. - prev := nonEmptyString(f.RebasedHead, f.ApprovedHead) - signed, err := rebaseMergeSignFixerRebase(ctx, gh, f.Repo, f.Number, prev, head) - switch { - case err == nil && signed != "": - if s.logger != nil { - s.logger.Info("rebase-then-merge: signed the fixer's rebase", "repo", f.Repo, "number", f.Number, "rebased_head", head, "signed_head", signed, "parent", prev) - } - return - case ghpkg.IsSignedHeadMoved(err): - if s.logger != nil { - s.logger.Info("rebase-then-merge: head moved while signing the fixer's rebase; waiting", "repo", f.Repo, "number", f.Number, "head", head, "error", err) - } - return - case err != nil && s.logger != nil: - s.logger.Warn("rebase-then-merge: cannot sign the fixer's rebase; the head counts only if GitHub says the hive committed it", "repo", f.Repo, "number", f.Number, "head", head, "from_fork", st.FromFork, "error", err) - } // The approval was bound to ApprovedHead. Before the new head can // count as "the rebase", make sure the hive produced it; a read // error leaves the decision to the next tick rather than guessing. diff --git a/src/pkg/dashboard/rebase_merge_followthrough_test.go b/src/pkg/dashboard/rebase_merge_followthrough_test.go index 2731e789fe..17fb013617 100644 --- a/src/pkg/dashboard/rebase_merge_followthrough_test.go +++ b/src/pkg/dashboard/rebase_merge_followthrough_test.go @@ -3,11 +3,9 @@ package dashboard import ( "context" "encoding/json" - "errors" "fmt" "net/http" "path/filepath" - "strconv" "strings" "testing" "time" @@ -371,65 +369,6 @@ func TestDriveRebaseMergeForeignHeadFailsClosed(t *testing.T) { } } -// The signing step (hivecommons/hive#15182): the fixer's plain-git rebase -// of a contributor PR is sealed as a GitHub-signed head before the -// follow-through judges it, so it does not settle as foreign-head; the next -// tick reads the signed head. A head the hive cannot sign still fails -// closed on CommitByHive's verdict. -func TestDriveRebaseMergeSignsFixerRebaseFirst(t *testing.T) { - const ( - approved = "feedfacefeedfacefeedfacefeedfacefeedface" - rebased = "0123456789abcdef0123456789abcdef01234567" - signed = "5190ed5190ed5190ed5190ed5190ed5190ed5190" - ) - cases := []struct { - name string - signErr error - signed string - wantState string - wantFail string - }{ - {name: "signed", signed: signed, wantState: rebasemerge.StateRebasing}, - {name: "cannot sign", signErr: errors.New("creating the signed commit in alice/r: 403"), wantState: rebasemerge.StateFailed, wantFail: rebasemerge.FailForeignHead}, - {name: "not a fixer rebase", wantState: rebasemerge.StateFailed, wantFail: rebasemerge.FailForeignHead}, - } - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - store := useRebaseMergeStore(t) - mock := &repoItemDecisionMock{prForeign: true} - srv := newRepoItemDecisionServer(t, mock) - srv.operatorActionStore = newOperatorActionStore(filepath.Join(t.TempDir(), "ops.json")) - now := time.Date(2026, 10, 29, 9, 0, 0, 0, time.UTC) - prevNow := rebaseMergeNow - rebaseMergeNow = func() time.Time { return now } - t.Cleanup(func() { rebaseMergeNow = prevNow }) - var calls []string - prevSign := rebaseMergeSignFixerRebase - rebaseMergeSignFixerRebase = func(_ context.Context, _ *ghpkg.Client, repo string, number int, prev, head string) (string, error) { - calls = append(calls, repo+"#"+strconv.Itoa(number)+" "+prev+"->"+head) - return tc.signed, tc.signErr - } - t.Cleanup(func() { rebaseMergeSignFixerRebase = prevSign }) - - f := rebasemerge.Arm("testorg/testrepo", 8, "writer", "main", approved, false, now) - f.Kicked(now, "fixer") - _ = store.Put(f) - now = now.Add(5 * time.Minute) - srv.driveRebaseMerge(context.Background(), store, f, ghpkg.PRMergeState{State: "open", HeadSHA: rebased, BaseRef: "main", MergeableState: "clean", FromFork: true, MaintainerCanModify: true}) - f, _ = store.Get("testorg/testrepo", 8) - if len(calls) != 1 || calls[0] != "testorg/testrepo#8 "+approved+"->"+rebased { - t.Fatalf("sign calls = %q", calls) - } - if f.State != tc.wantState || f.FailReason != tc.wantFail { - t.Fatalf("follow-through = %+v", f) - } - if len(mock.merges) != 0 { - t.Fatalf("nothing merges on the unsigned head: %v", mock.merges) - } - }) - } -} - // A maintainer-editable fork with workflow changes must not enter the fixer // queue, even when its author is the hive's App. Approval cannot grant push // permissions, and a fresh-branch adoption is fenced for these paths too. diff --git a/src/pkg/github/pr_fixer_rebase_signed.go b/src/pkg/github/pr_fixer_rebase_signed.go deleted file mode 100644 index 766fe2c054..0000000000 --- a/src/pkg/github/pr_fixer_rebase_signed.go +++ /dev/null @@ -1,212 +0,0 @@ -package github - -import ( - "context" - "errors" - "fmt" - "strings" - - gh "github.com/google/go-github/v72/github" -) - -// The signing step for the fixer's rebase of a contributor PR -// (hivecommons/hive#15182, follow-through of #15104). -// -// The rebase-then-merge follow-through counts a contributor PR's new head as -// the rebase only when CommitByHive says the hive committed it, and since -// #15182 an email-only pane-identity committer needs a GitHub-verified -// signature. The fixer rebases with plain git, so its head is unsigned by -// construction and would settle every such follow-through as foreign-head. -// -// SignFixerRebase seals that rebase as a GitHub-signed commit without -// re-authoring anybody. GitHub signs a commit the App creates through the -// REST API only when the request carries no custom author or committer, so -// the signed commit is the App's own: a merge commit whose first parent is -// the head the operator approved (the contributor's commits, byte for byte, -// with their own authorship and sign-offs) and whose second parent is the -// base commit the fixer rebased onto, carrying the fixer's resolved tree. -// The squash-attribution DCO check skips merge commits, and the PR diff -// (base...head) is the same as the fixer's rebase. -// -// Provenance comes from GitHub, never from the commit's own fields: the PR -// timeline must show the App bot force-pushing exactly this head over the -// approved one. A head a person pushed with the pane identity's address is -// refused, so the signing step cannot launder a forged committer into a -// verified one. - -// fixerRebaseForcePushWindow is how many recent force-push events are read. -const fixerRebaseForcePushWindow = 20 - -// errFixerRebaseNotSigned marks a candidate head the hive refused to sign -// (wrong pusher, unexpected history). It wraps errSignedCommitSkip. -var errFixerRebaseNotSigned = fmt.Errorf("%w: fixer rebase not signed", errSignedCommitSkip) - -// IsSignedHeadMoved reports whether err is the transient "head moved while -// the signed commit was being built" refusal; the caller retries next tick. -func IsSignedHeadMoved(err error) bool { - var moved signedHeadMovedError - return errors.As(err, &moved) -} - -type fixerRebaseForcePush struct { - Actor struct { - Typename string `json:"__typename"` - Login string `json:"login"` - } `json:"actor"` - BeforeCommit struct { - OID string `json:"oid"` - } `json:"beforeCommit"` - AfterCommit struct { - OID string `json:"oid"` - } `json:"afterCommit"` -} - -type fixerRebasePullRequest struct { - HeadRefName string `json:"headRefName"` - BaseRefName string `json:"baseRefName"` - HeadRepository struct { - NameWithOwner string `json:"nameWithOwner"` - } `json:"headRepository"` - TimelineItems struct { - Nodes []fixerRebaseForcePush `json:"nodes"` - } `json:"timelineItems"` -} - -type fixerRebasePR struct { - Repository struct { - PullRequest fixerRebasePullRequest `json:"pullRequest"` - } `json:"repository"` -} - -const fixerRebasePRQuery = `query($owner: String!, $name: String!, $number: Int!, $last: Int!) { - repository(owner: $owner, name: $name) { - pullRequest(number: $number) { - headRefName - baseRefName - headRepository { nameWithOwner } - timelineItems(last: $last, itemTypes: [HEAD_REF_FORCE_PUSHED_EVENT]) { - nodes { - ... on HeadRefForcePushedEvent { - actor { __typename login } - beforeCommit { oid } - afterCommit { oid } - } - } - } - } - } -}` - -// SignFixerRebase seals head — the fixer's plain-git rebase of PR number, -// replacing prevHead (the approved head, or the last head the follow-through -// accepted) — as one GitHub-signed merge commit on the PR's head branch and -// returns its sha. ("", nil) means head is not a fixer rebase (its committer -// is not an unverified, email-only pane identity): nothing was written and -// CommitByHive decides as before. An error means a candidate the hive could -// not sign — a push it cannot attribute to the App, or a head repository -// (a contributor's fork) the App cannot write — and nothing was written; the -// follow-through then fails closed on CommitByHive's verdict. -func (c *Client) SignFixerRebase(ctx context.Context, repo string, number int, prevHead, head string) (string, error) { - if c == nil || c.client == nil { - return "", ErrNoGitHubClient - } - prevHead, head = strings.TrimSpace(prevHead), strings.TrimSpace(head) - if head == "" || prevHead == "" || head == prevHead { - return "", nil - } - owner, repoName := c.splitRepo(repo) - ctx = WithRESTCaller(ctx, "hive:rebase_merge_sign") - rc, _, err := c.client.Repositories.GetCommit(ctx, owner, repoName, head, nil) - if err != nil { - return "", fmt.Errorf("reading %s/%s@%s: %w", owner, repoName, shortSHA(head), err) - } - committerLogin := safeGetLogin(rc.GetCommitter()) - if committerLogin != "" || rc.GetCommit().GetVerification().GetVerified() || !c.hiveCommitIdentity("", rc.GetCommit().GetCommitter().GetEmail()) { - return "", nil - } - tree := rc.GetCommit().GetTree().GetSHA() - if tree == "" { - return "", fmt.Errorf("reading %s/%s@%s: no tree", owner, repoName, shortSHA(head)) - } - - var pr fixerRebasePR - if err := c.graphQL(ctx, fixerRebasePRQuery, map[string]any{"owner": owner, "name": repoName, "number": number, "last": fixerRebaseForcePushWindow}, &pr); err != nil { - return "", fmt.Errorf("reading %s/%s#%d force-pushes: %w", owner, repoName, number, err) - } - p := pr.Repository.PullRequest - if !c.fixerRebasePushedByHive(p, prevHead, head) { - return "", fmt.Errorf("%w: GitHub shows no force-push of %s over %s by the App on %s/%s#%d", errFixerRebaseNotSigned, shortSHA(head), shortSHA(prevHead), owner, repoName, number) - } - headRef := strings.TrimSpace(p.HeadRefName) - headOwner, headName, ok := strings.Cut(strings.TrimSpace(p.HeadRepository.NameWithOwner), "/") - if headRef == "" || !ok || headOwner == "" || headName == "" { - return "", fmt.Errorf("%w: %s/%s#%d has no readable head branch", errFixerRebaseNotSigned, owner, repoName, number) - } - - cmp, _, err := c.client.Repositories.CompareCommits(ctx, owner, repoName, p.BaseRefName, head, &gh.ListOptions{PerPage: 1}) - if err != nil { - return "", fmt.Errorf("comparing %s...%s: %w", p.BaseRefName, shortSHA(head), err) - } - onto := cmp.GetMergeBaseCommit().GetSHA() - if onto == "" || onto == prevHead { - return "", fmt.Errorf("%w: no base commit under %s to merge", errFixerRebaseNotSigned, shortSHA(head)) - } - - ref, _, err := c.client.Git.GetRef(ctx, headOwner, headName, "heads/"+headRef) - if err != nil { - return "", fmt.Errorf("reading %s:%s: %w", headOwner+"/"+headName, headRef, err) - } - if got := ref.GetObject().GetSHA(); got != head { - return "", signedHeadMovedError{fmt.Errorf("%w: %s moved from %s to %s before the fixer's rebase was signed", errSignedCommitSkip, headRef, shortSHA(head), shortSHA(got))} - } - // No Author / Committer: GitHub signs only an App commit without them. - signed, _, err := c.client.Git.CreateCommit(ctx, headOwner, headName, &gh.Commit{ - Message: gh.Ptr(fixerRebaseSignedMessage(p.BaseRefName, headRef, number, prevHead, head, c.appBotLogin)), - Tree: &gh.Tree{SHA: gh.Ptr(tree)}, - Parents: []*gh.Commit{{SHA: gh.Ptr(prevHead)}, {SHA: gh.Ptr(onto)}}, - }, nil) - if err != nil { - return "", fmt.Errorf("creating the signed commit in %s: %w", headOwner+"/"+headName, err) - } - if signed.GetSHA() == "" { - return "", fmt.Errorf("creating the signed commit in %s: no sha returned", headOwner+"/"+headName) - } - if _, _, err := c.client.Git.UpdateRef(ctx, headOwner, headName, &gh.Reference{ - Ref: gh.Ptr("refs/heads/" + headRef), - Object: &gh.GitObject{SHA: gh.Ptr(signed.GetSHA())}, - }, true); err != nil { - return "", fmt.Errorf("updating %s:%s to signed commit %s: %w", headOwner+"/"+headName, headRef, shortSHA(signed.GetSHA()), err) - } - return signed.GetSHA(), nil -} - -// fixerRebasePushedByHive: the newest force-push to head replaced prevHead -// and was made by the App bot. GraphQL reports a Bot's login without the -// "[bot]" suffix REST uses, so both spellings match. -func (c *Client) fixerRebasePushedByHive(p fixerRebasePullRequest, prevHead, head string) bool { - bot := strings.TrimSpace(c.appBotLogin) - if bot == "" { - return false - } - nodes := p.TimelineItems.Nodes - for i := len(nodes) - 1; i >= 0; i-- { - n := nodes[i] - if n.AfterCommit.OID != head { - continue - } - login := strings.TrimSpace(n.Actor.Login) - byBot := strings.EqualFold(login, bot) || (n.Actor.Typename == "Bot" && strings.EqualFold(login+"[bot]", bot)) - return byBot && n.BeforeCommit.OID == prevHead - } - return false -} - -func fixerRebaseSignedMessage(base, headRef string, number int, prevHead, head, bot string) string { - var b strings.Builder - fmt.Fprintf(&b, "Merge %s into %s\n\n", base, headRef) - fmt.Fprintf(&b, "The hive's rebase of #%d onto %s (%s), signed by GitHub as a merge on top of the approved head %s so the contributor's commits stay theirs.", number, base, shortSHA(head), shortSHA(prevHead)) - if bot = strings.TrimSpace(bot); bot != "" { - b.WriteString("\n\n" + BotSignedOffByTrailer(bot)) - } - return b.String() -} diff --git a/src/pkg/github/pr_fixer_rebase_signed_test.go b/src/pkg/github/pr_fixer_rebase_signed_test.go deleted file mode 100644 index 718997fa91..0000000000 --- a/src/pkg/github/pr_fixer_rebase_signed_test.go +++ /dev/null @@ -1,176 +0,0 @@ -package github - -import ( - "context" - "encoding/json" - "net/http" - "net/http/httptest" - "strings" - "sync" - "testing" -) - -// The signing step for the fixer's rebase of a contributor PR -// (hivecommons/hive#15182): an unverified, email-only pane-identity head the -// App force-pushed over the approved head is sealed as one GitHub-signed -// merge commit (approved head + the base it was rebased onto, the fixer's -// tree, no custom author or committer so GitHub signs it); anything else is -// left alone or refused without a write. -func TestSignFixerRebase(t *testing.T) { - t.Setenv(signedTrailerDomainEnv, "") - const ( - approved = "aaaa000000000000000000000000000000000001" - rebased = "bbbb000000000000000000000000000000000002" - onto = "cccc000000000000000000000000000000000003" - tree = "dddd000000000000000000000000000000000004" - signed = "eeee000000000000000000000000000000000005" - other = "ffff000000000000000000000000000000000006" - ) - type push struct{ typename, login, before, after string } - appPush := push{"Bot", "hive-app", approved, rebased} - cases := []struct { - name string - committerLogin string - committerEmail string - verified bool - headRepo string - pushes []push - refSHA string - createStatus int - want string - wantErr bool - wantMoved bool - wantGraphQL bool - wantWrites bool - }{ - {name: "fixer rebase, App force-push over the approved head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{appPush}, want: signed, wantGraphQL: true, wantWrites: true}, - {name: "REST bot login spelling", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"Bot", reconcileBot, approved, rebased}}, want: signed, wantGraphQL: true, wantWrites: true}, - {name: "fork head the App can write", committerEmail: "fixer@hive.kubestellar.io", headRepo: "alice/r", pushes: []push{appPush}, want: signed, wantGraphQL: true, wantWrites: true}, - {name: "fork head the App cannot write", committerEmail: "fixer@hive.kubestellar.io", headRepo: "alice/r", pushes: []push{appPush}, createStatus: http.StatusForbidden, wantErr: true, wantGraphQL: true}, - {name: "committer resolves to a login", committerLogin: "alice", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{appPush}}, - {name: "already verified", committerEmail: "fixer@hive.kubestellar.io", verified: true, headRepo: "o/r", pushes: []push{appPush}}, - {name: "committer outside the pane domain", committerEmail: "alice@example.com", headRepo: "o/r", pushes: []push{appPush}}, - {name: "a person force-pushed the pane-identity head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"User", "alice", approved, rebased}}, wantErr: true, wantGraphQL: true}, - {name: "App force-push over another head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"Bot", "hive-app", other, rebased}}, wantErr: true, wantGraphQL: true}, - {name: "no force-push of this head", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{{"Bot", "hive-app", approved, other}}, wantErr: true, wantGraphQL: true}, - {name: "head moved before signing", committerEmail: "fixer@hive.kubestellar.io", headRepo: "o/r", pushes: []push{appPush}, refSHA: other, wantErr: true, wantMoved: true, wantGraphQL: true}, - } - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - var ( - mu sync.Mutex - graphQLs int - created map[string]any - updated map[string]any - writePath []string - ) - headPrefix := "/repos/" + tc.headRepo + "/git/" - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - mu.Lock() - defer mu.Unlock() - w.Header().Set("Content-Type", "application/json") - switch { - case r.Method == http.MethodGet && r.URL.Path == "/repos/o/r/commits/"+rebased: - commit := map[string]any{ - "author": map[string]any{"name": "alice", "email": "alice@example.com"}, - "committer": map[string]any{"name": "fixer", "email": tc.committerEmail}, - "message": "feat: alice's change", - "tree": map[string]any{"sha": tree}, - "verification": map[string]any{"verified": tc.verified}, - } - body := map[string]any{"sha": rebased, "commit": commit, "author": map[string]any{"login": "alice"}} - if tc.committerLogin != "" { - body["committer"] = map[string]any{"login": tc.committerLogin} - } - _ = json.NewEncoder(w).Encode(body) - case r.Method == http.MethodPost && r.URL.Path == "/graphql": - graphQLs++ - nodes := make([]map[string]any, 0, len(tc.pushes)) - for _, p := range tc.pushes { - nodes = append(nodes, map[string]any{"actor": map[string]any{"__typename": p.typename, "login": p.login}, "beforeCommit": map[string]any{"oid": p.before}, "afterCommit": map[string]any{"oid": p.after}}) - } - _ = json.NewEncoder(w).Encode(map[string]any{"data": map[string]any{"repository": map[string]any{"pullRequest": map[string]any{ - "headRefName": "feature", "baseRefName": "main", - "headRepository": map[string]any{"nameWithOwner": tc.headRepo}, - "timelineItems": map[string]any{"nodes": nodes}, - }}}}) - case r.Method == http.MethodGet && r.URL.Path == "/repos/o/r/compare/main..."+rebased: - _ = json.NewEncoder(w).Encode(map[string]any{"merge_base_commit": map[string]any{"sha": onto}}) - case r.Method == http.MethodGet && r.URL.Path == headPrefix+"ref/heads/feature": - sha := rebased - if tc.refSHA != "" { - sha = tc.refSHA - } - _ = json.NewEncoder(w).Encode(map[string]any{"ref": "refs/heads/feature", "object": map[string]any{"sha": sha}}) - case r.Method == http.MethodPost && r.URL.Path == headPrefix+"commits": - writePath = append(writePath, r.URL.Path) - if tc.createStatus != 0 { - w.WriteHeader(tc.createStatus) - _, _ = w.Write([]byte(`{"message":"Resource not accessible by integration"}`)) - return - } - _ = json.NewDecoder(r.Body).Decode(&created) - _ = json.NewEncoder(w).Encode(map[string]any{"sha": signed}) - case r.Method == http.MethodPatch && r.URL.Path == headPrefix+"refs/heads/feature": - writePath = append(writePath, r.URL.Path) - _ = json.NewDecoder(r.Body).Decode(&updated) - _ = json.NewEncoder(w).Encode(map[string]any{"ref": "refs/heads/feature", "object": map[string]any{"sha": signed}}) - default: - t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path) - http.NotFound(w, r) - } - })) - defer server.Close() - c := NewClientForTest(server.URL, "o", []string{"r"}, nil) - c.SetAppBotLogin(reconcileBot) - - got, err := c.SignFixerRebase(context.Background(), "o/r", 8, approved, rebased) - if (err != nil) != tc.wantErr { - t.Fatalf("SignFixerRebase err = %v, wantErr %v", err, tc.wantErr) - } - if IsSignedHeadMoved(err) != tc.wantMoved { - t.Fatalf("IsSignedHeadMoved(%v) = %v, want %v", err, !tc.wantMoved, tc.wantMoved) - } - if got != tc.want { - t.Fatalf("SignFixerRebase = %q, want %q", got, tc.want) - } - mu.Lock() - defer mu.Unlock() - if (graphQLs > 0) != tc.wantGraphQL { - t.Fatalf("graphql calls = %d, want any: %v", graphQLs, tc.wantGraphQL) - } - if !tc.wantWrites { - if updated != nil { - t.Fatalf("a refused head must not move the branch: %v", updated) - } - if tc.createStatus == 0 && len(writePath) != 0 { - t.Fatalf("a refused head must not write: %v", writePath) - } - return - } - if created == nil || updated == nil { - t.Fatalf("writes: created=%v updated=%v", created, updated) - } - if _, ok := created["author"]; ok { - t.Fatalf("a custom author stops GitHub signing the commit: %v", created) - } - if _, ok := created["committer"]; ok { - t.Fatalf("a custom committer stops GitHub signing the commit: %v", created) - } - parents, _ := created["parents"].([]any) - if len(parents) != 2 || parents[0] != approved || parents[1] != onto { - t.Fatalf("parents = %v, want [approved head, rebase base]", created["parents"]) - } - if created["tree"] != tree { - t.Fatalf("tree = %v, want the fixer's tree %s", created["tree"], tree) - } - msg, _ := created["message"].(string) - if !strings.HasPrefix(msg, "Merge main into feature\n") || !strings.Contains(msg, BotSignedOffByTrailer(reconcileBot)) { - t.Fatalf("message = %q", msg) - } - if updated["sha"] != signed || updated["force"] != true { - t.Fatalf("ref update = %v", updated) - } - }) - } -} diff --git a/src/pkg/github/pr_merge_state.go b/src/pkg/github/pr_merge_state.go index ce33c00110..57e7e8251c 100644 --- a/src/pkg/github/pr_merge_state.go +++ b/src/pkg/github/pr_merge_state.go @@ -117,9 +117,7 @@ func (c *Client) GetPRMergeState(ctx context.Context, repo string, number int) ( // email-only match also requires the commit's signature to be verified by // GitHub, which binds the signing key to the committer address only // (hivecommons/hive#15182); the author is free text GitHub never vouches -// for, so no email-only author match counts. The fixer's plain-git rebase of -// a contributor PR is therefore sealed by SignFixerRebase first, as an App -// commit GitHub signs, before this verdict reads it. A head a person pushed +// for, so no email-only author match counts. A head a person pushed // after a rebase-then-merge approval is new content the approval never // covered, so the follow-through fails closed on it (hivecommons/hive#15104). func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) { From 393a1203c5ef5981790493de11b63aafbcf4d07f Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 02:37:51 -0400 Subject: [PATCH 5/5] docs: state the fixer-rebase prerequisite for the verified email-only match The operator-reference rebase-then-merge row and the CommitByHive doc comment still described the fixer's rebase as a head that counts. With the verified requirement it does not: the push broker sets commit.gpgsign=false and the signed reconciler only walks App-authored PRs, so a fixer rebase of a contributor PR settles foreign-head unless the fixer host signs its pushes. Say so, and name the way out. Hive-Fix-Attempt: 6/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/docs/operator-reference.md | 2 +- src/pkg/github/pr_merge_state.go | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 02df1c28cd..88ae7351d3 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -479,7 +479,7 @@ verified owner or an authorized user with the `merger` role: | Decision | What it does | Audit / ledger | |---|---|---| | `merge-now` — *Merge now as maintainer* (secondary; *Approve and let hive merge* leads) | Comments on the PR that @you merged it from the dashboard, then merges it at once through the hive's GitHub App (`MergePRVia`, audit path `dashboard`). Refused when the PR is merged or closed, or when you are its author. | `repo_item_decision_merge`; `last_operator_action.action: merge-now`; toast *merged*. | -| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it (the fixer's rebase or update-branch under the App; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as verified, and the author counts only when GitHub resolves it to the App bot). A head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | +| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it — update-branch under the App (author resolved to the App bot) or a committer GitHub resolves to the App bot; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as *verified*, and the author counts only when GitHub resolves it to the App bot ([#15182](https://github.com/hivecommons/hive/issues/15182)). **Operational prerequisite:** the fixer's own rebase of a contributor PR is a plain unsigned git commit (the push broker sets `commit.gpgsign=false`, and the signed-commit reconciler only re-signs PRs the App bot authored), so on a `dirty` contributor PR the follow-through settles `failed` (`foreign-head`) unless the fixer host signs its pushes with a key GitHub verifies against a pane-domain address; *Approve the new head & merge* on the fixer's head is the way out until then. A head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | | `queue-merge` — *Approve and let hive merge* (lead) | Admits the head (`admitted_by: operator-approval:`), leaves an `APPROVED` review in your name with a note, adds the automerge label, and leaves the merge to the hive's auto-merge sweep, which merges through its own App on the next tick once CI is green and the head has soaked. On an untrusted author's PR that admission is the one thing that lets the trusted-author lane merge it: the lane's `untrusted-author-role` skip yields to the recorded approval for that exact head, and the merge comment names you (*merged by Hive on behalf of @you …*). Refused on your own PR. | `repo_item_decision_queue_merge`; `last_operator_action.action: queue-merge`; toast *approved — hive will merge on the next tick once CI is green*. | **Approve is the trust override for that head diff --git a/src/pkg/github/pr_merge_state.go b/src/pkg/github/pr_merge_state.go index 57e7e8251c..08d3b5fcab 100644 --- a/src/pkg/github/pr_merge_state.go +++ b/src/pkg/github/pr_merge_state.go @@ -111,15 +111,20 @@ func (c *Client) GetPRMergeState(ctx context.Context, repo string, number int) ( // CommitByHive reports whether the commit at sha is the hive's own work: // its committer resolves to the App bot (by login or noreply address) or to -// an address in the pane identity domain — the fixer's rebase — or its -// author resolves by login to the App bot, as on GitHub's update-branch -// under the App. When GitHub resolves no login for the committer, the -// email-only match also requires the commit's signature to be verified by -// GitHub, which binds the signing key to the committer address only -// (hivecommons/hive#15182); the author is free text GitHub never vouches -// for, so no email-only author match counts. A head a person pushed -// after a rebase-then-merge approval is new content the approval never -// covered, so the follow-through fails closed on it (hivecommons/hive#15104). +// an address in the pane identity domain, or its author resolves by login +// to the App bot, as on GitHub's update-branch under the App. When GitHub +// resolves no login for the committer, the email-only match also requires +// the commit's signature to be verified by GitHub, which binds the signing +// key to the committer address only (hivecommons/hive#15182); the author is +// free text GitHub never vouches for, so no email-only author match counts. +// The fixer's plain-git rebase of a contributor PR is an unsigned, +// email-only pane committer (the push broker sets commit.gpgsign=false and +// the signed reconcile pass only walks App-authored PRs), so it does not +// count unless the fixer host signs its pushes — the follow-through then +// settles foreign-head rather than trusting a spoofable address. A head a +// person pushed after a rebase-then-merge approval is new content the +// approval never covered, so the follow-through fails closed on it +// (hivecommons/hive#15104). func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) { if c == nil || c.client == nil { return false, ErrNoGitHubClient