From 59c4b4db038e5dfdff2d8e2f2bd9d72fd3bad4f7 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 12:07:20 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20decide=20plan:=20read=20reco?= =?UTF-8?q?rded=20park=20reasons,=20pending=20CI=20is=20not=20red,=20adopt?= =?UTF-8?q?ed=20PRs=20go=20to=20the=20fixer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Let hive decide" preview for #15722 said "make CI green" / "CI is red" of a PR with every check green: GitHub reports mergeable_state "unstable" when any context — the non-required tide included — is pending, and the plan treated anything but clean as red without reading the checks. It also ignored the stage record's reasons (reviewer requires_human, high-risk) and had no notion of a PR the hive adopted in place, so it offered to send the hive's own branch back to the contributor. - delegatedHeadCI inspects the head's checks: red only when one failed, pending while running; Input.CIPending / CIRed() carry that through the policy, ladder, blockers and glossary effect. - gather reads the stage record (reasons, adoption) and the review verdict artifact; the WHY names the recorded park reason. - New rules adopted-fixer / adopted-security-finding: an adopted PR's finding goes to the hive's fixer (no action needed); a security finding stays a person's call, named in full. - Regression test: red CI on a clanker PR routes 072, never 085. Signed-off-by: Andrew Anderson --- changelog.d/fixed-decide-plan-adopted-pr.md | 1 + .../api_repo_item_decide_delegated.go | 121 +++++++++++++++--- .../api_repo_item_decide_delegated_plan.go | 53 +++++++- ...pi_repo_item_decide_delegated_plan_test.go | 105 +++++++++++++++ .../api_repo_item_decide_delegated_test.go | 6 +- .../dashboard/api_repo_item_decision_test.go | 5 + .../dashboard/delegated_decision_effect.go | 2 +- .../static-src/js/tracker-filter-fetch.js | 2 + src/pkg/dashboard/static/index.html | 2 + .../delegatedecision/adopted_by_hive_test.go | 79 ++++++++++++ src/pkg/delegatedecision/decision_glossary.go | 4 + src/pkg/delegatedecision/ladder.go | 9 +- src/pkg/delegatedecision/policy.go | 110 ++++++++++++---- src/pkg/stagelabels/human_test.go | 10 ++ 14 files changed, 452 insertions(+), 57 deletions(-) create mode 100644 changelog.d/fixed-decide-plan-adopted-pr.md create mode 100644 src/pkg/delegatedecision/adopted_by_hive_test.go diff --git a/changelog.d/fixed-decide-plan-adopted-pr.md b/changelog.d/fixed-decide-plan-adopted-pr.md new file mode 100644 index 0000000000..30e673abce --- /dev/null +++ b/changelog.d/fixed-decide-plan-adopted-pr.md @@ -0,0 +1 @@ +- "Let hive decide" no longer calls a PR's CI red when only a non-required context (tide) is pending: the plan reads the head's own checks, derives its WHY from the recorded stage-entry reasons (reviewer requires_human / high-risk), and on a PR the hive adopted in place hands the finding to the hive's fixer instead of "sending it back to its author". diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated.go b/src/pkg/dashboard/api_repo_item_decide_delegated.go index 8cb2316d0f..996d25cd49 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated.go @@ -18,6 +18,8 @@ import ( "github.com/hivecommons/hive/pkg/config" "github.com/hivecommons/hive/pkg/delegatedecision" ghpkg "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/review" + "github.com/hivecommons/hive/pkg/stageengine" stageengineprstage "github.com/hivecommons/hive/pkg/stageengine/prstage" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -643,11 +645,12 @@ func (s *Server) gatherDelegatedInput(ctx context.Context, repoFull string, numb in.DiffEmpty = ghpkg.PRChangedFilesClaimsEmpty(pr) state := strings.ToLower(pr.GetMergeableState()) in.Conflicting = state == "dirty" || (pr.Mergeable != nil && !pr.GetMergeable()) - green, err := delegatedHeadCIGreen(ctx, api, owner, repoName, pr, in.Conflicting, state) + ci, err := delegatedHeadCI(ctx, api, owner, repoName, pr, state) if err != nil { return in, fmt.Errorf("reading checks for %s#%d: %w", repoFull, number, err) } - in.CIGreen = green + in.CIGreen, in.CIPending = ci.green, ci.pending + s.gatherDelegatedRecordedPark(repoFull, number, pr.GetHead().GetSHA(), &in) if files, _, err := api.PullRequests.ListFiles(ctx, owner, repoName, number, &gh.ListOptions{PerPage: delegatedDecisionGatherLimit}); err == nil && len(files) > 0 { in.LowRiskPaths = true for _, f := range files { @@ -713,31 +716,107 @@ func (s *Server) delegatedAdoptionGraceElapsed(repoFull string, number int) bool return rec.AdoptionBlocked(rec.NudgeHead) != "" } -// delegatedHeadCIGreen decides Input.CIGreen for the PR under decision. -// mergeable_state alone cannot carry it: GitHub reports "blocked" both for a -// missing required review and for red required checks, and "unknown" / -// "behind" / "" say nothing about the head at all. Only "clean" and -// "has_hooks" assert a green head; "unstable" and a conflict deny it; every -// other state is settled from the head's combined status and check runs the -// way gatherDelegatedPRContext settles a competing PR — no red, nothing -// pending, and at least one green result, so a head whose checks never ran -// is not read as green either. -func delegatedHeadCIGreen(ctx context.Context, api *gh.Client, owner, repoName string, pr *gh.PullRequest, conflicting bool, state string) (bool, error) { - switch { - case conflicting, state == "unstable": - return false, nil - case state == "clean", state == "has_hooks": - return true, nil +// delegatedHeadCIState is what the head's checks say: green (every +// gating check passed), pending (some still running, none failed), or +// neither (a check failed, or none ever reported). +type delegatedHeadCIState struct { + green, pending bool +} + +// delegatedHeadCI decides Input.CIGreen / CIPending for the PR under +// decision. mergeable_state alone cannot carry it: GitHub reports "blocked" +// both for a missing required review and for red required checks, +// "unstable" whenever ANY context is pending or failing — a non-required +// merge-metadata context like tide included — and "unknown" / "behind" / +// "" say nothing about the head at all. Only "clean" and "has_hooks" +// assert a green head; every other state is settled from the head's +// combined status and check runs (meta contexts excluded, the way +// gatherDelegatedPRContext settles a competing PR): green is no red, +// nothing pending and at least one green result; pending is no red with +// a check still running. hivecommons/hive#15722 read "unstable" as red +// while every check on the head was green and only tide was pending, and +// the preview told the operator "CI is red". +func delegatedHeadCI(ctx context.Context, api *gh.Client, owner, repoName string, pr *gh.PullRequest, state string) (delegatedHeadCIState, error) { + if state == "clean" || state == "has_hooks" { + return delegatedHeadCIState{green: true}, nil } sha := strings.TrimSpace(pr.GetHead().GetSHA()) if sha == "" { - return false, nil + return delegatedHeadCIState{}, nil } summary, err := ghpkg.SummarizeCommitChecks(ctx, api, owner, repoName, sha) if err != nil { - return false, err + return delegatedHeadCIState{}, err + } + if len(summary.Red) > 0 { + return delegatedHeadCIState{}, nil + } + return delegatedHeadCIState{green: summary.Pending == 0 && summary.Green > 0, pending: summary.Pending > 0}, nil +} + +// gatherDelegatedRecordedPark reads what the stage engine recorded about +// the PR — the reason it parked it, whether the hive adopted it in place, +// and the reviewer verdict on its head — so the delegate decides on the +// same facts the 085 entry comment named, not only on the words the +// tracker row sent along (hivecommons/hive#15722: the row said reviewer +// requires_human / high-risk, the plan said "CI is red"). +func (s *Server) gatherDelegatedRecordedPark(repoFull string, number int, head string, in *delegatedecision.Input) { + head = strings.TrimSpace(head) + recorded := "" + if rec, ok := s.stageStoreOrShared().Get(stagelabels.Key(repoFull, number)); ok { + recorded = strings.TrimSpace(rec.Reason) + if recorded != "" && !slices.Contains(in.Reasons, recorded) { + in.Reasons = append(in.Reasons, recorded) + } + in.AdoptedByHive = rec.AdoptionLive(head) + } + for _, r := range in.Reasons { + lower := strings.ToLower(r) + if strings.Contains(lower, stageengineprstage.ContributorLaneReasonAdoptedByHive) { + in.AdoptedByHive = true + } + if stagelabels.ReasonClass(lower) == stageengine.StageReasonVerdictRequiresHuman || strings.Contains(lower, "requires_human") { + in.ReviewerRequiresHuman = true + } + } + art, err := review.LoadArtifact("") + if err != nil { + return } - return len(summary.Red) == 0 && summary.Pending == 0 && summary.Green > 0, nil + lookup := stageTrackerDecisionVerdictLookup(&art) + agg, ok := lookup(repoFull, number, head, in.ReviewerRequiresHuman) + if !ok { + _, short, _ := strings.Cut(repoFull, "/") + agg, ok = lookup(short, number, head, in.ReviewerRequiresHuman) + } + if !ok { + return + } + if agg.RequiresHuman || agg.DecisionRequested { + in.ReviewerRequiresHuman = true + } + if in.Question == "" { + in.Question = strings.TrimSpace(agg.DecisionQuestion) + } + in.ReviewerFinding = strings.TrimSpace(agg.DecisionFinding) + in.SecurityFinding = delegatedSecurityFinding(agg) +} + +// delegatedSecurityFinding: the reviewer's finding is the security +// review's own — that perspective withheld approval, or the finding names +// a security / credentials question. The reviewer's generic high-risk +// marker alone is not one: it is a risk-class flag the fixer addresses. +func delegatedSecurityFinding(agg review.Aggregate) bool { + if agg.Perspectives[review.PerspectiveSecurity] == review.VerdictRequiresHuman { + return true + } + lower := strings.ToLower(agg.DecisionFinding) + for _, term := range []string{"security", "credential", "secret", "permission", "privilege", "vulnerab", "insecure", "malicious", "supply chain", "supply-chain"} { + if strings.Contains(lower, term) { + return true + } + } + return false } // delegatedWorkflowPath reports a file under .github/workflows: the adoption @@ -791,7 +870,7 @@ func (s *Server) executeDelegatedDecision(ctx context.Context, in delegatedecisi notes = append(notes, "parking labels lifted, `"+ghpkg.HumanAckLabel+"` applied") s.noteDelegatedUnpark(repoFull, number) } - } else if d.Verdict == delegatedecision.VerdictDirection && in.HiveAuthored { + } else if d.Verdict == delegatedecision.VerdictDirection && (in.HiveAuthored || in.AdoptedByHive) { if _, err := client.RecordOperatorPullRequestDecision(ctx, repoFull, number, user, d.Text, repoItemDecisionChangeRequests()); err != nil && !errors.Is(err, ghpkg.ErrPullRequestNotHiveAuthored) { return notes, fmt.Errorf("recording PR direction: %w", err) } else if err == nil { diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go b/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go index 63b6af85f5..c2082420b8 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go @@ -214,6 +214,12 @@ func delegatedPlanWording(in delegatedecision.Input, d delegatedecision.Decision return "Close " + ref + " as superseded by #" + strconv.Itoa(target) + ".", []string{ref + " is closed with a comment pointing at #" + strconv.Itoa(target) + "."} case d.Verdict == delegatedecision.VerdictCloseDuplicate, d.Verdict == delegatedecision.VerdictCloseSuperseded: return "Close " + ref + ".", []string{ref + " is closed with a comment saying why."} + case d.Verdict == delegatedecision.VerdictDirection && in.AdoptedByHive: + // The hive adopted the PR in place: it is the author now, so the + // instruction is its own fixer's, not the contributor's + // (hivecommons/hive#15722). + return "Have hive's fixer " + delegatedPlanInstruction(in, delegatedecision.Decision{}) + " on " + ref + "; no action needed from you.", + []string{"Hive records that instruction on " + ref + " for its fixer — the hive owns this branch now, not the contributor.", "The fixer pushes; the row updates when the swarm re-reviews."} case d.Verdict == delegatedecision.VerdictDirection: return "Send " + ref + " back to its author with one instruction: " + delegatedPlanInstruction(in, d) + ".", []string{"Hive posts that instruction on " + ref + ".", "The author pushes a fix; the row updates when it lands."} @@ -237,17 +243,27 @@ func delegatedPlanWording(in delegatedecision.Input, d delegatedecision.Decision } // delegatedPlanInstruction is the direction in the author's terms: the -// fix list from the head's facts ("make CI green, nothing else"), or the -// decision's own text when the direction is a reviewer's question. +// fix list from the head's facts ("make CI green, nothing else"), the +// reviewer's finding when that is what parked it, or the decision's own +// text when the direction is a reviewer's question. "make CI green" is +// said only of a head with a failing check: pending checks are not red +// (hivecommons/hive#15722). func delegatedPlanInstruction(in delegatedecision.Input, d delegatedecision.Decision) string { var fix []string + if in.ReviewerRequiresHuman { + item := "address the reviewer's finding" + if f := strings.TrimSpace(in.ReviewerFinding); f != "" { + item += " (" + f + ")" + } + fix = append(fix, item) + } if in.Conflicting { fix = append(fix, "rebase onto the base branch") } if in.DCOMissing { fix = append(fix, "add the sign-off") } - if !in.CIGreen { + if in.CIRed() { fix = append(fix, "make CI green") } if len(fix) == 0 || strings.TrimSpace(in.Question) != "" { @@ -258,6 +274,9 @@ func delegatedPlanInstruction(in delegatedecision.Input, d delegatedecision.Deci if len(fix) == 0 { return "address the review" } + if in.ReviewerRequiresHuman { + return strings.Join(fix, ", ") + } return strings.Join(fix, ", ") + ", nothing else" } @@ -282,7 +301,7 @@ func delegatedPlanWhy(in delegatedecision.Input, d delegatedecision.Decision) st } why := strings.Join(parts, " and ") if why == "" && d.Verdict == delegatedecision.VerdictDirection { - why = delegatedPlanBlockers(in) + why = delegatedPlanParkReason(in) } if why == "" { why = delegatedPlanPlain(d.Rationale) @@ -313,12 +332,34 @@ func delegatedPlanLandedWhy(in delegatedecision.Input, d delegatedecision.Decisi return strings.ToUpper(landed[:1]) + landed[1:] + "." } +// delegatedPlanParkReason is WHY a direction is owed, from the same facts +// the stage engine recorded when it parked the PR: the reviewer's verdict +// first — "the reviewer returned requires_human: the reviewer marked this +// change high-risk" — then the head's blockers. hivecommons/hive#15722's +// preview said "CI is red" of a PR parked on requires_human with every +// check green. +func delegatedPlanParkReason(in delegatedecision.Input) string { + var parts []string + if in.ReviewerRequiresHuman { + why := "the reviewer returned requires_human" + if f := strings.TrimSpace(in.ReviewerFinding); f != "" { + why += ": " + f + } + parts = append(parts, why) + } + if b := delegatedPlanBlockers(in); b != "" { + parts = append(parts, b) + } + return strings.Join(parts, "; ") +} + // delegatedPlanBlockers names what keeps a head from merging, in plain // words: "CI is red", "it conflicts with the base branch", "the sign-off -// is missing". +// is missing". A head whose checks are still running is not red and is +// not a blocker a direction can name. func delegatedPlanBlockers(in delegatedecision.Input) string { var b []string - if !in.CIGreen { + if in.CIRed() { b = append(b, "CI is red") } if in.Conflicting { diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go index 988efe75bf..a4a31bf9f8 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go @@ -7,8 +7,11 @@ import ( "strconv" "strings" "testing" + "time" "github.com/hivecommons/hive/pkg/delegatedecision" + "github.com/hivecommons/hive/pkg/stageengine" + "github.com/hivecommons/hive/pkg/stagelabels" ) func postDelegatedPlan(t *testing.T, srv *Server, number int, user, body string, hdr map[string]string) *httptest.ResponseRecorder { @@ -333,3 +336,105 @@ func TestDelegatedDecisionPlanIssueAndAdvisory(t *testing.T) { }) } } + +// hivecommons/hive#15722, the live case: a clanker's PR the hive adopted in +// place (contributor-lane:adopted-by-hive), parked at 085 by the reviewer's +// requires_human / high-risk marker, every check green and only the tide +// context pending (mergeable_state "unstable"). The preview said "Send +// #15722 back to its author with one instruction: make CI green" / "CI is +// red". It must read the recorded park reason instead, never call a +// pending-only head red, and — the hive being the author now — hand the +// finding to the hive's own fixer. +func TestDelegatedDecisionPlanAdoptedRequiresHumanIsFixersNotCI(t *testing.T) { + mock := &repoItemDecisionMock{prForeign: true, prMergeState: "unstable", prTidePending: true, prLabels: []string{"stage/085-needs-decision"}} + srv := newDelegatedServer(t, mock) + key := stagelabels.Key("testorg/testrepo", 8) + srv.stageStore.Observe(key, stagelabels.NeedsDecision, stageengine.StageReasonVerdictRequiresHuman) + srv.stageStore.MarkAdoptedInPlace(key, "feedfacefeedfacefeedfacefeedfacefeedface", "contributor-offline", time.Now()) + + // The tracker row's words, as the SPA sends them. + body := `{"type":"pr","reason":"reviewer-verdict:requires_human","caption":"the reviewer marked this change high-risk"}` + w := postDelegatedPlan(t, srv, 8, "writer", body, map[string]string{"X-Hive-Role": "merger"}) + if w.Code != http.StatusOK { + t.Fatalf("code=%d body=%s", w.Code, w.Body.String()) + } + var plan delegatedDecisionPlan + if err := json.Unmarshal(w.Body.Bytes(), &plan); err != nil { + t.Fatal(err) + } + t.Logf("summary: %s\nwhy: %s\nconsequences: %v", plan.Summary, plan.Why, plan.Consequences) + if plan.Would != string(delegatedecision.VerdictDirection) || plan.Rule != delegatedecision.RuleAdoptedFixer { + t.Fatalf("plan = %+v", plan) + } + if !strings.HasPrefix(plan.Summary, "Have hive's fixer address the reviewer's finding") || !strings.Contains(plan.Summary, "no action needed from you") { + t.Fatalf("summary %q", plan.Summary) + } + if !strings.Contains(plan.Why, "requires_human") { + t.Fatalf("why %q does not name the recorded park reason", plan.Why) + } + for _, text := range append([]string{plan.Summary, plan.Why}, plan.Consequences...) { + lower := strings.ToLower(text) + if strings.Contains(text, "CI") || strings.Contains(lower, "back to its author") { + t.Errorf("a green head parked on requires_human is described as red or returned: %q", text) + } + } + if len(mock.comments) != 0 { + t.Fatalf("a plan may not write: %v", mock.comments) + } + + // The same head, not adopted: the clanker's PR is not "red" either — + // the plan never says CI is red of a head with no failing check. + mock2 := &repoItemDecisionMock{prForeign: true, prMergeState: "unstable", prTidePending: true, prLabels: []string{"stage/085-needs-decision"}} + srv2 := newDelegatedServer(t, mock2) + srv2.stageStore.Observe(key, stagelabels.NeedsDecision, stageengine.StageReasonVerdictRequiresHuman) + w = postDelegatedPlan(t, srv2, 8, "writer", body, map[string]string{"X-Hive-Role": "merger"}) + if w.Code != http.StatusOK { + t.Fatalf("code=%d body=%s", w.Code, w.Body.String()) + } + var plan2 delegatedDecisionPlan + if err := json.Unmarshal(w.Body.Bytes(), &plan2); err != nil { + t.Fatal(err) + } + t.Logf("not adopted: summary: %s\nwhy: %s", plan2.Summary, plan2.Why) + for _, text := range append([]string{plan2.Summary, plan2.Why}, plan2.Consequences...) { + if strings.Contains(text, "CI is red") || strings.Contains(text, "make CI green") { + t.Errorf("not adopted: head with green checks called red: %q", text) + } + } +} + +// delegatedPlanInstruction / delegatedPlanBlockers: pending checks are not +// red, and the recorded reviewer finding is the WHY. +func TestDelegatedPlanPendingCIIsNotRed(t *testing.T) { + in := delegatedecision.Input{Kind: delegatedecision.KindPR, Number: 15722, Author: "clubanderson", OwnerAuthor: true, TrustedAuthor: true, CIGreen: false, CIPending: true, Conflicting: true} + d := delegatedecision.Decide(in) + if d.Verdict != delegatedecision.VerdictDirection { + t.Fatalf("verdict %s rule %s", d.Verdict, d.Rule) + } + summary, _ := delegatedPlanWording(in, d) + if summary != "Send #15722 back to its author with one instruction: rebase onto the base branch, nothing else." { + t.Fatalf("summary %q", summary) + } + if why := delegatedPlanWhy(in, d); why != "It conflicts with the base branch." { + t.Fatalf("why %q", why) + } + in.Conflicting, in.ReviewerRequiresHuman, in.ReviewerFinding = false, true, "the reviewer marked this change high-risk" + in.AdoptedByHive, in.OwnerAuthor, in.TrustedAuthor, in.Author = true, false, false, "mendezr" + d = delegatedecision.Decide(in) + if d.Rule != delegatedecision.RuleAdoptedFixer { + t.Fatalf("verdict %s rule %s", d.Verdict, d.Rule) + } + summary, next := delegatedPlanWording(in, d) + if summary != "Have hive's fixer address the reviewer's finding (the reviewer marked this change high-risk) on #15722; no action needed from you." { + t.Fatalf("summary %q", summary) + } + if why := delegatedPlanWhy(in, d); why != "The reviewer returned requires_human: the reviewer marked this change high-risk." { + t.Fatalf("why %q", why) + } + if len(next) != 2 { + t.Fatalf("then items %v", next) + } + if delegatedPlanMergeableAsIs(in, d) { + t.Fatal("a head with checks still running is not mergeable as it is") + } +} diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_test.go b/src/pkg/dashboard/api_repo_item_decide_delegated_test.go index d000cfeb2f..2d8ab6358d 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated_test.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_test.go @@ -190,7 +190,11 @@ func TestDelegatedDecisionPRBlockedStateReadsHeadChecks(t *testing.T) { {"blocked by red required checks", "blocked", true, false, delegatedecision.VerdictDirection, "fix-then-merge"}, {"blocked with checks never run", "blocked", false, true, delegatedecision.VerdictDirection, "fix-then-merge"}, {"unknown state with checks never run", "unknown", false, true, delegatedecision.VerdictDirection, "fix-then-merge"}, - {"unstable head", "unstable", false, false, delegatedecision.VerdictDirection, "fix-then-merge"}, + // "unstable" means some context is pending or failing — the + // non-required tide included — so the head's own checks decide + // (hivecommons/hive#15722: all green, only tide pending, "CI is red"). + {"unstable head with green checks", "unstable", false, false, delegatedecision.VerdictApprove, "default-release"}, + {"unstable head with red checks", "unstable", true, false, delegatedecision.VerdictDirection, "fix-then-merge"}, {"blocked by missing review only", "blocked", false, false, delegatedecision.VerdictApprove, "default-release"}, {"clean head", "clean", false, false, delegatedecision.VerdictApprove, "default-release"}, } diff --git a/src/pkg/dashboard/api_repo_item_decision_test.go b/src/pkg/dashboard/api_repo_item_decision_test.go index 5300abb567..ee4c6c26a8 100644 --- a/src/pkg/dashboard/api_repo_item_decision_test.go +++ b/src/pkg/dashboard/api_repo_item_decision_test.go @@ -42,6 +42,9 @@ type repoItemDecisionMock struct { updates int prRedCI bool prNoCI bool + // prTidePending is hivecommons/hive#15722's head: every check green, + // only the tide merge-metadata context pending (GitHub: "unstable"). + prTidePending bool // priorComments are the comment bodies GET /comments lists (a prior // delegated decision makes a repeat click a no-op). priorComments []string @@ -169,6 +172,8 @@ func newRepoItemDecisionServer(t *testing.T, m *repoItemDecisionMock) *Server { _, _ = io.WriteString(w, `{"state":"failure","statuses":[{"context":"ci/test","state":"failure"}]}`) case m.prNoCI: _, _ = io.WriteString(w, `{"state":"pending","statuses":[]}`) + case m.prTidePending: + _, _ = io.WriteString(w, `{"state":"pending","statuses":[{"context":"ci/test","state":"success"},{"context":"tide","state":"pending"}]}`) default: _, _ = io.WriteString(w, `{"state":"success","statuses":[{"context":"ci/test","state":"success"}]}`) } diff --git a/src/pkg/dashboard/delegated_decision_effect.go b/src/pkg/dashboard/delegated_decision_effect.go index ffe4959b45..35ca010e6e 100644 --- a/src/pkg/dashboard/delegated_decision_effect.go +++ b/src/pkg/dashboard/delegated_decision_effect.go @@ -192,7 +192,7 @@ func (s *Server) delegatedStuckWhy(in delegatedecision.Input, d delegatedecision return delegatedecision.GlossaryHold case has("behind"): return delegatedecision.GlossaryBehind - case in.Kind == delegatedecision.KindPR && !in.CIGreen && d.Verdict != delegatedecision.VerdictCloseDuplicate && d.Verdict != delegatedecision.VerdictCloseSuperseded: + case in.Kind == delegatedecision.KindPR && in.CIRed() && d.Verdict != delegatedecision.VerdictCloseDuplicate && d.Verdict != delegatedecision.VerdictCloseSuperseded: return delegatedecision.GlossaryCIRed } switch { diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js b/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js index ca4dba9b82..c438b8bc0c 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js @@ -56,6 +56,8 @@ "adopt": {"kind": "action", "plain": "hive takes over finishing this PR", "detail": "Adopt means the hive takes over finishing this PR: it rebases, fixes CI and merges it, keeping the author's commits and sign-off."}, "adopt-supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, "adopted": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "adopted-fixer": {"kind": "rule", "plain": "the hive adopted this PR; its own fixer addresses the finding", "detail": "The hive adopted this PR in place and owns its branch, so the reviewer's finding and any blocker go to the hive's own fixer — not back to the contributor and not to a person. No action is needed."}, + "adopted-security-finding": {"kind": "rule", "plain": "the hive adopted this PR, but the security finding is a person's call", "detail": "The hive adopted this PR in place, but the reviewer's finding is the security review's. That policy call is a person's: read the finding and reply /hive decision with the instruction for the hive's fixer, or close the PR."}, "adoption-disabled": {"kind": "reason", "plain": "adoption is switched off on this hive", "detail": "Stage adoption is disabled on this hive (governor.labels.stage.adoption), so a request to take a PR over is never carried out."}, "adoption-executing": {"kind": "reason", "plain": "the adoption engine is carrying it out", "detail": "The decision is recorded and the adoption engine picks it up on its next stage pass (a few minutes): it pushes the commits to a hive branch and opens the hive's copy. Nothing to do yet."}, "adoption-stalled:contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 88a9d61473..c14ecd8ad1 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -19363,6 +19363,8 @@

