Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-agent-no-own-commits-on-person-prs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Hive agents no longer push their own commits to a person's PR. Fix kicks for a red or conflicting PR whose author is a person (the FIX-BEFORE-NEW block, the trusted-author rebase and the merge-request re-engagement kick) now say that a commit the agent authors, or its `Signed-off-by` on the person's commit, fails "Sign-off survives the squash", and that any change beyond the rebase goes in a PR comment for the author instead (#19110, #19102, #19063). The review-fix prompt no longer tells agents to run `git rebase --signoff` over the whole branch; it names the `--exec` that signs off only the agent's own commits.
5 changes: 5 additions & 0 deletions src/cmd/hive/adopted_pr_fixer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func TestWriteMergeEligible_TrustedAuthorConflictGetsRebaseKickWithLoopGuard(t *
if !row.Conflict || !row.TrustedAuthor || row.ReachableAction != github.ReachableActionPush || row.Agent != "scanner" {
t.Errorf("row = %+v, want a trusted-author push conflict row owned by the fallback fixer", row)
}
// hivecommons/hive#19102, #19063: the squash lands this PR under the
// person, so the row must tell the fixer it is a person's PR.
if !row.PersonAuthored {
t.Errorf("row = %+v, want person_authored on a trusted author's PR", row)
}
if row.RebaseAttempt != 1 || row.RebaseAttemptsMax != rebasemerge.MaxRebaseAttempts || row.BaseRef != "v5" {
t.Errorf("row = %+v, want attempt 1/%d onto v5", row, rebasemerge.MaxRebaseAttempts)
}
Expand Down
13 changes: 7 additions & 6 deletions src/cmd/hive/main_sweeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,9 @@ func resolveRedPRFixer(cfg *config.Config, owner string, available func(string)
}

// redPRFixOwnSignoffExec is the `git rebase --exec` step the no-dco repair
// advice names: it amends with --signoff only a commit whose author email is
// the agent's own (git var GIT_AUTHOR_IDENT honours the lane's pinned
// GIT_AUTHOR_* env), so a person's commit on the PR keeps exactly the
// trailers its author wrote. A blanket `git rebase --signoff` appended the
// agent's bot sign-off to a human's commit on hivecommons/hive#19102.
const redPRFixOwnSignoffExec = `'case "$(git var GIT_AUTHOR_IDENT)" in *"<$(git log -1 --format=%ae)>"*) git commit --amend --no-edit --signoff;; esac'`
// advice names (stagelabels.OwnSignoffRebaseExec): it signs off only the
// agent's own commits, never a person's (hivecommons/hive#19102).
const redPRFixOwnSignoffExec = stagelabels.OwnSignoffRebaseExec

// redPRFixKick renders the targeted FIX-BEFORE-NEW kick a re-engagement
// delivers. It names ONE PR — the stuck one — with its evidence, so the kick is
Expand All @@ -360,6 +357,10 @@ func redPRFixKick(o escalation.Observation, rerouted bool) string {
b.WriteString(" THEN fix any failing CI the same way.\n")
}
fmt.Fprintf(&b, " gh pr checkout %d --repo %s → fix → git commit -s → git push\n", o.Number, o.Repo)
// The merge-request re-engagement path reaches this kick for a person's
// PR too (hivecommons/hive#19110: a coverage fix pushed as the lane
// failed the squash sign-off check), and the hook knows no author.
b.WriteString(" If the PR's author is a person, not the hive App or a bot: " + stagelabels.PersonPRAgentCommitRule + "\n")
b.WriteString("Push to the SAME branch. Do NOT open a replacement PR.\n")
b.WriteString("After the push, STOP: do not watch, poll, or sleep on CI (no gh run watch/view loops).\n")
b.WriteString("The automerge sweep merges the PR once it is green; if the failure is infrastructure\n")
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,12 @@ func writeMergeEligible(actionable *github.ActionableResult, hold github.HoldRes
RebaseAttemptsMax int `json:"rebase_attempts_max,omitempty"`
BaseRef string `json:"base_ref,omitempty"`
TrustedAuthor bool `json:"trusted_author,omitempty"`
// PersonAuthored marks a PR whose GitHub author is a person: not
// hive-authored, not adopted, not a bot account. The squash lands
// every commit under that person, so the kick tells the fixer not
// to push its own commits there (hivecommons/hive#19110, #19102,
// #19063; the attribution check counts no Co-authored-by).
PersonAuthored bool `json:"person_authored,omitempty"`
// DeferredIncident is the open [shared-ci] incident issue this red
// PR was already deferred to (github.PullRequest.SharedCIIncident,
// hivecommons/hive#10528); only red PRs carry one. It applies to a
Expand Down Expand Up @@ -1280,6 +1286,7 @@ func writeMergeEligible(actionable *github.ActionableResult, hold github.HoldRes
BaseRedChecks: pr.BaseRedChecks,
BaseRed: pr.AllFailuresBaseRed(),
AppAuthored: scheduler.PRAppAuthored(pr),
PersonAuthored: !adopted && !hiveAuthoredPR(pr) && !pr.AuthorNonHuman,
HeadPushedAt: scheduler.PRHeadPushedAt(pr),
Issues: scheduler.PRIssueNumbers(pr),
}
Expand Down
23 changes: 23 additions & 0 deletions src/cmd/hive/merge_eligible_buckets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type failingEntry struct {
RebaseAttemptsMax int `json:"rebase_attempts_max"`
BaseRef string `json:"base_ref"`
TrustedAuthor bool `json:"trusted_author"`
PersonAuthored bool `json:"person_authored"`
}

type mergeEligibleInputs struct {
Expand Down Expand Up @@ -620,3 +621,25 @@ func TestWriteMergeEligible_EscalatedNonFailingPRsListedForReviewerLane(t *testi
t.Errorf("escalated row mergeable=%q ci_status=%q, want no/success", got.Mergeable, got.CIStatus)
}
}

// hivecommons/hive#19110: a person's red PR reaches ci-failing.json and its
// kick sent the fixer to push a coverage fix of its own, which the squash
// lands under the person with the lane's sign-off. Only a person's PR is
// marked person_authored: not the App's, not a bot account's.
func TestWriteMergeEligible_FailingRowMarksPersonAuthored(t *testing.T) {
prs := []github.PullRequest{
{Repo: "hive", Number: 19110, Author: "clubanderson", CIStatus: "failure", HeadSHA: "a", FailingChecks: []string{"coverage"}},
{Repo: "hive", Number: 19111, Author: "app/hivecommons-hive", CIStatus: "failure", HeadSHA: "b", FailingChecks: []string{"coverage"}, AppAuthored: true},
{Repo: "hive", Number: 19112, Author: "some-bot", CIStatus: "failure", HeadSHA: "c", FailingChecks: []string{"coverage"}, AuthorNonHuman: true},
}
_, failing := runWriteMergeEligible(t, prs, mergeEligibleInputs{org: "hivecommons"})
want := map[int]bool{19110: true, 19111: false, 19112: false}
if len(failing) != len(want) {
t.Fatalf("failing=%+v, want %d rows", failing, len(want))
}
for _, f := range failing {
if f.PersonAuthored != want[f.Number] {
t.Errorf("#%d person_authored = %v, want %v", f.Number, f.PersonAuthored, want[f.Number])
}
}
}
17 changes: 17 additions & 0 deletions src/cmd/hive/redpr_fix_kick_no_ci_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/hivecommons/hive/pkg/escalation"
"github.com/hivecommons/hive/pkg/stagelabels"
)

// The targeted FIX-BEFORE-NEW re-engagement kick carries no policy template,
Expand Down Expand Up @@ -62,3 +63,19 @@ func TestRedPRFixKickSignsOffOnlyOwnCommits(t *testing.T) {
}
}
}

