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-awaiting-rerun-lane.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a PR parked on a person who must act on the PR itself (rerun CI, approve workflow runs, resolve a GitHub permission, answer open review findings) now lights the PR in progress chevron — "Waiting for @who · rerun shared ci on GitHub" — and leaves the Merge queue column empty; only rows actually queued / merging, or a merge-ready PR parked on a merge decision, sit in Merge queue.
9 changes: 6 additions & 3 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ type StageTrackerItem struct {
// UnauthorizedStep is set when the item wears hive:unauthorized: the
// step the hive's GitHub App is not permitted to take, in words
// ("approve workflow runs"), from the `unauthorized:<step>` stage
// reason; the gate cell reads "Awaiting human: <step>". Unauthorized
// is the pill's tooltip naming the permission and the human action
// (hivecommons/hive#14589).
// reason; the PR in progress chevron reads "Waiting for @who · <step>
// on GitHub" (hive#16524). Unauthorized is the pill's tooltip naming
// the permission and the human action (hivecommons/hive#14589).
UnauthorizedStep string `json:"unauthorized_step,omitempty"`
Unauthorized string `json:"unauthorized,omitempty"`
// DecisionNeeded is set on a row parked on a person (085 / 045 / 015,
Expand Down Expand Up @@ -709,6 +709,9 @@ type StageTrackerLinkedPR struct {
Stage int `json:"stage,omitempty"`
StageSince *time.Time `json:"stage_since,omitempty"`
Caption string `json:"caption,omitempty"`
// UnauthorizedStep mirrors the PR's own field so the nested chevron
// reads "Waiting for @who · <step> on GitHub" too (hive#16524).
UnauthorizedStep string `json:"unauthorized_step,omitempty"`
// NoteChangedAt mirrors the PR row's: when the caption last changed
// meaning.
NoteChangedAt *time.Time `json:"note_changed_at,omitempty"`
Expand Down
6 changes: 4 additions & 2 deletions src/pkg/dashboard/stage_tracker_caption.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,10 @@ func stageTrackerCaption(stage stagelabels.Stage, reason, author string, kind st
}
if step, _ := stageTrackerUnauthorized(reason); step != "" {
// hivecommons/hive#14589: not a decision but a step only a
// person may take; the gate cell says the same.
return joinClause("Awaiting human: "+step, clause), "maintainer"
// person may take; the PR in progress chevron says the same
// (hive#16524: it is the person's move on the PR, not a
// merge-queue matter).
return joinClause("Waiting for a maintainer · "+step+" on GitHub", clause), "maintainer"
}
if c := stageTrackerMergeTrainCaption(reason); c != "" {
return c, "maintainer"
Expand Down
59 changes: 59 additions & 0 deletions src/pkg/dashboard/stage_tracker_item_column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,62 @@ func TestStageTrackerFixingAfterMergeFailedColumn(t *testing.T) {
t.Fatalf("linked_prs payload lacks left_train:\n%s", raw)
}
}

// TestStageTrackerPersonActsOnPRColumn replays hive's own #16524: a PR
// parked at 085 under hive:unauthorized (a maintainer must rerun shared
// CI on GitHub) with CI unknown and review findings open. The ask is a
// person's move ON THE PR, so its chevron is PR in progress and the
// Merge queue column is empty — the gate is only for rows queued /
// merging / merged, or a merge-ready PR parked on a merge decision.
func TestStageTrackerPersonActsOnPRColumn(t *testing.T) {
head := "7879a51f276a0f9aa5adc995d9d09a74487bbcf4"
ci := func(state string) *StageTrackerActivity { return &StageTrackerActivity{Head: head, State: state} }
review := func(state string) *StageTrackerActivity { return &StageTrackerActivity{Head: head, State: state} }
live := func() StageTrackerItem {
return StageTrackerItem{Repo: "hivecommons/hive", Number: 16524, Kind: "pr", Stage: stagelabels.NeedsDecision.Number(), Head: head,
Reason: "unauthorized:rerun-shared-ci", UnauthorizedStep: "rerun shared ci",
CIActivity: ci("unknown"), ReviewActivity: review("changes_requested")}
}
cases := []struct {
name string
mut func(*StageTrackerItem)
want int
}{
{"#16524 as served", func(*StageTrackerItem) {}, trackerColumnPR},
{"unauthorized step, no track evidence", func(it *StageTrackerItem) { it.CIActivity, it.ReviewActivity = nil, nil }, trackerColumnPR},
{"unauthorized step on a merge-ready head", func(it *StageTrackerItem) { it.CIActivity, it.ReviewActivity = ci("passing"), review("approved") }, trackerColumnMergeGate},
{"decision with review findings open", func(it *StageTrackerItem) { it.Reason, it.UnauthorizedStep = "", "" }, trackerColumnPR},
{"decision with CI red, review approved", func(it *StageTrackerItem) {
it.Reason, it.UnauthorizedStep, it.CIActivity, it.ReviewActivity = "", "", ci("failing"), review("approved")
}, trackerColumnPR},
{"bare 085 decision keeps the gate (#14821)", func(it *StageTrackerItem) {
it.Reason, it.UnauthorizedStep, it.CIActivity, it.ReviewActivity = "", "", nil, nil
}, trackerColumnMergeGate},
{"merge-ready decision keeps the gate", func(it *StageTrackerItem) {
it.Reason, it.UnauthorizedStep, it.CIActivity, it.ReviewActivity = "", "", ci("passing"), review("approved")
}, trackerColumnMergeGate},
{"stale track evidence on another head is not evidence", func(it *StageTrackerItem) {
it.Reason, it.UnauthorizedStep = "", ""
it.CIActivity.Head, it.ReviewActivity.Head = "old", "old"
}, trackerColumnMergeGate},
{"a seated train member is a Merge queue matter", func(it *StageTrackerItem) {
it.MergeTrain = &StageTrackerMergeTrain{ID: "v5#1", State: MergeGateStateQueuedBehind, Front: 1, Position: 2, Size: 2}
}, trackerColumnMergeGate},
{"a live merge attempt is a Merge queue matter", func(it *StageTrackerItem) { it.MergeGate = &StageTrackerMergeGate{State: MergeGateStateMerging} }, trackerColumnMergeGate},
{"an issue at 085 is unchanged", func(it *StageTrackerItem) { it.Kind = "issue" }, stageTrackerColumn(stagelabels.NeedsDecision)},
{"070 fixing is untouched", func(it *StageTrackerItem) { it.Stage = stagelabels.Fixing.Number() }, trackerColumnReview},
}
for _, tc := range cases {
it := live()
tc.mut(&it)
if got := stageTrackerItemColumn(&it); got != tc.want {
t.Errorf("%s: column %d, want %d", tc.name, got, tc.want)
}
}
// The caption names the step as the person's move on GitHub, never as
// a merge-queue wait.
caption, actor := stageTrackerCaption(stagelabels.NeedsDecision, "unauthorized:rerun-shared-ci", "clubanderson", "pr", false, stagelabels.Record{}, false, 0, head)
if !strings.Contains(caption, "Waiting for a maintainer · rerun shared ci on GitHub") || strings.Contains(caption, "Awaiting human") || actor != "maintainer" {
t.Fatalf("caption %q actor %q", caption, actor)
}
}
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 @@ -338,6 +338,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin
lp.AdmittedBy, lp.DCOUnsigned, lp.DCOTotal = pr.AdmittedBy, pr.DCOUnsigned, pr.DCOTotal
lp.BaseRef = pr.BaseRef
lp.DecisionNeeded = pr.DecisionNeeded
lp.UnauthorizedStep = pr.UnauthorizedStep
lp.SoakRemainingSeconds, lp.MergeGate = pr.SoakRemainingSeconds, pr.MergeGate
lp.MergeTrain, lp.LeftTrain, lp.Overlap = pr.MergeTrain, pr.LeftTrain, pr.Overlap
lp.Preparation = pr.Preparation
Expand Down
3 changes: 3 additions & 0 deletions src/pkg/dashboard/stage_tracker_sentinel_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ func stageTrackerManualMergeJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerReadyForHumanWord"),
jsConstLine(t, html, "STAGE_TRACKER_HUMAN_GATED"),
jsConstLine(t, html, "STAGE_TRACKER_UNAUTHORIZED_WORD"),
jsConstLine(t, html, "STAGE_TRACKER_UNAUTHORIZED_WHERE"),
jsFunc(t, html, "stageTrackerUnauthorizedWho"),
jsFunc(t, html, "stageTrackerUnauthorizedWord"),
jsFunc(t, html, "stageTrackerPersonActsOnPR"),
jsConstLine(t, html, "STAGE_TRACKER_ADOPTED_BY_HIVE"),
jsFunc(t, html, "stageTrackerAdoptedWord"),
}, "\n")
Expand Down
36 changes: 36 additions & 0 deletions src/pkg/dashboard/stage_tracker_ui_rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,42 @@ assert.ok(/<span class="ham-since( ham-stalled)?">[^<]*<\/span>/.test(row) && !/
assert.ok(!/ham-track-verdict"><svg [^>]*>[\s\S]*?<\/svg>(?:CI|Review) /.test(changes), 'settled verdicts carry no words beside the glyph: ' + changes);
assert.ok(/<li class="ham-seg active ham-settled-current ham-remediation-remediating detoured"/.test(busy) && busy.includes('Remediating · scanner · 4m'), 'the stage chevron is settled-current with its words: ' + busy);
}
// hivecommons/hive#16524: 085 under hive:unauthorized (a maintainer must
// rerun shared CI on GitHub), CI unknown, review findings open. The ask is
// the person's move ON THE PR, not a merge matter: the chevron lights PR in
// progress with "Waiting for @clubanderson · rerun shared ci on GitHub"
// and the person icon; the Merge queue column stays empty. A merge-ready
// twin (approved + CI green) or a queued one keeps the gate.
{
const seen = new Date(now - 60000).toISOString();
const head = '7879a51';
const ask = { question: "The hive's GitHub App may not rerun shared ci here. A maintainer has to do that step on GitHub.", asked_by: 'GitHub permissions', since: seen, blocker_reason: 'unauthorized:rerun-shared-ci', options: [{ action: 'decide:delegate', label: 'Let hive decide', enabled: false }] };
const shape = (extra) => Object.assign({ repo: 'hivecommons/hive', number: 16524, kind: 'pr', stage: 85, head, author: 'clubanderson', author_kind: 'human', modifiers: ['unauthorized'],
reason: 'unauthorized:rerun-shared-ci', unauthorized_step: 'rerun shared ci', unauthorized: "The hive's GitHub App lacks the permission to rerun shared ci, so only a person can take that step.",
caption: 'Waiting for a maintainer · rerun shared ci on GitHub — the hive\'s GitHub App is not permitted to rerun shared ci; a maintainer must', decision_needed: ask,
human_attention: { number: 16524, kind: 'pr', head, reason: ask.question, asked_by: 'GitHub permissions' },
ci_activity: { head, state: 'unknown', caption: 'CI unknown · no check results observed for this head yet', checks_passed: 34, checks_total: 42, checks_failed: 1, source: 'github-graphql-cache+required-branch', observed_at: seen },
review_activity: { head, state: 'changes_requested', caption: 'Review findings · awaiting author', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen, since: seen } }, extra || {});
const rerun = stageTrackerRowHtml(shape(), stages, ctx);
assert.strictEqual(stageTrackerAnchor(85, stages, 'pr', shape()), 30, 'the ask is the person\'s move on the PR: PR in progress');
assert.deepStrictEqual(segStates(rerun), [D, D, D, 'active detoured', T, T, 'todo cap'], 'PR in progress lit, Merge queue empty: ' + strip(rerun));
assert.ok(rerun.includes('Waiting for @clubanderson · rerun shared ci on GitHub'), 'the chevron names the person and the step: ' + strip(rerun));
assert.ok(!/<li class="ham-seg active[^"]*"[^>]*>[\s\S]*?Awaiting human/.test(strip(rerun)), 'no "Awaiting human" chevron: ' + strip(rerun));
const litSeg = /<li class="ham-seg active detoured"[^>]*>([\s\S]*?)<\/li>/.exec(strip(rerun));
assert.ok(litSeg && litSeg[1].includes('ham-actor-ico'), 'the person icon stays on the lit chevron: ' + strip(rerun));
const mergeSeg = Array.from(strip(rerun).matchAll(/<li class="ham-seg ([^"]*)"[^>]*>([\s\S]*?)<\/li>/g)).filter(m => !m[1].includes('ham-activity-track') && !m[1].includes('ham-head'))[4];
assert.ok(mergeSeg && mergeSeg[1] === 'todo' && !/ham-chevron-copy/.test(mergeSeg[2]), 'the merge-queue chevron carries no words: ' + mergeSeg[0]);
assert.strictEqual(litChevrons(strip(rerun)), 1, 'one lit chevron: ' + strip(rerun));
// Merge-ready (approved + CI green) or queued twins are merge matters: the gate keeps them.
const ready = shape({ ci_activity: { head, state: 'passing', caption: 'CI green', checks_passed: 42, checks_total: 42, source: 'checks', observed_at: seen }, review_activity: { head, state: 'approved', caption: 'Review approved', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen } });
assert.strictEqual(stageTrackerAnchor(85, stages, 'pr', ready), 80, 'merge-ready 085 keeps the gate');
assert.strictEqual(stageTrackerAnchor(85, stages, 'pr', shape({ merge_train: { id: 'v5#1', state: 'queued-behind', front: 1, position: 2, size: 2 } })), 80, 'a train member keeps the gate');
// A bare 085 decision (no track evidence, no step) still decides at the gate (#14821).
assert.strictEqual(stageTrackerAnchor(85, stages, 'pr', { kind: 'pr', stage: 85, caption: 'decision requested' }), 80);
// A nested PR under its issue follows the same column.
const nested = stageTrackerRowHtml({ repo: 'hivecommons/hive', number: 16500, kind: 'issue', stage: 40, linked_prs: [shape()] }, stages, ctx);
assert.ok(nested.includes('Waiting for @clubanderson · rerun shared ci on GitHub'), 'nested PR carries the word: ' + nested);
}
// Merged: the lit cap is the only chevron with hover text.
row = stageTrackerRowHtml({ repo: 'acme/console', number: 106, kind: 'pr', stage: 110 }, stages, ctx);
assert.ok(/<li class="ham-seg active cap merged" title="Merged — [^"]*" aria-current="step">/.test(row) && titled(strip(row)).length === 1, row);
Expand Down
8 changes: 5 additions & 3 deletions src/pkg/dashboard/stage_tracker_unauthorized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestStageTrackerUnauthorizedPayload(t *testing.T) {
if it.Stage != 85 || !hasMod(it, modUnauthorized) || it.UnauthorizedStep != "approve workflow runs" || !strings.Contains(it.Unauthorized, "`actions: write`") {
t.Fatalf("row = stage %d mods %v step %q tip %q", it.Stage, it.Modifiers, it.UnauthorizedStep, it.Unauthorized)
}
if !strings.Contains(it.Caption, "not permitted to approve workflow runs") || it.Actor != "maintainer" {
if !strings.HasPrefix(it.Caption, "Waiting for a maintainer · approve workflow runs on GitHub") || !strings.Contains(it.Caption, "not permitted to approve workflow runs") || it.Actor != "maintainer" {
t.Fatalf("caption %q actor %q", it.Caption, it.Actor)
}
raw, err := json.Marshal(it)
Expand All @@ -82,7 +82,7 @@ func TestStageTrackerUnauthorizedPayload(t *testing.T) {
}

// The frontend: the pill is muted and explains itself on hover, it counts
// under Needs attention, and the 085 chevron reads "Awaiting human: <step>".
// under Needs attention, and the 085 chevron reads "Waiting for @who · <step> on GitHub".
func TestStageTrackerUnauthorizedJS(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
Expand Down Expand Up @@ -129,7 +129,9 @@ assert.ok(stageTrackerNeedsAttention(item));
assert.ok(stageTrackerChipsHtml({ stage: 85, modifiers: ['needs-decision', 'unauthorized'] }).includes('>unauthorized +1<'));
assert.ok(stageTrackerChipsHtml({ stage: 10, modifiers: ['unauthorized', 'hold'] }).includes('>hold +1<'));
// The 085 chevron names the human step owed; without a step the generic word stays.
assert.strictEqual(stageTrackerUnauthorizedWord(item), 'Awaiting human: approve workflow runs');
assert.strictEqual(stageTrackerUnauthorizedWord(item), 'Waiting for a maintainer · approve workflow runs on GitHub');
assert.strictEqual(stageTrackerUnauthorizedWord(Object.assign({ author: 'clubanderson', author_kind: 'human' }, item)), 'Waiting for @clubanderson · approve workflow runs on GitHub');
assert.strictEqual(stageTrackerUnauthorizedWord(Object.assign({ author: 'hive-bot', author_kind: 'hive' }, item)), 'Waiting for a maintainer · approve workflow runs on GitHub');
assert.strictEqual(stageTrackerUnauthorizedWord({ stage: 85, modifiers: ['unauthorized'] }), '');
assert.strictEqual(STAGE_TRACKER_HUMAN_GATED, 85);
`
Expand Down
48 changes: 48 additions & 0 deletions src/pkg/dashboard/stage_tracker_vocabulary.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,57 @@ func stageTrackerItemColumn(it *StageTrackerItem) int {
return trackerColumnMergeGate
}
}
if stageTrackerPersonActsOnPR(it) {
return trackerColumnPR
}
return stageTrackerColumn(st)
}

// stageTrackerPersonActsOnPR: a PR parked at 085 because a person has to
// act ON THE PR — rerun CI, approve workflow runs, resolve a permission
// (reason `unauthorized:<step>`), or answer review findings / red checks
// still open on its head — is not queued, merging or merge-ready, so its
// chevron lights PR in progress, never Merge queue. The Merge queue
// column is only for rows actually queued / merging / merged, or a
// merge-ready PR (review approved, CI green) parked on a merge decision.
// A bare 085 with no track evidence keeps the gate: the person decides
// there (hive#14821). Hive's own #16524 read "Awaiting human: rerun
// shared ci" under Merge queue with CI unknown and review findings open.
func stageTrackerPersonActsOnPR(it *StageTrackerItem) bool {
if it == nil || it.Kind != "pr" || stageByNumber(it.Stage) != stagelabels.NeedsDecision {
return false
}
if mg := it.MergeGate; mg != nil && mg.State != "" {
return false
}
if mt := it.MergeTrain; mt != nil && mt.State != "" {
return false
}
if step, _ := stageTrackerUnauthorized(it.Reason); step != "" {
return !stageTrackerMergeReadyEvidence(it)
}
return stageTrackerNotMergeReadyEvidence(it)
}

func stageTrackerActivityOnHead(it *StageTrackerItem, a *StageTrackerActivity) bool {
return a != nil && (a.Head == "" || it.Head == "" || strings.EqualFold(a.Head, it.Head))
}

// stageTrackerMergeReadyEvidence: review approved and CI green on the
// row's current head — the only state in which a human-gated PR may sit
// in the Merge queue column.
func stageTrackerMergeReadyEvidence(it *StageTrackerItem) bool {
return stageTrackerActivityOnHead(it, it.ReviewActivity) && it.ReviewActivity.State == "approved" &&
stageTrackerActivityOnHead(it, it.CIActivity) && it.CIActivity.State == "passing"
}

// stageTrackerNotMergeReadyEvidence: a track on the current head says the
// PR is short of merge-ready (review not approved, CI not green).
func stageTrackerNotMergeReadyEvidence(it *StageTrackerItem) bool {
return (stageTrackerActivityOnHead(it, it.ReviewActivity) && it.ReviewActivity.State != "approved") ||
(stageTrackerActivityOnHead(it, it.CIActivity) && it.CIActivity.State != "passing")
}

// stageTrackerStagePhrase is the stage as a lowercase clause for the
// middle of a sentence ("its PR is reviewed · waiting for merge
// admission"), from the same words the chevron shows.
Expand Down
4 changes: 4 additions & 0 deletions src/pkg/dashboard/static-src/js/tracker-row-anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
// sits at 050/070, and hive's own #15400 ("1st") lit CI / Review
// next to its 2nd-place sibling in Merge queue (hivecommons/hive#15395).
if (item && item.merge_train && item.merge_train.state && cur > STAGE_TRACKER_PR_COLUMN) return STAGE_TRACKER_MERGE_COLUMN;
// A person owes a step on the PR itself (085 under hive:unauthorized,
// not merge-ready): PR in progress, with the merge-queue chevron
// empty (hivecommons/hive#16524).
if (kind === 'pr' && typeof stageTrackerPersonActsOnPR === 'function' && stageTrackerPersonActsOnPR(item)) return STAGE_TRACKER_PR_COLUMN;
if (cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION || cur === STAGE_TRACKER_TRIAGE_NEEDED || cur === STAGE_TRACKER_POSSIBLY_EXISTS) return STAGE_TRACKER_ISSUE_DECISION_COLUMN;
if (cur === STAGE_TRACKER_NEEDS_DECISION && kind === 'issue') return STAGE_TRACKER_ISSUE_DECISION_COLUMN;
if (STAGE_TRACKER_PATH.indexOf(cur) >= 0) return cur;
Expand Down
Loading
Loading