diff --git a/changelog.d/fixed-rereview-pill-attribution.md b/changelog.d/fixed-rereview-pill-attribution.md new file mode 100644 index 0000000000..6286525ffd --- /dev/null +++ b/changelog.d/fixed-rereview-pill-attribution.md @@ -0,0 +1 @@ +- Activity Monitor: a pushed head with nothing against it now waits on `๐Ÿ hive reviewer ยท re-review of ` instead of the PR author (`rework.owed_by`), the Review chevron is the lit one once CI is green, and the GraphQL PR batch no longer caches a truncated `statusCheckRollup` page as the head's full check list โ€” which had read `CI 7/11 ยท required check "test" hasn't reported` on an all-green head with 70+ contexts (#16635). diff --git a/src/pkg/dashboard/stage_tracker_activity.test.js b/src/pkg/dashboard/stage_tracker_activity.test.js index 41ca00b281..3825eb1286 100644 --- a/src/pkg/dashboard/stage_tracker_activity.test.js +++ b/src/pkg/dashboard/stage_tracker_activity.test.js @@ -28,7 +28,7 @@ function constLine(source, name) { return match[0]; } const trackConsts = ['STAGE_TRACKER_WORKFLOW_APPROVAL_BLOCKER', 'STAGE_TRACKER_WORKFLOW_APPROVAL_TIP', 'STAGE_TRACKER_RING_SEGMENT_GAP_MAX', 'STAGE_TRACKER_RING_RADIUS', 'STAGE_TRACKER_RING_GAP_DEG'].map(name => constLine(strip, name)).join('\n'); -const trackFns = ['stageTrackerTrackLead', 'stageTrackerWaitingOnPerson', 'stageTrackerTrackRunning', 'stageTrackerWorkflowApprovalPending', 'stageTrackerRingSvg', 'stageTrackerStalledTrack', 'stageTrackerQueueAheadWord', 'stageTrackerStageTrack', 'stageTrackerHiveOwnsRepair', 'stageTrackerTrackWord', 'stageTrackerActivityTrackHtml'].map(name => fn(strip, name)).join('\n'); +const trackFns = ['stageTrackerHiveOwesReReview', 'stageTrackerTrackLead', 'stageTrackerWaitingOnPerson', 'stageTrackerTrackRunning', 'stageTrackerWorkflowApprovalPending', 'stageTrackerRingSvg', 'stageTrackerStalledTrack', 'stageTrackerQueueAheadWord', 'stageTrackerStageTrack', 'stageTrackerHiveOwnsRepair', 'stageTrackerTrackWord', 'stageTrackerActivityTrackHtml'].map(name => fn(strip, name)).join('\n'); const track = new Function('esc', 'stageTrackerIcon', trackConsts + '\n' + trackFns + ';return stageTrackerActivityTrackHtml;')(esc, (n, cls) => ``); const getAnchor = new Function(globals + anchor + ';return stageTrackerAnchor;')(); const header = new Function('esc', 'stageTrackerIcon', globals + fn(strip, 'stageTrackerHeaderHtml') + ';return stageTrackerHeaderHtml;')(esc, () => ''); @@ -493,7 +493,7 @@ test('Hive #16434 shape: missing current-head CI and review stay unknown but vis assert.match(cells.ci, /title="Current pipeline phase ยท CI: CI \?\/\? ยท no checks reported yet ยท /); assert.doesNotMatch(cells.ci, /no checks reported yet { + const head = 'd88928e16f21ab6e653e5d06f137926bc0db1c0d'; + const fresh = (state, extra = {}) => ({ head, state, caption: state, source: 'github-check-runs', observed_at: new Date(now).toISOString(), ...extra }); + const text = cell => cell.match(/aria-describedby="[^"]+">([^]*?)]*>/g, ''); + const cls = cell => cell.match(/class="ham-seg ham-activity-track ([a-z -]+?)(?: ham-current)?"/)[1]; + const item = livePR({ head, stage: 72, display_column: 50, author: 'thatguywob', author_kind: 'clanker', + push: { state: 'waiting', login: 'thatguywob' }, + code_activity: { head, state: 'fix_pushed', caption: 'Fix pushed d88928e ยท re-review pending', actor: '@thatguywob', source: 'rework-commit' }, + rework: { state: 'pushed', actor: 'thatguywob', evidence: 'commit', head, owed_by: 'hive-reviewer' }, + ci_activity: fresh('passing', { checks_passed: 11, checks_total: 11, caption: 'CI green' }), + review_activity: fresh('unknown', { perspectives_done: 0, perspectives_total: 5 }) }); + const cells = physicalTracks(item); + assert.equal(cls(cells.ci), 'done', 'CI complete: icon only'); assert.equal(text(cells.ci), ''); + assert.match(cells.ci, /data-verdict="pass"/, 'green ring'); + assert.match(cls(cells.review), /^active/, 'the owed re-review is the lit chevron'); + assert.equal(text(cells.review), 'Review 0/5 ยท re-review of d88928e'); + assert.match(cells.review, /hive is waiting on review for new head d88928e/); + assert.equal((cells.ci + cells.review).match(/ham-activity-track active/g).length, 1, 'exactly one active track'); + // While CI still runs on the pushed head, CI is the lit one and Review waits as a glyph. + const running = physicalTracks({ ...item, ci_activity: fresh('running', { checks_passed: 7, checks_total: 11, active: true }) }); + assert.equal(cls(running.ci), 'active'); assert.equal(text(running.ci), 'CI 7/11 ยท running'); + assert.equal(cls(running.review), 'todo'); assert.equal(text(running.review), ''); +}); diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index 192e0a0146..4da5dbebd6 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -556,6 +556,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto stageTrackerApplyCodeActivity(&activityItem, dispatchState, status, now) stageTrackerApplyRemediation(&activityItem, dispatchState, status, stageTrackerFixerAgent(cfg), now) it.CodeActivity, it.Remediation, it.ReviewActivity, it.DisplayColumn, it.Caption = activityItem.CodeActivity, activityItem.Remediation, activityItem.ReviewActivity, activityItem.DisplayColumn, activityItem.Caption + stageTrackerApplyReworkOwedBy(it) } stageTrackerApplyReauthor(resp.Items, store, status.GitHubBaseURL, now) resp.NeedsHuman, resp.OnHold = stageTrackerHumanCounts(resp.Items) diff --git a/src/pkg/dashboard/stage_tracker_presence.test.js b/src/pkg/dashboard/stage_tracker_presence.test.js index 70c2aadb61..97b58da05b 100644 --- a/src/pkg/dashboard/stage_tracker_presence.test.js +++ b/src/pkg/dashboard/stage_tracker_presence.test.js @@ -40,6 +40,15 @@ const src = [ pick(/function stageTrackerPresenceInPillHtml\(item, text\) \{[\s\S]*?\n \}\n/, 'stageTrackerPresenceInPillHtml'), pick(/function stageTrackerPresenceChipText\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerPresenceChipText'), pick(/function stageTrackerPresenceChipHtml\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerPresenceChipHtml'), + pick(/const STAGE_TRACKER_REWORK_WORDS = [^\n]*\n/, 'STAGE_TRACKER_REWORK_WORDS'), + pick(/function stageTrackerReworkOf\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkOf'), + pick(/function stageTrackerReworkWord\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkWord'), + pick(/const STAGE_TRACKER_REWORK_OWED_BY_HIVE = [^\n]*\n/, 'STAGE_TRACKER_REWORK_OWED_BY_HIVE'), + pick(/function stageTrackerReReviewOwedByHive\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReReviewOwedByHive'), + pick(/function stageTrackerReReviewWord\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReReviewWord'), + pick(/function stageTrackerHiveReviewerChipText\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerHiveReviewerChipText'), + pick(/function stageTrackerReworkSuffix\(text, item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkSuffix'), + pick(/function stageTrackerReworkTip\(item, nowMs\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkTip'), ].join('\n'); // The clock the tooltips are rendered against, and the stubs the lifted @@ -52,7 +61,7 @@ const stubs = ` Date.now = () => ${NOW}; `; const api = new Function(stubs + src + `; return { of: stageTrackerPresenceOf, tip: stageTrackerPresenceTip, aria: stageTrackerPresenceAria, dot: stageTrackerPresenceDotHtml, - inPill: stageTrackerPresenceInPillHtml, chipText: stageTrackerPresenceChipText, chip: stageTrackerPresenceChipHtml, adoptionChip: stageTrackerAdoptionChipHtml, icons: STAGE_TRACKER_ICONS };`)(); + inPill: stageTrackerPresenceInPillHtml, chipText: stageTrackerPresenceChipText, chip: stageTrackerPresenceChipHtml, adoptionChip: stageTrackerAdoptionChipHtml, adoptionChipText: stageTrackerAdoptionChipText, reworkTip: stageTrackerReworkTip, icons: STAGE_TRACKER_ICONS };`)(); // Collapse an inline SVG's body so the surrounding markup can be matched exactly. const flat = (h) => h.replace(/]*)>[\s\S]*?<\/svg>/g, ''); @@ -170,3 +179,39 @@ test('style ratchet: the indicator uses classes and tokens, no inline styles; re assert.match(html, /\.ham-presence-unknown \.ham-presence-dot \{[^\n]*border: var\(--line-width\) solid var\(--text-faint\)[^\n]*background: transparent/); assert.match(html, /@media \(prefers-reduced-motion: reduce\) \{ \.ham-presence-online \.ham-presence-dot \{ animation: none; \} \}/); }); + +// hivecommons/hive#16615: @thatguywob (a clanker) pushed d88928e after the +// ask; every check on it is green and no findings stand against it. The +// re-review is the HIVE reviewer's to deliver โ€” the pill must not say the +// hive waits on the clanker. +const head16615 = 'd88928e16f21ab6e653e5d06f137926bc0db1c0d'; +const pushed16615 = { repo: 'hivecommons/hive', number: 16615, kind: 'pr', stage: 72, head: head16615, author: 'thatguywob', author_kind: 'clanker', + adoption: { author: 'thatguywob', due: false, since: iso(NOW - 4 * MIN), nudges: 1, author_online: false, author_registered: true, policy: 'adopt', text: 'waiting on @thatguywob (offline 4m, 1 nudge)' }, + presence: { login: 'thatguywob', state: 'offline', kind: 'clanker', since: iso(NOW - 4 * MIN), last_seen: iso(NOW - 10 * MIN), next: 'adopt', adopt_at: iso(NOW + 11 * MIN) }, + rework: { state: 'pushed', actor: 'thatguywob', requested_at: iso(NOW - 4 * MIN), since: iso(NOW - 3 * MIN), evidence: 'commit', head: head16615, owed_by: 'hive-reviewer' }, + ci_activity: { head: head16615, state: 'passing', caption: 'CI green' }, + review_activity: { head: head16615, state: 'unknown', perspectives_done: 0, perspectives_total: 5 } }; + +test('#16615: a pushed, green head waits on the hive reviewer, not the clanker that pushed it', () => { + assert.strictEqual(api.adoptionChipText(pushed16615), 'waiting on ๐Ÿ hive reviewer ยท re-review of d88928e'); + assert.strictEqual(api.chipText(pushed16615), 'waiting on ๐Ÿ hive reviewer ยท re-review of d88928e'); + const chip = api.adoptionChip(pushed16615); + assert.match(chip, />waiting on ๐Ÿ hive reviewer ยท re-review of d88928e { + const owes = (extra) => api.adoptionChipText({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined }, ...extra }); + assert.strictEqual(owes({ ci_activity: { head: head16615, state: 'failing' } }), 'waiting on @thatguywob ยท re-review pending', 'red CI on the pushed head is theirs to fix'); + assert.strictEqual(owes({ review_activity: { head: head16615, state: 'changes_requested' } }), 'waiting on @thatguywob ยท re-review pending', 'findings on the pushed head are theirs'); + assert.strictEqual(owes({ reason: 'conflicting' }), 'waiting on @thatguywob ยท re-review pending', 'a conflict nobody rebases is theirs'); + assert.strictEqual(owes({ reason: 'conflicting', rebase: { attempt: 1, max: 2 } }), 'waiting on ๐Ÿ hive reviewer ยท re-review of d88928e', 'the hive rebasing it is the hive\'s move'); + assert.strictEqual(api.adoptionChipText({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: 'author' } }), 'waiting on @thatguywob ยท re-review pending', 'the server\'s word wins over the activities'); + assert.strictEqual(api.adoptionChipText({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined, state: 'acknowledged' } }), 'waiting on @thatguywob ยท acknowledged', 'before the push the author owes the rework'); + const authorChip = api.adoptionChip({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined }, ci_activity: { head: head16615, state: 'failing' } }); + assert.match(authorChip, /ham-presence-dot/, 'the author pill keeps its presence glyph'); +}); diff --git a/src/pkg/dashboard/stage_tracker_rework.go b/src/pkg/dashboard/stage_tracker_rework.go index dc6588529e..fcd7511ea4 100644 --- a/src/pkg/dashboard/stage_tracker_rework.go +++ b/src/pkg/dashboard/stage_tracker_rework.go @@ -68,6 +68,51 @@ type StageTrackerRework struct { Ahead int `json:"ahead,omitempty"` // Head is the new head on a pushed state. Head string `json:"head,omitempty"` + // OwedBy names who owes the next move on a pushed state + // (hivecommons/hive#16615): "hive-reviewer" when the new head needs the + // hive's re-review and nothing on it is the author's to fix, so the + // waiting-on pill names the hive, not the author; "author" when they + // still owe something on the pushed head โ€” red CI, changes requested on + // it, or a conflict nobody in the hive is rebasing. Empty on the other + // states (and from older servers, which the dashboard reads from the + // activities instead). + OwedBy string `json:"owed_by,omitempty"` +} + +// Who owes the next move on a pushed head. +const ( + reworkOwedByHiveReviewer = "hive-reviewer" + reworkOwedByAuthor = "author" +) + +// stageTrackerApplyReworkOwedBy fills Rework.OwedBy once the row's CI and +// review activity are known (they are derived after the rework field). +func stageTrackerApplyReworkOwedBy(it *StageTrackerItem) { + if it == nil || it.Rework == nil || it.Rework.State != reworkStatePushed { + return + } + it.Rework.OwedBy = stageTrackerReworkOwedBy(*it) +} + +// stageTrackerReworkOwedBy answers "who owes the next move on the pushed +// head?" The author owes it only when the head itself asks them for +// something: CI failing on it, review findings against it, or a merge +// conflict the hive is not rebasing. Otherwise the re-review of the new +// head is the hive reviewer's to deliver. +func stageTrackerReworkOwedBy(it StageTrackerItem) string { + onHead := func(a *StageTrackerActivity) bool { + return a != nil && (a.Head == "" || it.Head == "" || strings.EqualFold(a.Head, it.Head)) + } + if onHead(it.CIActivity) && it.CIActivity.State == "failing" { + return reworkOwedByAuthor + } + if onHead(it.ReviewActivity) && it.ReviewActivity.State == "changes_requested" { + return reworkOwedByAuthor + } + if strings.Contains(strings.ToLower(it.Reason), "conflict") && it.Rebase == nil { + return reworkOwedByAuthor + } + return reworkOwedByHiveReviewer } // StageTrackerFixWork is the hub's fix-queue standing for one PR and one diff --git a/src/pkg/dashboard/stage_tracker_rework_test.go b/src/pkg/dashboard/stage_tracker_rework_test.go index 4e31912617..ce47bbd4cb 100644 --- a/src/pkg/dashboard/stage_tracker_rework_test.go +++ b/src/pkg/dashboard/stage_tracker_rework_test.go @@ -207,6 +207,10 @@ func TestStageTrackerReworkJS(t *testing.T) { jsConstLine(t, html, "STAGE_TRACKER_REWORK_WORDS"), jsFunc(t, html, "stageTrackerReworkOf"), jsFunc(t, html, "stageTrackerReworkWord"), + jsConstLine(t, html, "STAGE_TRACKER_REWORK_OWED_BY_HIVE"), + jsFunc(t, html, "stageTrackerReReviewOwedByHive"), + jsFunc(t, html, "stageTrackerReReviewWord"), + jsFunc(t, html, "stageTrackerHiveReviewerChipText"), jsFunc(t, html, "stageTrackerReworkSuffix"), jsFunc(t, html, "stageTrackerReworkTip"), jsFunc(t, html, "stageTrackerReworkJoinTip"), @@ -240,12 +244,14 @@ assert.strictEqual(stageTrackerPresenceChipText(requested), 'waiting on @Danatha assert.strictEqual(stageTrackerPresenceChipText(queued), 'waiting on @Danathar ยท queued'); assert.strictEqual(stageTrackerPresenceChipText(acked), 'waiting on @Danathar ยท acknowledged'); assert.strictEqual(stageTrackerPresenceChipText(working), 'waiting on @Danathar ยท working'); -assert.strictEqual(stageTrackerPresenceChipText(pushed), 'waiting on @Danathar ยท re-review pending'); +// A pushed head with nothing against it waits on the hive's reviewer (hivecommons/hive#16615). +assert.strictEqual(stageTrackerPresenceChipText(pushed), 'waiting on ๐Ÿ hive reviewer ยท re-review of bbb'); +assert.strictEqual(stageTrackerPresenceChipText(w(Object.assign({}, pushed.rework, { owed_by: 'author' }))), 'waiting on @Danathar ยท re-review pending', 'the server says the author still owes it'); assert.match(stageTrackerReworkTip(requested, NOW), /^rework requested 1 hour ago \(\S+ .*\) ยท no response from @Danathar yet$/); assert.match(stageTrackerReworkTip(queued, NOW), /^rework queued for @Danathar's clanker ยท 2 ahead ยท queued 10 min ago \(/); assert.match(stageTrackerReworkTip(acked, NOW), /^@Danathar acknowledged ยท activity on the PR 20 min ago \(/); assert.match(stageTrackerReworkTip(working, NOW), /^@Danathar's clanker picked up the rework 5 min ago \(.*\) \(spawn\)$/); -assert.match(stageTrackerReworkTip(pushed, NOW), /^@Danathar pushed a new head 1 min ago \(.*\) ยท re-review pending$/); +assert.match(stageTrackerReworkTip(pushed, NOW), /^@Danathar pushed a new head 1 min ago \(.*\) ยท hive reviewer owes the re-review of bbb$/); // The pill keeps its class, dot and login; title and aria carry the rework line after the presence line. const chip = stageTrackerPresenceChipHtml(acked); assert.ok(/^waiting on ]*>[\s\S]*<\/span>@Danathar ยท acknowledged<\/span>$/.test(chip), chip); @@ -271,3 +277,64 @@ assert.strictEqual(states([issue])[lk].rework, 'acknowledged'); `}, "\n") runStageTrackerRowActionsScript(t, script) } + +// hivecommons/hive#16615: @thatguywob's clanker pushed d88928e; every check +// on it is green and no findings stand against it. "re-review pending" is +// the HIVE reviewer's debt, so the row says so (`owed_by`) and the pill +// stops naming the author. The author keeps the pill only when the pushed +// head asks them for something. +func TestStageTrackerReworkOwedBy16615(t *testing.T) { + const head = "d88928e16f21ab6e653e5d06f137926bc0db1c0d" + base := func() StageTrackerItem { + return StageTrackerItem{Kind: "pr", Number: 16615, Head: head, Author: "thatguywob", AuthorKind: "clanker", Stage: 72, + Rework: &StageTrackerRework{State: reworkStatePushed, Actor: "thatguywob", Evidence: reworkEvidenceCommit, Head: head}, + CIActivity: &StageTrackerActivity{Head: head, State: "passing", ChecksPassed: 11, ChecksTotal: 11}, + ReviewActivity: &StageTrackerActivity{Head: head, State: "unknown", PerspectivesTotal: 5}} + } + it := base() + stageTrackerApplyReworkOwedBy(&it) + if it.Rework.OwedBy != reworkOwedByHiveReviewer { + t.Fatalf("green pushed head: owed_by = %q, want %q", it.Rework.OwedBy, reworkOwedByHiveReviewer) + } + raw, _ := json.Marshal(it.Rework) + if !strings.Contains(string(raw), `"owed_by":"hive-reviewer"`) { + t.Fatalf("payload lacks owed_by: %s", raw) + } + + for name, mutate := range map[string]func(*StageTrackerItem){ + "red CI on the pushed head": func(it *StageTrackerItem) { it.CIActivity.State = "failing" }, + "findings on the pushed head": func(it *StageTrackerItem) { it.ReviewActivity.State = "changes_requested" }, + "conflict nobody in the hive rebases": func(it *StageTrackerItem) { it.Reason = "conflicting" }, + } { + it := base() + mutate(&it) + stageTrackerApplyReworkOwedBy(&it) + if it.Rework.OwedBy != reworkOwedByAuthor { + t.Fatalf("%s: owed_by = %q, want %q so the author keeps the pill", name, it.Rework.OwedBy, reworkOwedByAuthor) + } + } + // The hive rebasing the conflict is the hive's move. + it = base() + it.Reason, it.Rebase = "conflicting", &StageTrackerRebase{Attempt: 1, Max: 2} + stageTrackerApplyReworkOwedBy(&it) + if it.Rework.OwedBy != reworkOwedByHiveReviewer { + t.Fatalf("hive rebasing: owed_by = %q, want %q", it.Rework.OwedBy, reworkOwedByHiveReviewer) + } + // Red CI on an OLDER head says nothing about the pushed one. + it = base() + it.CIActivity = &StageTrackerActivity{Head: "6384f9b", State: "failing"} + stageTrackerApplyReworkOwedBy(&it) + if it.Rework.OwedBy != reworkOwedByHiveReviewer { + t.Fatalf("stale red CI: owed_by = %q, want %q", it.Rework.OwedBy, reworkOwedByHiveReviewer) + } + // Before the push the author owes the rework; nothing to attribute. + it = base() + it.Rework.State = reworkStateAcknowledged + stageTrackerApplyReworkOwedBy(&it) + if it.Rework.OwedBy != "" { + t.Fatalf("acknowledged: owed_by = %q, want empty", it.Rework.OwedBy) + } + var none *StageTrackerItem + stageTrackerApplyReworkOwedBy(none) + stageTrackerApplyReworkOwedBy(&StageTrackerItem{}) +} diff --git a/src/pkg/dashboard/static-src/js/tracker-row-strip.js b/src/pkg/dashboard/static-src/js/tracker-row-strip.js index 87bc10364a..7694361e8c 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -15,6 +15,15 @@ return ``; } + // The backend's word that the pushed head waits on the hive's own + // reviewer, not the author (`rework.owed_by`, hivecommons/hive#16615): + // the re-review is the hive's move, so the row is not parked on a + // person and the Review track reads "re-review of ". + function stageTrackerHiveOwesReReview(item) { + const r = item && item.rework; + return !!(r && r.state === 'pushed' && r.owed_by === 'hive-reviewer' && (!r.head || !item.head || r.head === item.head)); + } + // Pure: which of the two column-50 tracks the hive is waiting on when // both share the current phase (hivecommons/hive#16484). Review // findings and red CI are the fixer's turn ("the fix"); otherwise CI @@ -28,7 +37,7 @@ const done = s => s === 'passing' || s === 'approved'; const code = item.code_activity; const push = item.push; - const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head)); + const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head) || (typeof stageTrackerHiveOwesReReview === 'function' && stageTrackerHiveOwesReReview(item))); if (review === 'changes_requested') return { track: 'review', waitingOn: 'the fix', newHead: false }; if (ci === 'failing') return { track: 'ci', waitingOn: 'the fix', newHead: false }; if (done(ci) && done(review)) return null; @@ -40,7 +49,7 @@ // asked for (hivecommons/hive#16484): "CI 12/14 passed", "CI 11/14 ยท 1 // failing (lint)", "CI 0/14 ยท queued", "CI ?/? ยท no checks reported // yet"; "Review 3/5 perspectives", "Review 5/5 approved", "Review 0/5 ยท - // re-review pending (new head)", "Review 2/5 ยท awaiting human + // re-review of d88928e", "Review 2/5 ยท awaiting human // decision". '' means the track has not started on this head (the // chevron shows its glyph alone). current: column 50 is the row's // active phase, so even absent evidence is "in progress" there. @@ -77,7 +86,10 @@ const actor = matches && a.actor ? String(a.actor) : ''; const code = item.code_activity; const push = item.push; - const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head)); + const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head) || (typeof stageTrackerHiveOwesReReview === 'function' && stageTrackerHiveOwesReReview(item))); + // "re-review of d88928e": the hive reviewer's owed pass, named by + // head so it never reads as the author's turn (hivecommons/hive#16615). + const reReview = 're-review of ' + String(item.head || '').slice(0, 7); switch (state) { case 'approved': return count + ' approved'; case 'changes_requested': return count + ' ยท changes requested'; @@ -98,7 +110,7 @@ case 'adjudicating': return count + ' ยท ' + (actor ? actor + ' adjudicating' : 'adjudicating'); case 'assigned': return count + ' ยท ' + (actor ? actor + ' queued' : 'queued') + stageTrackerQueueAheadWord(a); case 'unassigned': return count + ' ยท queued' + stageTrackerQueueAheadWord(a); - default: return count + ' ยท ' + (newHead ? 're-review pending (new head)' : total && done ? 'perspectives' : 'queued'); + default: return count + ' ยท ' + (newHead ? reReview : total && done ? 'perspectives' : 'queued'); } } @@ -207,7 +219,7 @@ const stage = Number(item.stage); // A freshly pushed head is in motion: checks run on it, matching // tracker-row-anchor's column-50 anchor (hivecommons/hive#16552). - if ((stage === 71 || stage === 72) && !(item.push && ['pushed', 'checking'].includes(item.push.state))) return true; + if ((stage === 71 || stage === 72) && !(item.push && ['pushed', 'checking'].includes(item.push.state)) && !(typeof stageTrackerHiveOwesReReview === 'function' && stageTrackerHiveOwesReReview(item))) return true; const code = item.code_activity; return !!(code && code.head === item.head && code.state === 'waiting_owner'); } diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index d94d7d5f2b..ec9db5498c 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -81,6 +81,7 @@ } } // Guarded: the test harnesses load helpers by name. + if (typeof stageTrackerHiveReviewerChipText === 'function' && stageTrackerHiveReviewerChipText(item)) return stageTrackerHiveReviewerChipText(item); const text = 'waiting on ' + (a.author ? '@' + a.author : 'author'); return typeof stageTrackerReworkSuffix === 'function' ? stageTrackerReworkSuffix(text, item) : text; } @@ -202,8 +203,10 @@ // Pill text with the indicator placed just before the @login (or // leading, when the text names nobody): "waiting on [robot โ—] @hanthor". function stageTrackerPresenceInPillHtml(item, text) { - const dot = stageTrackerPresenceDotHtml(item, Date.now()); const t = String(text || ''); + // The hive's own turn: no author presence glyph on the pill. + if (typeof stageTrackerReReviewOwedByHive === 'function' && stageTrackerReReviewOwedByHive(item)) return esc(t); + const dot = stageTrackerPresenceDotHtml(item, Date.now()); if (!dot) return esc(t); const i = t.indexOf('@'); if (i < 0) return dot + esc(t); @@ -217,6 +220,8 @@ function stageTrackerPresenceChipText(item) { const p = stageTrackerPresenceOf(item); if (!p) return ''; + // Guarded: the test harnesses load helpers by name. + if (typeof stageTrackerHiveReviewerChipText === 'function' && stageTrackerHiveReviewerChipText(item)) return stageTrackerHiveReviewerChipText(item); const ownPR = item && item.kind === 'pr' && item.author_kind === 'human' && p.kind === 'human' && String(item.author || '').toLowerCase() === String(p.login).toLowerCase(); const text = 'waiting on @' + p.login + (ownPR ? ' to push' : ''); // Guarded: the test harnesses load helpers by name. @@ -340,6 +345,35 @@ if (r.state === 'requested' && r.evidence === 'queued') return 'queued'; return STAGE_TRACKER_REWORK_WORDS[r.state]; } + // "re-review pending" means the HIVE's reviewer owes a pass on the new + // head, not the author (hivecommons/hive#16615: "are we waiting on the + // clanker or are we in CI?"). The backend says so with + // `rework.owed_by: "hive-reviewer"` once the pushed head carries + // nothing the author must fix (red CI, findings, a conflict nobody + // rebases) and "author" while it does; older payloads without the + // field are read the same way from the activities. + const STAGE_TRACKER_REWORK_OWED_BY_HIVE = 'hive-reviewer'; + function stageTrackerReReviewOwedByHive(item) { + const r = stageTrackerReworkOf(item); + if (!r || r.state !== 'pushed') return false; + if (r.owed_by) return r.owed_by === STAGE_TRACKER_REWORK_OWED_BY_HIVE; + const on = k => { const a = item[k + '_activity']; return a && (!a.head || !item.head || a.head === item.head) ? a.state || 'unknown' : 'unknown'; }; + if (on('ci') === 'failing' || on('review') === 'changes_requested') return false; + if (/conflict/i.test(String(item.reason || '')) && !item.rebase) return false; + return true; + } + // "re-review of d88928e" โ€” the owed pass, named by head. + function stageTrackerReReviewWord(item) { + const r = stageTrackerReworkOf(item); + const sha = String((r && r.head) || item.head || '').slice(0, 7); + return 're-review' + (sha ? ' of ' + sha : ' pending'); + } + // "waiting on ๐Ÿ hive reviewer ยท re-review of d88928e"; '' when the + // author still owes the next move. + function stageTrackerHiveReviewerChipText(item) { + if (!stageTrackerReReviewOwedByHive(item)) return ''; + return 'waiting on ๐Ÿ hive reviewer ยท ' + stageTrackerReReviewWord(item); + } // "waiting on @x ยท acknowledged" โ€” the pill text with the pickup word. function stageTrackerReworkSuffix(text, item) { const w = stageTrackerReworkWord(item); @@ -358,7 +392,7 @@ const since = when(r.since); switch (r.state) { case 'pushed': - return who + ' pushed a new head' + (since ? ' ' + since : '') + ' ยท re-review pending'; + return who + ' pushed a new head' + (since ? ' ' + since : '') + (stageTrackerReReviewOwedByHive(item) ? ' ยท hive reviewer owes the ' + stageTrackerReReviewWord(item) : ' ยท re-review pending'); case 'in_progress': return who + "'s clanker picked up the rework" + (since ? ' ' + since : '') + (r.mode ? ' (' + r.mode + ')' : ''); case 'acknowledged': diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index ba8b3295a2..f855250501 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -16997,6 +16997,7 @@

