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/added-15784-stage-tracker-push-progress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The activity monitor shows push progress on every PR row in the CI / Review column ([#15784](https://github.com/hivecommons/hive/issues/15784)): the stage record keeps `waiting_push_since` / `last_push_at` / `last_push_sha`, booked from the `pull_request` synchronize / `push` webhook re-read with the enumerate head change as fallback. A 071 / 072 pill ends with the wait's age ("waiting on 👤 @user to push · 38m", muted-amber past `dashboard.stage_tracker.waiting_push_stale_h`, default 4); once a push lands the chevron returns to the column's own word (the 👤 clears — the ball is back with the hive) and the gray pill names the push ("@user pushed abc1234 · 2m" linking to the commit, "adopted from @x's #N · pushed 2m ago" on adopted rows, "pushed abc1234 · 2m" on plain CI / Review rows) while CI / the re-review for that head still run; the hive line reads "push seen 2m ago → CI/re-review queued".
16 changes: 15 additions & 1 deletion src/docs/operator-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,20 @@ GitHub calls (hivecommons/hive#15280). Push detection needs the head saved
by a nudge: a never-nudged 071 row has only a stage-entry time, so a push
cannot produce `· re-review pending` and may appear as `· acknowledged`
from PR activity instead. The stage engine still routes the new head to
050 on its next sweep (hivecommons/hive#15286). When the
050 on its next sweep (hivecommons/hive#15286). Every PR row in the CI /
Review column also carries push progress (hivecommons/hive#15784): the
stage record keeps `waiting_push_since`, `last_push_at` and `last_push_sha`,
booked from the `pull_request` synchronize / `push` webhook re-read and, as
a fallback, from the head change the next enumerate sees. While a 071 / 072
row waits the pill ends with the wait's age (`waiting on 👤 @user to push ·
38m`), muted-amber once past `dashboard.stage_tracker.waiting_push_stale_h`
(default `4`; `0` keeps the default, negative disables the tone). Once a
push lands and CI / the re-review for that head still run, the chevron
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
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
Expand Down Expand Up @@ -2002,6 +2015,7 @@ dashboard:
webhook_refresh_debounce_ms: 2000
webhook_refresh_replay_window_s: 1800 # re-apply re-reads to snapshots published meanwhile
closed_sweep_interval_s: 300 # list items closed since the last look and evict rows still shown; -1 disables
waiting_push_stale_h: 4 # hours without a push on a CI / Review row before the pill's age turns muted-amber
```

## `HIVE_GITHUB_TOKEN` permissions
Expand Down
1 change: 1 addition & 0 deletions src/docs/webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ These are the acceptance criteria of #13373 and the tests that hold them.
| `dashboard.stage_tracker.webhook_refresh_debounce_ms` | `2000` | debounce of the single-item re-read a delivery queues |
| `dashboard.stage_tracker.webhook_refresh_replay_window_s` | `1800` | how long a re-read is remembered and re-applied to every status snapshot the governor publishes, so a cycle that enumerated before the close cannot re-list the item |
| `dashboard.stage_tracker.closed_sweep_interval_s` | `300` | how often (driven by status publishes) each repo's items closed since the last look are listed (one call per repo) and rows still shown are evicted; negative disables |
| `dashboard.stage_tracker.waiting_push_stale_h` | `4` | hours a CI / Review row may go without a push (booked from the `pull_request` synchronize / `push` re-read, enumerate as fallback) before its pill's age takes the muted-amber tone; negative disables |
| health window | `2 × governor.eval_interval_s` (10 min at the defaults) | how recent the newest verified delivery must be for webhooks to count as healthy |
| recovery hysteresis | `WebhookRecoveryHealthyWindows` = `2` | consecutive healthy windows required before the cadence returns to webhook mode after a degradation |

Expand Down
22 changes: 22 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package config

import (
Expand Down Expand Up @@ -4961,6 +4961,28 @@
// refused. Each status publish starts a sweep when one is due. 0
// means the default (300); a negative value disables it.
ClosedSweepIntervalS int `yaml:"closed_sweep_interval_s,omitempty" json:"closed_sweep_interval_s,omitempty"`
// WaitingPushStaleH is how many hours a PR row in the CI / Review
// column may wait for its author to push before the waiting-on pill's
// age takes the muted-stale tone (hivecommons/hive#15784). 0 means the
// default (4); a negative value never marks the wait stale.
WaitingPushStaleH int `yaml:"waiting_push_stale_h,omitempty" json:"waiting_push_stale_h,omitempty"`
}

// defaultStageTrackerWaitingPushStale is the default
// dashboard.stage_tracker.waiting_push_stale_h.
const defaultStageTrackerWaitingPushStale = 4 * time.Hour

// StageTrackerWaitingPushStale is the effective
// dashboard.stage_tracker.waiting_push_stale_h as a duration; 0 means a
// wait is never marked stale.
func (c *Config) StageTrackerWaitingPushStale() time.Duration {
if c == nil || c.Dashboard.StageTracker.WaitingPushStaleH == 0 {
return defaultStageTrackerWaitingPushStale
}
if c.Dashboard.StageTracker.WaitingPushStaleH < 0 {
return 0
}
return time.Duration(c.Dashboard.StageTracker.WaitingPushStaleH) * time.Hour
}

// defaultStageTrackerClosedSweepInterval is the default
Expand Down
7 changes: 7 additions & 0 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ type StageTrackerItem struct {
// in_progress or pushed, with the evidence (hivecommons/hive#15280,
// stage_tracker_rework.go).
Rework *StageTrackerRework `json:"rework,omitempty"`
// Push is, on a PR row in the CI / Review column, the push the hive
// waits on or the one that just landed, so the gray pill can say
// "waiting on @zoe to push · 38m" or "@zoe pushed abc1234 · 2m"
// (hivecommons/hive#15784, stage_tracker_push.go).
Push *StageTrackerPush `json:"push,omitempty"`
// Takeover is, on a 072 / 071 clanker PR, the operator's Adopt now /
// Reroute offer and any pending reroute or forced adoption
// (hivecommons/hive#15038, stage_tracker_takeover.go).
Expand Down Expand Up @@ -708,6 +713,8 @@ type StageTrackerLinkedPR struct {
Presence *StageTrackerPresence `json:"presence,omitempty"`
// Rework mirrors the nested PR's own row field (hivecommons/hive#15280).
Rework *StageTrackerRework `json:"rework,omitempty"`
// Push mirrors the nested PR's own row field (hivecommons/hive#15784).
Push *StageTrackerPush `json:"push,omitempty"`
// Takeover mirrors the nested PR's own row field (hivecommons/hive#15038).
Takeover *StageTrackerTakeover `json:"takeover,omitempty"`
// Supersedes mirrors the nested PR's own row field.
Expand Down
6 changes: 6 additions & 0 deletions src/pkg/dashboard/stage_tracker_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ func stageTrackerStageActor(it StageTrackerItem, workers map[string]stageTracker
case stagelabels.Reviewed:
return set(StageActorHive, "", "approved; a required check is still pending")
case stagelabels.Fixing, stagelabels.NeedsAuthor, stagelabels.ReturnedToContributor:
// The author's push landed and CI / the re-review for it still
// run: the ball is back with the hive, the person glyph goes
// (hivecommons/hive#15784).
if it.Push != nil && it.Push.State == pushStatePushed {
return set(StageActorHive, "", stageTrackerPushWhy(it.Push))
}
return stageTrackerAuthorStageActor(a, it, stage, workers, now)
case stagelabels.AdoptedByHive:
if w, ok := stageTrackerWorkerOn(workers, it.Repo, it.Number); ok {
Expand Down
20 changes: 19 additions & 1 deletion src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
isClankerOwner := stageTrackerIsClankerOwner()
adoptionClock := s.stageTrackerAdoptionClock()
rerouteCandidates := s.stageTrackerRerouteCandidates()
pushStaleAfter := s.stageTrackerWaitingPushStale()
finish := func(it *StageTrackerItem, labels []string, stage stagelabels.Stage, rec stagelabels.Record, hasRec bool, draft bool) {
// "Needs human decision" is read from the item's current labels, not
// a store record that outlived them: once the park label is gone
Expand Down Expand Up @@ -191,7 +192,24 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
it.Caption = stageTrackerAdoptionCaption(it.Caption, it.Adoption)
}
}
if login := stageTrackerWaitingOn(*it, stage); login != "" {
it.Push = stageTrackerPushFor(*it, stage, rec, hasRec, pushStaleAfter, now)
pushed := it.Push != nil && it.Push.State == pushStatePushed
if pushed {
// The ball is back with the hive: the row says what the push
// queued, and its note ages from the push (a new hive line).
it.Caption = stageTrackerPushCaption(it.Push, now)
if it.NoteChangedAt == nil || it.Push.Since.After(*it.NoteChangedAt) {
at := *it.Push.Since
it.NoteChangedAt = &at
}
}
// A pushed row no longer waits on its author: no presence marker,
// no rework pickup word, no adoption clock — the pill names the
// push instead.
if pushed {
it.Adoption = nil
}
if login := stageTrackerWaitingOn(*it, stage); login != "" && !pushed {
it.Presence = stageTrackerPresenceFor(*it, login, stage, rec, hasRec, presence, adoptionClock, now)
it.Rework = stageTrackerReworkFor(*it, login, stage, rec, hasRec, fixWork, now)
}
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_links.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin
lp.Adoption = pr.Adoption
lp.Presence = pr.Presence
lp.Rework = pr.Rework
lp.Push = pr.Push
lp.Takeover = pr.Takeover
lp.Supersedes = pr.Supersedes
lp.Lineage = pr.Lineage
Expand Down
169 changes: 169 additions & 0 deletions src/pkg/dashboard/stage_tracker_push.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
package dashboard

import (
"strings"
"time"

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

// Push progress on a CI / Review row (hivecommons/hive#15784). A PR whose
// author must push read "waiting on @zoe to push · acknowledged" and
// "Needs @zoe" until the next sweep re-staged it — nothing said the person
// had pushed, or how long the hive had been waiting. The row's `push`
// field answers from the stage record alone: when the waiting-on-push
// state began (Record.WaitingPushSince) and the last head change seen
// while the row sat in the column (Record.LastPushAt / LastPushSha, booked
// by the webhook re-read of a synchronize delivery or by the enumerate
// that followed). The chevron keeps the stage; the gray pill carries the
// who and the push; the hive caption says what is queued.

// Push states on the wire.
const (
// pushStateWaiting: the hive waits for the author's push; `since` is
// when the wait began.
pushStateWaiting = "waiting"
// pushStatePushed: a head landed; CI and the re-review for it are
// still running. `since` is when it landed.
pushStatePushed = "pushed"

// pushNextCI / pushNextReReview name what the push queued.
pushNextCI = "ci"
pushNextReReview = "re-review"
)

// StageTrackerPush is the `push` field of a PR row in the CI / Review column.
type StageTrackerPush struct {
// State is waiting (no push since the wait began) or pushed.
State string `json:"state"`
// Login is the PR author: whose push the hive waits on, or who pushed.
Login string `json:"login,omitempty"`
// Since is when the state began: the wait's start, or the push.
Since *time.Time `json:"since,omitempty"`
// Sha is the pushed head; URL links to the commit on GitHub.
Sha string `json:"sha,omitempty"`
URL string `json:"url,omitempty"`
// Next is what the push queued: ci or re-review.
Next string `json:"next,omitempty"`
// Stale is set on a wait older than dashboard.stage_tracker.waiting_push_stale_h.
Stale bool `json:"stale,omitempty"`
}

// stageTrackerPushFor derives the `push` field for a PR row at stage. rec
// is the row's stage record; staleAfter is the configured wait threshold
// (0: never stale).
func stageTrackerPushFor(it StageTrackerItem, stage stagelabels.Stage, rec stagelabels.Record, hasRec bool, staleAfter time.Duration, now time.Time) *StageTrackerPush {
if it.Kind != "pr" || !hasRec || !stage.TracksPush() {
return nil
}
login := strings.TrimSpace(it.Author)
if rec.PushedSinceWaiting() && stageTrackerPushSettling(stage, rec) {
at := rec.LastPushAt
if at.After(now) {
at = now
}
return &StageTrackerPush{
State: pushStatePushed,
Login: login,
Since: &at,
Sha: rec.LastPushSha,
URL: stageTrackerCommitURL(it, rec.LastPushSha),
Next: stageTrackerPushNext(stage, rec.Reason),
}
}
if !stage.WaitsOnPush() || rec.WaitingPushSince.IsZero() {
return nil
}
since := rec.WaitingPushSince
if since.After(now) {
since = now
}
return &StageTrackerPush{
State: pushStateWaiting,
Login: login,
Since: &since,
Stale: staleAfter > 0 && now.Sub(since) >= staleAfter,
}
}

// stageTrackerPushSettling reports whether CI or the re-review for the
// pushed head is still ahead: the sweep has not re-staged the row off its
// waiting stage yet, has not seen the head at all, the item waits on the
// hive (checks running, verdict pending), or the hive itself is working
// the head (070 / 074). Once the head is seen, settled and nothing waits
// on the hive, the push is old news and the pill goes.
func stageTrackerPushSettling(stage stagelabels.Stage, rec stagelabels.Record) bool {
switch {
case stage.WaitsOnPush(), stage == stagelabels.Fixing, stage == stagelabels.AdoptedByHive:
return true
case rec.WaitingOnHive:
return true
case !strings.EqualFold(rec.ActivityHead, rec.LastPushSha):
return true
}
return false
}

// stageTrackerPushNext names what the push queued: a re-review when the
// row was returned for review findings, CI otherwise.
func stageTrackerPushNext(stage stagelabels.Stage, reason string) string {
lower := strings.ToLower(reason)
if strings.Contains(lower, "changes") || strings.Contains(lower, "review") {
return pushNextReReview
}
if stage == stagelabels.ReviewPending {
return pushNextReReview
}
return pushNextCI
}

// stageTrackerCommitURL is the GitHub page of sha on the row's repository,
// derived from the PR URL ("https://github.com/o/r/pull/N"); "" when the
// URL is not shaped like that.
func stageTrackerCommitURL(it StageTrackerItem, sha string) string {
if sha == "" {
return ""
}
i := strings.Index(it.URL, "/pull/")
if i < 0 {
return ""
}
return it.URL[:i] + "/commit/" + sha
}

// stageTrackerPushCaption is the hive line for a pushed row: "push seen 2m
// ago → CI/re-review queued". "" when the row carries no push.
func stageTrackerPushCaption(p *StageTrackerPush, now time.Time) string {
if p == nil || p.State != pushStatePushed || p.Since == nil {
return ""
}
ago := shortDuration(now.Sub(*p.Since))
if ago == "0s" {
return "push seen just now → CI/re-review queued"
}
return "push seen " + ago + " ago → CI/re-review queued"
}

// stageTrackerPushWhy is the next-move line for a pushed row: who pushed
// and what the hive runs on the new head.
func stageTrackerPushWhy(p *StageTrackerPush) string {
who := "the author"
if p.Login != "" {
who = "@" + p.Login
}
what := "CI runs on the new head"
if p.Next == pushNextReReview {
what = "the re-review is queued for the new head"
}
return who + " pushed " + shortSHA(p.Sha) + " — " + what
}

// stageTrackerWaitingPushStale is dashboard.stage_tracker.waiting_push_stale_h
// as the server reads it (the config default when no config is wired).
func (s *Server) stageTrackerWaitingPushStale() time.Duration {
if s != nil && s.deps != nil && s.deps.Config != nil {
return s.deps.Config.StageTrackerWaitingPushStale()
}
return (*config.Config)(nil).StageTrackerWaitingPushStale()
}
Loading
Loading