From 6a8e3567ac789e7e74532b26c24e4ae40fd520c2 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Tue, 27 Oct 2026 10:43:59 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B=20fix(dashboard):=20merge=20ga?= =?UTF-8?q?te=20follows=20live=20sentinel=20label=20and=20honors=20human?= =?UTF-8?q?=20decisions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tracker's sentinel pill was derived from the head's append-only review evidence bundle, so it stayed red after a maintainer removed sentinel-alert. It now follows the live label (a notice-only finding still raises it). Linked issues match repo names regardless of owner qualification and link to the fully-qualified repo. humanEvidence now carries the trusted approver and lane reason, and RouteHuman routes an approved manual-merge rule to 090 with an explicit 'click Merge' caption/comment instead of re-posting 085. Fixes #14578 Signed-off-by: Andy Anderson --- .../fixed-14578-sentinel-gate-live-label.md | 1 + src/pkg/dashboard/delegated_pr_context.go | 2 +- src/pkg/dashboard/stage_tracker.go | 131 ++++++++++++--- .../dashboard/stage_tracker_motion_test.go | 3 + .../stage_tracker_reference_links_test.go | 2 +- .../dashboard/stage_tracker_regressed_test.go | 1 + .../stage_tracker_repo_grouping_test.go | 2 + .../stage_tracker_sentinel_lane_test.go | 76 ++++++++- src/pkg/dashboard/stage_tracker_test.go | 152 ++++++++++++++++-- src/pkg/dashboard/stage_tracker_ui_test.go | 2 + src/pkg/dashboard/static/index.html | 13 +- src/pkg/evidence/evidence.go | 8 +- src/pkg/evidence/schema/v1.json | 3 +- .../github/automerge/automerge_stage_human.go | 29 +++- .../automerge/pr_approve_command_test.go | 10 +- src/pkg/github/review_evidence.go | 8 +- .../github/review_evidence_complete_test.go | 10 +- src/pkg/github/sentinel_sweep.go | 2 +- src/pkg/stagelabels/human.go | 90 ++++++++++- src/pkg/stagelabels/human_test.go | 148 +++++++++++++++++ 20 files changed, 636 insertions(+), 57 deletions(-) create mode 100644 changelog.d/fixed-14578-sentinel-gate-live-label.md diff --git a/changelog.d/fixed-14578-sentinel-gate-live-label.md b/changelog.d/fixed-14578-sentinel-gate-live-label.md new file mode 100644 index 0000000000..647ae93767 --- /dev/null +++ b/changelog.d/fixed-14578-sentinel-gate-live-label.md @@ -0,0 +1 @@ +- The activity-monitor merge gate now follows the live `sentinel-alert` label instead of the head's append-only sentinel evidence, so removing the label clears the "Sentinel alert · needs human" pill on the next tick; linked issues resolve their title and URL when the configured repo is a short name; and a trusted merger's approving review on a manual-merge lane (workflow path, tests removed, human-merge path) now routes the PR to `stage/090-ready-for-human-merge` with an "Awaiting human merge — approved by @login; click Merge" caption and comment instead of re-posting an open-ended needs-decision ([#14578](https://github.com/hivecommons/hive/issues/14578)). diff --git a/src/pkg/dashboard/delegated_pr_context.go b/src/pkg/dashboard/delegated_pr_context.go index aa69634cb2..74895d8177 100644 --- a/src/pkg/dashboard/delegated_pr_context.go +++ b/src/pkg/dashboard/delegated_pr_context.go @@ -26,7 +26,7 @@ func delegatedCompetingNumbers(items []StageTrackerItem, repo string, pr *gh.Pul // The requested head may be newer than the enumeration's link evidence. refs := github.PRReferencedIssues(pr.GetTitle(), pr.GetBody(), repo, pr.GetNumber()) livePR := github.PullRequest{Repo: repo, Number: pr.GetNumber(), ReferencedIssues: refs} - live := StageTrackerItem{Repo: repo, Kind: "pr", Number: pr.GetNumber(), LinkedIssues: stageTrackerPRLinkedIssues(livePR, "")} + live := StageTrackerItem{Repo: repo, Kind: "pr", Number: pr.GetNumber(), LinkedIssues: stageTrackerPRLinkedIssues(livePR, repo, "")} found := false for i := range items { if items[i].Repo == repo && items[i].Kind == "pr" && items[i].Number == live.Number { diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 7cc2736d4b..3319e5fec1 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -18,6 +18,7 @@ import ( "github.com/hivecommons/hive/pkg/dashboard/webstatic" "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/stageengine" + stageengineprstage "github.com/hivecommons/hive/pkg/stageengine/prstage" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -287,12 +288,22 @@ type StageTrackerItem struct { // SentinelReason is the first finding's summary, so the lane text can // name why a person must look (hivecommons/hive: "Sentinel alert · // needs human"). - SentinelAlert bool `json:"sentinel_alert,omitempty"` - SentinelFindings int `json:"sentinel_findings,omitempty"` - SentinelReason string `json:"sentinel_reason,omitempty"` - NudgeCount int `json:"nudge_count,omitempty"` - LastNudgeAt *time.Time `json:"last_nudge_at,omitempty"` - AdoptedBy int `json:"adopted_by,omitempty"` + SentinelAlert bool `json:"sentinel_alert,omitempty"` + SentinelFindings int `json:"sentinel_findings,omitempty"` + SentinelReason string `json:"sentinel_reason,omitempty"` + // HumanApprover is the trusted merger whose GitHub Approve review on + // the current head settled a requires_human verdict or a manual-merge + // lane rule (the `:human-approved@login` suffix on the stage reason). + // ManualMerge is true when the stage reason is a lane rule the hive + // never merges unattended (CI workflow / action edits, removed tests, + // a human-merge path): at 090 the merge gate then reads "Awaiting + // human merge" and names the approver, since the only step left is + // the maintainer's merge click. + HumanApprover string `json:"human_approver,omitempty"` + ManualMerge bool `json:"manual_merge,omitempty"` + NudgeCount int `json:"nudge_count,omitempty"` + LastNudgeAt *time.Time `json:"last_nudge_at,omitempty"` + AdoptedBy int `json:"adopted_by,omitempty"` // ClaimantKind is the author kind of whoever holds the live claim on a // claimed issue (human / clanker / hive), from the worker-claim ledger. ClaimantKind string `json:"claimant_kind,omitempty"` @@ -573,16 +584,19 @@ func stageTrackerTier(labels []string) string { // named in SentinelReason. const stageTrackerSentinelMoreFormat = " (+%d more)" -// stageTrackerSentinel reports whether the sentinel flagged repo#number at -// head: the PR wears the configured alert label (the sweep's blocking -// signal, read from the live labels so a webhook label patch flips it at -// once) or the verified review evidence bundle for head records sentinel -// findings (how a trusted author's notice-only finding is seen, since those -// carry a comment rather than the label). The findings count and the first -// finding's summary come from the bundle; both are empty when only the -// label says so. One file read per PR with a known head, ENOENT when the -// sentinel never wrote one; the tracker payload is memoised so this runs -// once per snapshot, not per request. +// stageTrackerSentinel reports whether the sentinel alert on repo#number +// at head still stands. The live labels decide: the sweep announces a +// blocking finding through the configured alert label, and a maintainer +// removing that label is the sweep's own clearance signal +// (sentinelClearedByMaintainer), so a webhook label patch flips the gate at +// once. The verified review evidence bundle for head supplies the findings +// count and the first finding's summary, and promotes the alert on its own +// only for a notice-only finding (a trusted author's PR: comment, never the +// label), since no label ever carried that one. A blocking finding whose +// label is gone is reported as cleared — findings and reason still fill +// the tooltip, alert does not. One file read per PR with a known head, +// ENOENT when the sentinel never wrote one; the tracker payload is memoised +// so this runs once per snapshot, not per request. func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, repo string, number int, head string, labels []string) (alert bool, findings int, reason string) { label := s.sentinelLabel() for _, l := range labels { @@ -606,7 +620,13 @@ func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, r if findings > 1 { reason += fmt.Sprintf(stageTrackerSentinelMoreFormat, findings-1) } - return true, findings, reason + for _, f := range b.Sentinel { + if f.Notice { + alert = true + break + } + } + return alert, findings, reason } func stageTrackerModifiers(labels []string, hiveID string, rec stagelabels.Record, hasRec bool, overrides map[string]time.Duration, now time.Time, draft bool) []string { set := map[string]bool{} @@ -681,6 +701,13 @@ func humanizeStageReason(reason string) string { if r == "" { return "" } + if base, approver := stagelabels.HumanApprovedReason(r); approver != "" { + clause := humanizeStageReason(base) + if clause == "" { + return "approved by @" + approver + } + return clause + " — approved by @" + approver + } lower := strings.ToLower(r) switch lower { case "actionable", "live agent claim", "live issue claim", "open pr covers it": @@ -754,12 +781,31 @@ func humanizeStageReason(reason string) string { if strings.HasPrefix(lower, "status-") || strings.HasPrefix(lower, "check-") { return "CI is red (" + r + ")" } + switch lower { + case stageengineprstage.ContributorLaneReasonWorkflowPath: + return "workflow path" + case stageengineprstage.ContributorLaneReasonTestsRemoved: + return "tests removed" + case stageengineprstage.AutoMergeReasonHumanMergePath: + return "human-merge path" + } if rest, ok := strings.CutPrefix(lower, "contributor-lane:"); ok { return strings.ReplaceAll(strings.ReplaceAll(rest, "-", " "), "_", " ") } return strings.NewReplacer("-", " ", "_", " ", ":", ": ").Replace(r) } +// stageTrackerManualMergeReason reports whether a bare stage reason is a +// lane rule the hive never merges unattended, so a 090 under it is waiting +// on a maintainer's merge click rather than on /lgtm /approve. +func stageTrackerManualMergeReason(reason string) bool { + switch strings.ToLower(strings.TrimSpace(reason)) { + case stageengineprstage.ContributorLaneReasonWorkflowPath, stageengineprstage.ContributorLaneReasonTestsRemoved, stageengineprstage.AutoMergeReasonHumanMergePath: + return true + } + return false +} + // trackerSoakRemainingRE pulls the time left out of the lane's // `contributor-lane:soaking(remaining=12m0s)` reason. var trackerSoakRemainingRE = regexp.MustCompile(`remaining=([0-9hms.]+)`) @@ -884,6 +930,13 @@ func stageTrackerCaption(stage stagelabels.Stage, reason, author string, kind st case stagelabels.NeedsDecision, stagelabels.IssueNeedsDecision: return joinClause("A human decision is owed", clause), "maintainer" case stagelabels.ReadyForHumanMerge: + if base, approver := stagelabels.HumanApprovedReason(reason); stageTrackerManualMergeReason(base) { + c := "Awaiting human merge (" + humanizeStageReason(base) + ")" + if approver != "" { + c += " — approved by @" + approver + } + return c + "; the hive never merges this itself: click Merge (or /lgtm + /approve for tide)", "maintainer" + } return joinClause("Ready for a maintainer's /lgtm /approve; the hive cannot merge it itself", clause), "maintainer" case stagelabels.PreMergeSoak: return joinClause("Admitted by the automerge lane; the pre-merge soak window is running", clause), "automerge lane" @@ -1072,6 +1125,9 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto it.Modifiers = slices.DeleteFunc(it.Modifiers, func(m string) bool { return m == modNeedsTriage }) } it.Caption, it.Actor = stageTrackerCaption(stage, it.Reason, it.Author, it.Kind, it.Mirrored, rec, hasRec, it.LinkedPR, it.Head) + base, approver := stagelabels.HumanApprovedReason(it.Reason) + it.HumanApprover = approver + it.ManualMerge = stageTrackerManualMergeReason(base) it.History = stageTrackerHistory(rec) } seen := map[string]bool{} @@ -1171,7 +1227,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } finish(&it, pr.Labels, labelStage(pr.Labels), rec, ok, pr.Draft) it.SentinelAlert, it.SentinelFindings, it.SentinelReason = s.stageTrackerSentinel(evidenceVerifier, repoName, pr.Number, pr.HeadSHA, pr.Labels) - it.LinkedIssues = stageTrackerPRLinkedIssues(pr, status.GitHubBaseURL) + it.LinkedIssues = stageTrackerPRLinkedIssues(pr, repoName, status.GitHubBaseURL) add(it) } for _, repo := range status.Repos { @@ -1418,20 +1474,28 @@ func (s *Server) handleStageTracker(w http.ResponseWriter, r *http.Request) { // and carries no Via; the softer tiers keep theirs so the UI can mark them. // Mention-tier entries are provisional: stageTrackerResolveLinkedPRs drops // them unless the number is an issue listed in the response. -func stageTrackerPRLinkedIssues(pr github.PullRequest, baseURL string) []StageTrackerLinkedIssue { +// +// repoName is the PR's repository as owner/name. pr.Repo may be the config's +// short name ("hive") while GitHub's closing references carry the full one +// ("hivecommons/hive"): the two name the same repository, so a titled +// closing link is kept — not dropped for the untitled text reference that +// rendered "(title unavailable)" — and the fallback URL is built from the +// full name, never from the short one. +func stageTrackerPRLinkedIssues(pr github.PullRequest, repoName, baseURL string) []StageTrackerLinkedIssue { var out []StageTrackerLinkedIssue seen := map[int]bool{} + full := nonEmpty(strings.TrimSpace(repoName), pr.Repo) add := func(li github.PRLinkedIssue, via string) { if li.Number <= 0 || li.Number == pr.Number || seen[li.Number] { return } - if li.Repo != "" && !strings.EqualFold(li.Repo, pr.Repo) { + if li.Repo != "" && !stageTrackerSameRepo(li.Repo, pr.Repo) && !stageTrackerSameRepo(li.Repo, full) { return } seen[li.Number] = true out = append(out, StageTrackerLinkedIssue{ Number: li.Number, Title: li.Title, State: strings.ToLower(strings.TrimSpace(li.State)), - URL: overviewItemURL(li.URL, pr.Repo, li.Number, "issue", baseURL), Via: via, + URL: overviewItemURL(li.URL, full, li.Number, "issue", baseURL), Via: via, }) } for _, li := range pr.LinkedIssues { @@ -1447,6 +1511,31 @@ func stageTrackerPRLinkedIssues(pr github.PullRequest, baseURL string) []StageTr return out } +// stageTrackerSameRepo reports whether two repository names denote the +// same repository: equal ignoring case, or one is the bare name of the +// other's owner/name form. +func stageTrackerSameRepo(a, b string) bool { + a, b = strings.TrimSpace(a), strings.TrimSpace(b) + if a == "" || b == "" { + return false + } + if strings.EqualFold(a, b) { + return true + } + shortA, shortB := a, b + if i := strings.LastIndex(a, "/"); i >= 0 { + shortA = a[i+1:] + } + if i := strings.LastIndex(b, "/"); i >= 0 { + shortB = b[i+1:] + } + // Both fully qualified but different owners: different repositories. + if strings.Contains(a, "/") && strings.Contains(b, "/") { + return false + } + return strings.EqualFold(shortA, shortB) +} + // stageTrackerLinkSoft reports whether a linked issue is a reference link // rather than a closing one. func stageTrackerLinkSoft(li StageTrackerLinkedIssue) bool { diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index 5e5c59e683..a8dcb5b6b8 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -250,6 +250,7 @@ func TestStageTrackerMotionDetector(t *testing.T) { jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_DECISION_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_NEEDED"), @@ -380,6 +381,7 @@ func TestStageTrackerMotionRowStamp(t *testing.T) { jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_DECISION_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_NEEDED"), @@ -478,6 +480,7 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) { jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_NEEDED"), jsConstLine(t, html, "STAGE_TRACKER_POSSIBLY_EXISTS"), diff --git a/src/pkg/dashboard/stage_tracker_reference_links_test.go b/src/pkg/dashboard/stage_tracker_reference_links_test.go index 377ac2c81b..14651892db 100644 --- a/src/pkg/dashboard/stage_tracker_reference_links_test.go +++ b/src/pkg/dashboard/stage_tracker_reference_links_test.go @@ -121,7 +121,7 @@ func TestStageTrackerPRLinkedIssuesOrdersClosingFirst(t *testing.T) { pr := github.PullRequest{Repo: "acme/console", Number: 50, LinkedIssues: []github.PRLinkedIssue{{Number: 9, Title: "Nine", State: "OPEN"}}, ReferencedIssues: []github.PRLinkedIssue{{Number: 11, Repo: "acme/console", Via: github.PRLinkViaTitle}, {Number: 9, Repo: "acme/console", Via: github.PRLinkViaRefs}, {Number: 50, Repo: "acme/console", Via: github.PRLinkViaRefs}, {Number: 12, Repo: "acme/console", Via: github.PRLinkViaFixes}}} - got := stageTrackerPRLinkedIssues(pr, "https://github.com") + got := stageTrackerPRLinkedIssues(pr, "", "https://github.com") if len(got) != 3 || got[0].Number != 9 || got[0].Via != "" || got[0].State != "open" || got[1].Number != 11 || got[1].Via != github.PRLinkViaTitle || got[2].Number != 12 || got[2].Via != "" { t.Fatalf("got %+v", got) } diff --git a/src/pkg/dashboard/stage_tracker_regressed_test.go b/src/pkg/dashboard/stage_tracker_regressed_test.go index 91327864a4..6e7ed5a950 100644 --- a/src/pkg/dashboard/stage_tracker_regressed_test.go +++ b/src/pkg/dashboard/stage_tracker_regressed_test.go @@ -74,6 +74,7 @@ func TestStageTrackerRegressedPillExplainsItself(t *testing.T) { jsConstLine(t, html, "STAGE_TRACKER_MOD_TEXT"), jsFunc(t, html, "stageTrackerStageWord"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), stageTrackerSentinelJS(t, html), jsFunc(t, html, "stageTrackerRegressionText"), jsFunc(t, html, "stageTrackerChipsHtml"), diff --git a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go index 9e75fc3110..301689fcbd 100644 --- a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go +++ b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go @@ -81,6 +81,7 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), jsConstLine(t, html, "STAGE_TRACKER_CLOSED_ISSUE_TITLE"), jsConstLine(t, html, "STAGE_TRACKER_UNTITLED_ISSUE"), @@ -198,6 +199,7 @@ const stages = [ { number: 50, label: 'Review pending', short: 'CI / Review' }, { number: 60, label: 'Reviewed', short: 'Reviewed' }, { number: 70, label: 'Fixing', short: 'Fixing', branch_from: 50 }, { number: 71, label: 'Needs author', short: 'Needs author', branch_from: 50 }, { number: 80, label: 'Awaiting merge admission', short: 'Merge gate' }, { number: 85, label: 'Needs human decision', short: 'Needs human decision', branch_from: 80 }, + { number: 90, label: 'Ready for human merge', short: 'Ready for human merge', branch_from: 80 }, { number: 100, label: 'Merge queue', short: 'Merge queue' }, { number: 110, label: 'Merged', short: 'Merged' }, ]; const P = (repo, n, stage, extra) => Object.assign({ kind: 'pr', repo, number: n, stage, title: 'PR ' + n, url: 'https://x/' + n, author: 'ann', author_kind: 'human', stage_since: '2026-01-01T11:00:00Z', created_at: '2026-01-01T10:00:00Z', modifiers: [] }, extra || {}); diff --git a/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go b/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go index ab21d602c5..47c126904d 100644 --- a/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go +++ b/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go @@ -31,6 +31,18 @@ func stageTrackerSentinelJS(t *testing.T, html string) string { }, "\n") } +// stageTrackerManualMergeJS is the 090 manual-merge surface (the stage +// number, the word and its builder) every harness that runs +// stageTrackerSegments needs beside the sentinel one. +func stageTrackerManualMergeJS(t *testing.T, html string) string { + t.Helper() + return strings.Join([]string{ + jsConstLine(t, html, "STAGE_TRACKER_READY_FOR_HUMAN_MERGE"), + jsConstLine(t, html, "STAGE_TRACKER_MANUAL_MERGE_WORD"), + jsFunc(t, html, "stageTrackerManualMergeWord"), + }, "\n") +} + func writeSentinelBundle(t *testing.T, root, repo string, number int, head string, findings []evidence.SentinelFinding) { t.Helper() path := github.ReviewEvidencePath(root, repo, number, head) @@ -68,8 +80,8 @@ func TestStageTrackerSentinelFlag(t *testing.T) { const headEvidence = "feedface0123456789abcdef0123456789abcdef" const headClean = "0badf00d0123456789abcdef0123456789abcdef" writeSentinelBundle(t, root, "acme/console", 110, headEvidence, []evidence.SentinelFinding{ - {Rule: "sensitive_path", Summary: "touches OWNERS", Paths: []string{"OWNERS"}}, - {Rule: "workflow_permissions", Summary: "widens workflow permissions"}, + {Rule: "sensitive_path", Summary: "touches OWNERS", Paths: []string{"OWNERS"}, Notice: true}, + {Rule: "workflow_permissions", Summary: "widens workflow permissions", Notice: true}, }) // A bundle for a superseded head says nothing about the current one. writeSentinelBundle(t, root, "acme/console", 111, "0ld0ld0ld", []evidence.SentinelFinding{{Rule: "test_removal", Summary: "deletes tests"}}) @@ -161,6 +173,56 @@ func TestStageTrackerSentinelFlag(t *testing.T) { } } +// TestStageTrackerSentinelLabelClearsBlockingBundle pins the fix for the +// stale "Sentinel alert · needs human" pill: a blocking finding (the +// sweep applied the label) whose label a maintainer has since removed is +// cleared — alert follows the live label, the bundle only fills the count +// and reason — while a notice-only finding (trusted author, no label ever) +// keeps flagging on the bundle alone, and a notice-only finding beside a +// blocking one still flags. +func TestStageTrackerSentinelLabelClearsBlockingBundle(t *testing.T) { + prev := github.ReviewEvidenceRoot + root := filepath.Join(t.TempDir(), "evidence") + github.ReviewEvidenceRoot = root + t.Cleanup(func() { github.ReviewEvidenceRoot = prev }) + s := newTestServer() + verifier := &github.ReviewEvidenceVerifier{} + const head = "d7fde650a3992abad2a2a2c55076ac18afeb5540" + blocking := []evidence.SentinelFinding{ + {Rule: "sensitive_path", Summary: "changes 1 sensitive path(s)", Paths: []string{".github/workflows/mutation.yml"}}, + {Rule: "workflow_permissions", Summary: "widens workflow permissions"}, + } + notice := []evidence.SentinelFinding{{Rule: "sensitive_path", Summary: "touches OWNERS", Notice: true}} + mixed := []evidence.SentinelFinding{blocking[0], notice[0]} + + tests := []struct { + name string + number int + findings []evidence.SentinelFinding + labels []string + wantAlert bool + wantFindings int + wantReason string + }{ + {name: "blocking bundle, label still on", number: 401, findings: blocking, labels: []string{"lgtm", config.DefaultSentinelLabel}, wantAlert: true, wantFindings: 2, wantReason: "changes 1 sensitive path(s) (+1 more)"}, + {name: "blocking bundle, label removed by maintainer", number: 402, findings: blocking, labels: []string{"lgtm", "stage/085-needs-decision"}, wantAlert: false, wantFindings: 2, wantReason: "changes 1 sensitive path(s) (+1 more)"}, + {name: "notice-only bundle, never labelled", number: 403, findings: notice, labels: []string{"stage/050-review-pending"}, wantAlert: true, wantFindings: 1, wantReason: "touches OWNERS"}, + {name: "notice beside blocking, label removed", number: 404, findings: mixed, labels: nil, wantAlert: true, wantFindings: 2, wantReason: "changes 1 sensitive path(s) (+1 more)"}, + {name: "no bundle, no label", number: 405, labels: []string{"lgtm"}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.findings != nil { + writeSentinelBundle(t, root, "acme/console", tt.number, head, tt.findings) + } + alert, findings, reason := s.stageTrackerSentinel(verifier, "acme/console", tt.number, head, tt.labels) + if alert != tt.wantAlert || findings != tt.wantFindings || reason != tt.wantReason { + t.Fatalf("stageTrackerSentinel = alert %v findings %d reason %q, want %v %d %q", alert, findings, reason, tt.wantAlert, tt.wantFindings, tt.wantReason) + } + }) + } +} + // TestStageTrackerSentinelConfiguredLabel: the flag follows sentinel.label, // not the default name. func TestStageTrackerSentinelConfiguredLabel(t *testing.T) { @@ -308,6 +370,16 @@ assert.ok(subs[0].includes('Sentinel alert · needs human') && subs[0].includes( assert.ok(!subs[1].includes('entinel'), subs[1]); assert.ok(!multi.slice(0, multi.indexOf('
Awaiting human merge · approved by @clubanderson'), 'manual-merge 090 lane word: ' + manual); +assert.ok(!manual.includes('entinel') && !manual.includes('Needs human decision'), manual); +const plain090 = stageTrackerRowHtml(P('o/r', 402, 90, { reason: 'untrusted-author-role' }), stages, ctx); +assert.ok(!plain090.includes('Awaiting human merge') && plain090.includes('Ready for human merge'), 'a trust-blocked 090 keeps the stage word: ' + plain090); + // Decide… preface: one line per flagged PR, nothing for clean ones. assert.strictEqual(stageTrackerSentinelPreface([P('o/r', 109, 85, flagged), P('o/r', 104, 85)]), '⚠ o/r#109 — ' + TIP); assert.strictEqual(stageTrackerSentinelPreface([P('o/r', 104, 85)]), ''); diff --git a/src/pkg/dashboard/stage_tracker_test.go b/src/pkg/dashboard/stage_tracker_test.go index 203287520a..4515a07cd4 100644 --- a/src/pkg/dashboard/stage_tracker_test.go +++ b/src/pkg/dashboard/stage_tracker_test.go @@ -101,6 +101,11 @@ func TestHumanizeStageReason(t *testing.T) { "base-branch-red:docker (hive),docker (hub)": "waiting for the base branch's CI to recover (docker (hive), docker (hub)) — not this PR's fault", "shared-ci-incident:13208": "deferred to shared-CI incident #13208 — not this PR's fault", "fork-guard:Canary": "check Canary refuses fork PRs — a maintainer must push this branch to the repository", + "contributor-lane:workflow-path": "workflow path", + "contributor-lane:tests-removed": "tests removed", + "human-merge-path": "human-merge path", + "contributor-lane:workflow-path:human-approved@clubanderson": "workflow path — approved by @clubanderson", + "reviewer-verdict:requires_human:human-approved@octocat": "review verdict requires human — approved by @octocat", } for in, want := range cases { if got := humanizeStageReason(in); got != want { @@ -109,6 +114,89 @@ func TestHumanizeStageReason(t *testing.T) { } } +// TestStageTrackerManualMergeApproved: a 090 record under a manual-merge +// lane rule the trusted merger approved (reason suffixed +// `:human-approved@login`) renders "Awaiting human merge (workflow path) — +// approved by @login" with the one step left, and the payload carries the +// approver and manual_merge so the lit chevron can say the same; a +// trust-blocked 090 and an unapproved rule are unchanged. +func TestStageTrackerManualMergeApproved(t *testing.T) { + tests := []struct { + name string + stage stagelabels.Stage + reason string + wantCaption string + wantApprover string + wantManual bool + wantActor string + wantNoCaption string + }{ + { + name: "workflow path approved", stage: stagelabels.ReadyForHumanMerge, reason: "contributor-lane:workflow-path:human-approved@clubanderson", + wantCaption: "Awaiting human merge (workflow path) — approved by @clubanderson; the hive never merges this itself: click Merge (or /lgtm + /approve for tide)", + wantApprover: "clubanderson", wantManual: true, wantActor: "maintainer", + }, + { + name: "tests removed, approver unknown", stage: stagelabels.ReadyForHumanMerge, reason: "contributor-lane:tests-removed", + wantCaption: "Awaiting human merge (tests removed); the hive never merges this itself: click Merge (or /lgtm + /approve for tide)", + wantManual: true, wantActor: "maintainer", + }, + { + name: "trust-blocked 090 unchanged", stage: stagelabels.ReadyForHumanMerge, reason: "untrusted-author-role", + wantCaption: "Ready for a maintainer's /lgtm /approve; the hive cannot merge it itself — untrusted author role", wantActor: "maintainer", + }, + { + name: "requires_human approved at 090", stage: stagelabels.ReadyForHumanMerge, reason: "reviewer-verdict:requires_human:human-approved@octocat", + wantCaption: "Ready for a maintainer's /lgtm /approve; the hive cannot merge it itself — review verdict requires human — approved by @octocat", + wantApprover: "octocat", wantActor: "maintainer", + }, + { + name: "workflow path still at 085", stage: stagelabels.NeedsDecision, reason: "contributor-lane:workflow-path", + wantCaption: "A human decision is owed — workflow path", wantManual: true, wantActor: "maintainer", wantNoCaption: "approved", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + caption, actor := stageTrackerCaption(tt.stage, tt.reason, "pat", "pr", false, stagelabels.Record{}, false, 0, "") + if caption != tt.wantCaption || actor != tt.wantActor { + t.Fatalf("caption = %q actor %q, want %q %q", caption, actor, tt.wantCaption, tt.wantActor) + } + if tt.wantNoCaption != "" && strings.Contains(caption, tt.wantNoCaption) { + t.Fatalf("caption %q must not say %q", caption, tt.wantNoCaption) + } + base, approver := stagelabels.HumanApprovedReason(tt.reason) + if approver != tt.wantApprover || stageTrackerManualMergeReason(base) != tt.wantManual { + t.Fatalf("approver %q manual %v, want %q %v", approver, stageTrackerManualMergeReason(base), tt.wantApprover, tt.wantManual) + } + }) + } + + // End to end through the payload: the store record's reason fills + // human_approver / manual_merge on the row. + now := time.Date(2026, 10, 27, 14, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + store.Observe(stagelabels.Key("acme/console", 120), stagelabels.ReadyForHumanMerge, "contributor-lane:workflow-path:human-approved@clubanderson") + s.statusMu.Lock() + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: 120, Title: "Shard nightly", Author: "pat", Labels: []string{"stage/090-ready-for-human-merge", "lgtm"}}}) + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + it := trackerItem(t, resp, "pr", 120) + if it.Stage != 90 || it.HumanApprover != "clubanderson" || !it.ManualMerge || !strings.HasPrefix(it.Caption, "Awaiting human merge (workflow path) — approved by @clubanderson") { + t.Fatalf("row = stage %d approver %q manual %v caption %q", it.Stage, it.HumanApprover, it.ManualMerge, it.Caption) + } + raw, err := json.Marshal(it) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(raw), `"human_approver":"clubanderson","manual_merge":true`) { + t.Fatalf("payload lacks the manual-merge fields: %s", raw) + } + if clean := trackerItem(t, resp, "pr", 101); clean.HumanApprover != "" || clean.ManualMerge { + t.Fatalf("PR 101 must not carry manual-merge fields: %+v", clean) + } +} + func stageTrackerFixture(t *testing.T, now time.Time) (*Server, *stagelabels.Store) { t.Helper() s := newTestServer() @@ -599,23 +687,43 @@ func TestStageTrackerPRSidePairing(t *testing.T) { } func TestStageTrackerPRLinkedIssues(t *testing.T) { - pr := github.PullRequest{Repo: "acme/console", Number: 42} tests := []struct { - name string - linked []github.PRLinkedIssue - want []StageTrackerLinkedIssue + name string + pr github.PullRequest + repoName string + linked []github.PRLinkedIssue + refs []github.PRLinkedIssue + want []StageTrackerLinkedIssue }{ - {"none", nil, nil}, - {"same repo bare", []github.PRLinkedIssue{{Number: 7}}, []StageTrackerLinkedIssue{{Number: 7, URL: "https://github.com/acme/console/issues/7"}}}, - {"explicit same repo, any case, state lower-cased", []github.PRLinkedIssue{{Number: 7, Repo: "Acme/Console", State: "CLOSED", URL: "https://gh/7"}}, []StageTrackerLinkedIssue{{Number: 7, URL: "https://gh/7", State: "closed"}}}, - {"foreign repo dropped", []github.PRLinkedIssue{{Number: 7, Repo: "acme/other"}}, nil}, - {"self and non-positive dropped", []github.PRLinkedIssue{{Number: 42}, {Number: 0}, {Number: -1}}, nil}, - {"multiple, deduplicated, order kept", []github.PRLinkedIssue{{Number: 9}, {Number: 7}, {Number: 9}}, []StageTrackerLinkedIssue{{Number: 9, URL: "https://github.com/acme/console/issues/9"}, {Number: 7, URL: "https://github.com/acme/console/issues/7"}}}, + {name: "none", pr: github.PullRequest{Repo: "acme/console", Number: 42}}, + {name: "same repo bare", pr: github.PullRequest{Repo: "acme/console", Number: 42}, linked: []github.PRLinkedIssue{{Number: 7}}, want: []StageTrackerLinkedIssue{{Number: 7, URL: "https://github.com/acme/console/issues/7"}}}, + {name: "explicit same repo, any case, state lower-cased", pr: github.PullRequest{Repo: "acme/console", Number: 42}, linked: []github.PRLinkedIssue{{Number: 7, Repo: "Acme/Console", State: "CLOSED", URL: "https://gh/7"}}, want: []StageTrackerLinkedIssue{{Number: 7, URL: "https://gh/7", State: "closed"}}}, + {name: "foreign repo dropped", pr: github.PullRequest{Repo: "acme/console", Number: 42}, linked: []github.PRLinkedIssue{{Number: 7, Repo: "acme/other"}}}, + {name: "same name, other owner dropped", pr: github.PullRequest{Repo: "hive", Number: 42}, repoName: "hivecommons/hive", linked: []github.PRLinkedIssue{{Number: 7, Repo: "fork/hive", Title: "Theirs"}}}, + {name: "self and non-positive dropped", pr: github.PullRequest{Repo: "acme/console", Number: 42}, linked: []github.PRLinkedIssue{{Number: 42}, {Number: 0}, {Number: -1}}}, + {name: "multiple, deduplicated, order kept", pr: github.PullRequest{Repo: "acme/console", Number: 42}, linked: []github.PRLinkedIssue{{Number: 9}, {Number: 7}, {Number: 9}}, want: []StageTrackerLinkedIssue{{Number: 9, URL: "https://github.com/acme/console/issues/9"}, {Number: 7, URL: "https://github.com/acme/console/issues/7"}}}, + { + // hivecommons/hive#14568: the config names the repo "hive", the + // GraphQL closing reference says "hivecommons/hive". The titled + // closing link must win over the untitled `Fixes #14567` text + // reference, and the fallback URL must carry the owner. + name: "short config name vs full closing-ref name keeps the title", + pr: github.PullRequest{Repo: "hive", Number: 14568}, repoName: "hivecommons/hive", + linked: []github.PRLinkedIssue{{Number: 14567, Repo: "hivecommons/hive", Title: "Runner stalls", State: "CLOSED", URL: "https://github.com/hivecommons/hive/issues/14567"}}, + refs: []github.PRLinkedIssue{{Number: 14567, Repo: "hive", Via: github.PRLinkViaFixes}, {Number: 14560, Repo: "hive", Via: github.PRLinkViaRefs}}, + want: []StageTrackerLinkedIssue{ + {Number: 14567, Title: "Runner stalls", State: "closed", URL: "https://github.com/hivecommons/hive/issues/14567"}, + {Number: 14560, URL: "https://github.com/hivecommons/hive/issues/14560", Via: github.PRLinkViaRefs}, + }, + }, + {name: "short name only builds the URL from the full repo", pr: github.PullRequest{Repo: "hive", Number: 1}, repoName: "hivecommons/hive", linked: []github.PRLinkedIssue{{Number: 7}}, want: []StageTrackerLinkedIssue{{Number: 7, URL: "https://github.com/hivecommons/hive/issues/7"}}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + pr := tt.pr pr.LinkedIssues = tt.linked - got := stageTrackerPRLinkedIssues(pr, "") + pr.ReferencedIssues = tt.refs + got := stageTrackerPRLinkedIssues(pr, tt.repoName, "") if len(got) != len(tt.want) { t.Fatalf("got %+v, want %+v", got, tt.want) } @@ -628,6 +736,28 @@ func TestStageTrackerPRLinkedIssues(t *testing.T) { } } +func TestStageTrackerSameRepo(t *testing.T) { + tests := []struct { + a, b string + want bool + }{ + {"hivecommons/hive", "hivecommons/hive", true}, + {"HiveCommons/Hive", "hivecommons/hive", true}, + {"hive", "hivecommons/hive", true}, + {"hivecommons/hive", "hive", true}, + {"hive", "hive", true}, + {"fork/hive", "hivecommons/hive", false}, + {"hivecommons/docs", "hive", false}, + {"", "hive", false}, + {"hive", "", false}, + } + for _, tt := range tests { + if got := stageTrackerSameRepo(tt.a, tt.b); got != tt.want { + t.Errorf("stageTrackerSameRepo(%q, %q) = %v, want %v", tt.a, tt.b, got, tt.want) + } + } +} + // A closed issue is never a tracker row, whatever stage label it closed // wearing (hivecommons/homebrew-hive#127); and a 045 store record whose // issue has lost every park label — a `/hive decision` the engine has not diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index bde460441f..5c6146cff7 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -92,6 +92,7 @@ func TestStageTrackerRows(t *testing.T) { jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), jsConstLine(t, html, "STAGE_TRACKER_CLOSED_ISSUE_TITLE"), jsConstLine(t, html, "STAGE_TRACKER_UNTITLED_ISSUE"), @@ -703,6 +704,7 @@ func TestStageTrackerFilterSortPage(t *testing.T) { stageTrackerSentinelJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_PATH"), jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + stageTrackerManualMergeJS(t, html), jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), jsConstLine(t, html, "STAGE_TRACKER_CLOSED_ISSUE_TITLE"), jsConstLine(t, html, "STAGE_TRACKER_UNTITLED_ISSUE"), diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 1ac61344d6..dbb333a550 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -13646,6 +13646,17 @@

