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-15009-stage-dwell-warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- A contributor PR with no linked issue no longer logs the "waits on the hive past the stage dwell — reviewer lane needs attention" warning; it is waiting on a person, not the reviewer lane (#15009)
39 changes: 39 additions & 0 deletions src/pkg/github/automerge/automerge_stage_human_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,42 @@ func TestDecisionEntryRepostsWhenCauseChanges(t *testing.T) {
t.Fatalf("cause list grew: %+v", rec)
}
}

// TestHumanHandoffNoLinkedIssuePendingChecksWaitOnHive: a contributor PR
// admission skipped for no-linked-issue carries no CI state in its reason,
// so the human route's check digest decides whether the 050 head waits on
// the hive (hivecommons/hive#15009): running checks do, a settled head with
// no verdict does not.
func TestHumanHandoffNoLinkedIssuePendingChecksWaitOnHive(t *testing.T) {
api, closeAPI := seededStageAPI(t)
defer closeAPI()
clock := &contributorLaneClock{at: time.Date(2026, 10, 28, 12, 0, 0, 0, time.UTC)}
verdict := &ContributorLaneVerdict{Configured: true}
e, store := humanStageEngine(t, api.url, clock, verdict, 0)
e.checkSummary = func(context.Context, string, string, string) (hgithub.CommitChecksSummary, error) {
return hgithub.CommitChecksSummary{Total: 3, Green: 1, Pending: 2, DCO: 1}, nil
}
sweep := func() {
t.Helper()
pr := stagePR(11, "role/contributor", "author/human")
pr.Head.SHA = ptrString("sha11")
e.recordStage(stageLaneContributor, "acme/widget", "acme", "widget", pr, contributorLaneReasonNoLinkedIssue, false, nil)
e.noteStageRole("acme", "widget", 11, stagelabels.RoleContributor)
if _, err := e.ApplyStageLabels(context.Background()); err != nil {
t.Fatal(err)
}
}
sweep()
rec, _ := store.Get(stageKey("acme", "widget", 11))
if rec.Stage != stagelabels.ReviewPending || !rec.WaitingOnHive {
t.Fatalf("pending checks: stage=%v waiting_on_hive=%v", rec.Stage, rec.WaitingOnHive)
}

e.checkSummary = greenChecks
clock.at = clock.at.Add(humanChecksTTL)
sweep()
rec, _ = store.Get(stageKey("acme", "widget", 11))
if rec.Stage != stagelabels.ReviewPending || rec.WaitingOnHive {
t.Fatalf("checks settled, no verdict: stage=%v waiting_on_hive=%v", rec.Stage, rec.WaitingOnHive)
}
}
19 changes: 16 additions & 3 deletions src/pkg/github/automerge/automerge_stage_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,14 @@ func stageActivity(obs stageObservation, stage stagelabels.Stage) stagelabels.Ac
sort.Strings(labels)
a.Digest = verdict + "|ci:" + ci.String() + "|" + strings.Join(labels, ",")
// Checks still running, or a review-pending head with no reviewer
// verdict yet, is waiting on the hive, not on a person.
// verdict yet, is waiting on the hive, not on a person. A contributor PR
// the lane skipped for want of a linked issue gets no verdict until the
// contributor or a maintainer acts, so the missing verdict alone does
// not make it wait on the hive (ApplyStageLabels still honours the
// head's running checks from the human route's digest).
a.WaitingOnHive = ci == ciReasonPending || stageReasonWaitsOnHive(obs.Reason) ||
(stage == stagelabels.ReviewPending && !(obs.Detail.VerdictKnown && obs.Detail.Verdict.Verdict != ""))
(stage == stagelabels.ReviewPending && obs.Reason != contributorLaneReasonNoLinkedIssue &&
!(obs.Detail.VerdictKnown && obs.Detail.Verdict.Verdict != ""))
return a
}

Expand Down Expand Up @@ -950,7 +955,15 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error)
if verdict.Stage != stagelabels.ReturnedToContributor && verdict.Stage != stagelabels.NeedsAuthor {
c.resolveNudge(ctx, prevRec, hadPrev, obs)
}
store.NoteActivity(key, stageActivity(obs, verdict.Stage))
act := stageActivity(obs, verdict.Stage)
if !act.WaitingOnHive && verdict.Stage == stagelabels.ReviewPending && pass.Route != nil && pass.Route.Checks.Known && pass.Route.Checks.Pending > 0 {
// An admission reason decided before CI was read (no
// linked issue) says nothing about the checks; the human
// route's digest of the head does, and running checks
// wait on the hive.
act.WaitingOnHive = true
}
store.NoteActivity(key, act)
rec, _ := store.Get(key)
want = stagelabels.Desired{
Stage: verdict.Stage,
Expand Down
12 changes: 12 additions & 0 deletions src/pkg/github/automerge/automerge_stage_sharedci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ func TestStageActivitySharedCIAndBudgetWaitOnHive(t *testing.T) {
}
}

// A contributor PR skipped for no-linked-issue is waiting on a person, so
// the stage-dwell "waits on the hive" warning must not fire for it.
func TestStageActivityNoLinkedIssueDoesNotWaitOnHive(t *testing.T) {
obs := stageObservation{HeadSHA: "sha", Reason: contributorLaneReasonNoLinkedIssue}
if a := stageActivity(obs, stagelabels.ReviewPending); a.WaitingOnHive {
t.Fatal("no-linked-issue waits on the hive")
}
if a := stageActivity(stageObservation{HeadSHA: "sha"}, stagelabels.ReviewPending); !a.WaitingOnHive {
t.Fatal("verdict-less review-pending head no longer waits on the hive")
}
}

// A base-red clanker PR stays at 050 across repeated sweeps — no 072, no
// nudge comment or relay interrupt, no stall — and is handed back to its
// author with a nudge only once the incident closes and the head is still
Expand Down
Loading