Skip to content
Closed
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-review-activity-stale-unknown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a red Review chevron no longer reads "Review activity unknown · last observed changes_requested" once its verified bundle is older than the freshness window. A settled verdict on the current head keeps its state; staleness is an "observed Nm ago" suffix; and `review_activity.perspectives[]` names each perspective's verdict so the caption and tooltip say which perspective failed and why (hivecommons/hive#16617).
106 changes: 105 additions & 1 deletion src/pkg/dashboard/stage_tracker_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,100 @@ type StageTrackerActivity struct {
// verdict for the current head.
PerspectivesDone int `json:"perspectives_done,omitempty"`
PerspectivesTotal int `json:"perspectives_total,omitempty"`
// Perspectives are the latest per-perspective verdicts of the verified
// bundle on the current head, so a red Review chevron can always name
// which perspective failed and why (hivecommons/hive#16617). Empty when
// no bundle exists for the head.
Perspectives []StageTrackerPerspective `json:"perspectives,omitempty"`
}

// StageTrackerPerspective is one reviewer perspective's latest verdict on
// the current head: its name, the verdict word (approve, changes_requested,
// reject, requires_human) and the first finding's one-line summary.
type StageTrackerPerspective struct {
Name string `json:"name"`
Verdict string `json:"verdict"`
Summary string `json:"summary,omitempty"`
}

// stageTrackerBundlePerspectives folds the bundle's latest verdicts into one
// entry per perspective: a non-approving verdict wins over an approval from
// another model, otherwise the most recent one does. Sorted by name.
func stageTrackerBundlePerspectives(bundle *evidence.Bundle) []StageTrackerPerspective {
type pick struct {
verdict evidence.Verdict
set bool
}
picks := map[string]pick{}
for _, verdict := range trackerLatestBundleVerdicts(bundle) {
if verdict.Perspective == "" {
continue
}
previous := picks[verdict.Perspective]
if !previous.set ||
(previous.verdict.Verdict == "approve" && verdict.Verdict != "approve") ||
(previous.verdict.Verdict == "approve") == (verdict.Verdict == "approve") && verdict.RecordedAt.After(previous.verdict.RecordedAt) {
picks[verdict.Perspective] = pick{verdict: verdict, set: true}
}
}
names := make([]string, 0, len(picks))
for name := range picks {
names = append(names, name)
}
slices.Sort(names)
out := make([]StageTrackerPerspective, 0, len(names))
for _, name := range names {
verdict := picks[name].verdict
p := StageTrackerPerspective{Name: name, Verdict: verdict.Verdict}
if len(verdict.Findings) > 0 {
p.Summary = stageTrackerFirstLine(verdict.Findings[0].Summary)
}
out = append(out, p)
}
return out
}

// stageTrackerFailingPerspective is the caption fragment naming the first
// perspective that did not approve — "correctness ✗: <summary>" — or the empty string
// when every perspective approved.
func stageTrackerFailingPerspective(perspectives []StageTrackerPerspective) string {
p := stageTrackerFirstNonApproving(perspectives)
if p == nil {
return ""
}
mark := "✗"
if p.Verdict == "requires_human" {
mark = "?"
}
if p.Summary == "" {
return p.Name + " " + mark
}
return p.Name + " " + mark + ": " + p.Summary
}

func stageTrackerFirstNonApproving(perspectives []StageTrackerPerspective) *StageTrackerPerspective {
for i := range perspectives {
if p := &perspectives[i]; p.Verdict != "approve" && p.Verdict != "" {
return p
}
}
return nil
}

// stageTrackerBlockerRepeats reports whether the aggregate's one-line
// blocker restates the named perspective's finding (both are first-line
// truncations of the same reviewer text), so the tooltip says it once.
func stageTrackerBlockerRepeats(blocker string, perspectives []StageTrackerPerspective) bool {
p := stageTrackerFirstNonApproving(perspectives)
if p == nil || p.Summary == "" || blocker == "" {
return false
}
const probe = 40
key := []rune(strings.TrimSuffix(p.Summary, "…"))
if len(key) > probe {
key = key[:probe]
}
return len(key) > 0 && strings.Contains(blocker, string(key))
}