Where to get help

} } // Guarded: the test harnesses load helpers by name. + if (typeof stageTrackerHiveReviewerChipText === 'function' && stageTrackerHiveReviewerChipText(item)) return stageTrackerHiveReviewerChipText(item); const text = 'waiting on ' + (a.author ? '@' + a.author : 'author'); return typeof stageTrackerReworkSuffix === 'function' ? stageTrackerReworkSuffix(text, item) : text; } @@ -17118,8 +17119,10 @@

Where to get help

// Pill text with the indicator placed just before the @login (or // leading, when the text names nobody): "waiting on [robot โ—] @hanthor". function stageTrackerPresenceInPillHtml(item, text) { - const dot = stageTrackerPresenceDotHtml(item, Date.now()); const t = String(text || ''); + // The hive's own turn: no author presence glyph on the pill. + if (typeof stageTrackerReReviewOwedByHive === 'function' && stageTrackerReReviewOwedByHive(item)) return esc(t); + const dot = stageTrackerPresenceDotHtml(item, Date.now()); if (!dot) return esc(t); const i = t.indexOf('@'); if (i < 0) return dot + esc(t); @@ -17133,6 +17136,8 @@

Where to get help

function stageTrackerPresenceChipText(item) { const p = stageTrackerPresenceOf(item); if (!p) return ''; + // Guarded: the test harnesses load helpers by name. + if (typeof stageTrackerHiveReviewerChipText === 'function' && stageTrackerHiveReviewerChipText(item)) return stageTrackerHiveReviewerChipText(item); const ownPR = item && item.kind === 'pr' && item.author_kind === 'human' && p.kind === 'human' && String(item.author || '').toLowerCase() === String(p.login).toLowerCase(); const text = 'waiting on @' + p.login + (ownPR ? ' to push' : ''); // Guarded: the test harnesses load helpers by name. @@ -17256,6 +17261,35 @@

Where to get help

if (r.state === 'requested' && r.evidence === 'queued') return 'queued'; return STAGE_TRACKER_REWORK_WORDS[r.state]; } + // "re-review pending" means the HIVE's reviewer owes a pass on the new + // head, not the author (hivecommons/hive#16615: "are we waiting on the + // clanker or are we in CI?"). The backend says so with + // `rework.owed_by: "hive-reviewer"` once the pushed head carries + // nothing the author must fix (red CI, findings, a conflict nobody + // rebases) and "author" while it does; older payloads without the + // field are read the same way from the activities. + const STAGE_TRACKER_REWORK_OWED_BY_HIVE = 'hive-reviewer'; + function stageTrackerReReviewOwedByHive(item) { + const r = stageTrackerReworkOf(item); + if (!r || r.state !== 'pushed') return false; + if (r.owed_by) return r.owed_by === STAGE_TRACKER_REWORK_OWED_BY_HIVE; + const on = k => { const a = item[k + '_activity']; return a && (!a.head || !item.head || a.head === item.head) ? a.state || 'unknown' : 'unknown'; }; + if (on('ci') === 'failing' || on('review') === 'changes_requested') return false; + if (/conflict/i.test(String(item.reason || '')) && !item.rebase) return false; + return true; + } + // "re-review of d88928e" โ€” the owed pass, named by head. + function stageTrackerReReviewWord(item) { + const r = stageTrackerReworkOf(item); + const sha = String((r && r.head) || item.head || '').slice(0, 7); + return 're-review' + (sha ? ' of ' + sha : ' pending'); + } + // "waiting on ๐Ÿ hive reviewer ยท re-review of d88928e"; '' when the + // author still owes the next move. + function stageTrackerHiveReviewerChipText(item) { + if (!stageTrackerReReviewOwedByHive(item)) return ''; + return 'waiting on ๐Ÿ hive reviewer ยท ' + stageTrackerReReviewWord(item); + } // "waiting on @x ยท acknowledged" โ€” the pill text with the pickup word. function stageTrackerReworkSuffix(text, item) { const w = stageTrackerReworkWord(item); @@ -17274,7 +17308,7 @@