Where to get help

const STAGE_TRACKER_MERGE_COLUMN = 80; const STAGE_TRACKER_NEEDS_DECISION = 85; const STAGE_TRACKER_ISSUE_NEEDS_DECISION = 45; + // 090 under a manual-merge lane rule (payload manual_merge: CI workflow / + // action edits, removed tests, a human-merge path): the hive never merges + // it itself, so the lit chevron says what is actually owed — the + // maintainer's merge click — and names who already approved the head + // (payload human_approver) instead of the generic stage word. + const STAGE_TRACKER_READY_FOR_HUMAN_MERGE = 90; + const STAGE_TRACKER_MANUAL_MERGE_WORD = 'Awaiting human merge'; + function stageTrackerManualMergeWord(item) { + const approver = String((item && item.human_approver) || '').trim(); + return STAGE_TRACKER_MANUAL_MERGE_WORD + (approver ? ' · approved by @' + approver : ''); + } // Issue-slot placeholders for a closing reference whose title the server // could not resolve (the issue is closed and unreadable, or of unknown state). const STAGE_TRACKER_CLOSED_ISSUE_TITLE = '(closed issue)'; @@ -13887,7 +13898,7 @@

Where to get help

const terminal = anchor >= STAGE_TRACKER_TERMINAL; const sentinelLane = stageTrackerSentinelInLane(item); const detour = (!terminal && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) - ? { text: sentinelLane ? STAGE_TRACKER_SENTINEL_WORD : (STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur)), sentinel: sentinelLane } : null; + ? { text: sentinelLane ? STAGE_TRACKER_SENTINEL_WORD : (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.manual_merge ? stageTrackerManualMergeWord(item) : (STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))), sentinel: sentinelLane } : null; const segs = STAGE_TRACKER_PATH.map(n => { const st = n === 0 ? { label: 'Open', short: 'Open', description: 'Open, not yet in a stage' } : (byNum[n] || {}); let state = 'todo'; diff --git a/src/pkg/evidence/evidence.go b/src/pkg/evidence/evidence.go index 284d749a13..8c7ca324b4 100644 --- a/src/pkg/evidence/evidence.go +++ b/src/pkg/evidence/evidence.go @@ -162,11 +162,17 @@ type Check struct { URL string `json:"url,omitempty"` } -// SentinelFinding records why the sentinel sweep flagged the PR. +// SentinelFinding records why the sentinel sweep flagged the PR. Notice +// marks a notice-only finding: the sweep commented but never applied the +// alert label (a trusted author's PR), so the finding is the only record +// of the alert. A finding without Notice was announced through the label, +// and the live label — not this record — says whether it still stands: +// a maintainer removing the label is the sweep's clearance signal. type SentinelFinding struct { Rule string `json:"rule"` Summary string `json:"summary"` Paths []string `json:"paths,omitempty"` + Notice bool `json:"notice,omitempty"` } // Action is a human action on the PR: approval, label change, hold lift. diff --git a/src/pkg/evidence/schema/v1.json b/src/pkg/evidence/schema/v1.json index 20ededba16..87126041ba 100644 --- a/src/pkg/evidence/schema/v1.json +++ b/src/pkg/evidence/schema/v1.json @@ -188,7 +188,8 @@ "properties": { "rule": {"type": "string", "minLength": 1}, "summary": {"type": "string"}, - "paths": {"type": "array", "items": {"type": "string"}} + "paths": {"type": "array", "items": {"type": "string"}}, + "notice": {"type": "boolean"} } }, "shadow_review_gate": { diff --git a/src/pkg/github/automerge/automerge_stage_human.go b/src/pkg/github/automerge/automerge_stage_human.go index 48ba0e6bcc..766d567a14 100644 --- a/src/pkg/github/automerge/automerge_stage_human.go +++ b/src/pkg/github/automerge/automerge_stage_human.go @@ -97,6 +97,15 @@ func (c *Engine) humanEvidence(ctx context.Context, tracker *StageTracker, key s HumanSummaries: append([]string(nil), contributorVerdict.HumanSummaries...), SelfAuthored: obs.Lane == stageLaneSelf, AuthorKind: obs.AuthorKind, + LaneReason: obs.Reason, + ManualMergeRule: manualMergeRuleReason(obs.Reason), + } + // A trusted merger's APPROVED review on exactly this head is the human + // decision the lane noted (latestTrustedHumanApproval): it settles a + // requires_human verdict and a manual-merge lane rule, so the route + // must not keep asking for a decision already made (hivecommons/hive#14568). + if approver := strings.TrimSpace(obs.Detail.HumanApprover); approver != "" && obs.HeadSHA != "" && strings.TrimSpace(obs.Detail.HumanApprovalHead) == obs.HeadSHA { + e.HumanApprover = approver } if rec, ok := c.stageStoreOrShared().Get(key); ok && rec.AdoptedHead != "" && rec.AdoptDiffFence != "" && rec.AdoptDiffFence == obs.Reason && e.CauseReason != "" { // An adopted head whose diff fence is the blocker: the 085 note @@ -132,6 +141,17 @@ func (c *Engine) humanEvidence(ctx context.Context, tracker *StageTracker, key s return e } +// manualMergeRuleReason reports whether a lane reason is a rule no review +// or reply overrides: the hive never merges the head unattended, a person +// clicks merge. +func manualMergeRuleReason(reason string) bool { + switch reason { + case contributorLaneReasonWorkflowPath, contributorLaneReasonTestsRemoved, autoMergeReasonHumanMergePath: + return true + } + return false +} + // routeHuman refines a lane's human hand-off into the stage the evidence // supports. It returns the route (with the lane-vocabulary reason to // record) and the evidence it was decided on, which the stage pass hands @@ -155,9 +175,12 @@ func (c *Engine) routeHuman(ctx context.Context, tracker *StageTracker, key stri // consume `/hive approve` on a PR: the release lever for `requires_human` is // a trusted merger's GitHub Approve review on the current head. func decisionActions(obs stageObservation, e stagelabels.Evidence) ([]string, bool) { - switch obs.Reason { - case contributorLaneReasonWorkflowPath, contributorLaneReasonTestsRemoved, autoMergeReasonHumanMergePath: - return []string{"A maintainer must review and merge this PR manually; a GitHub Approve review or `/hive approve` reply cannot override this lane's manual-merge rule."}, true + if manualMergeRuleReason(obs.Reason) { + action := "The hive never merges this change itself: a maintainer must click **Merge** on GitHub (or comment `/lgtm` + `/approve` for tide). A GitHub Approve review records the decision but does not merge, and `/hive approve` cannot override this lane's manual-merge rule." + if approver := strings.TrimSpace(e.HumanApprover); approver != "" { + action = "@" + approver + " has approved this head; the only step left is the merge. " + action + } + return []string{action}, true } var actions []string if len(e.ForkGuard) > 0 { diff --git a/src/pkg/github/automerge/pr_approve_command_test.go b/src/pkg/github/automerge/pr_approve_command_test.go index 63ad52999f..63a444ea26 100644 --- a/src/pkg/github/automerge/pr_approve_command_test.go +++ b/src/pkg/github/automerge/pr_approve_command_test.go @@ -100,20 +100,22 @@ func TestDecisionCommentNamesLaneAction(t *testing.T) { for _, tc := range []struct { name, lane, reason, want string holds, labels []string + approver string manual bool }{ {name: "self", lane: stageLaneSelf, want: "trusted merger can submit a GitHub **Approve** review"}, {name: "contributor", lane: stageLaneContributor, want: "ordinary contributor cannot release their own PR"}, {name: "trusted author", lane: stageLaneTrusted, want: "`/hive approve` replies on a PR are acknowledged but not consumed"}, - {name: "workflow", lane: stageLaneContributor, reason: contributorLaneReasonWorkflowPath, want: "merge this PR manually", manual: true}, - {name: "tests removed", lane: stageLaneContributor, reason: contributorLaneReasonTestsRemoved, want: "merge this PR manually", manual: true}, - {name: "human path", lane: stageLaneSelf, reason: autoMergeReasonHumanMergePath, want: "merge this PR manually", manual: true}, + {name: "workflow", lane: stageLaneContributor, reason: contributorLaneReasonWorkflowPath, want: "must click **Merge** on GitHub", manual: true}, + {name: "tests removed", lane: stageLaneContributor, reason: contributorLaneReasonTestsRemoved, want: "must click **Merge** on GitHub", manual: true}, + {name: "human path", lane: stageLaneSelf, reason: autoMergeReasonHumanMergePath, want: "must click **Merge** on GitHub", manual: true}, + {name: "workflow, approver named", lane: stageLaneContributor, reason: contributorLaneReasonWorkflowPath, approver: "octocat", want: "@octocat has approved this head; the only step left is the merge", manual: true}, {name: "label hold", lane: stageLaneSelf, holds: []string{"hold"}, want: "remove that label"}, {name: "label needs-human reason", lane: stageLaneTrusted, reason: "label:needs-human", want: "Answer the `needs-human` ask"}, {name: "label needs-human on the PR", lane: stageLaneTrusted, labels: []string{"Needs-Human"}, want: "Answer the `needs-human` ask"}, } { t.Run(tc.name, func(t *testing.T) { - e := stagelabels.Evidence{Verdict: stagelabels.VerdictRequiresHuman, Holds: tc.holds} + e := stagelabels.Evidence{Verdict: stagelabels.VerdictRequiresHuman, Holds: tc.holds, HumanApprover: tc.approver, Sentinel: tc.approver != ""} route := stagelabels.RouteHuman(e) route.Actions, route.ManualMerge = decisionActions(stageObservation{Lane: tc.lane, Reason: tc.reason, Labels: tc.labels}, e) body := stagelabels.DecisionComment(route) diff --git a/src/pkg/github/review_evidence.go b/src/pkg/github/review_evidence.go index 592bffc9ba..b211fc990e 100644 --- a/src/pkg/github/review_evidence.go +++ b/src/pkg/github/review_evidence.go @@ -455,8 +455,11 @@ func reviewEvidenceMergeFromPR(pr *gh.PullRequest, head string, now time.Time) * // already holds, so a head the relay has not written yet gets its bundle // started from it (author, base, policy) without another fetch. Like the // relay's writes, every failure is logged and swallowed: the alert label and -// comment are already on GitHub. -func (c *Client) recordReviewEvidenceSentinel(repo string, pr *gh.PullRequest, findings []sentinel.Finding, now time.Time) { +// comment are already on GitHub. blocked reports that the sweep applied the +// alert label for these findings; a notice-only pass (trusted author, +// comment but no label) records them with Notice set so readers know the +// label never carried this alert. +func (c *Client) recordReviewEvidenceSentinel(repo string, pr *gh.PullRequest, findings []sentinel.Finding, blocked bool, now time.Time) { settings, ok := c.reviewEvidenceSettings(repo) if !ok || pr == nil || len(findings) == 0 { return @@ -469,6 +472,7 @@ func (c *Client) recordReviewEvidenceSentinel(repo string, pr *gh.PullRequest, f var u reviewEvidenceUpdate for _, f := range findings { if ef, ok := evidenceSentinelFinding(f); ok { + ef.Notice = !blocked u.sentinel = append(u.sentinel, ef) } } diff --git a/src/pkg/github/review_evidence_complete_test.go b/src/pkg/github/review_evidence_complete_test.go index c5cbaf935e..6f808b1d0b 100644 --- a/src/pkg/github/review_evidence_complete_test.go +++ b/src/pkg/github/review_evidence_complete_test.go @@ -235,12 +235,14 @@ func TestRecordReviewEvidenceSentinel(t *testing.T) { {Rule: "", Summary: "no rule, dropped"}, } want := []evidence.SentinelFinding{{Rule: sentinel.RuleSensitivePath, Summary: "touches OWNERS", Paths: []string{"OWNERS", "z.yml"}}} + wantNotice := []evidence.SentinelFinding{{Rule: sentinel.RuleSensitivePath, Summary: "touches OWNERS", Paths: []string{"OWNERS", "z.yml"}, Notice: true}} tests := []struct { name string settings *ReviewEvidenceSettings seed bool corrupt bool + notice bool pr *gh.PullRequest findings []sentinel.Finding wantSentinel []evidence.SentinelFinding @@ -260,6 +262,10 @@ func TestRecordReviewEvidenceSentinel(t *testing.T) { name: "starts a bundle from the listed PR", settings: &ReviewEvidenceSettings{Enabled: true}, pr: evidenceSentinelPR("h1"), findings: findings, wantSentinel: want, }, + { + name: "notice-only pass marks the finding", settings: &ReviewEvidenceSettings{Enabled: true}, notice: true, + pr: evidenceSentinelPR("h1"), findings: findings, wantSentinel: wantNotice, + }, { name: "unreadable bundle left alone", settings: &ReviewEvidenceSettings{Enabled: true}, corrupt: true, pr: evidenceSentinelPR("h1"), findings: findings, @@ -282,7 +288,7 @@ func TestRecordReviewEvidenceSentinel(t *testing.T) { } c := evidenceTestClient(t, &evidencePRFixture{head: "h1"}, tt.settings) - c.recordReviewEvidenceSentinel("o/r", tt.pr, tt.findings, now) + c.recordReviewEvidenceSentinel("o/r", tt.pr, tt.findings, !tt.notice, now) if tt.wantNoBundle { if _, err := os.Stat(path); !os.IsNotExist(err) { @@ -311,7 +317,7 @@ func TestRecordReviewEvidenceSentinel(t *testing.T) { } // The same finding flagged again is not duplicated and the file is untouched. - c.recordReviewEvidenceSentinel("o/r", tt.pr, tt.findings, now.Add(time.Hour)) + c.recordReviewEvidenceSentinel("o/r", tt.pr, tt.findings, !tt.notice, now.Add(time.Hour)) if again := mustLoadBundle(t, root, "h1"); again.Hash != b.Hash || len(again.Sentinel) != len(tt.wantSentinel) { t.Fatalf("re-flag changed the bundle: %+v", again.Sentinel) } diff --git a/src/pkg/github/sentinel_sweep.go b/src/pkg/github/sentinel_sweep.go index d78174c5d3..6c1912b977 100644 --- a/src/pkg/github/sentinel_sweep.go +++ b/src/pkg/github/sentinel_sweep.go @@ -375,7 +375,7 @@ func (c *Client) sentinelEvaluatePR(ctx context.Context, result *SentinelSweepRe return } event.Repo = repo - c.recordReviewEvidenceSentinel(repo, pr, event.Findings, time.Now()) + c.recordReviewEvidenceSentinel(repo, pr, event.Findings, event.Blocked, time.Now()) if event.Blocked { result.Flagged = append(result.Flagged, event) } else if prHasLabel(pr, label) { diff --git a/src/pkg/stagelabels/human.go b/src/pkg/stagelabels/human.go index 3f5fbd8798..402193d967 100644 --- a/src/pkg/stagelabels/human.go +++ b/src/pkg/stagelabels/human.go @@ -130,6 +130,36 @@ type Evidence struct { // the author's to fix: only a maintainer can clear them, so they route // to 085 instead of the fixing stage (hivecommons/hive#14273). ForkGuard []string + // HumanApprover is the trusted merger whose GitHub APPROVED review sits + // on exactly Head ("" when none). It is the human decision on a + // requires_human verdict and on a manual-merge lane rule: the person + // read the reviewer's objection and ruled the head lands as-is. + HumanApprover string + // ManualMergeRule is true when CauseReason names a lane rule no + // approval can override — the hive never merges the head unattended + // (CI workflow / action edits, removed tests, a human-merge path). With + // HumanApprover set and nothing else outstanding the PR is at 090: + // the only step left is the merge click, not an open-ended decision. + ManualMergeRule bool + // LaneReason is the lane's raw reason token behind CauseReason + // ("contributor-lane:workflow-path"); the 090 route for an approved + // manual-merge rule records it suffixed with the approver. + LaneReason string +} + +// HumanApprovedReasonSuffix joins a lane reason to the trusted merger who +// approved the head: "contributor-lane:workflow-path:human-approved@octocat". +const HumanApprovedReasonSuffix = ":human-approved@" + +// HumanApprovedReason splits a reason carrying HumanApprovedReasonSuffix +// into the bare lane reason and the approver's login ("" when none). +func HumanApprovedReason(reason string) (base, approver string) { + reason = strings.TrimSpace(reason) + i := strings.LastIndex(reason, HumanApprovedReasonSuffix) + if i < 0 { + return reason, "" + } + return reason[:i], strings.TrimSpace(reason[i+len(HumanApprovedReasonSuffix):]) } // HoldLabels are the modifier labels that turn a human hand-off into a @@ -164,7 +194,9 @@ type Route struct { // ManualMerge means this lane has no unattended way past its rule. ManualMerge bool // Reasons explains the stage: what the author must fix (072/070), what - // a person must decide (085), what is still running (060). Empty for 090. + // a person must decide (085), what is still running (060). Empty for a + // trust-blocked 090; an approved manual-merge 090 names the rule and + // the approver. Reasons []string // LaneReason is a reason in the lanes' vocabulary for the 072/070 case // ("check-failing:", "conflicting", …) so the contributor nudge @@ -179,6 +211,9 @@ type Route struct { Head string SelfAuthored bool Verdict VerdictState + // HumanApprover is the trusted merger whose approval on Head settled + // the requires_human verdict / manual-merge rule ("" when none). + HumanApprover string } // Lane-vocabulary reasons RouteHuman emits for the fixing stages. @@ -244,10 +279,16 @@ func RouteHuman(e Evidence) Route { } decide = append(decide, subject+" `"+strings.Join(e.ForkGuard, "`, `")+"` "+verb+" pull requests from a fork, so neither the author nor the hive can turn "+it+" green: a maintainer must push this branch to the repository (or approve the run as the repository requires)") } + approver := strings.TrimSpace(e.HumanApprover) switch e.Verdict { case VerdictUnavailable: decide = append(decide, "no reviewer agent is configured, so this head will never get a swarm verdict") case VerdictRequiresHuman: + if approver != "" { + // The person the reviewer deferred to has approved this very + // head: the decision is made, not owed. + break + } decide = append(decide, "the reviewer swarm returned `requires_human` @"+ShortSHA(e.Head)) if q := strings.TrimSpace(e.DecisionQuestion); q != "" { if decisionQuestionPlaceholderMention(q) { @@ -268,13 +309,14 @@ func RouteHuman(e Evidence) Route { for _, h := range e.Holds { decide = append(decide, "the `"+h+"` label is set") } - if e.Cause == CauseDecision && strings.TrimSpace(e.CauseReason) != "" { + manualMergeApproved := e.Cause == CauseDecision && e.ManualMergeRule && approver != "" && strings.TrimSpace(e.CauseReason) != "" && len(decide) == 0 + if e.Cause == CauseDecision && strings.TrimSpace(e.CauseReason) != "" && !manualMergeApproved { decide = append(decide, e.CauseReason) - } else if e.Cause == CauseDecision && len(e.ForkGuard) == 0 { + } else if e.Cause == CauseDecision && len(e.ForkGuard) == 0 && !manualMergeApproved { decide = append(decide, "the automerge lane will not merge this unattended") } if len(decide) > 0 { - return Route{Stage: NeedsDecision, Reasons: decide, Summary: summary, Head: e.Head, SelfAuthored: e.SelfAuthored, Verdict: e.Verdict} + return Route{Stage: NeedsDecision, Reasons: decide, Summary: summary, Head: e.Head, SelfAuthored: e.SelfAuthored, Verdict: e.Verdict, HumanApprover: approver} } var wait []string switch { @@ -290,9 +332,21 @@ func RouteHuman(e Evidence) Route { wait = append(wait, fmt.Sprintf("soak %s remaining", (e.Soak-e.SoakElapsed).Round(time.Minute))) } if len(wait) > 0 { - return Route{Stage: Reviewed, Reasons: wait, Summary: summary} + return Route{Stage: Reviewed, Reasons: wait, Summary: summary, HumanApprover: approver} + } + if manualMergeApproved { + // A manual-merge lane rule the trusted merger has ruled on: the + // hive still never merges the head itself, so the PR is ready for + // the person's merge click — a 090 with one named step, not an + // open-ended 085 (hivecommons/hive#14568, rationguard#401). + route := Route{Stage: ReadyForHumanMerge, ManualMerge: true, Summary: summary, Head: e.Head, SelfAuthored: e.SelfAuthored, Verdict: e.Verdict, HumanApprover: approver, + Reasons: []string{e.CauseReason + "; @" + approver + " approved this head, so the only step left is the merge"}} + if lane := strings.TrimSpace(e.LaneReason); lane != "" { + route.LaneReason = lane + HumanApprovedReasonSuffix + approver + } + return route } - return Route{Stage: ReadyForHumanMerge, Summary: summary} + return Route{Stage: ReadyForHumanMerge, Summary: summary, HumanApprover: approver} } // decisionQuestionPlaceholderMentionRE matches the policy example's @@ -330,6 +384,9 @@ func summarize(e Evidence) string { default: parts = append(parts, "verdict pending @"+ShortSHA(e.Head)) } + if approver := strings.TrimSpace(e.HumanApprover); approver != "" { + parts = append(parts, "approved by @"+approver) + } switch { case !e.Checks.Known: parts = append(parts, "checks unknown") @@ -394,12 +451,33 @@ const ( // require_tiers). // // blockedBy is the prose for the trust cause ("" when unknown). +// +// An approved manual-merge route (r.ManualMerge) names the lane rule and +// the approver instead of a trust cause, and tells the person the one step +// left — the merge click — since no review or reply can make the hive +// merge CI workflow edits itself: +// +// Ready for a human merge: verdict requires_human @abc1234, approved by +// @octocat, 55/55 checks green, DCO yes. The PR edits CI workflow / +// action files, which the lane never merges unattended; @octocat approved +// this head, so the only step left is the merge. func ReadyComment(r Route, blockedBy string) string { var b strings.Builder b.WriteString(ReadyCommentMarker) b.WriteString("\nReady for a human merge: ") b.WriteString(r.Summary) b.WriteString(".") + if r.ManualMerge { + for _, reason := range r.Reasons { + if reason = strings.TrimSpace(reason); reason != "" { + b.WriteString(" ") + b.WriteString(strings.ToUpper(reason[:1]) + reason[1:]) + b.WriteString(".") + } + } + b.WriteString("\n\nThe hive never merges this lane's changes itself: click **Merge** (or `/lgtm` + `/approve` for tide) to land it.") + return b.String() + } if blockedBy = strings.TrimSpace(blockedBy); blockedBy != "" { b.WriteString(" Blocked only by ") b.WriteString(blockedBy) diff --git a/src/pkg/stagelabels/human_test.go b/src/pkg/stagelabels/human_test.go index 660b6d6e6b..5bf713e967 100644 --- a/src/pkg/stagelabels/human_test.go +++ b/src/pkg/stagelabels/human_test.go @@ -179,6 +179,154 @@ func TestRouteHumanDecision(t *testing.T) { } } +// TestRouteHumanApproved: a trusted merger's approval on the head is the +// human decision (hivecommons/hive#14568, rationguard#401). It settles a +// requires_human verdict, and with a manual-merge lane rule — the hive never +// merges CI workflow edits itself — it moves the PR to 090 with the one +// step left named: the merge click. Anything else still outstanding (the +// sentinel label still on, a hold, a reviewer-less verdict, a fork guard) +// keeps the 085 decision, and a rule the person has not approved stays +// an open 085 as before. +func TestRouteHumanApproved(t *testing.T) { + const workflow = "the PR edits CI workflow / action files, which the lane never merges unattended" + manual := func(e *Evidence) { + e.Cause, e.CauseReason, e.ManualMergeRule, e.LaneReason = CauseDecision, workflow, true, "contributor-lane:workflow-path" + } + cases := []struct { + name string + mutate func(*Evidence) + wantStage Stage + wantManual bool + wantLaneReason string + wantReason string + wantNoReason string + }{ + { + name: "requires_human approved, trust cause", + mutate: func(e *Evidence) { e.Verdict, e.HumanApprover = VerdictRequiresHuman, "octocat" }, + wantStage: ReadyForHumanMerge, + wantNoReason: "requires_human", + }, + { + name: "requires_human approved, workflow-path rule", + mutate: func(e *Evidence) { + e.Verdict, e.HumanApprover = VerdictRequiresHuman, "clubanderson" + manual(e) + }, + wantStage: ReadyForHumanMerge, wantManual: true, + wantLaneReason: "contributor-lane:workflow-path" + HumanApprovedReasonSuffix + "clubanderson", + wantReason: workflow + "; @clubanderson approved this head, so the only step left is the merge", + wantNoReason: "requires_human", + }, + { + name: "swarm approved, workflow-path rule, human approved", + mutate: func(e *Evidence) { e.HumanApprover = "octocat"; manual(e) }, + wantStage: ReadyForHumanMerge, + wantManual: true, + wantReason: workflow + "; @octocat approved this head", + }, + { + name: "workflow-path rule, nobody approved yet", + mutate: manual, + wantStage: NeedsDecision, + wantReason: workflow, + }, + { + name: "requires_human, nobody approved yet", + mutate: func(e *Evidence) { e.Verdict = VerdictRequiresHuman; manual(e) }, + wantStage: NeedsDecision, + wantReason: "the reviewer swarm returned `requires_human` @abc1234", + }, + { + name: "approved but the sentinel label is still on", + mutate: func(e *Evidence) { + e.Verdict, e.HumanApprover, e.Sentinel = VerdictRequiresHuman, "octocat", true + manual(e) + }, + wantStage: NeedsDecision, + wantReason: "a sentinel alert is open on this PR", + }, + { + name: "approved but a hold label is set", + mutate: func(e *Evidence) { + e.HumanApprover, e.Holds = "octocat", Holds([]string{"hold"}) + manual(e) + }, + wantStage: NeedsDecision, + wantReason: "the `hold` label is set", + }, + { + name: "approved but no reviewer configured", + mutate: func(e *Evidence) { e.Verdict, e.HumanApprover = VerdictUnavailable, "octocat"; manual(e) }, + wantStage: NeedsDecision, + wantReason: "no reviewer agent is configured, so this head will never get a swarm verdict", + }, + { + name: "approved, lane rule that is not a manual-merge rule", + mutate: func(e *Evidence) { + e.HumanApprover, e.Cause, e.CauseReason = "octocat", CauseDecision, "the reporter-trust hold is in place" + }, + wantStage: NeedsDecision, + wantReason: "the reporter-trust hold is in place", + }, + { + name: "approved manual rule still waits for pending checks", + mutate: func(e *Evidence) { + e.HumanApprover = "octocat" + e.Checks = CheckSummary{Total: 55, Green: 54, Pending: 1, Known: true} + manual(e) + }, + wantStage: Reviewed, + wantReason: "1 check(s) still running", + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + e := readyEvidence() + tc.mutate(&e) + r := RouteHuman(e) + if r.Stage != tc.wantStage || r.ManualMerge != tc.wantManual || r.LaneReason != tc.wantLaneReason { + t.Fatalf("route = %+v, want stage %s manual %v lane %q", r, tc.wantStage, tc.wantManual, tc.wantLaneReason) + } + if r.HumanApprover != e.HumanApprover { + t.Fatalf("route approver = %q, want %q", r.HumanApprover, e.HumanApprover) + } + joined := strings.Join(r.Reasons, "\n") + if tc.wantReason != "" && !strings.Contains(joined, tc.wantReason) { + t.Fatalf("reasons = %q, want %q", joined, tc.wantReason) + } + if tc.wantNoReason != "" && strings.Contains(joined, tc.wantNoReason) { + t.Fatalf("reasons = %q must not mention %q once a human approved", joined, tc.wantNoReason) + } + if e.HumanApprover != "" && !strings.Contains(r.Summary, "approved by @"+e.HumanApprover) { + t.Fatalf("summary = %q must name the approver", r.Summary) + } + if tc.wantStage == ReadyForHumanMerge && tc.wantManual { + got := ReadyComment(r, "`role/newcomer` (below require_tiers)") + if !strings.Contains(got, "click **Merge**") || strings.Contains(got, "Blocked only by") || !strings.Contains(got, "@"+e.HumanApprover+" approved this head") { + t.Fatalf("ReadyComment = %q", got) + } + } + if tc.wantStage == NeedsDecision && !strings.Contains(DecisionComment(r), tc.wantReason) { + t.Fatalf("DecisionComment = %q", DecisionComment(r)) + } + }) + } +} + +func TestHumanApprovedReason(t *testing.T) { + for _, tc := range []struct{ in, base, approver string }{ + {"contributor-lane:workflow-path:human-approved@octocat", "contributor-lane:workflow-path", "octocat"}, + {"reviewer-verdict:requires_human:human-approved@a-b", "reviewer-verdict:requires_human", "a-b"}, + {"contributor-lane:workflow-path", "contributor-lane:workflow-path", ""}, + {"", "", ""}, + } { + if base, approver := HumanApprovedReason(tc.in); base != tc.base || approver != tc.approver { + t.Errorf("HumanApprovedReason(%q) = %q, %q; want %q, %q", tc.in, base, approver, tc.base, tc.approver) + } + } +} + // TestRouteHumanWaits: pending checks, unreadable checks, or a soak still // running keep the PR at 060 so it never claims 090 early. func TestRouteHumanWaits(t *testing.T) { From 174db5bc3cd2e0492ecb5354ed7c2ab171642097 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Tue, 27 Oct 2026 10:49:30 -0400 Subject: [PATCH 2/4] test(stagelabels): pin the lane reason suffix in the octocat route case Signed-off-by: Andy Anderson --- src/pkg/stagelabels/human_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pkg/stagelabels/human_test.go b/src/pkg/stagelabels/human_test.go index 5bf713e967..036c8a2615 100644 --- a/src/pkg/stagelabels/human_test.go +++ b/src/pkg/stagelabels/human_test.go @@ -219,11 +219,12 @@ func TestRouteHumanApproved(t *testing.T) { wantNoReason: "requires_human", }, { - name: "swarm approved, workflow-path rule, human approved", - mutate: func(e *Evidence) { e.HumanApprover = "octocat"; manual(e) }, - wantStage: ReadyForHumanMerge, - wantManual: true, - wantReason: workflow + "; @octocat approved this head", + name: "swarm approved, workflow-path rule, human approved", + mutate: func(e *Evidence) { e.HumanApprover = "octocat"; manual(e) }, + wantStage: ReadyForHumanMerge, + wantManual: true, + wantLaneReason: "contributor-lane:workflow-path" + HumanApprovedReasonSuffix + "octocat", + wantReason: workflow + "; @octocat approved this head", }, { name: "workflow-path rule, nobody approved yet", From 01c4906eaad169383c60c79f57c64a95b93fcf76 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Tue, 27 Oct 2026 10:49:53 -0400 Subject: [PATCH 3/4] fix(dashboard): match linked-issue repos against the fully-qualified name only Signed-off-by: Andy Anderson --- src/pkg/dashboard/stage_tracker.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 3319e5fec1..30016606b2 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -1489,7 +1489,9 @@ func stageTrackerPRLinkedIssues(pr github.PullRequest, repoName, baseURL string) if li.Number <= 0 || li.Number == pr.Number || seen[li.Number] { return } - if li.Repo != "" && !stageTrackerSameRepo(li.Repo, pr.Repo) && !stageTrackerSameRepo(li.Repo, full) { + // Compare against the fully-qualified name when one is known so a + // same-named repository under another owner is still foreign. + if li.Repo != "" && !stageTrackerSameRepo(li.Repo, full) { return } seen[li.Number] = true From 17dd6f7f8210f9db37d026f548d860783c548ec0 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Tue, 27 Oct 2026 11:01:10 -0400 Subject: [PATCH 4/4] test(dashboard): use the existing untrusted-author caption wording Signed-off-by: Andy Anderson --- src/pkg/dashboard/stage_tracker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/dashboard/stage_tracker_test.go b/src/pkg/dashboard/stage_tracker_test.go index 4515a07cd4..15325b098c 100644 --- a/src/pkg/dashboard/stage_tracker_test.go +++ b/src/pkg/dashboard/stage_tracker_test.go @@ -143,7 +143,7 @@ func TestStageTrackerManualMergeApproved(t *testing.T) { }, { name: "trust-blocked 090 unchanged", stage: stagelabels.ReadyForHumanMerge, reason: "untrusted-author-role", - wantCaption: "Ready for a maintainer's /lgtm /approve; the hive cannot merge it itself — untrusted author role", wantActor: "maintainer", + wantCaption: "Ready for a maintainer's /lgtm /approve; the hive cannot merge it itself — author's role is not trusted for unattended merge", wantActor: "maintainer", }, { name: "requires_human approved at 090", stage: stagelabels.ReadyForHumanMerge, reason: "reviewer-verdict:requires_human:human-approved@octocat",