diff --git a/changelog.d/fixed-15009-stage-dwell-warning.md b/changelog.d/fixed-15009-stage-dwell-warning.md new file mode 100644 index 0000000000..c4904b1b94 --- /dev/null +++ b/changelog.d/fixed-15009-stage-dwell-warning.md @@ -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) diff --git a/src/pkg/github/automerge/automerge_stage_human_test.go b/src/pkg/github/automerge/automerge_stage_human_test.go index 46a0da32ab..b2d16d05e3 100644 --- a/src/pkg/github/automerge/automerge_stage_human_test.go +++ b/src/pkg/github/automerge/automerge_stage_human_test.go @@ -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) + } +} diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index 27f1c93c6d..43beb9032b 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -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 } @@ -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, diff --git a/src/pkg/github/automerge/automerge_stage_sharedci_test.go b/src/pkg/github/automerge/automerge_stage_sharedci_test.go index 2371613f87..a7fb688d37 100644 --- a/src/pkg/github/automerge/automerge_stage_sharedci_test.go +++ b/src/pkg/github/automerge/automerge_stage_sharedci_test.go @@ -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