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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-tracker-auto-merge-off-new-pr.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions src/docs/dashboard-sections/activity-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
129 changes: 129 additions & 0 deletions src/pkg/dashboard/stage_tracker_auto_merge_off_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
15 changes: 12 additions & 3 deletions src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/dashboard/stage_tracker_decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions src/pkg/dashboard/stage_tracker_decision_human_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading
Loading