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-signoff-lead.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a row parked on a policy sign-off ask (e.g. a fork's workflow change) now says "Review 5/5 ยท needs your sign-off" / "needs owner sign-off" instead of "awaiting human decision", leads with an inline "Approve โ–ธ" when CI is green (then "Let hive decide โ–ธ"), and no longer captions "Recommendation recorded" when hive kept the park without recording a recommendation.
6 changes: 5 additions & 1 deletion src/pkg/dashboard/row_action_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type RowActionResult struct {
Next string `json:"next"`
Rule string `json:"rule,omitempty"`
AppliedAt *time.Time `json:"applied_at,omitempty"`
// Verdict is the delegate's verdict slug when the hive decided
// (owner-only, recommend-only, โ€ฆ), so the row caption can tell a
// recorded recommendation from an ask handed back to the person.
Verdict string `json:"verdict,omitempty"`
// Why is the glossary slug for why a recorded decision has not taken
// effect (Action no-effect); Options are the concrete next actions in
// the popover's shape (hivecommons/hive#14822). Both additive.
Expand Down Expand Up @@ -104,7 +108,7 @@ func delegatedRowActionResult(in delegatedecision.Input, d delegatedecision.Deci
if in.Kind == delegatedecision.KindPR {
kind = rowActionTargetPR
}
out := RowActionResult{Target: rowActionTarget(in.Repo, kind, in.Number), Rule: d.Rule}
out := RowActionResult{Target: rowActionTarget(in.Repo, kind, in.Number), Rule: d.Rule, Verdict: string(d.Verdict)}
ruleTag := ""
if d.Rule != "" {
ruleTag = " (" + delegatedecision.RulePlain(d.Rule) + ")"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/stage_tracker_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle,
out.State, out.Caption = "changes_requested", "Review findings ยท awaiting author"
out.Blocker = stageTrackerFixerExhaustedSummary(agg)
case "requires_human":
out.State, out.Caption = "human_decision", "Review findings ยท human decision"
out.State, out.Caption = "human_decision", "Review findings ยท needs owner sign-off"
out.Blocker = agg.DecisionQuestion
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/pkg/dashboard/stage_tracker_activity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,13 @@ test('#16484: count grammar โ€” CI passed/total and Review done/total across eve
const review = (state, extra = {}, item = {}) => word({ head: 'h', ...item, review_activity: { head: 'h', state, perspectives_done: 3, perspectives_total: 5, ...extra } }, 'review', true);
assert.equal(review('approved', { perspectives_done: 5 }), 'Review 5/5 approved');
assert.equal(review('changes_requested'), 'Review 3/5 ยท changes requested');
assert.equal(review('human_decision'), 'Review 3/5 ยท awaiting human decision');
assert.equal(review('human_decision'), 'Review 3/5 ยท needs owner sign-off', 'reviews done; the sign-off is what is left, never "awaiting human"');
assert.equal(review('human_decision', {}, { decision_needed: { question: '@clubanderson should decide whether to accept this workflow change from a fork.' } }), 'Review 3/5 ยท needs owner sign-off', 'no viewer known: the owner');
globalThis.window = { _hiveUser: 'ClubAnderson' };
try {
assert.equal(review('human_decision', {}, { decision_needed: { question: '@clubanderson should decide whether to accept this workflow change from a fork.' } }), 'Review 3/5 ยท needs your sign-off', 'the ask names the viewer');
assert.equal(review('human_decision', {}, { decision_needed: { question: '@someone-else should decide.' } }), 'Review 3/5 ยท needs owner sign-off');
} finally { delete globalThis.window; }
assert.equal(review('reviewing', { actor: 'reviewer-2' }), 'Review 3/5 ยท reviewer-2 reviewing');
assert.equal(review('adjudicating', { actor: 'adjudicator' }), 'Review 3/5 ยท adjudicator reviewing');
assert.equal(review('assigned', { actor: 'reviewer' }), 'Review 3/5 ยท reviewer queued');
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
}
it.ReviewActivity = stageTrackerReviewActivity(activityPR, bundle, currentAggregate, dispatchState, status, now)
stageTrackerCountPerspectives(it.ReviewActivity, activityPR, bundle, currentAggregate, dispatchState, stageTrackerRepoQualifier(status), expectedPerspectives)
stageTrackerLeadApproveForSignOff(&it)
if stageTrackerClaimantStage(it.Kind, it.Stage) {
var worker *stageTrackerWorker
if w, ok := stageTrackerWorkerOn(workers, repoName, pr.Number); ok {
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_decided_ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func stageTrackerDecidedUIJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerGateCueHtml"),
jsFunc(t, html, "stageTrackerDecidedOf"),
jsConstBlock(t, html, "STAGE_TRACKER_DECIDED_ACTING"),
jsConstLine(t, html, "STAGE_TRACKER_PARK_KEPT_ACTING"),
jsFunc(t, html, "stageTrackerDecidedActing"),
jsFunc(t, html, "stageTrackerDecidedLead"),
jsFunc(t, html, "stageTrackerLinkedSupersededText"),
Expand Down
46 changes: 46 additions & 0 deletions src/pkg/dashboard/stage_tracker_decision_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,52 @@ func decisionForPR(it StageTrackerItem, verdict *review.Aggregate, sentinelLabel
return d
}

// decisionApproveSignOffConsequence is the inline Approve pill's hover on
// a sign-off ask.
const decisionApproveSignOffConsequence = "Posts /lgtm + /approve as you; the merge queue takes it from there. Nothing merges here."

// stageTrackerLeadApproveForSignOff marks Approve the lead answer on a PR
// parked for a policy sign-off: a reviewer or the security check asked a
// person to accept something (a workflow change from a fork touching a
// secret, hivecommons/hive#16572), the reviews are otherwise done
// (human_decision / approved on this head), Approve is enabled and CI is
// not failing. The row then reads "Approve โ–ธ ยท Let hive decide โ–ธ" instead
// of leading with delegate. Runs after CI and review activity are
// derived, since decisionForPR sees neither. A lead the question already
// chose (Re-author, Close as superseded) stands.
func stageTrackerLeadApproveForSignOff(it *StageTrackerItem) {
if it == nil || it.Kind != "pr" || it.DecisionNeeded == nil {
return
}
d := it.DecisionNeeded
if d.AskedBy != decisionAskedByReviewer && d.AskedBy != decisionAskedBySentinel {
return
}
for _, o := range d.Options {
if o.Lead {
return
}
}
if it.CIActivity != nil && it.CIActivity.Head == it.Head && (it.CIActivity.State == "failing" || it.CIActivity.ChecksFailed > 0) {
return
}
if it.ReviewActivity == nil || it.ReviewActivity.Head != it.Head ||
(it.ReviewActivity.State != "human_decision" && it.ReviewActivity.State != "approved") {
return
}
for i := range d.Options {
o := &d.Options[i]
if o.Action != decisionActionApprove || !o.Enabled {
continue
}
o.Lead = true
if o.Consequence == "" {
o.Consequence = decisionApproveSignOffConsequence
}
return
}
}

// decisionLeadWithCloseSuperseded moves "Close as superseded" to the front
// of opts with the superseding PR named in its consequence.
func decisionLeadWithCloseSuperseded(opts []StageTrackerDecisionOption, redundantOf int) []StageTrackerDecisionOption {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ test('adopted row: a complete review verdict is done-style, and a human-decision

const parked = cells(redPR({ stage: 85, display_column: 85, needs_human: true, review_activity: decision }))[5];
assert.match(parked, /class="ham-seg ham-activity-track done decided"/, 'parked on a person is settled, still not amber');
assert.match(parked, /Review 5\/5 ยท awaiting human decision</, 'genuinely parked: the human word stands');
assert.match(parked, /Review 5\/5 ยท needs owner sign-off</, 'genuinely parked: the sign-off word stands');

const changes = cells(redPR({ stage: 74, display_column: 30, code_activity: adopted, review_activity: { ...decision, state: 'changes_requested' } }))[5];
assert.match(changes, /class="ham-seg ham-activity-track failing"/);
Expand Down
165 changes: 165 additions & 0 deletions src/pkg/dashboard/stage_tracker_signoff_lead_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
package dashboard

import (
"strings"
"testing"

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

// Owner on hive#16572 / docs#615 (085, a reviewer asking "@clubanderson
// should decide whether to accept this .github/workflows/fossa.yml change
// from a fork"): "why does review say awaiting humans if 5/5 reviews are
// good and nothing is left to do?" The reviews are done; what is left is
// the sign-off. Approve leads the row (Let hive decide beside it), the
// review word says whose sign-off, and a delegate verdict that recorded
// no recommendation never reads "Recommendation recorded".

func signOffItem(ci, review string, opts ...StageTrackerDecisionOption) StageTrackerItem {
if opts == nil {
opts = []StageTrackerDecisionOption{
decisionOption(decisionActionDelegate, "Let hive decide", true, ""),
decisionOption(decisionActionApprove, "Approve", true, ""),
decisionOption(decisionActionDirection, "Give direction", true, ""),
}
}
it := StageTrackerItem{Repo: "hivecommons/hive", Kind: "pr", Number: 16572, Stage: 85, Head: "h1",
DecisionNeeded: &StageTrackerDecision{AskedBy: decisionAskedByReviewer, Question: "@clubanderson should decide whether to accept this .github/workflows/fossa.yml change from a fork.", Options: opts}}
if ci != "" {
it.CIActivity = &StageTrackerActivity{Head: "h1", State: ci}
if ci == "failing" {
it.CIActivity.ChecksFailed = 1
}
}
if review != "" {
it.ReviewActivity = &StageTrackerActivity{Head: "h1", State: review}
}
return it
}

func leadActions(d *StageTrackerDecision) []string {
var out []string
for _, o := range d.Options {
if o.Lead {
out = append(out, o.Action)
}
}
return out
}

func TestStageTrackerLeadApproveForSignOff(t *testing.T) {
cases := []struct {
name string
it StageTrackerItem
want []string
}{
{"reviewer ask, CI green, reviews done โ†’ Approve leads", signOffItem("passing", "human_decision"), []string{decisionActionApprove}},
{"approved reviews also count", signOffItem("passing", "approved"), []string{decisionActionApprove}},
{"no CI evidence yet is not failing", signOffItem("", "human_decision"), []string{decisionActionApprove}},
{"CI failing: never lead with approve", signOffItem("failing", "human_decision"), nil},
{"reviews still running: no lead", signOffItem("passing", "reviewing"), nil},
{"no review evidence: no lead", signOffItem("passing", ""), nil},
{"approve disabled (changes requested): no lead", signOffItem("passing", "human_decision",
decisionOption(decisionActionDelegate, "Let hive decide", true, ""),
decisionOption(decisionActionApprove, "Approve", false, "A reviewer requested changes")), nil},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
it := tc.it
stageTrackerLeadApproveForSignOff(&it)
got := leadActions(it.DecisionNeeded)
if strings.Join(got, ",") != strings.Join(tc.want, ",") {
t.Fatalf("leads = %v, want %v", got, tc.want)
}
if len(tc.want) > 0 {
for _, o := range it.DecisionNeeded.Options {
if o.Lead && o.Consequence == "" {
t.Fatalf("lead %s carries no consequence for its hover", o.Action)
}
}
}
})
}
t.Run("sentinel ask leads too", func(t *testing.T) {
it := signOffItem("passing", "approved")
it.DecisionNeeded.AskedBy = decisionAskedBySentinel
stageTrackerLeadApproveForSignOff(&it)
if got := leadActions(it.DecisionNeeded); len(got) != 1 || got[0] != decisionActionApprove {
t.Fatalf("leads = %v", got)
}
})
t.Run("the hive's own park is not a sign-off", func(t *testing.T) {
it := signOffItem("passing", "human_decision")
it.DecisionNeeded.AskedBy = decisionAskedByLane
stageTrackerLeadApproveForSignOff(&it)
if got := leadActions(it.DecisionNeeded); got != nil {
t.Fatalf("leads = %v", got)
}
})
t.Run("an existing lead (Re-author) stands", func(t *testing.T) {
it := signOffItem("passing", "human_decision")
it.DecisionNeeded.Options = decisionLeadWithReauthor(it.DecisionNeeded.Options)
stageTrackerLeadApproveForSignOff(&it)
if got := leadActions(it.DecisionNeeded); len(got) != 1 || got[0] != decisionActionReauthor {
t.Fatalf("leads = %v", got)
}
})
t.Run("issues and rows without an ask are untouched", func(t *testing.T) {
it := signOffItem("passing", "human_decision")
it.Kind = "issue"
stageTrackerLeadApproveForSignOff(&it)
if leadActions(it.DecisionNeeded) != nil {
t.Fatal("issue row gained a lead")
}
none := StageTrackerItem{Kind: "pr"}
stageTrackerLeadApproveForSignOff(&none)
})
}

func TestStageTrackerRowActionResultCarriesVerdict(t *testing.T) {
got := delegatedRowActionResult(delegatedecision.Input{Repo: "o/r", Kind: delegatedecision.KindPR, Number: 7},
delegatedecision.Decision{Verdict: delegatedecision.VerdictOwnerOnly, Text: "owner only"}, nil)
if got.Verdict != string(delegatedecision.VerdictOwnerOnly) || got.Action != rowActionRecommended {
t.Fatalf("result = %+v", got)
}
}

// The row as the SPA draws it: Approve โ–ธ first, Let hive decide โ–ธ second;
// the review chevron says whose sign-off; a recommend-less verdict's
// caption hands the decision back.
func TestStageTrackerSignOffRowInline(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
`' ยท needs your sign-off'`,
`' ยท needs owner sign-off'`,
`const STAGE_TRACKER_PARK_KEPT_ACTING = {`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html lacks %q", want)
}
}
runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+`
const ctx = { user: true, canHold: true, canHuman: true, login: 'clubanderson', nowMs: Date.parse('2026-11-04T12:00:00Z'), governor: null };
const row = { repo: 'hivecommons/hive', kind: 'pr', number: 16572, title: 'fossa workflow', url: 'https://github.com/hivecommons/hive/pull/16572', stage: 85, head: 'h1', actor: 'maintainer', modifiers: ['needs-decision'],
review_activity: { head: 'h1', state: 'human_decision', perspectives_done: 5, perspectives_total: 5 },
decision_needed: { question: '@clubanderson should decide whether to accept this .github/workflows/fossa.yml change from a fork.', asked_by: 'a reviewer',
options: [{ action: 'decide:delegate', label: 'Let hive decide', enabled: true }, { action: 'decide:approve', label: 'Approve', enabled: true, lead: true, consequence: 'Posts /lgtm + /approve as you; the merge queue takes it from there. Nothing merges here.' }, { action: 'decide:direction', label: 'Give direction', enabled: true }] } };
const h = stageTrackerLeadActionHtml(row, ctx);
const acts = [...h.matchAll(/data-ham-act="([^"]+)"/g)].map(m => m[1]);
assert.deepStrictEqual(acts, ['decide:approve', 'decide:delegate'], h);
assert.ok(h.includes('class="ham-lead-act ham-act-primary" data-ham-act="decide:approve" title="Posts /lgtm + /approve as you; the merge queue takes it from there. Nothing merges here."'), h);
assert.ok(h.includes('>Approve</button>') && h.includes('>Let hive decide</button>'), h);
`)
runStageTrackerRowActionsScript(t, `
const assert = require('assert');
const STAGE_TRACKER_DECIDED_ACTING = { adopted: 'Adopting ยท opening hive copyโ€ฆ', approved: 'Approvingโ€ฆ', directed: 'Sending backโ€ฆ', closed: 'Closingโ€ฆ', merged: 'Mergingโ€ฆ', 'queued-for-merge': 'Queuing for mergeโ€ฆ', recommended: 'Recommendation recorded' };
`+jsConstLine(t, html, "STAGE_TRACKER_PARK_KEPT_ACTING")+`
`+jsFunc(t, html, "stageTrackerDecidedActing")+`
assert.strictEqual(stageTrackerDecidedActing({ action: 'recommended', verdict: 'owner-only' }, {}), 'Your decision needed ยท owner sign-off');
assert.strictEqual(stageTrackerDecidedActing({ action: 'recommended', verdict: 'operator-action' }, {}), 'Your action needed ยท operator step');
assert.strictEqual(stageTrackerDecidedActing({ action: 'recommended', verdict: 'recommend-only' }, {}), 'Recommendation recorded');
assert.strictEqual(stageTrackerDecidedActing({ action: 'recommended' }, {}), 'Your decision needed', 'no verdict, no recommendation claimed');
assert.strictEqual(stageTrackerDecidedActing({ action: 'adopted' }, {}), 'Adopting ยท opening hive copyโ€ฆ');
assert.strictEqual(stageTrackerDecidedActing({ action: 'recommended', verdict: 'owner-only' }, { decided: { acting: 'from server' } }), 'from server');
`)
}
2 changes: 1 addition & 1 deletion src/pkg/dashboard/stage_tracker_ui_rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ assert.ok(/<span class="ham-since( ham-stalled)?">[^<]*<\/span>/.test(row) && !/
assert.strictEqual(ci[1], 'done', '11/11 passed is done-style: ' + adoptedRow);
const parkedRow = stageTrackerRowHtml({ repo: 'acme/console', number: 16510, kind: 'pr', stage: 85, display_column: 85, head: 'f269349', needs_human: true, author: 'thatguywob', author_kind: 'human',
review_activity: { head: 'f269349', state: 'human_decision', caption: 'Review findings ยท human decision', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen } }, stages, ctx);
assert.ok(/<li class="ham-seg ham-activity-track done decided" data-track="review"[^>]*>[\s\S]*?Review 5\/5 ยท awaiting human decision<\/span>/.test(parkedRow), 'genuinely parked on a person keeps the human word, still not amber: ' + parkedRow);
assert.ok(/<li class="ham-seg ham-activity-track done decided" data-track="review"[^>]*>[\s\S]*?Review 5\/5 ยท needs owner sign-off<\/span>/.test(parkedRow), 'genuinely parked on a person names the sign-off, still not amber: ' + parkedRow);
}
// hivecommons/hive#16540 rows. #16509: adopted, CI 7/11 unreported, review
// decided โ†’ one lit chevron. #16268: waiting for the contributor, CI 7/11
Expand Down
21 changes: 18 additions & 3 deletions src/pkg/dashboard/static-src/js/tracker-row-strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,18 @@
case 'approved': return count + ' approved';
case 'changes_requested': return count + ' ยท changes requested';
// The hive on the repair (adopted / remediating) is not a human
// decision: the findings are the changes requested.
case 'human_decision': return count + (stageTrackerHiveOwnsRepair(item) ? ' ยท changes requested' : ' ยท awaiting human decision');
// decision: the findings are the changes requested. Otherwise the
// reviews are done and a person's sign-off is what is left โ€” the
// viewer's when the ask names them, else the owner's. Never
// "awaiting human" to the human it waits on (hivecommons/hive#16572:
// "why does review say awaiting humans if 5/5 reviews are good?").
case 'human_decision': {
if (stageTrackerHiveOwnsRepair(item)) return count + ' ยท changes requested';
const q = item.decision_needed && item.decision_needed.question ? String(item.decision_needed.question).toLowerCase() : '';
const me = typeof window !== 'undefined' && window._hiveUser ? String(window._hiveUser).toLowerCase() : '';
const mine = !!me && q.indexOf('@' + me) >= 0;
return count + (mine ? ' ยท needs your sign-off' : ' ยท needs owner sign-off');
}
case 'reviewing': case 'adjudicating': return count + ' ยท ' + (actor ? actor + ' reviewing' : 'reviewing');
case 'assigned': return count + ' ยท ' + (actor ? actor + ' queued' : 'queued');
case 'unassigned': return count + ' ยท swarm requested';
Expand Down Expand Up @@ -161,7 +171,12 @@
const source = matches ? a.source || 'unavailable' : 'unavailable';
const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale ยท ' : 'observed ยท ') + new Date(observed).toISOString();
const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' ยท since ' + new Date(a.since).toISOString() : '';
const blocker = matches && a.blocker ? ' ยท ' + a.blocker : '';
let blocker = matches && a.blocker ? ' ยท ' + a.blocker : '';
// A sign-off ask: the tooltip carries the question itself (who should
// decide what, and why โ€” "workflow change from a fork") when the
// review evidence did not already quote it.
const ask = matches && state === 'human_decision' && item.decision_needed && item.decision_needed.question ? String(item.decision_needed.question) : '';
if (ask && blocker.indexOf(ask) < 0) blocker += ' ยท ' + ask;
// The backend's plain-language sentence behind the caption rides in
// the tooltip only; the chevron clamps the caption.
const detail = matches && a.detail ? ' ยท ' + a.detail : '';
Expand Down
Loading
Loading