From 716748a38cc2de42c2caeda8f70a3359597d479b Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Sat, 31 Oct 2026 07:23:37 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Activity=20Monitor:=20a=20fo?= =?UTF-8?q?rce-push=20after=20a=20071=20ask=20reads=20pushed,=20not=20no?= =?UTF-8?q?=20response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stage record keeps the original ask and the head pushed after it across the re-ask the sweep issues when the new head is red again, the rework chip derives pushed from it (requested_at on the original ask), and a row whose push field says pushed drops the Needs @author decision and the needs-human count until CI / the re-review settle. Fixes hivecommons/hive#16021 Signed-off-by: Andrew Anderson --- changelog.d/fixed-rework-push-response.md | 1 + .../sweeps-and-operations.md | 10 ++- src/pkg/dashboard/stage_tracker_build.go | 4 +- src/pkg/dashboard/stage_tracker_decision.go | 6 ++ .../stage_tracker_decision_redundant_test.go | 20 ++++++ .../stage_tracker_needs_human_test.go | 4 ++ src/pkg/dashboard/stage_tracker_push.go | 7 ++ src/pkg/dashboard/stage_tracker_rework.go | 53 +++++++++++++- .../dashboard/stage_tracker_rework_test.go | 20 ++++++ src/pkg/stagelabels/push_test.go | 71 +++++++++++++++++++ src/pkg/stagelabels/store.go | 71 ++++++++++++++++++- 11 files changed, 261 insertions(+), 6 deletions(-) create mode 100644 changelog.d/fixed-rework-push-response.md diff --git a/changelog.d/fixed-rework-push-response.md b/changelog.d/fixed-rework-push-response.md new file mode 100644 index 0000000000..4df276caaa --- /dev/null +++ b/changelog.d/fixed-rework-push-response.md @@ -0,0 +1 @@ +- The activity monitor no longer tells an author who just force-pushed that they have given "no response" ([#16021](https://github.com/hivecommons/hive/issues/16021)): a human PR whose new head was red again re-entered 071 within one sweep, which restarted the waiting-on-push state and re-nudged for the new head, so the rework chip read `requested ยท no response` and the row kept "Needs @author". The stage record now remembers the original ask and the head pushed after it (`rework_asked_at`, `rework_pushed_head`, `rework_pushed_at`) across that re-ask, the chip reads `pushed ยท re-review pending` dated from the push with `requested_at` on the original ask (a review verdict on the pushed head is a fresh ask), and a row whose `push` field says pushed drops the "Needs @author" decision and the needs-human count until CI / the re-review settle. diff --git a/src/docs/operator-reference/sweeps-and-operations.md b/src/docs/operator-reference/sweeps-and-operations.md index 6095e955cd..0cdebfbd0c 100644 --- a/src/docs/operator-reference/sweeps-and-operations.md +++ b/src/docs/operator-reference/sweeps-and-operations.md @@ -158,7 +158,15 @@ returns to the column's own word โ€” stage only, the ๐Ÿ‘ค clears because the ball is back with the hive โ€” and the gray pill names the push: `@user pushed abc1234 ยท 2m` (links to the commit), `adopted from @x's #N ยท pushed 2m ago` on an adopted row, `pushed abc1234 ยท 2m` on a plain CI / Review -row; the hive line reads `push seen 2m ago โ†’ CI/re-review queued`. When the +row; the hive line reads `push seen 2m ago โ†’ CI/re-review queued`. A pushed +human-authored 071 / 072 row asks nothing of a person until the hive has +looked at the new head: no "Needs @author" decision, not counted as needs- +human (hivecommons/hive#16021). When the new head is red again and the +sweep returns it to 071 within one pass, the record keeps the original ask +and the push that answered it (`rework_asked_at`, `rework_pushed_head`, +`rework_pushed_at`), so the chip reads `ยท re-review pending` dated from the +push rather than `ยท no response` for a fresh ask on the very head the +author just pushed; a review verdict on that head is a fresh ask. When the PR allows maintainer edits (`adoption.in_place`, default on) the hive adopts it in place: `stage/074-adopted-by-hive`, the PR's own branch filed in `ci-failing.json` as the hive's (`adopted: true`) for the scanner's red-PR diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index b1a71f8d06..d81952d9ca 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -570,7 +570,9 @@ func stageTrackerNeedsHuman(it StageTrackerItem) bool { if slices.Contains(stageTrackerNeedsHumanStages, it.Stage) { return true } - return slices.Contains(stageTrackerNeedsHumanAuthorStages, it.Stage) && it.AuthorKind == authorKindHuman + // The author pushed and the hive has not evaluated the new head yet: + // the ball is with the hive, not a person (hivecommons/hive#16021). + return slices.Contains(stageTrackerNeedsHumanAuthorStages, it.Stage) && it.AuthorKind == authorKindHuman && !stageTrackerPushPending(it) } // stageTrackerOnHold mirrors the dashboard's stageTrackerItemOnHold: the diff --git a/src/pkg/dashboard/stage_tracker_decision.go b/src/pkg/dashboard/stage_tracker_decision.go index 2e7c36e3ba..d0b265a974 100644 --- a/src/pkg/dashboard/stage_tracker_decision.go +++ b/src/pkg/dashboard/stage_tracker_decision.go @@ -237,6 +237,12 @@ func stageTrackerDecisionNeededWith(it StageTrackerItem, verdict *review.Aggrega // person's to end (Adopt now / Reroute) โ€” hivecommons/hive#15038. return decisionForWaitingOnContributor(it, held, now) case it.Kind == "pr" && it.AuthorKind == authorKindHuman && slices.Contains(stageTrackerNeedsHumanAuthorStages, it.Stage): + if stageTrackerPushPending(it) { + // The author pushed and CI / the re-review for the new head + // still run: nothing to decide until the hive has looked + // (hivecommons/hive#16021). + return nil + } return decisionForWaitingOnAuthor(it, held) case stageTrackerNeedsHuman(it) || (held && stageTrackerNeedsHuman(stageTrackerWithoutHold(it))): // Flagged for a person by a stage/kind pairing none of the cases diff --git a/src/pkg/dashboard/stage_tracker_decision_redundant_test.go b/src/pkg/dashboard/stage_tracker_decision_redundant_test.go index ec3cc4ac5b..fc99cd4fd2 100644 --- a/src/pkg/dashboard/stage_tracker_decision_redundant_test.go +++ b/src/pkg/dashboard/stage_tracker_decision_redundant_test.go @@ -101,3 +101,23 @@ func TestDecisionForWaitingOnAuthorNeverLeadsWithClose(t *testing.T) { t.Fatalf("closes in the menu = %d, want 2: %+v", closes, d.Options) } } + +// hivecommons/hive#16021: once the author pushed and the new head's CI / +// re-review are still running, the row asks nothing of a person โ€” the +// "waits on @author to push" question would ask for what already happened. +func TestDecisionNeededDropsWaitingOnAuthorAfterPush(t *testing.T) { + now := time.Date(2026, 10, 31, 11, 5, 0, 0, time.UTC) + it := StageTrackerItem{Repo: "hivecommons/hive", Number: 15849, Kind: "pr", Stage: 71, Author: "clubanderson", AuthorKind: authorKindHuman, Reason: "required-check-failing:build-and-test"} + if d := stageTrackerDecisionNeededAt(it, nil, "", now); d == nil || !strings.Contains(d.Question, "waits on @clubanderson to push") { + t.Fatalf("waiting row must ask: %+v", d) + } + it.Push = &StageTrackerPush{State: pushStatePushed, Login: "clubanderson", Sha: "0ff4ed17e"} + if d := stageTrackerDecisionNeededAt(it, nil, "", now); d != nil { + t.Fatalf("pushed row must ask nothing: %+v", d) + } + // Held rows still derive from the underlying state: nothing either. + it.Modifiers = []string{modHold} + if d := stageTrackerDecisionNeededAt(it, nil, "", now); d != nil { + t.Fatalf("held pushed row must ask nothing: %+v", d) + } +} diff --git a/src/pkg/dashboard/stage_tracker_needs_human_test.go b/src/pkg/dashboard/stage_tracker_needs_human_test.go index 88cf3a91e1..67ce18be71 100644 --- a/src/pkg/dashboard/stage_tracker_needs_human_test.go +++ b/src/pkg/dashboard/stage_tracker_needs_human_test.go @@ -20,6 +20,10 @@ func TestStageTrackerNeedsHuman(t *testing.T) { {"071 human author", StageTrackerItem{Stage: 71, AuthorKind: authorKindHuman}, true, false}, {"071 clanker author", StageTrackerItem{Stage: 71, AuthorKind: "clanker"}, false, false}, {"072 human author", StageTrackerItem{Stage: 72, AuthorKind: authorKindHuman}, true, false}, + // hivecommons/hive#16021: the author pushed; CI / the re-review for + // the new head are the hive's to run. + {"071 human author who pushed", StageTrackerItem{Stage: 71, AuthorKind: authorKindHuman, Push: &StageTrackerPush{State: pushStatePushed}}, false, false}, + {"071 human author still waited on", StageTrackerItem{Stage: 71, AuthorKind: authorKindHuman, Push: &StageTrackerPush{State: pushStateWaiting}}, true, false}, {"needs-human pill", StageTrackerItem{Stage: 20, Modifiers: []string{modNeedsHuman}}, true, false}, {"needs-decision pill", StageTrackerItem{Stage: 50, Modifiers: []string{modNeedsDecision}}, true, false}, {"unauthorized pill", StageTrackerItem{Stage: 50, Modifiers: []string{modUnauthorized}}, true, false}, diff --git a/src/pkg/dashboard/stage_tracker_push.go b/src/pkg/dashboard/stage_tracker_push.go index e0a8471638..67d8b87796 100644 --- a/src/pkg/dashboard/stage_tracker_push.go +++ b/src/pkg/dashboard/stage_tracker_push.go @@ -177,3 +177,10 @@ func (s *Server) stageTrackerWaitingPushStale() time.Duration { func stageTrackerPushOnHead(it StageTrackerItem, rec stagelabels.Record) bool { return it.Head == "" || strings.EqualFold(it.Head, rec.LastPushSha) || strings.EqualFold(it.Head, rec.ActivityHead) } + +// stageTrackerPushPending reports whether the row's `push` field says a +// head landed that CI / the re-review have not settled: the ball is with +// the hive, so the row asks nothing of a person (hivecommons/hive#16021). +func stageTrackerPushPending(it StageTrackerItem) bool { + return it.Push != nil && it.Push.State == pushStatePushed +} diff --git a/src/pkg/dashboard/stage_tracker_rework.go b/src/pkg/dashboard/stage_tracker_rework.go index 6cf2195761..d53228a81b 100644 --- a/src/pkg/dashboard/stage_tracker_rework.go +++ b/src/pkg/dashboard/stage_tracker_rework.go @@ -111,6 +111,13 @@ func stageTrackerReworkFor(it StageTrackerItem, login string, stage stagelabels. if requested.IsZero() { requested = rec.EnteredAt } + // A re-ask on the head the author pushed restarts the nudge clock and + // the stage entry; the ask the operator cares about is the original + // one (hivecommons/hive#16021). + pushedHead, pushedAt, pushed := stageTrackerReworkPushed(it, rec) + if pushed && !rec.ReworkAskedAt.IsZero() && rec.ReworkAskedAt.Before(requested) { + requested = rec.ReworkAskedAt + } if requested.IsZero() { return nil } @@ -125,9 +132,16 @@ func stageTrackerReworkFor(it StageTrackerItem, login string, stage stagelabels. } // Pushed: the head the request named is gone. The stage engine routes // the row back to 050 on its next sweep; until then the row says so. - if rec.NudgeHead != "" && it.Head != "" && it.Head != rec.NudgeHead { - out.State, out.Evidence, out.Head = reworkStatePushed, reworkEvidenceCommit, it.Head - if it.UpdatedAt != nil && it.UpdatedAt.After(requested) { + // Or the engine already did, found the pushed head red again and asked + // once more for it: the author answered the ask all the same. + if pushed { + out.State, out.Evidence, out.Head = reworkStatePushed, reworkEvidenceCommit, pushedHead + if !pushedAt.IsZero() { + if pushedAt.After(now) { + pushedAt = now + } + out.Since = &pushedAt + } else if it.UpdatedAt != nil && it.UpdatedAt.After(requested) { u := *it.UpdatedAt out.Since = &u } @@ -183,3 +197,36 @@ func stageTrackerReworkFor(it StageTrackerItem, login string, stage stagelabels. } return out } + +// stageTrackerReworkPushed reports the author's head pushed after the ask, +// and when it landed when the record knows: the row's head is no longer +// the one the nudge named (the sweep has not re-staged the row yet; the +// push instant is the booked one when the webhook saw it), or the record +// remembers the push across the re-ask on that head +// (hivecommons/hive#16021) โ€” unless the re-ask is a review verdict on it, +// which means the re-review the push queued has happened and the new ask +// stands on its own. +func stageTrackerReworkPushed(it StageTrackerItem, rec stagelabels.Record) (head string, at time.Time, ok bool) { + if rec.NudgeHead != "" && it.Head != "" && it.Head != rec.NudgeHead { + if strings.EqualFold(rec.LastPushSha, it.Head) { + at = rec.LastPushAt + } + return it.Head, at, true + } + head, at, ok = rec.ReworkPushed() + if !ok || (it.Head != "" && !strings.EqualFold(it.Head, head)) { + return "", time.Time{}, false + } + if stageTrackerReworkAnswered(rec.Reason) { + return "", time.Time{}, false + } + return head, at, true +} + +// stageTrackerReworkAnswered reports whether the standing ask's reason is +// a review verdict โ€” a reviewer or the swarm looked at the pushed head and +// asked for more โ€” rather than a gate the hive reads off the head (CI, +// conflict, sign-off). +func stageTrackerReworkAnswered(reason string) bool { + return stageTrackerPushNext(stagelabels.NeedsAuthor, reason) == pushNextReReview +} diff --git a/src/pkg/dashboard/stage_tracker_rework_test.go b/src/pkg/dashboard/stage_tracker_rework_test.go index 504664849a..38504dccc5 100644 --- a/src/pkg/dashboard/stage_tracker_rework_test.go +++ b/src/pkg/dashboard/stage_tracker_rework_test.go @@ -89,6 +89,26 @@ func TestStageTrackerReworkFor(t *testing.T) { state: "requested", actor: "zoe", since: requested, reqAtFrom: requested}, {name: "new head pushed", it: pr("bbb", tp(-3*time.Minute)), login: "zoe", stage: stagelabels.ReturnedToContributor, rec: nudged, hasRec: true, fixWork: inflight, state: "pushed", evidence: "commit", actor: "zoe", since: now.Add(-3 * time.Minute), head: "bbb", reqAtFrom: requested}, + // hivecommons/hive#16021: the author force-pushed (rebased commits + // keep their old dates; the list payload's updated_at predates the + // ask), the sweep re-entered 071 for the new red head and re-nudged + // for it. The record remembers the push: pushed, dated from the + // push, requested_at from the original ask. + {name: "re-asked on the pushed head still reads pushed", it: pr("bbb", tp(-2*time.Hour)), login: "zoe", stage: stagelabels.NeedsAuthor, + rec: stagelabels.Record{Stage: stagelabels.NeedsAuthor, Reason: "optional-check-failing:server-tests", EnteredAt: now.Add(-10 * time.Minute), NudgeHead: "bbb", FirstNudgeAt: now.Add(-10 * time.Minute), LastNudgeAt: now.Add(-10 * time.Minute), NudgeCount: 1, + ReworkAskedAt: requested, ReworkPushedHead: "bbb", ReworkPushedAt: now.Add(-12 * time.Minute)}, hasRec: true, fixWork: none, + state: "pushed", evidence: "commit", actor: "zoe", since: now.Add(-12 * time.Minute), head: "bbb", reqAtFrom: requested}, + {name: "review verdict on the pushed head is a fresh ask", it: pr("bbb", nil), login: "zoe", stage: stagelabels.NeedsAuthor, + rec: stagelabels.Record{Stage: stagelabels.NeedsAuthor, Reason: stagelabels.LaneReasonChangesRequested, EnteredAt: now.Add(-10 * time.Minute), NudgeHead: "bbb", FirstNudgeAt: now.Add(-10 * time.Minute), LastNudgeAt: now.Add(-10 * time.Minute), NudgeCount: 1, + ReworkAskedAt: requested, ReworkPushedHead: "bbb", ReworkPushedAt: now.Add(-12 * time.Minute)}, hasRec: true, fixWork: none, + state: "requested", actor: "zoe", since: now.Add(-10 * time.Minute), reqAtFrom: now.Add(-10 * time.Minute)}, + {name: "remembered push on another head does not vouch for this one", it: pr("ccc", nil), login: "zoe", stage: stagelabels.NeedsAuthor, + rec: stagelabels.Record{Stage: stagelabels.NeedsAuthor, Reason: "conflicting", EnteredAt: now.Add(-10 * time.Minute), NudgeHead: "ccc", FirstNudgeAt: now.Add(-10 * time.Minute), LastNudgeAt: now.Add(-10 * time.Minute), NudgeCount: 1, + ReworkAskedAt: requested, ReworkPushedHead: "bbb", ReworkPushedAt: now.Add(-12 * time.Minute)}, hasRec: true, fixWork: none, + state: "requested", actor: "zoe", since: now.Add(-10 * time.Minute), reqAtFrom: now.Add(-10 * time.Minute)}, + {name: "webhook-booked push dates the pushed state", it: pr("bbb", tp(-2*time.Hour)), login: "zoe", stage: stagelabels.ReturnedToContributor, + rec: stagelabels.Record{Stage: stagelabels.ReturnedToContributor, EnteredAt: requested.Add(-time.Minute), NudgeHead: "aaa", FirstNudgeAt: requested, LastNudgeAt: requested, NudgeCount: 1, LastPushSha: "bbb", LastPushAt: now.Add(-4 * time.Minute)}, hasRec: true, fixWork: none, + state: "pushed", evidence: "commit", actor: "zoe", since: now.Add(-4 * time.Minute), head: "bbb", reqAtFrom: requested}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { diff --git a/src/pkg/stagelabels/push_test.go b/src/pkg/stagelabels/push_test.go index 5742958e83..ef540d5a7e 100644 --- a/src/pkg/stagelabels/push_test.go +++ b/src/pkg/stagelabels/push_test.go @@ -133,3 +133,74 @@ func TestStoreNotePushEnumerateFallback(t *testing.T) { t.Fatalf("waiting clock must survive a reload: %+v ok=%v", rec, ok) } } + +// TestStoreReworkPushSurvivesReAsk (hivecommons/hive#16021): the author +// answers a 071 ask with a new head; the sweep re-stages the PR to 050 and, +// the head red again, back to 071 within one pass, re-nudging for it. That +// re-entry restarts the waiting-on-push state and the nudge clock, but the +// record keeps the original ask and the push that answered it. +func TestStoreReworkPushSurvivesReAsk(t *testing.T) { + now := time.Date(2026, 10, 30, 22, 48, 0, 0, time.UTC) + s := NewStore(filepath.Join(t.TempDir(), "stage.json"), func() time.Time { return now }) + key := Key("hivecommons/hive", 15849) + asked := now + s.Observe(key, NeedsAuthor, "required-check-failing:build-and-test") + s.NoteActivity(key, Activity{Head: "3746f58", Comments: -1, Reviews: -1}) + s.MarkNudged(key, "3746f58", 1, false, now) + rec, _ := s.Get(key) + if !rec.ReworkAskedAt.Equal(asked) || rec.ReworkPushedHead != "" { + t.Fatalf("071 entry must open the ask and nothing else: %+v", rec) + } + // The webhook sees the force-push (rebased commits keep their old + // dates; only the delivery instant counts). + pushAt := now.Add(12 * time.Hour) + now = pushAt.Add(time.Minute) + if !s.NotePush(key, "0ff4ed1", pushAt) { + t.Fatal("new head is a push") + } + // Sweep A: CI pending on the new head โ†’ 050, waiting on the hive. + now = now.Add(time.Minute) + s.Observe(key, ReviewPending, "required-check-pending:sign-off") + s.NoteActivity(key, Activity{Head: "0ff4ed1", Comments: -1, Reviews: -1, WaitingOnHive: true}) + // Sweep B, seconds later: an optional check failed fast โ†’ 071 again, + // nudged for the new head. + now = now.Add(12 * time.Second) + s.Observe(key, NeedsAuthor, "optional-check-failing:server-tests") + s.MarkNudged(key, "0ff4ed1", 1, false, now) + s.NoteActivity(key, Activity{Head: "0ff4ed1", Comments: -1, Reviews: -1}) + rec, _ = s.Get(key) + if rec.LastPushSha != "" || !rec.WaitingPushSince.Equal(now) || rec.NudgeHead != "0ff4ed1" || !rec.FirstNudgeAt.Equal(now) { + t.Fatalf("re-entry must restart the push wait and the nudge clock as before: %+v", rec) + } + head, at, ok := rec.ReworkPushed() + if !ok || head != "0ff4ed1" || !at.Equal(pushAt) || !rec.ReworkAskedAt.Equal(asked) { + t.Fatalf("the push that answered the ask must survive the re-ask: %+v", rec) + } + // A second push the webhook missed, seen by the enumerate while the + // row still sits at 071, replaces it. + now = now.Add(time.Hour) + s.NoteActivity(key, Activity{Head: "0157cc9", Comments: -1, Reviews: -1}) + rec, _ = s.Get(key) + if head, at, _ = rec.ReworkPushed(); head != "0157cc9" || !at.Equal(now) { + t.Fatalf("enumerate head change must book the newer push: %+v", rec) + } + // The hive evaluates it, finds it green and waits on nobody: the + // exchange is over, the next 071 is a fresh ask. + now = now.Add(time.Minute) + s.Observe(key, ReviewPending, "review-gate:awaiting-review-approval") + s.NoteActivity(key, Activity{Head: "0157cc9", Comments: -1, Reviews: -1}) + rec, _ = s.Get(key) + if _, _, ok := rec.ReworkPushed(); ok || !rec.ReworkAskedAt.IsZero() { + t.Fatalf("settled head must close the ask: %+v", rec) + } + now = now.Add(time.Hour) + s.Observe(key, NeedsAuthor, LaneReasonChangesRequested) + if rec, _ := s.Get(key); !rec.ReworkAskedAt.Equal(now) || rec.ReworkPushedHead != "" { + t.Fatalf("a later 071 is a new ask: %+v", rec) + } + // Leaving the CI / Review column forgets it all. + s.Observe(key, AwaitingMergeAdmission, "green") + if rec, _ := s.Get(key); !rec.ReworkAskedAt.IsZero() || rec.ReworkPushedHead != "" { + t.Fatalf("leaving the column must clear the ask: %+v", rec) + } +} diff --git a/src/pkg/stagelabels/store.go b/src/pkg/stagelabels/store.go index 7a75540898..29a6bd9703 100644 --- a/src/pkg/stagelabels/store.go +++ b/src/pkg/stagelabels/store.go @@ -350,6 +350,19 @@ type Record struct { // them too. LastPushAt time.Time `json:"last_push_at,omitempty"` LastPushSha string `json:"last_push_sha,omitempty"` + // ReworkAskedAt / ReworkPushedHead / ReworkPushedAt remember the + // author's answer to a 071 / 072 ask across the re-ask on the head + // they pushed (hivecommons/hive#16021): when the hive first asked them + // to push in this run of asks, and the latest head seen after it with + // when it landed. A new head red again re-enters 071 within one sweep, + // which restarts the waiting-on-push state and re-nudges for the new + // head โ€” the two fields the dashboard's rework chip read โ€” so the + // row said "no response" to an author who had just pushed. Cleared + // when the pushed head settles in the CI / Review column without a + // re-ask, and when the item leaves the column. + ReworkAskedAt time.Time `json:"rework_asked_at,omitempty"` + ReworkPushedHead string `json:"rework_pushed_head,omitempty"` + ReworkPushedAt time.Time `json:"rework_pushed_at,omitempty"` // LabelsSuppressed is set when the write-back gate kept the stage // labels off the item on GitHub (a contributor PR without the opt-in // label): the stage lives in this record only, so a label-less item @@ -828,15 +841,23 @@ func (s *Store) NoteActivity(key string, a Activity) (changed bool) { if a.Head != "" && r.ActivityHead != "" && a.Head != r.ActivityHead { // The enumerate fallback for a push no webhook announced // (hivecommons/hive#15784). A head the sweep evaluated and still - // routed back to the author starts a fresh waiting-on-push state. + // routed back to the author starts a fresh waiting-on-push state + // โ€” but it is still the author's answer to the standing ask + // (hivecommons/hive#16021). switch { case r.Stage.WaitsOnPush(): + r.noteReworkPush(a.Head, at) r.WaitingPushSince = at r.LastPushAt, r.LastPushSha = time.Time{}, "" case a.Head != r.LastPushSha: r.LastPushAt, r.LastPushSha = at, a.Head } } + if a.Head != "" && !a.WaitingOnHive && r.Stage.TracksPush() && !r.Stage.WaitsOnPush() && r.Stage != Fixing && r.Stage != AdoptedByHive && strings.EqualFold(a.Head, r.ReworkPushedHead) { + // The hive evaluated the author's answer and is not waiting on + // itself any more: the exchange is over, a later ask is a new one. + r.clearRework() + } if changed { r.HiveHeldWarned = false } @@ -866,6 +887,13 @@ func (s *Store) NoteActivity(key string, a Activity) (changed bool) { func (r *Record) notePushStageChange(now time.Time) { switch { case r.Stage.WaitsOnPush(): + if r.ReworkAskedAt.IsZero() { + r.ReworkAskedAt = now + } else if r.LastPushSha != "" && !r.LastPushAt.Before(r.ReworkAskedAt) { + // Back to the author on the head they pushed for the standing + // ask: the push is the answer, keep it (hivecommons/hive#16021). + r.noteReworkPush(r.LastPushSha, r.LastPushAt) + } r.WaitingPushSince = now r.LastPushAt, r.LastPushSha = time.Time{}, "" case r.Stage.TracksPush(): @@ -873,7 +901,36 @@ func (r *Record) notePushStageChange(now time.Time) { default: r.WaitingPushSince = time.Time{} r.LastPushAt, r.LastPushSha = time.Time{}, "" + r.clearRework() + } +} + +// noteReworkPush books head as the author's latest answer to the standing +// 071 / 072 ask (hivecommons/hive#16021). The same head twice keeps the +// first instant; no standing ask, nothing to answer. +func (r *Record) noteReworkPush(head string, at time.Time) { + head = strings.TrimSpace(head) + if head == "" || r.ReworkAskedAt.IsZero() || strings.EqualFold(head, r.ReworkPushedHead) { + return + } + if at.IsZero() || at.Before(r.ReworkAskedAt) { + at = r.ReworkAskedAt } + r.ReworkPushedHead, r.ReworkPushedAt = head, at +} + +// clearRework forgets the standing ask and the author's answer to it. +func (r *Record) clearRework() { + r.ReworkAskedAt, r.ReworkPushedHead, r.ReworkPushedAt = time.Time{}, "", time.Time{} +} + +// ReworkPushed reports the author's head pushed after the standing ask, +// with when it landed; ok is false when none is on record. +func (r Record) ReworkPushed() (head string, at time.Time, ok bool) { + if r.ReworkPushedHead == "" || r.ReworkAskedAt.IsZero() { + return "", time.Time{}, false + } + return r.ReworkPushedHead, r.ReworkPushedAt, true } // NotePush records that key's head moved to sha at the given instant, as a @@ -1228,7 +1285,19 @@ func (s *Store) MarkNudged(key, head string, n int, online bool, now time.Time) if !ok { return } + if r.ReworkAskedAt.IsZero() { + // Records written before the field existed: the first nudge on + // record is the ask. + if r.ReworkAskedAt = r.NudgeStart(); r.ReworkAskedAt.IsZero() { + r.ReworkAskedAt = now + } + } if r.NudgeHead != head { + if r.NudgeHead != "" { + // A nudge for another head: the author pushed since the last + // one (hivecommons/hive#16021). + r.noteReworkPush(head, now) + } r.NudgeCount = 0 r.FirstNudgeAt = now r.NudgeOnline = online From cd192237f29798fcbf21a079d979af706aa36906 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Sat, 31 Oct 2026 07:37:51 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20tests:=20needs-human=20count?= =?UTF-8?q?=20includes=20the=20new=20pushed-author=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson --- src/pkg/dashboard/stage_tracker_needs_human_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkg/dashboard/stage_tracker_needs_human_test.go b/src/pkg/dashboard/stage_tracker_needs_human_test.go index 67ce18be71..b0e5da21ba 100644 --- a/src/pkg/dashboard/stage_tracker_needs_human_test.go +++ b/src/pkg/dashboard/stage_tracker_needs_human_test.go @@ -50,8 +50,8 @@ func TestStageTrackerNeedsHuman(t *testing.T) { items = append(items, c.it) } nh, oh := stageTrackerHumanCounts(items) - if nh != 9 || oh != 2 { - t.Fatalf("counts = (%d, %d), want (9, 2)", nh, oh) + if nh != 10 || oh != 2 { + t.Fatalf("counts = (%d, %d), want (10, 2)", nh, oh) } for i, c := range cases { if items[i].NeedsHuman != c.needsHuman || items[i].OnHold != c.hold {