All labels

"adopt": {"kind": "action", "plain": "hive takes over finishing this PR", "detail": "Adopt means the hive takes over finishing this PR: it rebases, fixes CI and merges it, keeping the author's commits and sign-off."}, "adopt-supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, "adopted": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "adopted-fixer": {"kind": "rule", "plain": "the hive adopted this PR; its own fixer addresses the finding", "detail": "The hive adopted this PR in place and owns its branch, so the reviewer's finding and any blocker go to the hive's own fixer — not back to the contributor and not to a person. No action is needed."}, + "adopted-security-finding": {"kind": "rule", "plain": "the hive adopted this PR, but the security finding is a person's call", "detail": "The hive adopted this PR in place, but the reviewer's finding is the security review's. That policy call is a person's: read the finding and reply /hive decision with the instruction for the hive's fixer, or close the PR."}, "adoption-disabled": {"kind": "reason", "plain": "adoption is switched off on this hive", "detail": "Stage adoption is disabled on this hive (governor.labels.stage.adoption), so a request to take a PR over is never carried out."}, "adoption-executing": {"kind": "reason", "plain": "the adoption engine is carrying it out", "detail": "The decision is recorded and the adoption engine picks it up on its next stage pass (a few minutes): it pushes the commits to a hive branch and opens the hive's copy. Nothing to do yet."}, "adoption-stalled:contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, diff --git a/src/pkg/delegatedecision/adopted_by_hive_test.go b/src/pkg/delegatedecision/adopted_by_hive_test.go new file mode 100644 index 0000000000..c8354b7cbd --- /dev/null +++ b/src/pkg/delegatedecision/adopted_by_hive_test.go @@ -0,0 +1,79 @@ +package delegatedecision + +import ( + "strings" + "testing" +) + +// hivecommons/hive#15722: PR #15722 (a clanker's, adopted by the hive in +// place) parked at 085 on the reviewer's requires_human / high-risk marker +// with every check green; the delegate said "make CI green" and would have +// sent it "back to its author". The hive is the author of an adopted PR: +// the finding is its own fixer's, and CI is only red when a check failed. +func TestDecidePRAdoptedByHiveRoutesToFixer(t *testing.T) { + base := Input{Kind: KindPR, Number: 15722, Author: "mendezr", ContributorOnline: true, AdoptedByHive: true, + Reasons: []string{"reviewer-verdict:requires_human"}, ReviewerRequiresHuman: true, + ReviewerFinding: "the reviewer marked this change high-risk", CIGreen: true} + + d := Decide(base) + if d.Verdict != VerdictDirection || d.Rule != RuleAdoptedFixer { + t.Fatalf("verdict %s rule %s text %q", d.Verdict, d.Rule, d.Text) + } + for _, want := range []string{"hive's fixer", "the reviewer marked this change high-risk", "#15722"} { + if !strings.Contains(d.Text, want) { + t.Errorf("text %q lacks %q", d.Text, want) + } + } + for _, text := range []string{d.Text, d.Rationale} { + if strings.Contains(text, "CI") || strings.Contains(text, "back to") || strings.Contains(text, "@mendezr") { + t.Errorf("an adopted PR's direction names the contributor or CI: %q", text) + } + } + if len(d.Actions) != 1 || d.Actions[0].Kind != ActionCommentDecision { + t.Fatalf("actions %+v", d.Actions) + } + + // Checks still running are not red: the fixer is not told to make CI + // green, only to address the finding. + pending := with(base, func(i *Input) { i.CIGreen = false; i.CIPending = true }) + if d := Decide(pending); d.Rule != RuleAdoptedFixer || strings.Contains(d.Text, "CI") { + t.Fatalf("pending CI: rule %s text %q", d.Rule, d.Text) + } + if got := mergeBlockers(pending); got != "CI still running" { + t.Fatalf("mergeBlockers = %q", got) + } + // A failing check joins the fixer's list. + red := with(base, func(i *Input) { i.CIGreen = false }) + if d := Decide(red); d.Rule != RuleAdoptedFixer || !strings.Contains(d.Text, "make CI green") { + t.Fatalf("red CI: rule %s text %q", d.Rule, d.Text) + } + + // The security review's finding is a person's policy call: named in + // full, recommend-only, park kept. + sec := with(base, func(i *Input) { + i.SecurityFinding = true + i.ReviewerFinding = "the security review withheld approval: token written to the log" + }) + d = Decide(sec) + if d.Verdict != VerdictRecommendOnly || d.Rule != RuleAdoptedSecurityFinding || !d.KeepsPark { + t.Fatalf("security: verdict %s rule %s", d.Verdict, d.Rule) + } + if !strings.Contains(d.Text, "token written to the log") || !strings.Contains(d.Text, "/hive decision") { + t.Fatalf("security text %q", d.Text) + } + + // Adopted, green, no finding: nothing for the fixer; the ordinary + // rules release it. + clean := with(base, func(i *Input) { i.ReviewerRequiresHuman = false; i.ReviewerFinding = ""; i.Reasons = nil }) + if d := Decide(clean); d.Verdict != VerdictApprove { + t.Fatalf("clean adopted head: verdict %s rule %s", d.Verdict, d.Rule) + } + + // Not adopted: the contributor's connected clanker gets the fix list + // as before, and pending CI is not on it. + theirs := with(base, func(i *Input) { i.AdoptedByHive = false; i.CIGreen = false; i.CIPending = true; i.Conflicting = true }) + d = Decide(theirs) + if d.Rule != RuleReturnToContributor || strings.Contains(d.Text, "CI") || !strings.Contains(d.Text, "rebase") { + t.Fatalf("contributor: rule %s text %q", d.Rule, d.Text) + } +} diff --git a/src/pkg/delegatedecision/decision_glossary.go b/src/pkg/delegatedecision/decision_glossary.go index fd6ebc33b8..c907653c6c 100644 --- a/src/pkg/delegatedecision/decision_glossary.go +++ b/src/pkg/delegatedecision/decision_glossary.go @@ -101,6 +101,10 @@ var glossary = []GlossaryEntry{ Detail: "An older issue already tracks the same work; one thread keeps it moving."}, {Slug: "fix-then-merge", Kind: GlossaryRule, Plain: "the branch isn't mergeable yet", Detail: "The branch cannot merge as it is (conflicts, red CI or a missing sign-off); the hive told the author agent exactly what to fix."}, + {Slug: RuleAdoptedFixer, Kind: GlossaryRule, Plain: "the hive adopted this PR; its own fixer addresses the finding", + Detail: "The hive adopted this PR in place and owns its branch, so the reviewer's finding and any blocker go to the hive's own fixer — not back to the contributor and not to a person. No action is needed."}, + {Slug: RuleAdoptedSecurityFinding, Kind: GlossaryRule, Plain: "the hive adopted this PR, but the security finding is a person's call", + Detail: "The hive adopted this PR in place, but the reviewer's finding is the security review's. That policy call is a person's: read the finding and reply /hive decision with the instruction for the hive's fixer, or close the PR."}, {Slug: RuleReturnToAuthor, Kind: GlossaryRule, Plain: "a person pushed this PR; the hive asked them, not adopted it", Detail: "The PR was pushed by a person (author/human or one of this hive's owners), so the hive never adopts it. It told the author by name what to fix (rebase, sign-off, CI) and relayed the reviewer's question."}, {Slug: "owner-only", Kind: GlossaryRule, Plain: "only the hive owner can do this", diff --git a/src/pkg/delegatedecision/ladder.go b/src/pkg/delegatedecision/ladder.go index cc0cbe705c..497f058ad7 100644 --- a/src/pkg/delegatedecision/ladder.go +++ b/src/pkg/delegatedecision/ladder.go @@ -232,7 +232,7 @@ func decideLadder(in Input, ref string) (Decision, bool) { } return out(d, in.OfflineWording()+" and the grace has elapsed; adopted now") } - if in.AdoptionStalled || in.Conflicting || !in.CIGreen || in.DCOMissing { + if in.AdoptionStalled || in.Conflicting || in.CIRed() || in.DCOMissing { text := "supersede now: adopt " + ref + " in supersede mode, preserving the author's commits and sign-off; do not wait for the grace deadline" d := Decision{ Verdict: VerdictAdoptSupersede, Rule: RuleContributorOffline, Text: text, @@ -279,7 +279,10 @@ func mergeBlockers(in Input) string { if in.Conflicting { b = append(b, "conflicting") } - if !in.CIGreen { + switch { + case in.CIPending: + b = append(b, "CI still running") + case !in.CIGreen: b = append(b, "CI not green") } if in.DCOMissing { @@ -306,7 +309,7 @@ func fixList(in Input) []string { if in.DCOMissing { fix = append(fix, "add the DCO sign-off") } - if !in.CIGreen { + if in.CIRed() { fix = append(fix, "make CI green without widening scope") } return fix diff --git a/src/pkg/delegatedecision/policy.go b/src/pkg/delegatedecision/policy.go index 38ade5e914..ee9b0db6f4 100644 --- a/src/pkg/delegatedecision/policy.go +++ b/src/pkg/delegatedecision/policy.go @@ -208,8 +208,13 @@ type Input struct { // SentinelAlert: the sentinel label is on; SentinelReason says why. SentinelAlert bool SentinelReason string - // CIGreen / Conflicting / DCOMissing describe a PR head. + // CIGreen / Conflicting / DCOMissing describe a PR head. CIPending + // refines a head that is not green: its checks are still running and + // none has failed, so no fix is owed and "CI is red" is not true of it + // (hivecommons/hive#15722's preview said so of a green head whose only + // pending context was tide). CIGreen bool + CIPending bool Conflicting bool DCOMissing bool // Small: a size/XS or size/S PR (also read from the labels). @@ -276,7 +281,25 @@ type Input struct { // Advisory is set for a hive advisory issue (triage/advisory, a dedupe // checklist): not work, the hive's sweep ticks and closes it itself. Advisory *AdvisoryChecklist -} + // AdoptedByHive: the hive adopted this contributor PR in place (stage + // 074, contributor-lane:adopted-by-hive) and its fix lane owns the + // branch, so a direction is the hive's own fixer's to carry out — not + // the contributor's (hivecommons/hive#15722: "send #15722 back to its + // author" on a PR the hive had adopted). + AdoptedByHive bool + // ReviewerRequiresHuman: the recorded park reason is the reviewer + // swarm's requires_human on the current head; ReviewerFinding is what + // the review found ("the reviewer marked this change high-risk"), and + // SecurityFinding says that finding is the security review's — a + // policy call no fixer can make for a person. + ReviewerRequiresHuman bool + ReviewerFinding string + SecurityFinding bool +} + +// CIRed reports a head that is not green because a check failed (or none +// ever reported), as opposed to one still waiting on running checks. +func (in Input) CIRed() bool { return !in.CIGreen && !in.CIPending } // RuleAdoptNow is the rule name of the grace-elapsed Adopt now decision; // the dashboard runs it as a forced adoption (Adopt now), not a queued one. @@ -652,6 +675,12 @@ func decidePR(in Input) Decision { return d } } + // A PR the hive adopted in place is the hive's own to fix: the + // reviewer's finding and the head's blockers go to the fixer, never + // "back to the author" (hivecommons/hive#15722). + if d, ok := decideAdoptedByHive(in, ref); ok { + return d + } // The contributor-PR ladder (hivecommons/hive#15289): already fixed → // mergeable as-is → rebase-then-merge → return to contributor → // adopt-supersede, in that order, so a PR whose issue a merged PR @@ -667,7 +696,7 @@ func decidePR(in Input) Decision { return d } } - if !in.HiveAuthored && !in.PersonAuthored() && !in.ContributorOnline && in.WorkflowPath && (in.AdoptionStalled || in.AdoptionGraceElapsed || in.Conflicting || !in.CIGreen || in.DCOMissing) { + if !in.HiveAuthored && !in.PersonAuthored() && !in.ContributorOnline && in.WorkflowPath && (in.AdoptionStalled || in.AdoptionGraceElapsed || in.Conflicting || in.CIRed() || in.DCOMissing) { // The adoption engine refuses to publish a contributor's workflow // edits from the App (contributor-lane:workflow-path), so an // adopt-supersede here is decided and never executed @@ -681,17 +710,7 @@ func decidePR(in Input) Decision { d.Actions = append(d.Actions, Action{Kind: ActionLabelsAdd, Labels: []string{LabelTriageAccepted}}) return d } - if in.Conflicting || in.DCOMissing || !in.CIGreen { - var fix []string - if in.Conflicting { - fix = append(fix, "rebase onto the base branch") - } - if in.DCOMissing { - fix = append(fix, "add the DCO sign-off") - } - if !in.CIGreen { - fix = append(fix, "make CI green without widening scope") - } + if fix := fixList(in); len(fix) > 0 { text := strings.Join(fix, ", ") + "; keep the smallest reversible change, then it merges" return Decision{ Verdict: VerdictDirection, Rule: "fix-then-merge", Text: text, @@ -705,6 +724,56 @@ func decidePR(in Input) Decision { return releasePR("default-release", "approve "+ref+": green head, reviewer question answered with the reversible default — proceed as implemented", "no owner rule holds this back; a merge is reversible and keeps work moving") } +// RuleAdoptedFixer: the hive adopted the PR in place, so the reviewer's +// finding and the head's blockers are its own fixer's to address; no person +// and no contributor is asked. RuleAdoptedSecurityFinding is the one case +// the fixer cannot settle alone: the security review withheld approval, +// and that policy call is a person's (hivecommons/hive#15722). +const ( + RuleAdoptedFixer = "adopted-fixer" + RuleAdoptedSecurityFinding = "adopted-security-finding" +) + +// decideAdoptedByHive is the adopted-in-place branch of decidePR. The hive +// owns the branch, so "send it back to its author" is wrong — the hive is +// the author now. A reviewer requires_human or a head blocker becomes a +// direction the hive's fixer carries out; a security finding is named in +// full and left to a person. A green, unquestioned adopted head falls +// through to the ordinary rules. +func decideAdoptedByHive(in Input, ref string) (Decision, bool) { + if in.Kind != KindPR || !in.AdoptedByHive || in.HiveAuthored || in.PersonAuthored() { + return Decision{}, false + } + finding := strings.TrimSpace(in.ReviewerFinding) + if in.ReviewerRequiresHuman && in.SecurityFinding { + what := "the security review withheld approval" + if finding != "" { + what = finding + } + return recommendOnly(RuleAdoptedSecurityFinding, + "the hive adopted "+ref+" and owns its branch, but the reviewer's finding is a security one — "+what+" — and that policy call is a person's, not the fixer's", + "read the finding on "+ref+" ("+what+") and reply `/hive decision ` for the hive's fixer to carry out, or close it"), true + } + var fix []string + if in.ReviewerRequiresHuman { + item := "address the reviewer's finding" + if finding != "" { + item += " (" + finding + ")" + } + fix = append(fix, item) + } + fix = append(fix, fixList(in)...) + if len(fix) == 0 { + return Decision{}, false + } + text := "hive's fixer: " + strings.Join(fix, ", ") + " on " + ref + "; then it merges" + return Decision{ + Verdict: VerdictDirection, Rule: RuleAdoptedFixer, Text: text, + Rationale: "the hive adopted " + ref + " in place and owns its branch, so the reviewer's finding is the hive's own fixer's to address — not the contributor's and not a person's (hivecommons/hive#15722)", + Actions: []Action{decisionComment(text)}, + }, true +} + // RuleOnePRPerIssue: the merge queue carries one PR per issue; the one it // held as a duplicate closes as superseded by the one it kept. const RuleOnePRPerIssue = "one-pr-per-issue" @@ -742,7 +811,7 @@ func decideTrainDuplicate(in Input, ref string) (Decision, bool) { continue } held := fmt.Sprintf("#%d", other.Number) - if in.Conflicting || !in.CIGreen || in.DCOMissing { + if in.Conflicting || in.CIRed() || in.DCOMissing { return recommendOnly(RuleOnePRPerIssue, fmt.Sprintf("the merge queue kept %s over %s%s, but %s is not mergeable now (%s); the queue re-picks on its next pass", ref, held, issue, ref, mergeBlockers(in)), "fix "+ref+" ("+mergeBlockers(in)+"), or decide on "+held+" to let it supersede this one"), true @@ -799,16 +868,7 @@ func ReturnToAuthor(in Input) (Decision, bool) { } func decideReturnToAuthor(in Input, ref string) (Decision, bool) { - var fix []string - if in.Conflicting { - fix = append(fix, "rebase onto the base branch") - } - if in.DCOMissing { - fix = append(fix, "add the DCO sign-off") - } - if !in.CIGreen { - fix = append(fix, "make CI green without widening scope") - } + fix := fixList(in) question := strings.TrimSpace(in.Question) if len(fix) == 0 && question == "" { return Decision{}, false diff --git a/src/pkg/stagelabels/human_test.go b/src/pkg/stagelabels/human_test.go index a44b46d750..eb68b952b3 100644 --- a/src/pkg/stagelabels/human_test.go +++ b/src/pkg/stagelabels/human_test.go @@ -94,6 +94,16 @@ func TestRouteHumanFixEvidence(t *testing.T) { if r := RouteHuman(e); len(r.Reasons) != 2 || r.LaneReason != LaneReasonChangesRequested { t.Fatalf("multi-reason route = %+v", r) } + // Red CI on a clanker's PR goes back to the clanker (072) even when the + // reviewer also said requires_human: a failing check is the author's to + // fix first and never alone parks the PR at 085 (hivecommons/hive#15722). + e = readyEvidence() + e.AuthorKind = authorkind.Clanker + e.Verdict = VerdictRequiresHuman + e.Checks = CheckSummary{Total: 2, Green: 1, Red: []string{"unit"}, Known: true} + if r := RouteHuman(e); r.Stage != ReturnedToContributor || r.LaneReason != "check-failing:unit" { + t.Fatalf("clanker red CI + requires_human route = %+v", r) + } } // TestRouteHumanPendingStaysAtReview: no current-head verdict, or a head From b3770d37e61822aebdc101ea3f71add95c2a096e Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 12:54:43 -0400 Subject: [PATCH 2/2] test: give the adopted-PR plan test its own stage store Signed-off-by: Andrew Anderson --- src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go index a4a31bf9f8..2094a052b4 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_test.go @@ -348,6 +348,7 @@ func TestDelegatedDecisionPlanIssueAndAdvisory(t *testing.T) { func TestDelegatedDecisionPlanAdoptedRequiresHumanIsFixersNotCI(t *testing.T) { mock := &repoItemDecisionMock{prForeign: true, prMergeState: "unstable", prTidePending: true, prLabels: []string{"stage/085-needs-decision"}} srv := newDelegatedServer(t, mock) + srv.stageStore = stagelabels.NewStore("", time.Now) key := stagelabels.Key("testorg/testrepo", 8) srv.stageStore.Observe(key, stagelabels.NeedsDecision, stageengine.StageReasonVerdictRequiresHuman) srv.stageStore.MarkAdoptedInPlace(key, "feedfacefeedfacefeedfacefeedfacefeedface", "contributor-offline", time.Now()) @@ -386,6 +387,7 @@ func TestDelegatedDecisionPlanAdoptedRequiresHumanIsFixersNotCI(t *testing.T) { // the plan never says CI is red of a head with no failing check. mock2 := &repoItemDecisionMock{prForeign: true, prMergeState: "unstable", prTidePending: true, prLabels: []string{"stage/085-needs-decision"}} srv2 := newDelegatedServer(t, mock2) + srv2.stageStore = stagelabels.NewStore("", time.Now) srv2.stageStore.Observe(key, stagelabels.NeedsDecision, stageengine.StageReasonVerdictRequiresHuman) w = postDelegatedPlan(t, srv2, 8, "writer", body, map[string]string{"X-Hive-Role": "merger"}) if w.Code != http.StatusOK {