Where to get help

const since = when(r.since); switch (r.state) { case 'pushed': - return who + ' pushed a new head' + (since ? ' ' + since : '') + ' ยท re-review pending'; + return who + ' pushed a new head' + (since ? ' ' + since : '') + (stageTrackerReReviewOwedByHive(item) ? ' ยท hive reviewer owes the ' + stageTrackerReReviewWord(item) : ' ยท re-review pending'); case 'in_progress': return who + "'s clanker picked up the rework" + (since ? ' ' + since : '') + (r.mode ? ' (' + r.mode + ')' : ''); case 'acknowledged': @@ -17886,6 +17920,15 @@

Where to get help

return ``; } + // The backend's word that the pushed head waits on the hive's own + // reviewer, not the author (`rework.owed_by`, hivecommons/hive#16615): + // the re-review is the hive's move, so the row is not parked on a + // person and the Review track reads "re-review of ". + function stageTrackerHiveOwesReReview(item) { + const r = item && item.rework; + return !!(r && r.state === 'pushed' && r.owed_by === 'hive-reviewer' && (!r.head || !item.head || r.head === item.head)); + } + // Pure: which of the two column-50 tracks the hive is waiting on when // both share the current phase (hivecommons/hive#16484). Review // findings and red CI are the fixer's turn ("the fix"); otherwise CI @@ -17899,7 +17942,7 @@

