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-delegate-offline-author-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- "Let hive decide" no longer sends a PR back to an author whose clanker is offline just because someone else touched the PR. The rework-pickup signal it reads counted any change to the PR's `updated_at` as the author having "picked the rework up": a maintainer's review, a comment or a label all count. On projectbluefin/bluefin-bling#128 a maintainer's review made the hive return the PR to an author who had been offline for a day, and nothing followed for five days. Only a fix task the author's relay has taken, or a new head, counts now. An offline author falls through to the next rung, which adopts the PR. Separately, a hive decision whose effect timed out ("no effect after 30m") now shows in **Waiting on you** by the PR's real stage. Nothing re-runs such a decision, and until now the row dropped out of that list for good.
14 changes: 9 additions & 5 deletions src/pkg/dashboard/delegated_ladder.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ func (s *Server) delegatedAuthorTooling(labels []string, owner bool) delegatedec
}

// delegatedReworkPickedUp reads the rework-pickup signal of
// hivecommons/hive#15280 for the PR's author: their relay holds or queued
// the fix task, someone acted on the PR since the request, or a new head
// is up. It rests on the stage record and the hub's fix queue; no GitHub
// call. "requested" (nobody has acted) is not a pickup.
// hivecommons/hive#15280 for the PR's author: their relay holds the fix
// task, or a new head is up. It rests on the stage record and the hub's fix
// queue; no GitHub call. "requested" (nobody has acted) is not a pickup,
// and neither is "acknowledged": that state only says the PR's updated_at
// moved after the request, which anyone's review, comment or label moves.
// Read as the author's pickup, a maintainer's review on a PR whose author
// had been offline for a day sent it back to that author, and nothing
// followed for five days (projectbluefin/bluefin-bling#128).
func (s *Server) delegatedReworkPickedUp(repoFull string, pr *gh.PullRequest, author string, now time.Time) bool {
rec, ok := s.stageStoreOrShared().Get(stagelabels.Key(repoFull, pr.GetNumber()))
if !ok {
Expand All @@ -83,7 +87,7 @@ func (s *Server) delegatedReworkPickedUp(repoFull string, pr *gh.PullRequest, au
return false
}
switch rw.State {
case reworkStateAcknowledged, reworkStateInProgress, reworkStatePushed:
case reworkStateInProgress, reworkStatePushed:
return true
}
return false
Expand Down
53 changes: 53 additions & 0 deletions src/pkg/dashboard/delegated_rework_pickup_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package dashboard

import (
"testing"
"time"

gh "github.com/google/go-github/v72/github"

"github.com/hivecommons/hive/pkg/stagelabels"
)

// projectbluefin/bluefin-bling#128: the PR sat at 085 from 11-08, a
// maintainer reviewed it on 11-11, and "Let hive decide" on 11-12 read the
// review's updated_at bump as the author's clanker picking the rework up.
// The author had been offline for a day; the PR went back to them and
// nothing followed. Only a fix task the author's relay holds, or a new head,
// is a pickup.
func TestDelegatedReworkPickedUpIgnoresAnyonesActivity(t *testing.T) {
entered := time.Date(2026, 11, 8, 20, 44, 0, 0, time.UTC)
reviewed := time.Date(2026, 11, 11, 15, 3, 21, 0, time.UTC)
decided := time.Date(2026, 11, 12, 19, 16, 34, 0, time.UTC)
const repo, author = "projectbluefin/bluefin-bling", "mendezr"
store := stagelabels.NewStore("", func() time.Time { return entered })
store.ObserveHead(stagelabels.Key(repo, 128), "bbd5a8d", stagelabels.NeedsDecision, "adoption-stalled:hive-signoff-attribution")
rec, _ := store.Get(stagelabels.Key(repo, 128))
pr := &gh.PullRequest{Number: gh.Ptr(128), Head: &gh.PullRequestBranch{SHA: gh.Ptr("bbd5a8d")}, UpdatedAt: &gh.Timestamp{Time: reviewed}}

// The tracker does read the bump as "acknowledged"…
it := StageTrackerItem{Repo: repo, Kind: "pr", Number: 128, Head: "bbd5a8d", UpdatedAt: &reviewed}
if rw := stageTrackerReworkFor(it, author, stagelabels.ReturnedToContributor, rec, true, nil, decided); rw == nil || rw.State != reworkStateAcknowledged {
t.Fatalf("rework = %+v, want the activity-only acknowledged state this test is about", rw)
}
// …but the delegate does not take it for the author's pickup.
s := &Server{stageStore: store}
if s.delegatedReworkPickedUp(repo, pr, author, decided) {
t.Fatal("a maintainer's review read as the offline author picking the rework up")
}

// The author's relay holding the fix task is a pickup.
s.fixWorkLookup = func(login, r string, number int) (StageTrackerFixWork, bool) {
return StageTrackerFixWork{InFlight: true, DispatchedAt: decided.Add(-time.Hour)}, login == author && r == repo && number == 128
}
if !s.delegatedReworkPickedUp(repo, pr, author, decided) {
t.Fatal("an in-flight fix task held by the author's relay is not a pickup")
}
// A task only queued on the hub, never taken, is not.
s.fixWorkLookup = func(string, string, int) (StageTrackerFixWork, bool) {
return StageTrackerFixWork{Queued: true, QueuedAt: decided.Add(-time.Hour)}, true
}
if s.delegatedReworkPickedUp(repo, pr, author, decided) {
t.Fatal("a queued, untaken fix task read as a pickup")
}
}
5 changes: 5 additions & 0 deletions src/pkg/dashboard/stage_tracker_decided_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ func TestStageTrackerDecidedProjection(t *testing.T) {
if !strings.Contains(pr.Decided.Title, "not in effect after 30m") {
t.Fatalf("title %q", pr.Decided.Title)
}
// Nothing re-runs a timed-out decision: the row is a person's wait
// again, by its real stage.
if kind, who := stageTrackerWaitKind(pr); kind != waitKindReadyForHumanMerge || who != waitWhoOperator {
t.Fatalf("timed-out wait kind/who = %s/%s, want %s/%s", kind, who, waitKindReadyForHumanMerge, waitWhoOperator)
}
})

t.Run("approve reads approving; other verdicts never do", func(t *testing.T) {
Expand Down
8 changes: 6 additions & 2 deletions src/pkg/dashboard/stage_tracker_waiting.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ var stageTrackerReturnedStages = []int{stagelabels.NeedsAuthor.Number(), stagela
// standing meta issues and already-decided rows never count: hold is the
// operator's own choice, an advisory asks for nothing, a bot Dependency
// Dashboard is a control panel whatever labels it wears, and a decided
// row is the hive's to act on next.
// row is the hive's to act on next. A decision whose effect timed out is
// no longer the hive's: nothing re-runs it, so the row waits on a person
// again by its real stage (projectbluefin/bluefin-bling#128 sat five days
// as "no effect after 30m" and never reached Waiting on you).
func stageTrackerWaitKind(it StageTrackerItem) (kind, who string) {
if stageTrackerOnHold(it) || it.Advisory != nil || it.Decided != nil || stageTrackerWaitStandingMeta(it) {
decided := it.Decided != nil && it.Decided.Effect != decidedEffectTimedOut
if stageTrackerOnHold(it) || it.Advisory != nil || decided || stageTrackerWaitStandingMeta(it) {
return "", ""
}
switch {
Expand Down
8 changes: 6 additions & 2 deletions src/pkg/dashboard/stage_tracker_waiting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ func TestStageTrackerWaitingOnHuman_KindsAndAttribution(t *testing.T) {
{Repo: "o/r", Number: 60, Kind: "pr", Stage: stagelabels.NeedsDecision.Number(), Modifiers: []string{modHold}},
{Repo: "o/r", Number: 61, Kind: "pr", Stage: stagelabels.NeedsDecision.Number(), Advisory: &StageTrackerAdvisory{}},
{Repo: "o/r", Number: 62, Kind: "pr", Stage: stagelabels.NeedsDecision.Number(), Decided: &StageTrackerDecided{}},
// …unless the decision timed out: nothing re-runs it, so the row
// waits on a person by its real stage (projectbluefin/bluefin-bling#128).
{Repo: "o/r", Number: 64, Kind: "pr", Stage: stagelabels.NeedsDecision.Number(), Decided: &StageTrackerDecided{Effect: decidedEffectTimedOut}},
// a nested PR is counted once, under its issue.
{Repo: "o/r", Number: 63, Kind: "pr", Stage: stagelabels.NeedsDecision.Number(), NestedUnder: 20},
// an ordinary in-flight PR waits on nobody.
{Repo: "o/r", Number: 70, Kind: "pr", Stage: 60},
}
got := stageTrackerWaitingOnHuman(items)
if got.Count != 6 || len(got.Items) != 6 {
t.Fatalf("count = %d (%d items), want 6: %+v", got.Count, len(got.Items), got.Items)
if got.Count != 7 || len(got.Items) != 7 {
t.Fatalf("count = %d (%d items), want 7: %+v", got.Count, len(got.Items), got.Items)
}
want := map[int][2]string{
15312: {waitKindNeedsDecision, waitWhoOperator},
64: {waitKindNeedsDecision, waitWhoOperator},
20: {waitKindNeedsDecision, waitWhoOperator},
15433: {waitKindReadyForHumanMerge, waitWhoOperator},
30: {waitKindApproveNeeded, waitWhoOperator},
Expand Down
6 changes: 3 additions & 3 deletions src/pkg/delegatedecision/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ type Input struct {
// AuthorTooling: what the author drives (hive / clanker / person);
// picks the words a decision uses for them (AuthorWord).
AuthorTooling AuthorTooling
// ReworkPickedUp: the author's relay has acknowledged, claimed or
// pushed the requested rework (hivecommons/hive#15280's signal), so
// they are responsive even without recent activity.
// ReworkPickedUp: the author's relay has claimed or pushed the
// requested rework (hivecommons/hive#15280's signal), so they are
// responsive even without recent activity.
ReworkPickedUp bool
// RepoPaused: the repo is under an operator pause; a decision that
// would write (close) is recommend-only instead.
Expand Down
Loading