const trackerActivityFreshWindow = 2 * time.Minute
Expand Down Expand Up @@ -440,6 +534,8 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle,
qualify := stageTrackerRepoQualifier(status)
if bundle != nil && trackerHeadMatches(pr.Repo, pr.Number, pr.HeadSHA, bundle.Repo, bundle.Number, bundle.HeadSHA) {
out.Source, out.ObservedAt = "verified-review-bundle", timePtr(bundle.UpdatedAt)
out.Perspectives = stageTrackerBundlePerspectives(bundle)
failing := stageTrackerFailingPerspective(out.Perspectives)
for _, verdict := range trackerLatestBundleVerdicts(bundle) {
if !verdict.RecordedAt.IsZero() && (out.Since == nil || verdict.RecordedAt.After(*out.Since)) {
at := verdict.RecordedAt
Expand All @@ -462,6 +558,12 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle,
case "changes_requested", "reject":
out.State, out.Caption = "changes_requested", "Review findings · awaiting author"
out.Blocker = stageTrackerFixerExhaustedSummary(agg)
if failing != "" {
out.Caption += " · " + failing
if stageTrackerBlockerRepeats(out.Blocker, out.Perspectives) {
out.Blocker = ""
}
}
case "requires_human":
out.State, out.Caption = "human_decision", "Review findings · needs owner sign-off"
out.Blocker = agg.DecisionQuestion
Expand All @@ -471,7 +573,9 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle,
for _, verdict := range trackerLatestBundleVerdicts(bundle) {
if verdict.Verdict == "changes_requested" || verdict.Verdict == "reject" {
out.State, out.Caption = "changes_requested", "Review findings · awaiting author"
if len(verdict.Findings) > 0 {
if failing != "" {
out.Caption += " · " + failing
} else if len(verdict.Findings) > 0 {
out.Blocker = verdict.Findings[0].Summary
}
break
Expand Down
32 changes: 31 additions & 1 deletion src/pkg/dashboard/stage_tracker_activity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ test('old-head or stale observations cannot fabricate running/completion, but do
} else {
assert.match(cells.ci, /active ham-current[^]*CI \?\/\? · running</, mode + ': the last observed state still reads in words');
assert.match(cells.review, /done ham-current[^]*data-verdict="pass"[^]*Review: Review approved · /, mode + ': an approval of this head stays done, freshness only in the tooltip');
assert.match(cells.review, mode === 'stale' ? /stale · / : /observation time unknown/);
assert.match(cells.review, mode === 'stale' ? /observed 5m ago · 2026-11-02T20:55:00\.000Z/ : /observation time unknown/, mode + ': a settled verdict ages into an observed-ago suffix, never "stale" or "unknown"');
assert.doesNotMatch(cells.review, /activity unknown|stale/);
}
}
});
Expand Down Expand Up @@ -824,3 +825,32 @@ test('#16484: the three screenshot rows — both tracks lit with counts, swarm r
assert.match(cell, /<svg /);
}
});

test('hive #16617: a stale changes-requested bundle on the current head stays red, names the failing perspective, and never reads "unknown"', () => {
const observed = new Date(now - 36 * 60000).toISOString();
const item = { kind: 'pr', head: 'b5c1f96c', review_activity: {
head: 'b5c1f96c', state: 'changes_requested', source: 'verified-review-bundle', observed_at: observed, since: new Date(now - 100 * 60000).toISOString(),
caption: 'Review findings · awaiting author · correctness ✗: Provenance helpers are a faithful move from the automerge engine',
perspectives_done: 5, perspectives_total: 5,
perspectives: [
{ name: 'correctness', verdict: 'changes_requested', summary: 'Provenance helpers are a faithful move from the automerge engine' },
{ name: 'plan-match', verdict: 'approve' }, { name: 'quality', verdict: 'approve' }, { name: 'security', verdict: 'approve' }, { name: 'style', verdict: 'approve' },
],
} };
const html = track(item, 'review', { state: 'active' }, false, now);
assert.match(html, /ham-activity-track failing/, 'the chevron is red');
assert.match(html, /data-display-state="known"/);
assert.doesNotMatch(html, /unknown|stale|last observed/, 'a verdict on this head is known however old the observation');
const tip = html.match(/title="([^"]*)"/)[1];
assert.match(tip, /^Current pipeline phase · Review: Review 5\/5 · changes requested · Review findings · awaiting author · correctness ✗: Provenance/);
assert.equal((tip.match(/Review 5\/5 · changes requested/g) || []).length, 1, 'one state, said once');
assert.match(tip, /\ncorrectness ✗: Provenance helpers are a faithful move from the automerge engine\nplan-match ✓\nquality ✓\nsecurity ✓\nstyle ✓\nhead b5c1f96c · verified-review-bundle · observed 36m ago · /, 'every perspective on its own line, then head / source / observed / since');
assert.doesNotMatch(html, /data-motion/);
// Motion, by contrast, does age into unknown: a reviewer last seen working
// 36 minutes ago cannot be assumed to still be at it.
item.review_activity = { ...activity('reviewing', 'Review working · reviewer', true), head: 'b5c1f96c', observed_at: observed, actor: 'reviewer' };
assert.match(track(item, 'review', {}, false, now), /Review activity unknown · last observed reviewing/);
// No bundle for the head is the only unknown verdict.
item.review_activity = { head: 'other', state: 'changes_requested', caption: 'Review findings · awaiting author', source: 'verified-review-bundle', observed_at: observed };
assert.match(track(item, 'review', {}, false, now), /data-activity-state="unknown"/);
});
73 changes: 73 additions & 0 deletions src/pkg/dashboard/stage_tracker_activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dashboard