Where to get help

const done = s => s === 'passing' || s === 'approved'; const code = item.code_activity; const push = item.push; - const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head)); + const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head) || (typeof stageTrackerHiveOwesReReview === 'function' && stageTrackerHiveOwesReReview(item))); if (review === 'changes_requested') return { track: 'review', waitingOn: 'the fix', newHead: false }; if (ci === 'failing') return { track: 'ci', waitingOn: 'the fix', newHead: false }; if (done(ci) && done(review)) return null; @@ -17911,7 +17954,7 @@

Where to get help

// asked for (hivecommons/hive#16484): "CI 12/14 passed", "CI 11/14 ยท 1 // failing (lint)", "CI 0/14 ยท queued", "CI ?/? ยท no checks reported // yet"; "Review 3/5 perspectives", "Review 5/5 approved", "Review 0/5 ยท - // re-review pending (new head)", "Review 2/5 ยท awaiting human + // re-review of d88928e", "Review 2/5 ยท awaiting human // decision". '' means the track has not started on this head (the // chevron shows its glyph alone). current: column 50 is the row's // active phase, so even absent evidence is "in progress" there. @@ -17948,7 +17991,10 @@

Where to get help

const actor = matches && a.actor ? String(a.actor) : ''; const code = item.code_activity; const push = item.push; - const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head)); + const newHead = !!((code && code.head === item.head && code.state === 'pushed') || (push && push.state === 'pushed' && push.sha === item.head) || (typeof stageTrackerHiveOwesReReview === 'function' && stageTrackerHiveOwesReReview(item))); + // "re-review of d88928e": the hive reviewer's owed pass, named by + // head so it never reads as the author's turn (hivecommons/hive#16615). + const reReview = 're-review of ' + String(item.head || '').slice(0, 7); switch (state) { case 'approved': return count + ' approved'; case 'changes_requested': return count + ' ยท changes requested'; @@ -17969,7 +18015,7 @@