// hivecommons/hive#19110: the merge-request re-engagement kick reached a
// person's red PR and the lane pushed its own coverage fix, which the squash
// would land under the person's name with the lane's sign-off. The kick
// carries the person's-PR rule whatever the labels say.
func TestRedPRFixKickCarriesPersonPRRule(t *testing.T) {
for _, o := range []escalation.Observation{
{Repo: "hivecommons/hive", Number: 19110},
{Repo: "hivecommons/hive", Number: 19110, Labels: []string{"no-dco"}},
} {
got := redPRFixKick(o, false)
if !strings.Contains(got, "author is a person") || !strings.Contains(got, stagelabels.PersonPRAgentCommitRule) {
t.Errorf("kick for %v lacks the person's-PR rule:\n%s", o.Labels, got)
}
}
}
17 changes: 17 additions & 0 deletions src/docs/labels-and-control-signals/stage-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,23 @@ sandbox push broker enforces the same rule: it refuses to push a commit that
carries the lane's `Signed-off-by` when another identity authored or committed
it (see [Sandbox isolation](../sandbox-isolation.md)).

On a **person's PR** (GitHub author not the hive App and not a bot) an agent
pushes no commit of its own and never re-signs the person's commits, unless the
PR carries `merge-method/merge`. The squash lands every commit under the PR
author, and the attribution check counts no `Co-authored-by`, so an agent's
self-signed follow-up (a test fix or refreshed citations after a rebase, a
coverage fix) fails it just like a re-signed commit
([#19110](https://github.com/hivecommons/hive/pull/19110),
[#19102](https://github.com/hivecommons/hive/pull/19102),
[#19063](https://github.com/hivecommons/hive/pull/19063)). The agent may
rebase such a PR (replaying the person's commits with their own trailers);
any other change goes in a PR comment for the author. Every kick that sends an
agent to such a branch carries this rule (`stagelabels.PersonPRAgentCommitRule`):
the FIX-BEFORE-NEW block marks the row `person_authored`, and the targeted
re-engagement kick states it for any author. The rule is prompt-level for
agents that push outside the sandbox push broker, which only sees sandboxed
kicks.

The labels are written on every managed repo; the **072 routing is per
repo**. It applies only where the repo actually enforces DCO — detected when
a `dco` / `DCO` context is in the branch's required checks or reported on
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/github/automerge/automerge_signoff_attribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func signoffAttributionCore(n ContributorNudge, stage stagelabels.Stage) string
b.WriteString(SignoffAttributionMarker)
b.WriteString("\n")
fmt.Fprintf(&b, "@%s this PR is back in your court (`%s`). ", n.Author, stage.Label())
b.WriteString("Its commits are signed off as the hive App rather than as you, so a squash merge would misattribute them and the sign-off attribution check stays red. No hive agent can rewrite a contributor's commits — the fix is yours:\n\n")
b.WriteString("Some of its commits are signed off by a hive agent, not by you (an agent wrote them or re-signed them), so a squash merge would land them under your name with the agent's sign-off and the sign-off attribution check stays red. No hive agent rewrites a contributor's commits, so the fix is yours:\n\n")
for _, a := range n.ReviewAsks {
fmt.Fprintf(&b, "- %s\n", a)
}
Expand All @@ -64,7 +64,7 @@ func signoffAttributionChange(headSHA string, hiveSigned int) string {
if hiveSigned == 1 {
plural = ""
}
return fmt.Sprintf("head `%s`, %d commit%s signed off as the hive App", shortSHA(headSHA), hiveSigned, plural)
return fmt.Sprintf("head `%s`, %d commit%s signed off by a hive agent", shortSHA(headSHA), hiveSigned, plural)
}

// nudgeSignoffAttribution tells a non-clanker author once per PR that the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ func TestSignoffAttributionRewrite(t *testing.T) {
{name: "same head and asks leave the note alone", previous: first, head: "eb40422ae63967eb7363a3f866e73121c58f2c1b", hiveSigned: 8},
{
name: "new head rewrites and records one line", previous: first, head: "2940830726b72f08dff5a1ef6a37bff871b4a7d5", hiveSigned: 20,
wantChanged: true, wantLines: 1, wantLast: "updated 2026-11-04 12:04 UTC: head `2940830726b7`, 20 commits signed off as the hive App",
wantChanged: true, wantLines: 1, wantLast: "updated 2026-11-04 12:04 UTC: head `2940830726b7`, 20 commits signed off by a hive agent",
},
{
name: "legacy per-head note is adopted under the stable marker", previous: legacy, head: "2940830726b72f08dff5a1ef6a37bff871b4a7d5", hiveSigned: 1,
wantChanged: true, wantLines: 1, wantLast: "updated 2026-11-04 12:04 UTC: head `2940830726b7`, 1 commit signed off as the hive App",
wantChanged: true, wantLines: 1, wantLast: "updated 2026-11-04 12:04 UTC: head `2940830726b7`, 1 commit signed off by a hive agent",
},
{
name: "history stays capped at five", previous: fiveDeep, head: "dc8ccef2b084b5860f317dacc5037071d78bc1b6", hiveSigned: 30,
wantChanged: true, wantLines: markerHistoryCap, wantLast: "updated 2026-11-04 12:04 UTC: head `dc8ccef2b084`, 30 commits signed off as the hive App",
wantChanged: true, wantLines: markerHistoryCap, wantLast: "updated 2026-11-04 12:04 UTC: head `dc8ccef2b084`, 30 commits signed off by a hive agent",
},
} {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestApplyStageLabelsSignoffAttributionUpsertsAcrossHeads(t *testing.T) {
if !strings.HasPrefix(last, SignoffAttributionMarker+"\n") || !strings.Contains(last, "Current head: `"+head+"`.") {
t.Fatalf("head %s: edit not the upserted note:\n%s", head, last)
}
if _, hist := splitMarkerHistory(last); len(hist) != i+1 || !strings.Contains(hist[i], "head `"+head+"`, 1 commit signed off as the hive App") {
if _, hist := splitMarkerHistory(last); len(hist) != i+1 || !strings.Contains(hist[i], "head `"+head+"`, 1 commit signed off by a hive agent") {
t.Fatalf("head %s: history %q", head, hist)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/automerge_stage_dco.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,6 @@ func signoffAttributionAsk(d stageDetail) string {
if n == 1 {
plural, pronoun = " is", "it"
}
return fmt.Sprintf("%d commit%s signed off as the hive App instead of you, so a squash merge would misattribute %s — set `git config user.email` to your own address, then run `%s`",
return fmt.Sprintf("%d commit%s signed off by a hive agent, not by you, so a squash merge would misattribute %s: set `git config user.email` to your own address, then run `%s`",
n, plural, pronoun, signoffResetCommand(max(d.DCOTotal, n)))
}
4 changes: 2 additions & 2 deletions src/pkg/github/automerge/automerge_stage_labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2276,11 +2276,11 @@ func TestApplyStageLabelsHiveBotSignoffOnHumanHeadNeedsAuthorWithInstructions(t

func TestSignoffAttributionAsk(t *testing.T) {
one := signoffAttributionAsk(stageDetail{DCOTotal: 1, DCOSquashUnsafeHive: 1})
if !strings.Contains(one, "1 commit is signed off as the hive App") || !strings.Contains(one, "`git commit --amend --reset-author -s && git push --force-with-lease`") {
if !strings.Contains(one, "1 commit is signed off by a hive agent") || !strings.Contains(one, "`git commit --amend --reset-author -s && git push --force-with-lease`") {
t.Fatalf("one: %s", one)
}
many := signoffAttributionAsk(stageDetail{DCOTotal: 3, DCOSquashUnsafeHive: 2})
if !strings.Contains(many, "2 commits are signed off as the hive App") || !strings.Contains(many, "git rebase --exec 'git commit --amend --no-edit --reset-author -s' HEAD~3 && git push --force-with-lease") {
if !strings.Contains(many, "2 commits are signed off by a hive agent") || !strings.Contains(many, "git rebase --exec 'git commit --amend --no-edit --reset-author -s' HEAD~3 && git push --force-with-lease") {
t.Fatalf("many: %s", many)
}
if zero := signoffAttributionAsk(stageDetail{}); !strings.Contains(zero, "1 commit is") {
Expand Down
5 changes: 4 additions & 1 deletion src/pkg/review/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,10 @@ func BuildFixPrompt(pr PullRequest, agg Aggregate, attempt, maxAttempts int) str
}
fmt.Fprintf(&b, "Auto-fix attempt %d of %d. Stay narrowly scoped to the review findings below; push a new commit to the PR branch.\n\n", attempt, maxAttempts)
fmt.Fprintf(&b, "When committing the fix, include this exact git trailer so rework metrics can count the attempt: Hive-Fix-Attempt: %d/%d\n\n", attempt, maxAttempts)
b.WriteString("REQUIRED: every follow-up commit MUST carry a Signed-off-by trailer — create it with `git commit -s`, and run `git rebase --signoff` before pushing if any new commit lacks one. An unsigned fix commit bounces the PR to no-dco.\n\n")
// Sign only the agent's own commits: a blanket `git rebase --signoff`
// re-signs every commit in the range, a contributor's too
// (hivecommons/hive#19267 and its follow-up audit).
b.WriteString("REQUIRED: every follow-up commit MUST carry a Signed-off-by trailer: create it with `git commit -s`, and if a commit you authored lacks one, sign off ONLY your own commits before pushing: `git rebase <base> --exec " + stagelabels.OwnSignoffRebaseExec + "`. Never add your Signed-off-by to a commit someone else wrote. An unsigned fix commit bounces the PR to no-dco.\n\n")
if req := pr.HumanChangeRequest; req != nil && strings.TrimSpace(req.Body) != "" {
b.WriteString(humanChangeRequestPromptSection(*req))
}
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/review/dispatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/escalation"
"github.com/hivecommons/hive/pkg/outputschema"
"github.com/hivecommons/hive/pkg/stagelabels"
)

func reviewer(name string) AgentCapability {
Expand Down Expand Up @@ -170,7 +171,7 @@ func TestBuildFixPromptAndCapExhaustion(t *testing.T) {
if !strings.Contains(prompt, "nil panic") || !strings.Contains(prompt, "attempt 1") || !strings.Contains(prompt, "Hive-Fix-Attempt: 1/") || !strings.Contains(prompt, "acme/hive#7") {
t.Fatalf("fix prompt missing expected context:\n%s", prompt)
}
if !strings.Contains(prompt, "git commit -s") || !strings.Contains(prompt, "git rebase --signoff") || !strings.Contains(prompt, "Signed-off-by") {
if !strings.Contains(prompt, "git commit -s") || !strings.Contains(prompt, stagelabels.OwnSignoffRebaseExec) || strings.Contains(prompt, "git rebase --signoff") || !strings.Contains(prompt, "Signed-off-by") {
t.Fatalf("fix prompt must require sign-off on follow-up commits:\n%s", prompt)
}
state := DispatchState{}
Expand Down
27 changes: 27 additions & 0 deletions src/pkg/scheduler/fork_aware_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"testing"

"github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/stagelabels"
)

const forkQueueFixture = `{"generated_at":"2026-09-17T00:00:00Z","ci_failing":[
Expand Down Expand Up @@ -254,3 +255,29 @@ func TestRebaseResolveInstructions(t *testing.T) {
}
}
}

// hivecommons/hive#19110, #19102, #19063: the FIX-BEFORE-NEW block sent the
// fixer to a person's PR with "commit -s → git push" and nothing else, and its
// own follow-up commits failed `Sign-off survives the squash`. A person's row
// carries the rule; the hive's own PR does not.
func TestFormatRedPRFixData_PersonAuthoredRowCarriesSignoffRule(t *testing.T) {
data := `{"ci_failing":[` +
`{"number":19110,"repo":"hivecommons/hive","title":"human red","author":"clubanderson","failing_checks":["coverage"],"person_authored":true},` +
`{"number":19102,"repo":"hivecommons/hive","title":"human dirty","author":"clubanderson","conflict":true,"mergeable_state":"dirty","trusted_author":true,"person_authored":true,"base_ref":"v5","rebase_attempt":1,"rebase_attempts_max":2},` +
`{"number":19200,"repo":"hivecommons/hive","title":"hive red","author":"app/hivecommons-hive","app_authored":true,"failing_checks":["test"]}` +
`]}`
out := formatRedPRFixData([]byte(data), "scanner")
if got := strings.Count(out, stagelabels.PersonPRAgentCommitRule); got != 2 {
t.Fatalf("person's-PR rule appears %d times, want once per person's row:\n%s", got, out)
}
if !strings.Contains(out, "PERSON'S PR (author clubanderson)") {
t.Errorf("rule does not name the author:\n%s", out)
}
hive := out[strings.Index(out, "#19200"):]
if strings.Contains(hive, "PERSON'S PR") {
t.Errorf("the hive's own PR got the person's-PR rule:\n%s", hive)
}
if !strings.Contains(out, "add no commit or Signed-off-by of your own") {
t.Errorf("trusted-author rebase lacks the no-own-commit clause:\n%s", out)
}
}
Loading
Loading