diff --git a/changelog.d/fixed-tracker-auto-merge-off-new-pr.md b/changelog.d/fixed-tracker-auto-merge-off-new-pr.md new file mode 100644 index 0000000000..a7a8dd5e5f --- /dev/null +++ b/changelog.d/fixed-tracker-auto-merge-off-new-pr.md @@ -0,0 +1 @@ +- Activity Monitor: a new pull request on a repo whose auto-merge is off (or on any repo of a hive below ACMM L6) no longer reads "waiting for the stage-label pass (next pass due now)", since no merge lane runs there to stage it; the row says a person merges it, shows the merge verdict, and, when GitHub would take the merge, offers **Merge now as maintainer** as its lead action. diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index 2ef9530763..f1c8de7617 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -403,9 +403,9 @@ A `blocked` issue with neither marker (a human-applied label) keeps the bare pil Every open issue and pull request in `project.repos` is on the list from the moment GitHub reports it — there is no gap between "opened" and "the hive has an opinion about it" ([#15094](https://github.com/hivecommons/hive/issues/15094)). The `issues.opened` / `pull_request.opened` webhook re-read inserts the item into the status payload straight away (`insertFrontendRepoItem`; the governor side keeps the same row in its cached snapshot so a republish does not drop it), the per-item replay re-applies that insert after a governor republish, and the enumeration poll is the fallback for a missed delivery. -Until something places the item — a stage record, a `stage/*` label, a hold, a blocked marker, a bucket other than *reporter triage* / *unclassified* — the row is anchored in the **Open** column with the lit chevron reading **New** (`ham-open-new`, blue ✦ rather than amber) — or **Triage needed** when the next mover is a maintainer, see above — and a caption that names who moves it next and when: `New · waiting for the stage-label pass (→ 010 actionable), then the scanner (next pass in 7m)` for an issue the reporter gate has already admitted, `Triage needed — accept or close` for a human contributor's issue the reporter-trust gate is still holding (the hover still names the label to add and the next pass) (the label names come from `issues.filter.reporter_trust.untrusted_require_labels`), and `New · waiting for the stage-label pass (→ 050 review pending)` for a pull request. +Until something places the item — a stage record, a `stage/*` label, a hold, a blocked marker, a bucket other than *reporter triage* / *unclassified* — the row is anchored in the **Open** column with the lit chevron reading **New** (`ham-open-new`, blue ✦ rather than amber) — or **Triage needed** when the next mover is a maintainer, see above — and a caption that names who moves it next and when: `New · waiting for the stage-label pass (→ 010 actionable), then the scanner (next pass in 7m)` for an issue the reporter gate has already admitted, `Triage needed — accept or close` for a human contributor's issue the reporter-trust gate is still holding (the hover still names the label to add and the next pass) (the label names come from `issues.filter.reporter_trust.untrusted_require_labels`), and `New · waiting for the stage-label pass (→ 050 review pending)` for a pull request. On a repo whose auto-merge is off (its `project.repo_policies[].auto_merge` switch, or any repo of a hive below ACMM L6, per `config.RepoAutoMergeEnabled`) no merge lane runs, so no stage-label pass ever places a pull request there: the PR narration says so instead (`new.auto_merge_off`), never shows the next-pass countdown, and ends at the human-merge gate *auto-merge is off for this repo (its auto-merge setting, or the hive is below ACMM L6) — a person merges it*, with the governor's merge verdict quoted in the gates. When that verdict is a hand merge (GitHub would take the merge; only the switch holds it) the caption reads `New · auto-merge off — a person merges it`, the next mover is the maintainer and the row carries a decision whose lead is **Merge now as maintainer** (**Approve and let hive merge** greyed, since no merge pass runs there); otherwise it reads `New · not staged (auto-merge off) — waiting for CI and review; a person merges it` with the hive as next mover. Seen on projectbluefin/server#626, which read *next pass due now* for four days. -The *since* time is the item's `created_at`; "next pass" is the governor's next kick (`governor.nextKickAt`, so it counts down with the Governor tile and reads *due now* once it has passed). The payload carries it all as `new{since, next_mover (maintainer|hive), next_mover_text, next_pass_at, next_pass_in_seconds, gates[], text}`; the chevron tooltip lists the gates ahead — **triage** (the reporter gate: done when admitted, next when a triage label is still needed), **actionable** (the stage-label pass marks it 010), **claimed** (the scanner claims it, 020) — each marked ✓ done, → next or · later, and the row's actor icon reads *human* while the next mover is a maintainer and *hive* otherwise. +The *since* time is the item's `created_at`; "next pass" is the governor's next kick (`governor.nextKickAt`, so it counts down with the Governor tile and reads *due now* once it has passed). The payload carries it all as `new{since, next_mover (maintainer|hive), next_mover_text, next_pass_at, next_pass_in_seconds, gates[], text, auto_merge_off}`; the chevron tooltip lists the gates ahead — **triage** (the reporter gate: done when admitted, next when a triage label is still needed), **actionable** (the stage-label pass marks it 010), **claimed** (the scanner claims it, 020) — each marked ✓ done, → next or · later, and the row's actor icon reads *human* while the next mover is a maintainer and *hive* otherwise. A row that already wears a hold, `blocked`, a draft marker or any stage record is never *New*; neither is an issue at `015` once the stage-label pass has written it. diff --git a/src/pkg/dashboard/stage_tracker_auto_merge_off_test.go b/src/pkg/dashboard/stage_tracker_auto_merge_off_test.go new file mode 100644 index 0000000000..cf51df0c49 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_auto_merge_off_test.go @@ -0,0 +1,129 @@ +package dashboard + +import ( + "encoding/json" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" +) + +// projectbluefin/server#626 (opened 2026-11-05) and its 48 siblings on the +// projectbluefin hive's common, server, actions, website and documentation +// repos — auto-merge switched off there — read "New · waiting for the +// stage-label pass (→ 050 review pending) (next pass due now)" for days. +// Every merge lane skips a repo whose auto-merge is off before it records +// any stage evidence, so that pass never comes. The 000-new narration on +// such a repo must drop the countdown and the stage-label pass, name the +// person's merge as the last gate, and carry the merge verdict. +func autoMergeOffTrackerFixture(t *testing.T, now time.Time, level int, autoMerge *bool) (*Server, StageTrackerResponse) { + t.Helper() + s, store := stageTrackerFixture(t, now) + cfg := &config.Config{ACMMLevel: &level} + cfg.Project.Org = "acme" + if autoMerge != nil { + cfg.Project.RepoPolicies = []config.RepoPolicy{{Repo: "acme/console", AutoMerge: autoMerge}} + } + s.deps = &Dependencies{Config: cfg} + opened := now.Add(-4 * 24 * time.Hour) + s.statusMu.Lock() + // The governor's kick already passed: the old caption read "next pass due now". + s.status.Governor.NextKickAt = now.Add(-time.Minute).UTC().Format(time.RFC3339) + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + // Mergeable on GitHub; only the repo switch holds it (the merge + // verdict #16815 writes for an auto-merge-off repo). + FrontendPR{PullRequest: github.PullRequest{Number: 626, Title: "fix: stop false build safety failures", Author: "karibhou", HeadSHA: "eaf066b", BaseRef: "main", CreatedAt: opened, UpdatedAt: opened}, + MergeVerdict: &github.MergeVerdict{State: github.MergeVerdictOutstanding, HandMerge: true, Reason: "auto-merge is off for this repo (its auto-merge setting, or the hive is below ACMM L6) — a person merges it"}}, + // Red CI: GitHub refuses the merge; the author has work to do first. + FrontendPR{PullRequest: github.PullRequest{Number: 645, Title: "fix: list both pcre2 copies", Author: "kylerankin", HeadSHA: "c0ffee1", BaseRef: "main", CreatedAt: opened, UpdatedAt: opened}, + MergeVerdict: &github.MergeVerdict{State: github.MergeVerdictBlocked, Reason: "blocked — CI failing: zizmor"}}, + ) + s.statusMu.Unlock() + return s, s.buildStageTracker(s.status, store, now) +} + +func TestStageTrackerAutoMergeOffNewPRNamesThePersonsMerge(t *testing.T) { + now := time.Date(2026, 11, 10, 12, 0, 0, 0, time.UTC) + off := false + _, resp := autoMergeOffTrackerFixture(t, now, 6, &off) + + ready := trackerItem(t, resp, "pr", 626) + if ready.New == nil || ready.StageSlug != StageTrackerNewSlug || !ready.New.AutoMergeOff { + t.Fatalf("#626 = slug %q new %+v, want 000-new on an auto-merge-off repo", ready.StageSlug, ready.New) + } + for _, it := range []StageTrackerItem{ready, trackerItem(t, resp, "pr", 645)} { + if strings.Contains(it.Caption, "stage-label pass") || strings.Contains(it.Caption, "next pass") || strings.Contains(it.New.NextMoverText, "stage-label pass") { + t.Errorf("#%d caption %q / next %q still promises a stage pass that never runs on an auto-merge-off repo", it.Number, it.Caption, it.New.NextMoverText) + } + if it.New.NextPassAt != nil || it.New.NextPassInSeconds != 0 { + t.Errorf("#%d carries the governor's countdown %v / %ds; the SPA would print \"next hive pass due now\"", it.Number, it.New.NextPassAt, it.New.NextPassInSeconds) + } + var gate *StageTrackerGate + for i := range it.New.Gates { + if it.New.Gates[i].Name == StageTrackerGateHumanMerge { + gate = &it.New.Gates[i] + } + } + if gate == nil || gate.Text != stageTrackerAutoMergeOffGateText { + t.Errorf("#%d gates = %+v, want the human-merge gate %q", it.Number, it.New.Gates, stageTrackerAutoMergeOffGateText) + } + } + + // Mergeable: a person's merge is the next move, and the row offers it. + if ready.New.NextMover != StageTrackerMoverMaintainer || ready.Actor != StageTrackerMoverMaintainer || ready.Caption != "New · auto-merge off — a person merges it" { + t.Fatalf("#626 mover %q actor %q caption %q, want the maintainer's merge", ready.New.NextMover, ready.Actor, ready.Caption) + } + if len(ready.New.Gates) == 0 || ready.New.Gates[0].Name != "merge-verdict" || !strings.Contains(ready.New.Gates[0].Text, "a person merges it") { + t.Fatalf("#626 gates = %+v, want the merge verdict first", ready.New.Gates) + } + d := ready.DecisionNeeded + if d == nil || len(d.Options) < 2 { + t.Fatalf("#626 decision = %+v, want a merge decision", d) + } + if lead := d.Options[0]; lead.Action != decisionActionMergeNow || !lead.Enabled { + t.Fatalf("#626 lead option = %+v, want an enabled merge-now", lead) + } + if q := decisionOptionByAction(t, d, decisionActionQueueMerge); q.Enabled || !strings.Contains(strings.ToLower(q.ReasonIfDisabled), "auto-merge is off") { + t.Fatalf("#626 queue option = %+v, want it greyed: no merge pass runs here", q) + } + + // Red CI: still CI / review, but no promise of a stage pass. + red := trackerItem(t, resp, "pr", 645) + if red.New.NextMover != StageTrackerMoverHive || red.DecisionNeeded != nil { + t.Fatalf("#645 mover %q decision %+v, want CI / review and no merge ask", red.New.NextMover, red.DecisionNeeded) + } + if len(red.New.Gates) == 0 || !strings.Contains(red.New.Gates[0].Text, "CI failing: zizmor") { + t.Fatalf("#645 gates = %+v, want the merge verdict on the review gate", red.New.Gates) + } + + // The maintainer row has a real lead action in the SPA (the rule + // TestStageTrackerMaintainerRowsHaveLeadAction pins for the fixture). + raw, err := json.Marshal([]StageTrackerItem{ready}) + if err != nil { + t.Fatal(err) + } + runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, indexHTML(t))+` +const rows = `+string(raw)+`; +const ctx = { user: true, canHold: true, canHuman: true, login: 'octo', nowMs: `+itoa(int(now.UnixMilli()))+`, governor: null }; +const lead = stageTrackerLeadAction(rows[0], ctx); +assert.ok(lead && lead.enabled && lead.id === 'decide:merge-now', JSON.stringify(lead)); +`) +} + +// Below ACMM L6 every repo reads auto-merge off (config.RepoAutoMergeEnabled) +// and no lane runs anywhere, so the same narration applies; at L6 with the +// switch on, the stage-label pass is still the honest next mover. +func TestStageTrackerAutoMergeOffNewFollowsTheEffectiveSwitch(t *testing.T) { + now := time.Date(2026, 11, 10, 12, 0, 0, 0, time.UTC) + _, below := autoMergeOffTrackerFixture(t, now, 5, nil) + if it := trackerItem(t, below, "pr", 626); it.New == nil || !it.New.AutoMergeOff || strings.Contains(it.Caption, "stage-label pass") { + t.Fatalf("below L6: new %+v caption %q, want the auto-merge-off narration", it.New, it.Caption) + } + _, on := autoMergeOffTrackerFixture(t, now, 6, nil) + it := trackerItem(t, on, "pr", 626) + if it.New == nil || it.New.AutoMergeOff || it.New.NextMover != StageTrackerMoverHive || !strings.Contains(it.Caption, "stage-label pass") || it.DecisionNeeded != nil { + t.Fatalf("L6, auto-merge on: new %+v caption %q decision %+v, want the stage-label pass unchanged", it.New, it.Caption, it.DecisionNeeded) + } +} diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index 946b657684..c62049614c 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -442,10 +442,19 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } it.Caption = stageTrackerReturnedToHiveCaption(it.Caption, it.Author, requesters) } - applyStageTrackerNew(&it, stageTrackerNewState(it, ok, issueFilter, status.Governor, now)) + newState := stageTrackerNewState(it, ok, issueFilter, status.Governor, now) + if newState != nil && cfg != nil && !cfg.RepoAutoMergeEnabled(repoName) { + // No merge lane runs on this repo, so no stage pass will place + // the PR: say who lands it instead. + newState = stageTrackerAutoMergeOffNew(newState, verdict) + } + applyStageTrackerNew(&it, newState) // After the New caption: an unclassified clanker PR whose clanker - // is offline says what that means for it. - it.Caption = stageTrackerOfflineAuthorCaption(it.Caption, it.Presence, it.Stage, adoptionClock, now) + // is offline says what that means for it — not where auto-merge is + // off, since its "merged without its author" is the lanes' promise. + if it.New == nil || !it.New.AutoMergeOff { + it.Caption = stageTrackerOfflineAuthorCaption(it.Caption, it.Presence, it.Stage, adoptionClock, now) + } it.SentinelAlert, it.SentinelFindings, it.SentinelReason, it.SentinelDetails = s.stageTrackerSentinel(evidenceVerifier, repoName, pr.Number, pr.HeadSHA, pr.Labels) it.SentinelNotice = it.SentinelAlert && !slices.ContainsFunc(pr.Labels, func(label string) bool { return strings.EqualFold(strings.TrimSpace(label), sentinelLabel) diff --git a/src/pkg/dashboard/stage_tracker_decision.go b/src/pkg/dashboard/stage_tracker_decision.go index 9d3d30513f..02e09f7951 100644 --- a/src/pkg/dashboard/stage_tracker_decision.go +++ b/src/pkg/dashboard/stage_tracker_decision.go @@ -213,6 +213,8 @@ func stageTrackerDecisionNeededWith(it StageTrackerItem, verdict *review.Aggrega return decisionForPR(it, verdict, sentinelLabel, held) case it.Kind == "pr" && it.Stage == stagelabels.ReadyForHumanMerge.Number(): return decisionForHumanMerge(it, held) + case it.Kind == "pr" && it.Stage == 0 && it.New != nil && it.New.AutoMergeOff && it.New.NextMover == StageTrackerMoverMaintainer: + return decisionForAutoMergeOffNew(it, held) case it.Kind == "issue" && it.Mirrored: // The issue rides its covering PR; the PR's own row (nested under // the issue) carries the decision. diff --git a/src/pkg/dashboard/stage_tracker_decision_human_merge.go b/src/pkg/dashboard/stage_tracker_decision_human_merge.go index de31729acd..04d4f74705 100644 --- a/src/pkg/dashboard/stage_tracker_decision_human_merge.go +++ b/src/pkg/dashboard/stage_tracker_decision_human_merge.go @@ -255,3 +255,31 @@ func stageTrackerNeedsRebase(it StageTrackerItem) bool { } return it.RebaseMerge != nil && it.RebaseMerge.State != "" && it.RebaseMerge.State != "merged" && it.RebaseMerge.State != "failed" } + +// decisionForAutoMergeOffNew: a 000-new pull request on a repo whose +// auto-merge is off (stageTrackerAutoMergeOffNew), whose merge verdict +// says GitHub would take the merge. No lane stages or merges anything +// there, so the row asks a person to merge, like 090 · auto-merge off: +// Merge now as maintainer leads, and "Approve and let hive merge" is +// offered greyed, since no merge pass runs on the repo. +func decisionForAutoMergeOffNew(it StageTrackerItem, held bool) *StageTrackerDecision { + ref := "#" + strconv.Itoa(it.Number) + d := &StageTrackerDecision{Since: it.StageSince, AskedBy: decisionAskedByLane, BlockerReason: stageTrackerAutoMergeOffBlockerReason} + d.Question = "Auto-merge is off for this repo, so a person merges it." + d.Blocker = sentence(stageTrackerAutoMergeOffGateText) + details := []string{"Hive never stages or merges pull requests on this repo; a maintainer merges here or on GitHub."} + if held { + details = append(details, decisionHeldBlocker(it.Hold)) + } + d.Detail = stageTrackerSayOnce(d.Question, details...) + mergeNow := decisionMergeNowOption(it, held) + queue := decisionOption(decisionActionQueueMerge, decisionQueueMergeLabel, false, "Auto-merge is off for this repo; hive never merges here — merge it now as maintainer") + closeWontfix := decisionOption(decisionActionCloseWontfix, "Close as won't fix", true, "") + closeWontfix.Consequence = "Closes " + ref + " without merging" + d.Options = append(decisionHumanMergeLeadOptions(mergeNow, queue), closeWontfix, decisionHoldOption(held)) + return d +} + +// stageTrackerAutoMergeOffBlockerReason is the lane token every merge sweep +// logs when it skips a repo whose auto-merge is off. +const stageTrackerAutoMergeOffBlockerReason = "repo-auto-merge-disabled" diff --git a/src/pkg/dashboard/stage_tracker_new.go b/src/pkg/dashboard/stage_tracker_new.go index 6b6ba3ac34..ac567ccf14 100644 --- a/src/pkg/dashboard/stage_tracker_new.go +++ b/src/pkg/dashboard/stage_tracker_new.go @@ -7,6 +7,7 @@ import ( "time" "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" stageengineprstage "github.com/hivecommons/hive/pkg/stageengine/prstage" ) @@ -59,6 +60,11 @@ type StageTrackerNew struct { Gates []StageTrackerGate `json:"gates"` // Text is the row caption: "New · waiting for (next pass in Nm)". Text string `json:"text"` + // AutoMergeOff marks a pull request on a repo whose auto-merge is off + // (the repo's setting, or a hive below ACMM L6): no hive pass will + // stage or merge it, so the narration names a person's merge instead + // of a stage-label pass that never comes. + AutoMergeOff bool `json:"auto_merge_off,omitempty"` } // stageTrackerIsNew reports whether a finished row is a 000-new item: no @@ -249,3 +255,64 @@ func (s *Server) issueFilterConfig() *config.IssueFilterConfig { } return &s.deps.Config.Project.IssueFilter } + +// stageTrackerAutoMergeOffGateText is the merge gate of a 000-new pull +// request on a repo whose auto-merge is off. Below ACMM L6 every repo +// reads off (config.RepoAutoMergeEnabled), and the sentence says so. +const stageTrackerAutoMergeOffGateText = "auto-merge is off for this repo (its auto-merge setting, or the hive is below ACMM L6) — a person merges it" + +// stageTrackerAutoMergeOffNew rewrites the 000-new narration of a pull +// request on a repo whose auto-merge is off. Every merge lane skips such a +// repo before it records anything, so no stage-label pass ever places the +// PR: the "waiting for the stage-label pass (next pass due now)" caption +// and its countdown were never true there (projectbluefin/server#626 read +// it for four days). The narration drops the countdown, names the person's +// merge as the last gate and carries the governor's merge verdict. +// +// next_mover is the maintainer only when the verdict is a hand merge +// (outstanding: GitHub would take the merge and only the repo switch, or a +// hive-side gate on top of it, holds it); the row then carries a decision +// whose lead is Merge now as maintainer (decisionForAutoMergeOffNew). Any +// other PR is still in CI / review, and the hive stays the next mover as +// before, without the false promise of a stage pass. +func stageTrackerAutoMergeOffNew(n *StageTrackerNew, verdict *github.MergeVerdict) *StageTrackerNew { + if n == nil { + return nil + } + out := *n + out.AutoMergeOff = true + out.NextPassAt, out.NextPassInSeconds = nil, 0 + reason := "" + if verdict != nil { + reason = strings.TrimSpace(verdict.Reason) + } + mergeGate := StageTrackerGate{Name: StageTrackerGateHumanMerge, State: StageTrackerGateLater, Text: stageTrackerAutoMergeOffGateText} + for _, g := range n.Gates { + // A breaking-titled or needs-owner-merge PR keeps that rule beside + // the switch (hivecommons/hive#15442). + if g.Name == StageTrackerGateHumanMerge && g.Text != "" { + mergeGate.Text = g.Text + "; " + stageTrackerAutoMergeOffGateText + } + } + if verdict != nil && verdict.HandMerge && verdict.State == github.MergeVerdictOutstanding { + out.NextMover = StageTrackerMoverMaintainer + out.NextMoverText = "a person's merge (" + stageTrackerAutoMergeOffGateText + ")" + mergeGate.State = StageTrackerGateNext + verdictText := "GitHub would accept the merge" + if reason != "" { + verdictText += "; hive's merge verdict: " + reason + } + out.Gates = []StageTrackerGate{{Name: "merge-verdict", State: StageTrackerGateDone, Text: verdictText}, mergeGate} + out.Text = "New · auto-merge off — a person merges it" + return &out + } + out.NextMover = StageTrackerMoverHive + out.NextMoverText = "CI and review; no hive pass stages or merges it here" + reviewText := "CI and review run on the head" + if reason != "" { + reviewText += "; hive's merge verdict: " + reason + } + out.Gates = []StageTrackerGate{{Name: "review", State: StageTrackerGateNext, Text: reviewText}, mergeGate} + out.Text = "New · not staged (auto-merge off) — waiting for CI and review; a person merges it" + return &out +} diff --git a/src/pkg/dashboard/stage_tracker_offline_clanker_test.go b/src/pkg/dashboard/stage_tracker_offline_clanker_test.go index 7a02b4a84b..d4a38aa03a 100644 --- a/src/pkg/dashboard/stage_tracker_offline_clanker_test.go +++ b/src/pkg/dashboard/stage_tracker_offline_clanker_test.go @@ -30,7 +30,10 @@ func offlineClankerFixture(t *testing.T, now time.Time, lastSeen time.Time) (*Se } return automerge.ContributorPresence{Registered: true, Online: false, LastSeen: lastSeen}, true } - s.deps = &Dependencies{Config: &config.Config{}} + // L6 with auto-merge on: the lanes run, so an unclassified PR waits for + // the stage-label pass (below L6 it reads auto-merge off instead). + level := 6 + s.deps = &Dependencies{Config: &config.Config{ACMMLevel: &level}} status := minimalPayload() status.HiveID = "hive" status.Repos = []FrontendRepo{{