Where to get help

case 'adjudicating': return count + ' ยท ' + (actor ? actor + ' adjudicating' : 'adjudicating'); case 'assigned': return count + ' ยท ' + (actor ? actor + ' queued' : 'queued') + stageTrackerQueueAheadWord(a); case 'unassigned': return count + ' ยท queued' + stageTrackerQueueAheadWord(a); - default: return count + ' ยท ' + (newHead ? 're-review pending (new head)' : total && done ? 'perspectives' : 'queued'); + default: return count + ' ยท ' + (newHead ? reReview : total && done ? 'perspectives' : 'queued'); } } @@ -18078,7 +18124,7 @@

Where to get help

const stage = Number(item.stage); // A freshly pushed head is in motion: checks run on it, matching // tracker-row-anchor's column-50 anchor (hivecommons/hive#16552). - if ((stage === 71 || stage === 72) && !(item.push && ['pushed', 'checking'].includes(item.push.state))) return true; + if ((stage === 71 || stage === 72) && !(item.push && ['pushed', 'checking'].includes(item.push.state)) && !(typeof stageTrackerHiveOwesReReview === 'function' && stageTrackerHiveOwesReReview(item))) return true; const code = item.code_activity; return !!(code && code.head === item.head && code.state === 'waiting_owner'); } diff --git a/src/pkg/github/pr_batch_graphql.go b/src/pkg/github/pr_batch_graphql.go index a44d0c6cf3..29153d0b7a 100644 --- a/src/pkg/github/pr_batch_graphql.go +++ b/src/pkg/github/pr_batch_graphql.go @@ -34,7 +34,8 @@ query($owner: String!, $name: String!, $first: Int!, $cursor: String) { oid statusCheckRollup { state - contexts(first: 50) { + contexts(first: 100) { + totalCount nodes { __typename ... on CheckRun { id databaseId name conclusion status detailsUrl startedAt completedAt checkSuite { app { databaseId } commit { oid } } } @@ -102,7 +103,8 @@ type graphQLPRBatchNode struct { StatusCheckRollup *struct { State string `json:"state"` Contexts struct { - Nodes []graphQLPRBatchContext `json:"nodes"` + TotalCount int `json:"totalCount"` + Nodes []graphQLPRBatchContext `json:"nodes"` } `json:"contexts"` } `json:"statusCheckRollup"` } `json:"commit"` @@ -304,10 +306,21 @@ func graphQLMergeable(raw string) *bool { } } +// graphQLCheckRuns converts a PR node's statusCheckRollup into check runs. It +// reports ok=false when the rollup is absent OR when GitHub truncated the +// contexts page: a head with more contexts than one page holds (a 70-job +// matrix plus statuses) would otherwise be cached as a partial listing, and +// enrichPRCI would read the missing required checks as "never reported" +// (hivecommons/hive#16615 showed `CI 7/11 ยท required check "test" hasn't +// reported` while every check was green). The caller falls back to the +// paginated REST listing instead. func graphQLCheckRuns(n graphQLPRBatchNode) ([]*gh.CheckRun, bool) { if len(n.Commits.Nodes) == 0 || n.Commits.Nodes[0].Commit.StatusCheckRollup == nil { return nil, false } + if graphQLContextsTruncated(n) { + return nil, false + } var out []*gh.CheckRun for _, ctx := range n.Commits.Nodes[0].Commit.StatusCheckRollup.Contexts.Nodes { name, status, conclusion, url := "", "", "", "" @@ -356,6 +369,16 @@ func graphQLCheckRuns(n graphQLPRBatchNode) ([]*gh.CheckRun, bool) { return out, true } +// graphQLContextsTruncated reports whether the rollup's contexts connection +// holds fewer nodes than GitHub says exist for the head. +func graphQLContextsTruncated(n graphQLPRBatchNode) bool { + if len(n.Commits.Nodes) == 0 || n.Commits.Nodes[0].Commit.StatusCheckRollup == nil { + return false + } + contexts := n.Commits.Nodes[0].Commit.StatusCheckRollup.Contexts + return contexts.TotalCount > len(contexts.Nodes) +} + func statusFromStatusContext(state string) string { switch strings.ToUpper(strings.TrimSpace(state)) { case "SUCCESS", "FAILURE", "ERROR": diff --git a/src/pkg/github/pr_batch_graphql_status_test.go b/src/pkg/github/pr_batch_graphql_status_test.go index c0f5dd628e..ac7bdc0856 100644 --- a/src/pkg/github/pr_batch_graphql_status_test.go +++ b/src/pkg/github/pr_batch_graphql_status_test.go @@ -338,3 +338,33 @@ func TestGraphQLPRBatchRefetchClearsStaleRepoEntries(t *testing.T) { t.Fatalf("GraphQL calls = %d, want 2 (none while disabled)", got) } } + +// hivecommons/hive#16615: a head with more contexts than one GraphQL page +// (70 matrix jobs + statuses) was cached as a partial listing, so the +// required `test` aggregate fell off the page and the dashboard reported +// `CI 7/11 ยท required check "test" hasn't reported` on an all-green head. +func TestGraphQLCheckRunsTruncatedContextsReportsNotOK(t *testing.T) { + node := `{"number":16615,"headRefOid":"d88928e","commits":{"nodes":[{"commit":{"oid":"d88928e","statusCheckRollup":{"state":"SUCCESS","contexts":{"totalCount":73,"nodes":[` + + `{"__typename":"CheckRun","id":"CR_1","databaseId":1,"name":"test (agent 1/5)","status":"COMPLETED","conclusion":"SUCCESS"},` + + `{"__typename":"CheckRun","id":"CR_2","databaseId":2,"name":"coverage","status":"COMPLETED","conclusion":"SUCCESS"}` + + `]}}}}]}}` + n := decodeGQLPRNode(t, node) + if !graphQLContextsTruncated(n) { + t.Fatalf("totalCount 73 with 2 nodes should be truncated") + } + if checks, ok := graphQLCheckRuns(n); ok || checks != nil { + t.Fatalf("truncated rollup: got ok=%v checks=%d, want ok=false nil so enrichPRCI falls back to paginated REST", ok, len(checks)) + } + + complete := decodeGQLPRNode(t, strings.Replace(node, `"totalCount":73`, `"totalCount":2`, 1)) + if graphQLContextsTruncated(complete) { + t.Fatalf("totalCount == len(nodes) must not be truncated") + } + if checks, ok := graphQLCheckRuns(complete); !ok || len(checks) != 2 { + t.Fatalf("complete rollup: got ok=%v checks=%d, want ok=true 2", ok, len(checks)) + } + legacy := decodeGQLPRNode(t, strings.Replace(node, `"totalCount":73,`, ``, 1)) + if checks, ok := graphQLCheckRuns(legacy); !ok || len(checks) != 2 { + t.Fatalf("rollup without totalCount (older fixtures): got ok=%v checks=%d, want ok=true 2", ok, len(checks)) + } +}