import (
"os/exec"
"reflect"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -485,3 +486,75 @@ func TestStageTrackerActivityReviewPerspectiveCounts(t *testing.T) {
t.Fatalf("old-head evidence leaked into counts: %d/%d", got.PerspectivesDone, got.PerspectivesTotal)
}
}

// hivecommons/hive#16617: a verified bundle on the current head keeps its
// verdict however long ago it was observed, and names each perspective's
// verdict so a red chevron can say which perspective failed and why.
func TestStageTrackerActivityStaleBundleKeepsVerdictAndPerspectives(t *testing.T) {
now := time.Date(2026, 11, 4, 16, 30, 0, 0, time.UTC)
pr, _, status := trackerActivityFixture(now)
dispatch := review.DispatchState{GeneratedAt: now}
finding := "Provenance helpers are a faithful move from the automerge engine; relay gate lifts only after author confirms."
verdicts := func(observed time.Time, correctness string) []evidence.Verdict {
return []evidence.Verdict{
{Perspective: "security", Backend: "b", Model: "m", Verdict: "approve", RecordedAt: observed},
{Perspective: "correctness", Backend: "b", Model: "m", Verdict: correctness, RecordedAt: observed, Findings: []evidence.Finding{{Summary: finding}}},
{Perspective: "style", Backend: "b", Model: "m", Verdict: "approve", RecordedAt: observed},
}
}
for _, tc := range []struct {
name string
observed time.Time
aggVerdict review.Verdict
humanSummary string
correctness string
wantState string
wantCaptionPart string
wantBlocker string
}{
{"fresh changes_requested", now.Add(-30 * time.Second), "changes_requested", "", "changes_requested", "changes_requested", "correctness ✗: " + finding, ""},
{"stale changes_requested keeps verdict", now.Add(-90 * time.Minute), "changes_requested", "", "changes_requested", "changes_requested", "correctness ✗: " + finding, ""},
{"aggregate blocker restating the finding is said once", now.Add(-90 * time.Minute), "changes_requested", "correctness requires human: " + finding, "requires_human", "changes_requested", "correctness ?: " + finding, ""},
{"unrelated aggregate blocker is kept", now.Add(-90 * time.Minute), "changes_requested", "fixer gave up after 3 attempts", "changes_requested", "changes_requested", "correctness ✗: " + finding, "fixer gave up after 3 attempts"},
} {
t.Run(tc.name, func(t *testing.T) {
bundle := &evidence.Bundle{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, UpdatedAt: tc.observed, Verdicts: verdicts(tc.observed, tc.correctness)}
agg := &review.Aggregate{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, Verdict: tc.aggVerdict, RecordedAt: tc.observed}
if tc.humanSummary != "" {
agg.HumanSummaries = []string{tc.humanSummary}
}
got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now)
if got.State != tc.wantState || got.Source != "verified-review-bundle" {
t.Fatalf("state/source = %s/%s, want %s/verified-review-bundle: %+v", got.State, got.Source, tc.wantState, got)
}
if !strings.Contains(got.Caption, tc.wantCaptionPart) || strings.Contains(got.Caption, "unknown") {
t.Fatalf("caption %q does not name the failing perspective %q", got.Caption, tc.wantCaptionPart)
}
if got.Blocker != tc.wantBlocker {
t.Fatalf("blocker = %q, want %q", got.Blocker, tc.wantBlocker)
}
if got.ObservedAt == nil || !got.ObservedAt.Equal(tc.observed) {
t.Fatalf("observed_at = %v, want %v", got.ObservedAt, tc.observed)
}
want := []StageTrackerPerspective{
{Name: "correctness", Verdict: tc.correctness, Summary: stageTrackerFirstLine(finding)},
{Name: "security", Verdict: "approve"},
{Name: "style", Verdict: "approve"},
}
if !reflect.DeepEqual(got.Perspectives, want) {
t.Fatalf("perspectives = %+v, want %+v", got.Perspectives, want)
}
})
}
// No bundle for the head at all is the only "unknown".
if got := stageTrackerReviewActivity(pr, nil, nil, dispatch, status, now); got.State != "unknown" || len(got.Perspectives) != 0 {
t.Fatalf("no bundle should be unknown with no perspectives: %+v", got)
}
// Two models on one perspective: the non-approving one is the one named.
bundle := &evidence.Bundle{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, UpdatedAt: now, Verdicts: append(verdicts(now, "approve"),
evidence.Verdict{Perspective: "correctness", Backend: "b2", Model: "m2", Verdict: "changes_requested", RecordedAt: now.Add(-time.Minute), Findings: []evidence.Finding{{Summary: "off-by-one"}}})}
got := stageTrackerReviewActivity(pr, bundle, nil, dispatch, status, now)
if got.State != "changes_requested" || !strings.Contains(got.Caption, "correctness ✗: off-by-one") || got.Perspectives[0].Verdict != "changes_requested" {
t.Fatalf("split-model perspective did not name the dissent: %+v", got)
}
}
2 changes: 1 addition & 1 deletion src/pkg/dashboard/static-src/css/tracker.css
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
.ham-chevron-copy { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-height: calc(var(--ham-chevron-text-lines) * var(--ham-chevron-line-height) * 1em); flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.ham-chevron-copy :is(.ham-seg-t, .ham-detour, .ham-holder, .ham-gate-detail) { display: inline; white-space: normal; overflow-wrap: anywhere; }
.ham-chevron-copy > .ham-decision-trigger { min-height: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-width: 100%; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
.config-tooltip.ham-chevron-tip { overflow-wrap: anywhere; max-width: calc(100vw - var(--sp-8)); max-height: calc(100vh - var(--sp-8)); overflow-y: auto; pointer-events: auto; }
.config-tooltip.ham-chevron-tip { overflow-wrap: anywhere; white-space: pre-line; max-width: calc(100vw - var(--sp-8)); max-height: calc(100vh - var(--sp-8)); overflow-y: auto; pointer-events: auto; }
@keyframes ham-pulse { 0%, 100% { opacity: 0; } 50% { opacity: 0.3; } }
/* ---- tracker-cues: the Activity Monitor's shared cue vocabulary ------
Owner request: a viewer must always read where an item stands,
Expand Down
Loading
Loading